babylon.max.js 7.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499
  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, __spreadArrays, __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__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. 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;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. 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;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. 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); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. 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; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. 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);
  282. 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); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../node_modules/webpack/buildin/global.js":
  301. /*!*************************************************!*\
  302. !*** ../node_modules/webpack/buildin/global.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./Actions/abstractActionManager.ts":
  324. /*!******************************************!*\
  325. !*** ./Actions/abstractActionManager.ts ***!
  326. \******************************************/
  327. /*! exports provided: AbstractActionManager */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  332. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  333. /**
  334. * Abstract class used to decouple action Manager from scene and meshes.
  335. * Do not instantiate.
  336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  337. */
  338. var AbstractActionManager = /** @class */ (function () {
  339. function AbstractActionManager() {
  340. /** Gets the cursor to use when hovering items */
  341. this.hoverCursor = '';
  342. /** Gets the list of actions */
  343. this.actions = new Array();
  344. /**
  345. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  346. */
  347. this.isRecursive = false;
  348. }
  349. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  350. /**
  351. * Does exist one action manager with at least one trigger
  352. **/
  353. get: function () {
  354. for (var t in AbstractActionManager.Triggers) {
  355. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  356. return true;
  357. }
  358. }
  359. return false;
  360. },
  361. enumerable: true,
  362. configurable: true
  363. });
  364. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  365. /**
  366. * Does exist one action manager with at least one pick trigger
  367. **/
  368. get: function () {
  369. for (var t in AbstractActionManager.Triggers) {
  370. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  371. var t_int = parseInt(t);
  372. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  373. return true;
  374. }
  375. }
  376. }
  377. return false;
  378. },
  379. enumerable: true,
  380. configurable: true
  381. });
  382. /**
  383. * Does exist one action manager that handles actions of a given trigger
  384. * @param trigger defines the trigger to be tested
  385. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  386. **/
  387. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  388. for (var t in AbstractActionManager.Triggers) {
  389. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  390. var t_int = parseInt(t);
  391. if (t_int === trigger) {
  392. return true;
  393. }
  394. }
  395. }
  396. return false;
  397. };
  398. /** Gets the list of active triggers */
  399. AbstractActionManager.Triggers = {};
  400. return AbstractActionManager;
  401. }());
  402. /***/ }),
  403. /***/ "./Actions/action.ts":
  404. /*!***************************!*\
  405. !*** ./Actions/action.ts ***!
  406. \***************************/
  407. /*! exports provided: Action */
  408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  409. "use strict";
  410. __webpack_require__.r(__webpack_exports__);
  411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  412. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  413. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  414. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  415. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  416. /**
  417. * The action to be carried out following a trigger
  418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  419. */
  420. var Action = /** @class */ (function () {
  421. /**
  422. * Creates a new Action
  423. * @param triggerOptions the trigger, with or without parameters, for the action
  424. * @param condition an optional determinant of action
  425. */
  426. function Action(
  427. /** the trigger, with or without parameters, for the action */
  428. triggerOptions, condition) {
  429. this.triggerOptions = triggerOptions;
  430. /**
  431. * An event triggered prior to action being executed.
  432. */
  433. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  434. if (triggerOptions.parameter) {
  435. this.trigger = triggerOptions.trigger;
  436. this._triggerParameter = triggerOptions.parameter;
  437. }
  438. else if (triggerOptions.trigger) {
  439. this.trigger = triggerOptions.trigger;
  440. }
  441. else {
  442. this.trigger = triggerOptions;
  443. }
  444. this._nextActiveAction = this;
  445. this._condition = condition;
  446. }
  447. /**
  448. * Internal only
  449. * @hidden
  450. */
  451. Action.prototype._prepare = function () {
  452. };
  453. /**
  454. * Gets the trigger parameters
  455. * @returns the trigger parameters
  456. */
  457. Action.prototype.getTriggerParameter = function () {
  458. return this._triggerParameter;
  459. };
  460. /**
  461. * Internal only - executes current action event
  462. * @hidden
  463. */
  464. Action.prototype._executeCurrent = function (evt) {
  465. if (this._nextActiveAction._condition) {
  466. var condition = this._nextActiveAction._condition;
  467. var currentRenderId = this._actionManager.getScene().getRenderId();
  468. // We cache the current evaluation for the current frame
  469. if (condition._evaluationId === currentRenderId) {
  470. if (!condition._currentResult) {
  471. return;
  472. }
  473. }
  474. else {
  475. condition._evaluationId = currentRenderId;
  476. if (!condition.isValid()) {
  477. condition._currentResult = false;
  478. return;
  479. }
  480. condition._currentResult = true;
  481. }
  482. }
  483. this.onBeforeExecuteObservable.notifyObservers(this);
  484. this._nextActiveAction.execute(evt);
  485. this.skipToNextActiveAction();
  486. };
  487. /**
  488. * Execute placeholder for child classes
  489. * @param evt optional action event
  490. */
  491. Action.prototype.execute = function (evt) {
  492. };
  493. /**
  494. * Skips to next active action
  495. */
  496. Action.prototype.skipToNextActiveAction = function () {
  497. if (this._nextActiveAction._child) {
  498. if (!this._nextActiveAction._child._actionManager) {
  499. this._nextActiveAction._child._actionManager = this._actionManager;
  500. }
  501. this._nextActiveAction = this._nextActiveAction._child;
  502. }
  503. else {
  504. this._nextActiveAction = this;
  505. }
  506. };
  507. /**
  508. * Adds action to chain of actions, may be a DoNothingAction
  509. * @param action defines the next action to execute
  510. * @returns The action passed in
  511. * @see https://www.babylonjs-playground.com/#1T30HR#0
  512. */
  513. Action.prototype.then = function (action) {
  514. this._child = action;
  515. action._actionManager = this._actionManager;
  516. action._prepare();
  517. return action;
  518. };
  519. /**
  520. * Internal only
  521. * @hidden
  522. */
  523. Action.prototype._getProperty = function (propertyPath) {
  524. return this._actionManager._getProperty(propertyPath);
  525. };
  526. /**
  527. * Internal only
  528. * @hidden
  529. */
  530. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  531. return this._actionManager._getEffectiveTarget(target, propertyPath);
  532. };
  533. /**
  534. * Serialize placeholder for child classes
  535. * @param parent of child
  536. * @returns the serialized object
  537. */
  538. Action.prototype.serialize = function (parent) {
  539. };
  540. /**
  541. * Internal only called by serialize
  542. * @hidden
  543. */
  544. Action.prototype._serialize = function (serializedAction, parent) {
  545. var serializationObject = {
  546. type: 1,
  547. children: [],
  548. name: serializedAction.name,
  549. properties: serializedAction.properties || []
  550. };
  551. // Serialize child
  552. if (this._child) {
  553. this._child.serialize(serializationObject);
  554. }
  555. // Check if "this" has a condition
  556. if (this._condition) {
  557. var serializedCondition = this._condition.serialize();
  558. serializedCondition.children.push(serializationObject);
  559. if (parent) {
  560. parent.children.push(serializedCondition);
  561. }
  562. return serializedCondition;
  563. }
  564. if (parent) {
  565. parent.children.push(serializationObject);
  566. }
  567. return serializationObject;
  568. };
  569. /**
  570. * Internal only
  571. * @hidden
  572. */
  573. Action._SerializeValueAsString = function (value) {
  574. if (typeof value === "number") {
  575. return value.toString();
  576. }
  577. if (typeof value === "boolean") {
  578. return value ? "true" : "false";
  579. }
  580. if (value instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  581. return value.x + ", " + value.y;
  582. }
  583. if (value instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  584. return value.x + ", " + value.y + ", " + value.z;
  585. }
  586. if (value instanceof _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"]) {
  587. return value.r + ", " + value.g + ", " + value.b;
  588. }
  589. if (value instanceof _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"]) {
  590. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  591. }
  592. return value; // string
  593. };
  594. /**
  595. * Internal only
  596. * @hidden
  597. */
  598. Action._GetTargetProperty = function (target) {
  599. return {
  600. name: "target",
  601. targetType: target._isMesh ? "MeshProperties"
  602. : target._isLight ? "LightProperties"
  603. : target._isCamera ? "CameraProperties"
  604. : "SceneProperties",
  605. value: target._isScene ? "Scene" : target.name
  606. };
  607. };
  608. return Action;
  609. }());
  610. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  611. /***/ }),
  612. /***/ "./Actions/actionEvent.ts":
  613. /*!********************************!*\
  614. !*** ./Actions/actionEvent.ts ***!
  615. \********************************/
  616. /*! exports provided: ActionEvent */
  617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  618. "use strict";
  619. __webpack_require__.r(__webpack_exports__);
  620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  621. /**
  622. * ActionEvent is the event being sent when an action is triggered.
  623. */
  624. var ActionEvent = /** @class */ (function () {
  625. /**
  626. * Creates a new ActionEvent
  627. * @param source The mesh or sprite that triggered the action
  628. * @param pointerX The X mouse cursor position at the time of the event
  629. * @param pointerY The Y mouse cursor position at the time of the event
  630. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  631. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  632. * @param additionalData additional data for the event
  633. */
  634. function ActionEvent(
  635. /** The mesh or sprite that triggered the action */
  636. source,
  637. /** The X mouse cursor position at the time of the event */
  638. pointerX,
  639. /** The Y mouse cursor position at the time of the event */
  640. pointerY,
  641. /** The mesh that is currently pointed at (can be null) */
  642. meshUnderPointer,
  643. /** the original (browser) event that triggered the ActionEvent */
  644. sourceEvent,
  645. /** additional data for the event */
  646. additionalData) {
  647. this.source = source;
  648. this.pointerX = pointerX;
  649. this.pointerY = pointerY;
  650. this.meshUnderPointer = meshUnderPointer;
  651. this.sourceEvent = sourceEvent;
  652. this.additionalData = additionalData;
  653. }
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source mesh.
  656. * @param source The source mesh that triggered the event
  657. * @param evt The original (browser) event
  658. * @param additionalData additional data for the event
  659. * @returns the new ActionEvent
  660. */
  661. ActionEvent.CreateNew = function (source, evt, additionalData) {
  662. var scene = source.getScene();
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer || source, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a source sprite
  667. * @param source The source sprite that triggered the event
  668. * @param scene Scene associated with the sprite
  669. * @param evt The original (browser) event
  670. * @param additionalData additional data for the event
  671. * @returns the new ActionEvent
  672. */
  673. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  674. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  675. };
  676. /**
  677. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  678. * @param scene the scene where the event occurred
  679. * @param evt The original (browser) event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromScene = function (scene, evt) {
  683. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  684. };
  685. /**
  686. * Helper function to auto-create an ActionEvent from a primitive
  687. * @param prim defines the target primitive
  688. * @param pointerPos defines the pointer position
  689. * @param evt The original (browser) event
  690. * @param additionalData additional data for the event
  691. * @returns the new ActionEvent
  692. */
  693. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  694. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  695. };
  696. return ActionEvent;
  697. }());
  698. /***/ }),
  699. /***/ "./Actions/actionManager.ts":
  700. /*!**********************************!*\
  701. !*** ./Actions/actionManager.ts ***!
  702. \**********************************/
  703. /*! exports provided: ActionManager */
  704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  705. "use strict";
  706. __webpack_require__.r(__webpack_exports__);
  707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  708. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  709. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  710. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  711. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  712. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  713. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  714. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  715. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  716. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  717. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  718. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  719. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  720. /**
  721. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  722. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  724. */
  725. var ActionManager = /** @class */ (function (_super) {
  726. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  727. /**
  728. * Creates a new action manager
  729. * @param scene defines the hosting scene
  730. */
  731. function ActionManager(scene) {
  732. var _this = _super.call(this) || this;
  733. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  734. scene.actionManagers.push(_this);
  735. return _this;
  736. }
  737. // Methods
  738. /**
  739. * Releases all associated resources
  740. */
  741. ActionManager.prototype.dispose = function () {
  742. var index = this._scene.actionManagers.indexOf(this);
  743. for (var i = 0; i < this.actions.length; i++) {
  744. var action = this.actions[i];
  745. ActionManager.Triggers[action.trigger]--;
  746. if (ActionManager.Triggers[action.trigger] === 0) {
  747. delete ActionManager.Triggers[action.trigger];
  748. }
  749. }
  750. if (index > -1) {
  751. this._scene.actionManagers.splice(index, 1);
  752. }
  753. };
  754. /**
  755. * Gets hosting scene
  756. * @returns the hosting scene
  757. */
  758. ActionManager.prototype.getScene = function () {
  759. return this._scene;
  760. };
  761. /**
  762. * Does this action manager handles actions of any of the given triggers
  763. * @param triggers defines the triggers to be tested
  764. * @return a boolean indicating whether one (or more) of the triggers is handled
  765. */
  766. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  767. for (var index = 0; index < this.actions.length; index++) {
  768. var action = this.actions[index];
  769. if (triggers.indexOf(action.trigger) > -1) {
  770. return true;
  771. }
  772. }
  773. return false;
  774. };
  775. /**
  776. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  777. * speed.
  778. * @param triggerA defines the trigger to be tested
  779. * @param triggerB defines the trigger to be tested
  780. * @return a boolean indicating whether one (or more) of the triggers is handled
  781. */
  782. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  783. for (var index = 0; index < this.actions.length; index++) {
  784. var action = this.actions[index];
  785. if (triggerA == action.trigger || triggerB == action.trigger) {
  786. return true;
  787. }
  788. }
  789. return false;
  790. };
  791. /**
  792. * Does this action manager handles actions of a given trigger
  793. * @param trigger defines the trigger to be tested
  794. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  795. * @return whether the trigger is handled
  796. */
  797. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  798. for (var index = 0; index < this.actions.length; index++) {
  799. var action = this.actions[index];
  800. if (action.trigger === trigger) {
  801. if (parameterPredicate) {
  802. if (parameterPredicate(action.getTriggerParameter())) {
  803. return true;
  804. }
  805. }
  806. else {
  807. return true;
  808. }
  809. }
  810. }
  811. return false;
  812. };
  813. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  814. /**
  815. * Does this action manager has pointer triggers
  816. */
  817. get: function () {
  818. for (var index = 0; index < this.actions.length; index++) {
  819. var action = this.actions[index];
  820. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  821. return true;
  822. }
  823. }
  824. return false;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  830. /**
  831. * Does this action manager has pick triggers
  832. */
  833. get: function () {
  834. for (var index = 0; index < this.actions.length; index++) {
  835. var action = this.actions[index];
  836. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  837. return true;
  838. }
  839. }
  840. return false;
  841. },
  842. enumerable: true,
  843. configurable: true
  844. });
  845. /**
  846. * Registers an action to this action manager
  847. * @param action defines the action to be registered
  848. * @return the action amended (prepared) after registration
  849. */
  850. ActionManager.prototype.registerAction = function (action) {
  851. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  852. if (this.getScene().actionManager !== this) {
  853. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  854. return null;
  855. }
  856. }
  857. this.actions.push(action);
  858. if (ActionManager.Triggers[action.trigger]) {
  859. ActionManager.Triggers[action.trigger]++;
  860. }
  861. else {
  862. ActionManager.Triggers[action.trigger] = 1;
  863. }
  864. action._actionManager = this;
  865. action._prepare();
  866. return action;
  867. };
  868. /**
  869. * Unregisters an action to this action manager
  870. * @param action defines the action to be unregistered
  871. * @return a boolean indicating whether the action has been unregistered
  872. */
  873. ActionManager.prototype.unregisterAction = function (action) {
  874. var index = this.actions.indexOf(action);
  875. if (index !== -1) {
  876. this.actions.splice(index, 1);
  877. ActionManager.Triggers[action.trigger] -= 1;
  878. if (ActionManager.Triggers[action.trigger] === 0) {
  879. delete ActionManager.Triggers[action.trigger];
  880. }
  881. delete action._actionManager;
  882. return true;
  883. }
  884. return false;
  885. };
  886. /**
  887. * Process a specific trigger
  888. * @param trigger defines the trigger to process
  889. * @param evt defines the event details to be processed
  890. */
  891. ActionManager.prototype.processTrigger = function (trigger, evt) {
  892. for (var index = 0; index < this.actions.length; index++) {
  893. var action = this.actions[index];
  894. if (action.trigger === trigger) {
  895. if (evt) {
  896. if (trigger === ActionManager.OnKeyUpTrigger
  897. || trigger === ActionManager.OnKeyDownTrigger) {
  898. var parameter = action.getTriggerParameter();
  899. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  900. if (!parameter.toLowerCase) {
  901. continue;
  902. }
  903. var lowerCase = parameter.toLowerCase();
  904. if (lowerCase !== evt.sourceEvent.key) {
  905. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  906. var actualkey = String.fromCharCode(unicode).toLowerCase();
  907. if (actualkey !== lowerCase) {
  908. continue;
  909. }
  910. }
  911. }
  912. }
  913. }
  914. action._executeCurrent(evt);
  915. }
  916. }
  917. };
  918. /** @hidden */
  919. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  920. var properties = propertyPath.split(".");
  921. for (var index = 0; index < properties.length - 1; index++) {
  922. target = target[properties[index]];
  923. }
  924. return target;
  925. };
  926. /** @hidden */
  927. ActionManager.prototype._getProperty = function (propertyPath) {
  928. var properties = propertyPath.split(".");
  929. return properties[properties.length - 1];
  930. };
  931. /**
  932. * Serialize this manager to a JSON object
  933. * @param name defines the property name to store this manager
  934. * @returns a JSON representation of this manager
  935. */
  936. ActionManager.prototype.serialize = function (name) {
  937. var root = {
  938. children: new Array(),
  939. name: name,
  940. type: 3,
  941. properties: new Array() // Empty for root but required
  942. };
  943. for (var i = 0; i < this.actions.length; i++) {
  944. var triggerObject = {
  945. type: 0,
  946. children: new Array(),
  947. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  948. properties: new Array()
  949. };
  950. var triggerOptions = this.actions[i].triggerOptions;
  951. if (triggerOptions && typeof triggerOptions !== "number") {
  952. if (triggerOptions.parameter instanceof Node) {
  953. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_4__["Action"]._GetTargetProperty(triggerOptions.parameter));
  954. }
  955. else {
  956. var parameter = {};
  957. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  958. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  959. parameter._meshId = triggerOptions.parameter.mesh.id;
  960. }
  961. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  962. }
  963. }
  964. // Serialize child action, recursively
  965. this.actions[i].serialize(triggerObject);
  966. // Add serialized trigger
  967. root.children.push(triggerObject);
  968. }
  969. return root;
  970. };
  971. /**
  972. * Creates a new ActionManager from a JSON data
  973. * @param parsedActions defines the JSON data to read from
  974. * @param object defines the hosting mesh
  975. * @param scene defines the hosting scene
  976. */
  977. ActionManager.Parse = function (parsedActions, object, scene) {
  978. var actionManager = new ActionManager(scene);
  979. if (object === null) {
  980. scene.actionManager = actionManager;
  981. }
  982. else {
  983. object.actionManager = actionManager;
  984. }
  985. // instanciate a new object
  986. var instanciate = function (name, params) {
  987. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_9__["_TypeStore"].GetClass("BABYLON." + name);
  988. if (internalClassType) {
  989. var newInstance = Object.create(internalClassType.prototype);
  990. newInstance.constructor.apply(newInstance, params);
  991. return newInstance;
  992. }
  993. };
  994. var parseParameter = function (name, value, target, propertyPath) {
  995. if (propertyPath === null) {
  996. // String, boolean or float
  997. var floatValue = parseFloat(value);
  998. if (value === "true" || value === "false") {
  999. return value === "true";
  1000. }
  1001. else {
  1002. return isNaN(floatValue) ? value : floatValue;
  1003. }
  1004. }
  1005. var effectiveTarget = propertyPath.split(".");
  1006. var values = value.split(",");
  1007. // Get effective Target
  1008. for (var i = 0; i < effectiveTarget.length; i++) {
  1009. target = target[effectiveTarget[i]];
  1010. }
  1011. // Return appropriate value with its type
  1012. if (typeof (target) === "boolean") {
  1013. return values[0] === "true";
  1014. }
  1015. if (typeof (target) === "string") {
  1016. return values[0];
  1017. }
  1018. // Parameters with multiple values such as Vector3 etc.
  1019. var split = new Array();
  1020. for (var i = 0; i < values.length; i++) {
  1021. split.push(parseFloat(values[i]));
  1022. }
  1023. if (target instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1024. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1025. }
  1026. if (target instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1027. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1028. }
  1029. if (target instanceof _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"]) {
  1030. return _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(split);
  1031. }
  1032. if (target instanceof _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"]) {
  1033. return _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(split);
  1034. }
  1035. return parseFloat(values[0]);
  1036. };
  1037. // traverse graph per trigger
  1038. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1039. if (combineArray === void 0) { combineArray = null; }
  1040. if (parsedAction.detached) {
  1041. return;
  1042. }
  1043. var parameters = new Array();
  1044. var target = null;
  1045. var propertyPath = null;
  1046. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1047. // Parameters
  1048. if (parsedAction.type === 2) {
  1049. parameters.push(actionManager);
  1050. }
  1051. else {
  1052. parameters.push(trigger);
  1053. }
  1054. if (combine) {
  1055. var actions = new Array();
  1056. for (var j = 0; j < parsedAction.combine.length; j++) {
  1057. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1058. }
  1059. parameters.push(actions);
  1060. }
  1061. else {
  1062. for (var i = 0; i < parsedAction.properties.length; i++) {
  1063. var value = parsedAction.properties[i].value;
  1064. var name = parsedAction.properties[i].name;
  1065. var targetType = parsedAction.properties[i].targetType;
  1066. if (name === "target") {
  1067. if (targetType !== null && targetType === "SceneProperties") {
  1068. value = target = scene;
  1069. }
  1070. else {
  1071. value = target = scene.getNodeByName(value);
  1072. }
  1073. }
  1074. else if (name === "parent") {
  1075. value = scene.getNodeByName(value);
  1076. }
  1077. else if (name === "sound") {
  1078. // Can not externalize to component, so only checks for the presence off the API.
  1079. if (scene.getSoundByName) {
  1080. value = scene.getSoundByName(value);
  1081. }
  1082. }
  1083. else if (name !== "propertyPath") {
  1084. if (parsedAction.type === 2 && name === "operator") {
  1085. value = _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"][value];
  1086. }
  1087. else {
  1088. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1089. }
  1090. }
  1091. else {
  1092. propertyPath = value;
  1093. }
  1094. parameters.push(value);
  1095. }
  1096. }
  1097. if (combineArray === null) {
  1098. parameters.push(condition);
  1099. }
  1100. else {
  1101. parameters.push(null);
  1102. }
  1103. // If interpolate value action
  1104. if (parsedAction.name === "InterpolateValueAction") {
  1105. var param = parameters[parameters.length - 2];
  1106. parameters[parameters.length - 1] = param;
  1107. parameters[parameters.length - 2] = condition;
  1108. }
  1109. // Action or condition(s) and not CombineAction
  1110. var newAction = instanciate(parsedAction.name, parameters);
  1111. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"] && condition !== null) {
  1112. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_5__["DoNothingAction"](trigger, condition);
  1113. if (action) {
  1114. action.then(nothing);
  1115. }
  1116. else {
  1117. actionManager.registerAction(nothing);
  1118. }
  1119. action = nothing;
  1120. }
  1121. if (combineArray === null) {
  1122. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]) {
  1123. condition = newAction;
  1124. newAction = action;
  1125. }
  1126. else {
  1127. condition = null;
  1128. if (action) {
  1129. action.then(newAction);
  1130. }
  1131. else {
  1132. actionManager.registerAction(newAction);
  1133. }
  1134. }
  1135. }
  1136. else {
  1137. combineArray.push(newAction);
  1138. }
  1139. for (var i = 0; i < parsedAction.children.length; i++) {
  1140. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1141. }
  1142. };
  1143. // triggers
  1144. for (var i = 0; i < parsedActions.children.length; i++) {
  1145. var triggerParams;
  1146. var trigger = parsedActions.children[i];
  1147. if (trigger.properties.length > 0) {
  1148. var param = trigger.properties[0].value;
  1149. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1150. if (value._meshId) {
  1151. value.mesh = scene.getMeshByID(value._meshId);
  1152. }
  1153. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1154. }
  1155. else {
  1156. triggerParams = ActionManager[trigger.name];
  1157. }
  1158. for (var j = 0; j < trigger.children.length; j++) {
  1159. if (!trigger.detached) {
  1160. traverse(trigger.children[j], triggerParams, null, null);
  1161. }
  1162. }
  1163. }
  1164. };
  1165. /**
  1166. * Get a trigger name by index
  1167. * @param trigger defines the trigger index
  1168. * @returns a trigger name
  1169. */
  1170. ActionManager.GetTriggerName = function (trigger) {
  1171. switch (trigger) {
  1172. case 0: return "NothingTrigger";
  1173. case 1: return "OnPickTrigger";
  1174. case 2: return "OnLeftPickTrigger";
  1175. case 3: return "OnRightPickTrigger";
  1176. case 4: return "OnCenterPickTrigger";
  1177. case 5: return "OnPickDownTrigger";
  1178. case 6: return "OnPickUpTrigger";
  1179. case 7: return "OnLongPressTrigger";
  1180. case 8: return "OnPointerOverTrigger";
  1181. case 9: return "OnPointerOutTrigger";
  1182. case 10: return "OnEveryFrameTrigger";
  1183. case 11: return "OnIntersectionEnterTrigger";
  1184. case 12: return "OnIntersectionExitTrigger";
  1185. case 13: return "OnKeyDownTrigger";
  1186. case 14: return "OnKeyUpTrigger";
  1187. case 15: return "OnPickOutTrigger";
  1188. default: return "";
  1189. }
  1190. };
  1191. /**
  1192. * Nothing
  1193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1194. */
  1195. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_NothingTrigger;
  1196. /**
  1197. * On pick
  1198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1199. */
  1200. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnPickTrigger;
  1201. /**
  1202. * On left pick
  1203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1204. */
  1205. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnLeftPickTrigger;
  1206. /**
  1207. * On right pick
  1208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1209. */
  1210. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnRightPickTrigger;
  1211. /**
  1212. * On center pick
  1213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1214. */
  1215. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnCenterPickTrigger;
  1216. /**
  1217. * On pick down
  1218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1219. */
  1220. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnPickDownTrigger;
  1221. /**
  1222. * On double pick
  1223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1224. */
  1225. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnDoublePickTrigger;
  1226. /**
  1227. * On pick up
  1228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1229. */
  1230. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnPickUpTrigger;
  1231. /**
  1232. * On pick out.
  1233. * This trigger will only be raised if you also declared a OnPickDown
  1234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1235. */
  1236. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnPickOutTrigger;
  1237. /**
  1238. * On long press
  1239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1240. */
  1241. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnLongPressTrigger;
  1242. /**
  1243. * On pointer over
  1244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1245. */
  1246. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnPointerOverTrigger;
  1247. /**
  1248. * On pointer out
  1249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1250. */
  1251. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnPointerOutTrigger;
  1252. /**
  1253. * On every frame
  1254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1255. */
  1256. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnEveryFrameTrigger;
  1257. /**
  1258. * On intersection enter
  1259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1260. */
  1261. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1262. /**
  1263. * On intersection exit
  1264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1265. */
  1266. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnIntersectionExitTrigger;
  1267. /**
  1268. * On key down
  1269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1270. */
  1271. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ACTION_OnKeyDownTrigger;
  1272. /**
  1273. * On key up
  1274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1275. */
  1276. ActionManager.OnKeyUpTrigger = 15;
  1277. return ActionManager;
  1278. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_10__["AbstractActionManager"]));
  1279. /***/ }),
  1280. /***/ "./Actions/condition.ts":
  1281. /*!******************************!*\
  1282. !*** ./Actions/condition.ts ***!
  1283. \******************************/
  1284. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1286. "use strict";
  1287. __webpack_require__.r(__webpack_exports__);
  1288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1293. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1294. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1295. /**
  1296. * A Condition applied to an Action
  1297. */
  1298. var Condition = /** @class */ (function () {
  1299. /**
  1300. * Creates a new Condition
  1301. * @param actionManager the manager of the action the condition is applied to
  1302. */
  1303. function Condition(actionManager) {
  1304. this._actionManager = actionManager;
  1305. }
  1306. /**
  1307. * Check if the current condition is valid
  1308. * @returns a boolean
  1309. */
  1310. Condition.prototype.isValid = function () {
  1311. return true;
  1312. };
  1313. /**
  1314. * Internal only
  1315. * @hidden
  1316. */
  1317. Condition.prototype._getProperty = function (propertyPath) {
  1318. return this._actionManager._getProperty(propertyPath);
  1319. };
  1320. /**
  1321. * Internal only
  1322. * @hidden
  1323. */
  1324. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1325. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1326. };
  1327. /**
  1328. * Serialize placeholder for child classes
  1329. * @returns the serialized object
  1330. */
  1331. Condition.prototype.serialize = function () {
  1332. };
  1333. /**
  1334. * Internal only
  1335. * @hidden
  1336. */
  1337. Condition.prototype._serialize = function (serializedCondition) {
  1338. return {
  1339. type: 2,
  1340. children: [],
  1341. name: serializedCondition.name,
  1342. properties: serializedCondition.properties
  1343. };
  1344. };
  1345. return Condition;
  1346. }());
  1347. /**
  1348. * Defines specific conditional operators as extensions of Condition
  1349. */
  1350. var ValueCondition = /** @class */ (function (_super) {
  1351. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1352. /**
  1353. * Creates a new ValueCondition
  1354. * @param actionManager manager for the action the condition applies to
  1355. * @param target for the action
  1356. * @param propertyPath path to specify the property of the target the conditional operator uses
  1357. * @param value the value compared by the conditional operator against the current value of the property
  1358. * @param operator the conditional operator, default ValueCondition.IsEqual
  1359. */
  1360. function ValueCondition(actionManager, target,
  1361. /** path to specify the property of the target the conditional operator uses */
  1362. propertyPath,
  1363. /** the value compared by the conditional operator against the current value of the property */
  1364. value,
  1365. /** the conditional operator, default ValueCondition.IsEqual */
  1366. operator) {
  1367. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1368. var _this = _super.call(this, actionManager) || this;
  1369. _this.propertyPath = propertyPath;
  1370. _this.value = value;
  1371. _this.operator = operator;
  1372. _this._target = target;
  1373. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1374. _this._property = _this._getProperty(_this.propertyPath);
  1375. return _this;
  1376. }
  1377. Object.defineProperty(ValueCondition, "IsEqual", {
  1378. /**
  1379. * returns the number for IsEqual
  1380. */
  1381. get: function () {
  1382. return ValueCondition._IsEqual;
  1383. },
  1384. enumerable: true,
  1385. configurable: true
  1386. });
  1387. Object.defineProperty(ValueCondition, "IsDifferent", {
  1388. /**
  1389. * Returns the number for IsDifferent
  1390. */
  1391. get: function () {
  1392. return ValueCondition._IsDifferent;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Object.defineProperty(ValueCondition, "IsGreater", {
  1398. /**
  1399. * Returns the number for IsGreater
  1400. */
  1401. get: function () {
  1402. return ValueCondition._IsGreater;
  1403. },
  1404. enumerable: true,
  1405. configurable: true
  1406. });
  1407. Object.defineProperty(ValueCondition, "IsLesser", {
  1408. /**
  1409. * Returns the number for IsLesser
  1410. */
  1411. get: function () {
  1412. return ValueCondition._IsLesser;
  1413. },
  1414. enumerable: true,
  1415. configurable: true
  1416. });
  1417. /**
  1418. * Compares the given value with the property value for the specified conditional operator
  1419. * @returns the result of the comparison
  1420. */
  1421. ValueCondition.prototype.isValid = function () {
  1422. switch (this.operator) {
  1423. case ValueCondition.IsGreater:
  1424. return this._effectiveTarget[this._property] > this.value;
  1425. case ValueCondition.IsLesser:
  1426. return this._effectiveTarget[this._property] < this.value;
  1427. case ValueCondition.IsEqual:
  1428. case ValueCondition.IsDifferent:
  1429. var check;
  1430. if (this.value.equals) {
  1431. check = this.value.equals(this._effectiveTarget[this._property]);
  1432. }
  1433. else {
  1434. check = this.value === this._effectiveTarget[this._property];
  1435. }
  1436. return this.operator === ValueCondition.IsEqual ? check : !check;
  1437. }
  1438. return false;
  1439. };
  1440. /**
  1441. * Serialize the ValueCondition into a JSON compatible object
  1442. * @returns serialization object
  1443. */
  1444. ValueCondition.prototype.serialize = function () {
  1445. return this._serialize({
  1446. name: "ValueCondition",
  1447. properties: [
  1448. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1449. { name: "propertyPath", value: this.propertyPath },
  1450. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1451. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1452. ]
  1453. });
  1454. };
  1455. /**
  1456. * Gets the name of the conditional operator for the ValueCondition
  1457. * @param operator the conditional operator
  1458. * @returns the name
  1459. */
  1460. ValueCondition.GetOperatorName = function (operator) {
  1461. switch (operator) {
  1462. case ValueCondition._IsEqual: return "IsEqual";
  1463. case ValueCondition._IsDifferent: return "IsDifferent";
  1464. case ValueCondition._IsGreater: return "IsGreater";
  1465. case ValueCondition._IsLesser: return "IsLesser";
  1466. default: return "";
  1467. }
  1468. };
  1469. /**
  1470. * Internal only
  1471. * @hidden
  1472. */
  1473. ValueCondition._IsEqual = 0;
  1474. /**
  1475. * Internal only
  1476. * @hidden
  1477. */
  1478. ValueCondition._IsDifferent = 1;
  1479. /**
  1480. * Internal only
  1481. * @hidden
  1482. */
  1483. ValueCondition._IsGreater = 2;
  1484. /**
  1485. * Internal only
  1486. * @hidden
  1487. */
  1488. ValueCondition._IsLesser = 3;
  1489. return ValueCondition;
  1490. }(Condition));
  1491. /**
  1492. * Defines a predicate condition as an extension of Condition
  1493. */
  1494. var PredicateCondition = /** @class */ (function (_super) {
  1495. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1496. /**
  1497. * Creates a new PredicateCondition
  1498. * @param actionManager manager for the action the condition applies to
  1499. * @param predicate defines the predicate function used to validate the condition
  1500. */
  1501. function PredicateCondition(actionManager,
  1502. /** defines the predicate function used to validate the condition */
  1503. predicate) {
  1504. var _this = _super.call(this, actionManager) || this;
  1505. _this.predicate = predicate;
  1506. return _this;
  1507. }
  1508. /**
  1509. * @returns the validity of the predicate condition
  1510. */
  1511. PredicateCondition.prototype.isValid = function () {
  1512. return this.predicate();
  1513. };
  1514. return PredicateCondition;
  1515. }(Condition));
  1516. /**
  1517. * Defines a state condition as an extension of Condition
  1518. */
  1519. var StateCondition = /** @class */ (function (_super) {
  1520. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1521. /**
  1522. * Creates a new StateCondition
  1523. * @param actionManager manager for the action the condition applies to
  1524. * @param target of the condition
  1525. * @param value to compare with target state
  1526. */
  1527. function StateCondition(actionManager, target,
  1528. /** Value to compare with target state */
  1529. value) {
  1530. var _this = _super.call(this, actionManager) || this;
  1531. _this.value = value;
  1532. _this._target = target;
  1533. return _this;
  1534. }
  1535. /**
  1536. * Gets a boolean indicating if the current condition is met
  1537. * @returns the validity of the state
  1538. */
  1539. StateCondition.prototype.isValid = function () {
  1540. return this._target.state === this.value;
  1541. };
  1542. /**
  1543. * Serialize the StateCondition into a JSON compatible object
  1544. * @returns serialization object
  1545. */
  1546. StateCondition.prototype.serialize = function () {
  1547. return this._serialize({
  1548. name: "StateCondition",
  1549. properties: [
  1550. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1551. { name: "value", value: this.value }
  1552. ]
  1553. });
  1554. };
  1555. return StateCondition;
  1556. }(Condition));
  1557. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1558. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1559. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1560. /***/ }),
  1561. /***/ "./Actions/directActions.ts":
  1562. /*!**********************************!*\
  1563. !*** ./Actions/directActions.ts ***!
  1564. \**********************************/
  1565. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1567. "use strict";
  1568. __webpack_require__.r(__webpack_exports__);
  1569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1580. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1581. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  1582. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1583. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1584. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1585. /**
  1586. * This defines an action responsible to toggle a boolean once triggered.
  1587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1588. */
  1589. var SwitchBooleanAction = /** @class */ (function (_super) {
  1590. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1591. /**
  1592. * Instantiate the action
  1593. * @param triggerOptions defines the trigger options
  1594. * @param target defines the object containing the boolean
  1595. * @param propertyPath defines the path to the boolean property in the target object
  1596. * @param condition defines the trigger related conditions
  1597. */
  1598. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1599. var _this = _super.call(this, triggerOptions, condition) || this;
  1600. _this.propertyPath = propertyPath;
  1601. _this._target = _this._effectiveTarget = target;
  1602. return _this;
  1603. }
  1604. /** @hidden */
  1605. SwitchBooleanAction.prototype._prepare = function () {
  1606. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1607. this._property = this._getProperty(this.propertyPath);
  1608. };
  1609. /**
  1610. * Execute the action toggle the boolean value.
  1611. */
  1612. SwitchBooleanAction.prototype.execute = function () {
  1613. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1614. };
  1615. /**
  1616. * Serializes the actions and its related information.
  1617. * @param parent defines the object to serialize in
  1618. * @returns the serialized object
  1619. */
  1620. SwitchBooleanAction.prototype.serialize = function (parent) {
  1621. return _super.prototype._serialize.call(this, {
  1622. name: "SwitchBooleanAction",
  1623. properties: [
  1624. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1625. { name: "propertyPath", value: this.propertyPath }
  1626. ]
  1627. }, parent);
  1628. };
  1629. return SwitchBooleanAction;
  1630. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1631. /**
  1632. * This defines an action responsible to set a the state field of the target
  1633. * to a desired value once triggered.
  1634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1635. */
  1636. var SetStateAction = /** @class */ (function (_super) {
  1637. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1638. /**
  1639. * Instantiate the action
  1640. * @param triggerOptions defines the trigger options
  1641. * @param target defines the object containing the state property
  1642. * @param value defines the value to store in the state field
  1643. * @param condition defines the trigger related conditions
  1644. */
  1645. function SetStateAction(triggerOptions, target, value, condition) {
  1646. var _this = _super.call(this, triggerOptions, condition) || this;
  1647. _this.value = value;
  1648. _this._target = target;
  1649. return _this;
  1650. }
  1651. /**
  1652. * Execute the action and store the value on the target state property.
  1653. */
  1654. SetStateAction.prototype.execute = function () {
  1655. this._target.state = this.value;
  1656. };
  1657. /**
  1658. * Serializes the actions and its related information.
  1659. * @param parent defines the object to serialize in
  1660. * @returns the serialized object
  1661. */
  1662. SetStateAction.prototype.serialize = function (parent) {
  1663. return _super.prototype._serialize.call(this, {
  1664. name: "SetStateAction",
  1665. properties: [
  1666. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1667. { name: "value", value: this.value }
  1668. ]
  1669. }, parent);
  1670. };
  1671. return SetStateAction;
  1672. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1673. /**
  1674. * This defines an action responsible to set a property of the target
  1675. * to a desired value once triggered.
  1676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1677. */
  1678. var SetValueAction = /** @class */ (function (_super) {
  1679. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1680. /**
  1681. * Instantiate the action
  1682. * @param triggerOptions defines the trigger options
  1683. * @param target defines the object containing the property
  1684. * @param propertyPath defines the path of the property to set in the target
  1685. * @param value defines the value to set in the property
  1686. * @param condition defines the trigger related conditions
  1687. */
  1688. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1689. var _this = _super.call(this, triggerOptions, condition) || this;
  1690. _this.propertyPath = propertyPath;
  1691. _this.value = value;
  1692. _this._target = _this._effectiveTarget = target;
  1693. return _this;
  1694. }
  1695. /** @hidden */
  1696. SetValueAction.prototype._prepare = function () {
  1697. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1698. this._property = this._getProperty(this.propertyPath);
  1699. };
  1700. /**
  1701. * Execute the action and set the targetted property to the desired value.
  1702. */
  1703. SetValueAction.prototype.execute = function () {
  1704. this._effectiveTarget[this._property] = this.value;
  1705. if (this._target.markAsDirty) {
  1706. this._target.markAsDirty(this._property);
  1707. }
  1708. };
  1709. /**
  1710. * Serializes the actions and its related information.
  1711. * @param parent defines the object to serialize in
  1712. * @returns the serialized object
  1713. */
  1714. SetValueAction.prototype.serialize = function (parent) {
  1715. return _super.prototype._serialize.call(this, {
  1716. name: "SetValueAction",
  1717. properties: [
  1718. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1719. { name: "propertyPath", value: this.propertyPath },
  1720. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1721. ]
  1722. }, parent);
  1723. };
  1724. return SetValueAction;
  1725. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1726. /**
  1727. * This defines an action responsible to increment the target value
  1728. * to a desired value once triggered.
  1729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1730. */
  1731. var IncrementValueAction = /** @class */ (function (_super) {
  1732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1733. /**
  1734. * Instantiate the action
  1735. * @param triggerOptions defines the trigger options
  1736. * @param target defines the object containing the property
  1737. * @param propertyPath defines the path of the property to increment in the target
  1738. * @param value defines the value value we should increment the property by
  1739. * @param condition defines the trigger related conditions
  1740. */
  1741. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1742. var _this = _super.call(this, triggerOptions, condition) || this;
  1743. _this.propertyPath = propertyPath;
  1744. _this.value = value;
  1745. _this._target = _this._effectiveTarget = target;
  1746. return _this;
  1747. }
  1748. /** @hidden */
  1749. IncrementValueAction.prototype._prepare = function () {
  1750. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1751. this._property = this._getProperty(this.propertyPath);
  1752. if (typeof this._effectiveTarget[this._property] !== "number") {
  1753. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1754. }
  1755. };
  1756. /**
  1757. * Execute the action and increment the target of the value amount.
  1758. */
  1759. IncrementValueAction.prototype.execute = function () {
  1760. this._effectiveTarget[this._property] += this.value;
  1761. if (this._target.markAsDirty) {
  1762. this._target.markAsDirty(this._property);
  1763. }
  1764. };
  1765. /**
  1766. * Serializes the actions and its related information.
  1767. * @param parent defines the object to serialize in
  1768. * @returns the serialized object
  1769. */
  1770. IncrementValueAction.prototype.serialize = function (parent) {
  1771. return _super.prototype._serialize.call(this, {
  1772. name: "IncrementValueAction",
  1773. properties: [
  1774. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1775. { name: "propertyPath", value: this.propertyPath },
  1776. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1777. ]
  1778. }, parent);
  1779. };
  1780. return IncrementValueAction;
  1781. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1782. /**
  1783. * This defines an action responsible to start an animation once triggered.
  1784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1785. */
  1786. var PlayAnimationAction = /** @class */ (function (_super) {
  1787. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1788. /**
  1789. * Instantiate the action
  1790. * @param triggerOptions defines the trigger options
  1791. * @param target defines the target animation or animation name
  1792. * @param from defines from where the animation should start (animation frame)
  1793. * @param end defines where the animation should stop (animation frame)
  1794. * @param loop defines if the animation should loop or stop after the first play
  1795. * @param condition defines the trigger related conditions
  1796. */
  1797. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1798. var _this = _super.call(this, triggerOptions, condition) || this;
  1799. _this.from = from;
  1800. _this.to = to;
  1801. _this.loop = loop;
  1802. _this._target = target;
  1803. return _this;
  1804. }
  1805. /** @hidden */
  1806. PlayAnimationAction.prototype._prepare = function () {
  1807. };
  1808. /**
  1809. * Execute the action and play the animation.
  1810. */
  1811. PlayAnimationAction.prototype.execute = function () {
  1812. var scene = this._actionManager.getScene();
  1813. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1814. };
  1815. /**
  1816. * Serializes the actions and its related information.
  1817. * @param parent defines the object to serialize in
  1818. * @returns the serialized object
  1819. */
  1820. PlayAnimationAction.prototype.serialize = function (parent) {
  1821. return _super.prototype._serialize.call(this, {
  1822. name: "PlayAnimationAction",
  1823. properties: [
  1824. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1825. { name: "from", value: String(this.from) },
  1826. { name: "to", value: String(this.to) },
  1827. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1828. ]
  1829. }, parent);
  1830. };
  1831. return PlayAnimationAction;
  1832. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1833. /**
  1834. * This defines an action responsible to stop an animation once triggered.
  1835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1836. */
  1837. var StopAnimationAction = /** @class */ (function (_super) {
  1838. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1839. /**
  1840. * Instantiate the action
  1841. * @param triggerOptions defines the trigger options
  1842. * @param target defines the target animation or animation name
  1843. * @param condition defines the trigger related conditions
  1844. */
  1845. function StopAnimationAction(triggerOptions, target, condition) {
  1846. var _this = _super.call(this, triggerOptions, condition) || this;
  1847. _this._target = target;
  1848. return _this;
  1849. }
  1850. /** @hidden */
  1851. StopAnimationAction.prototype._prepare = function () {
  1852. };
  1853. /**
  1854. * Execute the action and stop the animation.
  1855. */
  1856. StopAnimationAction.prototype.execute = function () {
  1857. var scene = this._actionManager.getScene();
  1858. scene.stopAnimation(this._target);
  1859. };
  1860. /**
  1861. * Serializes the actions and its related information.
  1862. * @param parent defines the object to serialize in
  1863. * @returns the serialized object
  1864. */
  1865. StopAnimationAction.prototype.serialize = function (parent) {
  1866. return _super.prototype._serialize.call(this, {
  1867. name: "StopAnimationAction",
  1868. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1869. }, parent);
  1870. };
  1871. return StopAnimationAction;
  1872. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1873. /**
  1874. * This defines an action responsible that does nothing once triggered.
  1875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1876. */
  1877. var DoNothingAction = /** @class */ (function (_super) {
  1878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1879. /**
  1880. * Instantiate the action
  1881. * @param triggerOptions defines the trigger options
  1882. * @param condition defines the trigger related conditions
  1883. */
  1884. function DoNothingAction(triggerOptions, condition) {
  1885. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1886. return _super.call(this, triggerOptions, condition) || this;
  1887. }
  1888. /**
  1889. * Execute the action and do nothing.
  1890. */
  1891. DoNothingAction.prototype.execute = function () {
  1892. };
  1893. /**
  1894. * Serializes the actions and its related information.
  1895. * @param parent defines the object to serialize in
  1896. * @returns the serialized object
  1897. */
  1898. DoNothingAction.prototype.serialize = function (parent) {
  1899. return _super.prototype._serialize.call(this, {
  1900. name: "DoNothingAction",
  1901. properties: []
  1902. }, parent);
  1903. };
  1904. return DoNothingAction;
  1905. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1906. /**
  1907. * This defines an action responsible to trigger several actions once triggered.
  1908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1909. */
  1910. var CombineAction = /** @class */ (function (_super) {
  1911. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1912. /**
  1913. * Instantiate the action
  1914. * @param triggerOptions defines the trigger options
  1915. * @param children defines the list of aggregated animations to run
  1916. * @param condition defines the trigger related conditions
  1917. */
  1918. function CombineAction(triggerOptions, children, condition) {
  1919. var _this = _super.call(this, triggerOptions, condition) || this;
  1920. _this.children = children;
  1921. return _this;
  1922. }
  1923. /** @hidden */
  1924. CombineAction.prototype._prepare = function () {
  1925. for (var index = 0; index < this.children.length; index++) {
  1926. this.children[index]._actionManager = this._actionManager;
  1927. this.children[index]._prepare();
  1928. }
  1929. };
  1930. /**
  1931. * Execute the action and executes all the aggregated actions.
  1932. */
  1933. CombineAction.prototype.execute = function (evt) {
  1934. for (var index = 0; index < this.children.length; index++) {
  1935. this.children[index].execute(evt);
  1936. }
  1937. };
  1938. /**
  1939. * Serializes the actions and its related information.
  1940. * @param parent defines the object to serialize in
  1941. * @returns the serialized object
  1942. */
  1943. CombineAction.prototype.serialize = function (parent) {
  1944. var serializationObject = _super.prototype._serialize.call(this, {
  1945. name: "CombineAction",
  1946. properties: [],
  1947. combine: []
  1948. }, parent);
  1949. for (var i = 0; i < this.children.length; i++) {
  1950. serializationObject.combine.push(this.children[i].serialize(null));
  1951. }
  1952. return serializationObject;
  1953. };
  1954. return CombineAction;
  1955. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1956. /**
  1957. * This defines an action responsible to run code (external event) once triggered.
  1958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1959. */
  1960. var ExecuteCodeAction = /** @class */ (function (_super) {
  1961. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1962. /**
  1963. * Instantiate the action
  1964. * @param triggerOptions defines the trigger options
  1965. * @param func defines the callback function to run
  1966. * @param condition defines the trigger related conditions
  1967. */
  1968. function ExecuteCodeAction(triggerOptions, func, condition) {
  1969. var _this = _super.call(this, triggerOptions, condition) || this;
  1970. _this.func = func;
  1971. return _this;
  1972. }
  1973. /**
  1974. * Execute the action and run the attached code.
  1975. */
  1976. ExecuteCodeAction.prototype.execute = function (evt) {
  1977. this.func(evt);
  1978. };
  1979. return ExecuteCodeAction;
  1980. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1981. /**
  1982. * This defines an action responsible to set the parent property of the target once triggered.
  1983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1984. */
  1985. var SetParentAction = /** @class */ (function (_super) {
  1986. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1987. /**
  1988. * Instantiate the action
  1989. * @param triggerOptions defines the trigger options
  1990. * @param target defines the target containing the parent property
  1991. * @param parent defines from where the animation should start (animation frame)
  1992. * @param condition defines the trigger related conditions
  1993. */
  1994. function SetParentAction(triggerOptions, target, parent, condition) {
  1995. var _this = _super.call(this, triggerOptions, condition) || this;
  1996. _this._target = target;
  1997. _this._parent = parent;
  1998. return _this;
  1999. }
  2000. /** @hidden */
  2001. SetParentAction.prototype._prepare = function () {
  2002. };
  2003. /**
  2004. * Execute the action and set the parent property.
  2005. */
  2006. SetParentAction.prototype.execute = function () {
  2007. if (this._target.parent === this._parent) {
  2008. return;
  2009. }
  2010. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  2011. invertParentWorldMatrix.invert();
  2012. this._target.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2013. this._target.parent = this._parent;
  2014. };
  2015. /**
  2016. * Serializes the actions and its related information.
  2017. * @param parent defines the object to serialize in
  2018. * @returns the serialized object
  2019. */
  2020. SetParentAction.prototype.serialize = function (parent) {
  2021. return _super.prototype._serialize.call(this, {
  2022. name: "SetParentAction",
  2023. properties: [
  2024. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2025. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2026. ]
  2027. }, parent);
  2028. };
  2029. return SetParentAction;
  2030. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2031. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2032. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2033. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2034. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2035. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2036. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2037. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2038. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2039. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2040. /***/ }),
  2041. /***/ "./Actions/directAudioActions.ts":
  2042. /*!***************************************!*\
  2043. !*** ./Actions/directAudioActions.ts ***!
  2044. \***************************************/
  2045. /*! exports provided: PlaySoundAction, StopSoundAction */
  2046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2047. "use strict";
  2048. __webpack_require__.r(__webpack_exports__);
  2049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2051. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2052. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2053. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2054. /**
  2055. * This defines an action helpful to play a defined sound on a triggered action.
  2056. */
  2057. var PlaySoundAction = /** @class */ (function (_super) {
  2058. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2059. /**
  2060. * Instantiate the action
  2061. * @param triggerOptions defines the trigger options
  2062. * @param sound defines the sound to play
  2063. * @param condition defines the trigger related conditions
  2064. */
  2065. function PlaySoundAction(triggerOptions, sound, condition) {
  2066. var _this = _super.call(this, triggerOptions, condition) || this;
  2067. _this._sound = sound;
  2068. return _this;
  2069. }
  2070. /** @hidden */
  2071. PlaySoundAction.prototype._prepare = function () {
  2072. };
  2073. /**
  2074. * Execute the action and play the sound.
  2075. */
  2076. PlaySoundAction.prototype.execute = function () {
  2077. if (this._sound !== undefined) {
  2078. this._sound.play();
  2079. }
  2080. };
  2081. /**
  2082. * Serializes the actions and its related information.
  2083. * @param parent defines the object to serialize in
  2084. * @returns the serialized object
  2085. */
  2086. PlaySoundAction.prototype.serialize = function (parent) {
  2087. return _super.prototype._serialize.call(this, {
  2088. name: "PlaySoundAction",
  2089. properties: [{ name: "sound", value: this._sound.name }]
  2090. }, parent);
  2091. };
  2092. return PlaySoundAction;
  2093. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2094. /**
  2095. * This defines an action helpful to stop a defined sound on a triggered action.
  2096. */
  2097. var StopSoundAction = /** @class */ (function (_super) {
  2098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2099. /**
  2100. * Instantiate the action
  2101. * @param triggerOptions defines the trigger options
  2102. * @param sound defines the sound to stop
  2103. * @param condition defines the trigger related conditions
  2104. */
  2105. function StopSoundAction(triggerOptions, sound, condition) {
  2106. var _this = _super.call(this, triggerOptions, condition) || this;
  2107. _this._sound = sound;
  2108. return _this;
  2109. }
  2110. /** @hidden */
  2111. StopSoundAction.prototype._prepare = function () {
  2112. };
  2113. /**
  2114. * Execute the action and stop the sound.
  2115. */
  2116. StopSoundAction.prototype.execute = function () {
  2117. if (this._sound !== undefined) {
  2118. this._sound.stop();
  2119. }
  2120. };
  2121. /**
  2122. * Serializes the actions and its related information.
  2123. * @param parent defines the object to serialize in
  2124. * @returns the serialized object
  2125. */
  2126. StopSoundAction.prototype.serialize = function (parent) {
  2127. return _super.prototype._serialize.call(this, {
  2128. name: "StopSoundAction",
  2129. properties: [{ name: "sound", value: this._sound.name }]
  2130. }, parent);
  2131. };
  2132. return StopSoundAction;
  2133. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2134. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2135. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2136. /***/ }),
  2137. /***/ "./Actions/index.ts":
  2138. /*!**************************!*\
  2139. !*** ./Actions/index.ts ***!
  2140. \**************************/
  2141. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2143. "use strict";
  2144. __webpack_require__.r(__webpack_exports__);
  2145. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2147. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2149. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2151. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2156. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2167. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2170. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2172. /***/ }),
  2173. /***/ "./Actions/interpolateValueAction.ts":
  2174. /*!*******************************************!*\
  2175. !*** ./Actions/interpolateValueAction.ts ***!
  2176. \*******************************************/
  2177. /*! exports provided: InterpolateValueAction */
  2178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2179. "use strict";
  2180. __webpack_require__.r(__webpack_exports__);
  2181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2182. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2183. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2184. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2185. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2186. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  2187. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  2188. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2189. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2190. /**
  2191. * This defines an action responsible to change the value of a property
  2192. * by interpolating between its current value and the newly set one once triggered.
  2193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2194. */
  2195. var InterpolateValueAction = /** @class */ (function (_super) {
  2196. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2197. /**
  2198. * Instantiate the action
  2199. * @param triggerOptions defines the trigger options
  2200. * @param target defines the object containing the value to interpolate
  2201. * @param propertyPath defines the path to the property in the target object
  2202. * @param value defines the target value at the end of the interpolation
  2203. * @param duration deines the time it will take for the property to interpolate to the value.
  2204. * @param condition defines the trigger related conditions
  2205. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2206. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2207. */
  2208. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2209. if (duration === void 0) { duration = 1000; }
  2210. var _this = _super.call(this, triggerOptions, condition) || this;
  2211. /**
  2212. * Defines the time it will take for the property to interpolate to the value.
  2213. */
  2214. _this.duration = 1000;
  2215. /**
  2216. * Observable triggered once the interpolation animation has been done.
  2217. */
  2218. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2219. _this.propertyPath = propertyPath;
  2220. _this.value = value;
  2221. _this.duration = duration;
  2222. _this.stopOtherAnimations = stopOtherAnimations;
  2223. _this.onInterpolationDone = onInterpolationDone;
  2224. _this._target = _this._effectiveTarget = target;
  2225. return _this;
  2226. }
  2227. /** @hidden */
  2228. InterpolateValueAction.prototype._prepare = function () {
  2229. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2230. this._property = this._getProperty(this.propertyPath);
  2231. };
  2232. /**
  2233. * Execute the action starts the value interpolation.
  2234. */
  2235. InterpolateValueAction.prototype.execute = function () {
  2236. var _this = this;
  2237. var scene = this._actionManager.getScene();
  2238. var keys = [
  2239. {
  2240. frame: 0,
  2241. value: this._effectiveTarget[this._property]
  2242. }, {
  2243. frame: 100,
  2244. value: this.value
  2245. }
  2246. ];
  2247. var dataType;
  2248. if (typeof this.value === "number") {
  2249. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONTYPE_FLOAT;
  2250. }
  2251. else if (this.value instanceof _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2252. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONTYPE_COLOR3;
  2253. }
  2254. else if (this.value instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"]) {
  2255. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONTYPE_VECTOR3;
  2256. }
  2257. else if (this.value instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"]) {
  2258. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONTYPE_MATRIX;
  2259. }
  2260. else if (this.value instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Quaternion"]) {
  2261. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONTYPE_QUATERNION;
  2262. }
  2263. else {
  2264. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2265. return;
  2266. }
  2267. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2268. animation.setKeys(keys);
  2269. if (this.stopOtherAnimations) {
  2270. scene.stopAnimation(this._effectiveTarget);
  2271. }
  2272. var wrapper = function () {
  2273. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2274. if (_this.onInterpolationDone) {
  2275. _this.onInterpolationDone();
  2276. }
  2277. };
  2278. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2279. };
  2280. /**
  2281. * Serializes the actions and its related information.
  2282. * @param parent defines the object to serialize in
  2283. * @returns the serialized object
  2284. */
  2285. InterpolateValueAction.prototype.serialize = function (parent) {
  2286. return _super.prototype._serialize.call(this, {
  2287. name: "InterpolateValueAction",
  2288. properties: [
  2289. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2290. { name: "propertyPath", value: this.propertyPath },
  2291. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2292. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2293. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2294. ]
  2295. }, parent);
  2296. };
  2297. return InterpolateValueAction;
  2298. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2299. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2300. /***/ }),
  2301. /***/ "./Animations/animatable.ts":
  2302. /*!**********************************!*\
  2303. !*** ./Animations/animatable.ts ***!
  2304. \**********************************/
  2305. /*! exports provided: Animatable */
  2306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2307. "use strict";
  2308. __webpack_require__.r(__webpack_exports__);
  2309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2310. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2311. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2312. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2313. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2314. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  2315. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2316. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2317. /**
  2318. * Class used to store an actual running animation
  2319. */
  2320. var Animatable = /** @class */ (function () {
  2321. /**
  2322. * Creates a new Animatable
  2323. * @param scene defines the hosting scene
  2324. * @param target defines the target object
  2325. * @param fromFrame defines the starting frame number (default is 0)
  2326. * @param toFrame defines the ending frame number (default is 100)
  2327. * @param loopAnimation defines if the animation must loop (default is false)
  2328. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2329. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2330. * @param animations defines a group of animation to add to the new Animatable
  2331. * @param onAnimationLoop defines a callback to call when animation loops
  2332. */
  2333. function Animatable(scene,
  2334. /** defines the target object */
  2335. target,
  2336. /** defines the starting frame number (default is 0) */
  2337. fromFrame,
  2338. /** defines the ending frame number (default is 100) */
  2339. toFrame,
  2340. /** defines if the animation must loop (default is false) */
  2341. loopAnimation, speedRatio,
  2342. /** defines a callback to call when animation ends if it is not looping */
  2343. onAnimationEnd, animations,
  2344. /** defines a callback to call when animation loops */
  2345. onAnimationLoop) {
  2346. if (fromFrame === void 0) { fromFrame = 0; }
  2347. if (toFrame === void 0) { toFrame = 100; }
  2348. if (loopAnimation === void 0) { loopAnimation = false; }
  2349. if (speedRatio === void 0) { speedRatio = 1.0; }
  2350. this.target = target;
  2351. this.fromFrame = fromFrame;
  2352. this.toFrame = toFrame;
  2353. this.loopAnimation = loopAnimation;
  2354. this.onAnimationEnd = onAnimationEnd;
  2355. this.onAnimationLoop = onAnimationLoop;
  2356. this._localDelayOffset = null;
  2357. this._pausedDelay = null;
  2358. this._runtimeAnimations = new Array();
  2359. this._paused = false;
  2360. this._speedRatio = 1;
  2361. this._weight = -1.0;
  2362. this._syncRoot = null;
  2363. /**
  2364. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2365. * This will only apply for non looping animation (default is true)
  2366. */
  2367. this.disposeOnEnd = true;
  2368. /**
  2369. * Gets a boolean indicating if the animation has started
  2370. */
  2371. this.animationStarted = false;
  2372. /**
  2373. * Observer raised when the animation ends
  2374. */
  2375. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2376. /**
  2377. * Observer raised when the animation loops
  2378. */
  2379. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2380. this._scene = scene;
  2381. if (animations) {
  2382. this.appendAnimations(target, animations);
  2383. }
  2384. this._speedRatio = speedRatio;
  2385. scene._activeAnimatables.push(this);
  2386. }
  2387. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2388. /**
  2389. * Gets the root Animatable used to synchronize and normalize animations
  2390. */
  2391. get: function () {
  2392. return this._syncRoot;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2398. /**
  2399. * Gets the current frame of the first RuntimeAnimation
  2400. * Used to synchronize Animatables
  2401. */
  2402. get: function () {
  2403. if (this._runtimeAnimations.length === 0) {
  2404. return 0;
  2405. }
  2406. return this._runtimeAnimations[0].currentFrame;
  2407. },
  2408. enumerable: true,
  2409. configurable: true
  2410. });
  2411. Object.defineProperty(Animatable.prototype, "weight", {
  2412. /**
  2413. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2414. */
  2415. get: function () {
  2416. return this._weight;
  2417. },
  2418. set: function (value) {
  2419. if (value === -1) { // -1 is ok and means no weight
  2420. this._weight = -1;
  2421. return;
  2422. }
  2423. // Else weight must be in [0, 1] range
  2424. this._weight = Math.min(Math.max(value, 0), 1.0);
  2425. },
  2426. enumerable: true,
  2427. configurable: true
  2428. });
  2429. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2430. /**
  2431. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2432. */
  2433. get: function () {
  2434. return this._speedRatio;
  2435. },
  2436. set: function (value) {
  2437. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2438. var animation = this._runtimeAnimations[index];
  2439. animation._prepareForSpeedRatioChange(value);
  2440. }
  2441. this._speedRatio = value;
  2442. },
  2443. enumerable: true,
  2444. configurable: true
  2445. });
  2446. // Methods
  2447. /**
  2448. * Synchronize and normalize current Animatable with a source Animatable
  2449. * This is useful when using animation weights and when animations are not of the same length
  2450. * @param root defines the root Animatable to synchronize with
  2451. * @returns the current Animatable
  2452. */
  2453. Animatable.prototype.syncWith = function (root) {
  2454. this._syncRoot = root;
  2455. if (root) {
  2456. // Make sure this animatable will animate after the root
  2457. var index = this._scene._activeAnimatables.indexOf(this);
  2458. if (index > -1) {
  2459. this._scene._activeAnimatables.splice(index, 1);
  2460. this._scene._activeAnimatables.push(this);
  2461. }
  2462. }
  2463. return this;
  2464. };
  2465. /**
  2466. * Gets the list of runtime animations
  2467. * @returns an array of RuntimeAnimation
  2468. */
  2469. Animatable.prototype.getAnimations = function () {
  2470. return this._runtimeAnimations;
  2471. };
  2472. /**
  2473. * Adds more animations to the current animatable
  2474. * @param target defines the target of the animations
  2475. * @param animations defines the new animations to add
  2476. */
  2477. Animatable.prototype.appendAnimations = function (target, animations) {
  2478. var _this = this;
  2479. for (var index = 0; index < animations.length; index++) {
  2480. var animation = animations[index];
  2481. var newRuntimeAnimation = new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this);
  2482. newRuntimeAnimation._onLoop = function () {
  2483. _this.onAnimationLoopObservable.notifyObservers(_this);
  2484. if (_this.onAnimationLoop) {
  2485. _this.onAnimationLoop();
  2486. }
  2487. };
  2488. this._runtimeAnimations.push(newRuntimeAnimation);
  2489. }
  2490. };
  2491. /**
  2492. * Gets the source animation for a specific property
  2493. * @param property defines the propertyu to look for
  2494. * @returns null or the source animation for the given property
  2495. */
  2496. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2497. var runtimeAnimations = this._runtimeAnimations;
  2498. for (var index = 0; index < runtimeAnimations.length; index++) {
  2499. if (runtimeAnimations[index].animation.targetProperty === property) {
  2500. return runtimeAnimations[index].animation;
  2501. }
  2502. }
  2503. return null;
  2504. };
  2505. /**
  2506. * Gets the runtime animation for a specific property
  2507. * @param property defines the propertyu to look for
  2508. * @returns null or the runtime animation for the given property
  2509. */
  2510. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2511. var runtimeAnimations = this._runtimeAnimations;
  2512. for (var index = 0; index < runtimeAnimations.length; index++) {
  2513. if (runtimeAnimations[index].animation.targetProperty === property) {
  2514. return runtimeAnimations[index];
  2515. }
  2516. }
  2517. return null;
  2518. };
  2519. /**
  2520. * Resets the animatable to its original state
  2521. */
  2522. Animatable.prototype.reset = function () {
  2523. var runtimeAnimations = this._runtimeAnimations;
  2524. for (var index = 0; index < runtimeAnimations.length; index++) {
  2525. runtimeAnimations[index].reset(true);
  2526. }
  2527. this._localDelayOffset = null;
  2528. this._pausedDelay = null;
  2529. };
  2530. /**
  2531. * Allows the animatable to blend with current running animations
  2532. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2533. * @param blendingSpeed defines the blending speed to use
  2534. */
  2535. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2536. var runtimeAnimations = this._runtimeAnimations;
  2537. for (var index = 0; index < runtimeAnimations.length; index++) {
  2538. runtimeAnimations[index].animation.enableBlending = true;
  2539. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2540. }
  2541. };
  2542. /**
  2543. * Disable animation blending
  2544. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2545. */
  2546. Animatable.prototype.disableBlending = function () {
  2547. var runtimeAnimations = this._runtimeAnimations;
  2548. for (var index = 0; index < runtimeAnimations.length; index++) {
  2549. runtimeAnimations[index].animation.enableBlending = false;
  2550. }
  2551. };
  2552. /**
  2553. * Jump directly to a given frame
  2554. * @param frame defines the frame to jump to
  2555. */
  2556. Animatable.prototype.goToFrame = function (frame) {
  2557. var runtimeAnimations = this._runtimeAnimations;
  2558. if (runtimeAnimations[0]) {
  2559. var fps = runtimeAnimations[0].animation.framePerSecond;
  2560. var currentFrame = runtimeAnimations[0].currentFrame;
  2561. var adjustTime = frame - currentFrame;
  2562. var delay = this.speedRatio !== 0 ? adjustTime * 1000 / (fps * this.speedRatio) : 0;
  2563. if (this._localDelayOffset === null) {
  2564. this._localDelayOffset = 0;
  2565. }
  2566. this._localDelayOffset -= delay;
  2567. }
  2568. for (var index = 0; index < runtimeAnimations.length; index++) {
  2569. runtimeAnimations[index].goToFrame(frame);
  2570. }
  2571. };
  2572. /**
  2573. * Pause the animation
  2574. */
  2575. Animatable.prototype.pause = function () {
  2576. if (this._paused) {
  2577. return;
  2578. }
  2579. this._paused = true;
  2580. };
  2581. /**
  2582. * Restart the animation
  2583. */
  2584. Animatable.prototype.restart = function () {
  2585. this._paused = false;
  2586. };
  2587. Animatable.prototype._raiseOnAnimationEnd = function () {
  2588. if (this.onAnimationEnd) {
  2589. this.onAnimationEnd();
  2590. }
  2591. this.onAnimationEndObservable.notifyObservers(this);
  2592. };
  2593. /**
  2594. * Stop and delete the current animation
  2595. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2596. * @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)
  2597. */
  2598. Animatable.prototype.stop = function (animationName, targetMask) {
  2599. if (animationName || targetMask) {
  2600. var idx = this._scene._activeAnimatables.indexOf(this);
  2601. if (idx > -1) {
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2604. var runtimeAnimation = runtimeAnimations[index];
  2605. if (animationName && runtimeAnimation.animation.name != animationName) {
  2606. continue;
  2607. }
  2608. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2609. continue;
  2610. }
  2611. runtimeAnimation.dispose();
  2612. runtimeAnimations.splice(index, 1);
  2613. }
  2614. if (runtimeAnimations.length == 0) {
  2615. this._scene._activeAnimatables.splice(idx, 1);
  2616. this._raiseOnAnimationEnd();
  2617. }
  2618. }
  2619. }
  2620. else {
  2621. var index = this._scene._activeAnimatables.indexOf(this);
  2622. if (index > -1) {
  2623. this._scene._activeAnimatables.splice(index, 1);
  2624. var runtimeAnimations = this._runtimeAnimations;
  2625. for (var index = 0; index < runtimeAnimations.length; index++) {
  2626. runtimeAnimations[index].dispose();
  2627. }
  2628. this._raiseOnAnimationEnd();
  2629. }
  2630. }
  2631. };
  2632. /**
  2633. * Wait asynchronously for the animation to end
  2634. * @returns a promise which will be fullfilled when the animation ends
  2635. */
  2636. Animatable.prototype.waitAsync = function () {
  2637. var _this = this;
  2638. return new Promise(function (resolve, reject) {
  2639. _this.onAnimationEndObservable.add(function () {
  2640. resolve(_this);
  2641. }, undefined, undefined, _this, true);
  2642. });
  2643. };
  2644. /** @hidden */
  2645. Animatable.prototype._animate = function (delay) {
  2646. if (this._paused) {
  2647. this.animationStarted = false;
  2648. if (this._pausedDelay === null) {
  2649. this._pausedDelay = delay;
  2650. }
  2651. return true;
  2652. }
  2653. if (this._localDelayOffset === null) {
  2654. this._localDelayOffset = delay;
  2655. this._pausedDelay = null;
  2656. }
  2657. else if (this._pausedDelay !== null) {
  2658. this._localDelayOffset += delay - this._pausedDelay;
  2659. this._pausedDelay = null;
  2660. }
  2661. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2662. return true;
  2663. }
  2664. // Animating
  2665. var running = false;
  2666. var runtimeAnimations = this._runtimeAnimations;
  2667. var index;
  2668. for (index = 0; index < runtimeAnimations.length; index++) {
  2669. var animation = runtimeAnimations[index];
  2670. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
  2671. running = running || isRunning;
  2672. }
  2673. this.animationStarted = running;
  2674. if (!running) {
  2675. if (this.disposeOnEnd) {
  2676. // Remove from active animatables
  2677. index = this._scene._activeAnimatables.indexOf(this);
  2678. this._scene._activeAnimatables.splice(index, 1);
  2679. // Dispose all runtime animations
  2680. for (index = 0; index < runtimeAnimations.length; index++) {
  2681. runtimeAnimations[index].dispose();
  2682. }
  2683. }
  2684. this._raiseOnAnimationEnd();
  2685. if (this.disposeOnEnd) {
  2686. this.onAnimationEnd = null;
  2687. this.onAnimationLoop = null;
  2688. this.onAnimationLoopObservable.clear();
  2689. this.onAnimationEndObservable.clear();
  2690. }
  2691. }
  2692. return running;
  2693. };
  2694. return Animatable;
  2695. }());
  2696. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2697. if (!this.animationsEnabled) {
  2698. return;
  2699. }
  2700. var animatables = this._activeAnimatables;
  2701. if (animatables.length === 0) {
  2702. return;
  2703. }
  2704. // Getting time
  2705. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2706. if (!this._animationTimeLast) {
  2707. if (this._pendingData.length > 0) {
  2708. return;
  2709. }
  2710. this._animationTimeLast = now;
  2711. }
  2712. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2713. this._animationTime += deltaTime;
  2714. var animationTime = this._animationTime;
  2715. this._animationTimeLast = now;
  2716. for (var index = 0; index < animatables.length; index++) {
  2717. var animatable = animatables[index];
  2718. if (!animatable._animate(animationTime) && animatable.disposeOnEnd) {
  2719. index--; // Array was updated
  2720. }
  2721. }
  2722. // Late animation bindings
  2723. this._processLateAnimationBindings();
  2724. };
  2725. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2726. if (weight === void 0) { weight = 1.0; }
  2727. if (speedRatio === void 0) { speedRatio = 1.0; }
  2728. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2729. returnedAnimatable.weight = weight;
  2730. return returnedAnimatable;
  2731. };
  2732. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2733. if (speedRatio === void 0) { speedRatio = 1.0; }
  2734. if (stopCurrent === void 0) { stopCurrent = true; }
  2735. if (from > to && speedRatio > 0) {
  2736. speedRatio *= -1;
  2737. }
  2738. if (stopCurrent) {
  2739. this.stopAnimation(target, undefined, targetMask);
  2740. }
  2741. if (!animatable) {
  2742. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2743. }
  2744. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2745. // Local animations
  2746. if (target.animations && shouldRunTargetAnimations) {
  2747. animatable.appendAnimations(target, target.animations);
  2748. }
  2749. // Children animations
  2750. if (target.getAnimatables) {
  2751. var animatables = target.getAnimatables();
  2752. for (var index = 0; index < animatables.length; index++) {
  2753. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2754. }
  2755. }
  2756. animatable.reset();
  2757. return animatable;
  2758. };
  2759. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2760. if (speedRatio === void 0) { speedRatio = 1.0; }
  2761. if (stopCurrent === void 0) { stopCurrent = true; }
  2762. var children = target.getDescendants(directDescendantsOnly);
  2763. var result = [];
  2764. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2765. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2766. var child = children_1[_i];
  2767. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2768. }
  2769. return result;
  2770. };
  2771. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2772. if (speedRatio === undefined) {
  2773. speedRatio = 1.0;
  2774. }
  2775. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2776. return animatable;
  2777. };
  2778. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2779. var children = target.getDescendants(directDescendantsOnly);
  2780. var result = [];
  2781. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2782. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2783. var child = children_2[_i];
  2784. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2785. }
  2786. return result;
  2787. };
  2788. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2789. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2790. if (this._activeAnimatables[index].target === target) {
  2791. return this._activeAnimatables[index];
  2792. }
  2793. }
  2794. return null;
  2795. };
  2796. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2797. var result = [];
  2798. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2799. if (this._activeAnimatables[index].target === target) {
  2800. result.push(this._activeAnimatables[index]);
  2801. }
  2802. }
  2803. return result;
  2804. };
  2805. /**
  2806. * Will stop the animation of the given target
  2807. * @param target - the target
  2808. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2809. * @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)
  2810. */
  2811. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2812. var animatables = this.getAllAnimatablesByTarget(target);
  2813. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2814. var animatable = animatables_1[_i];
  2815. animatable.stop(animationName, targetMask);
  2816. }
  2817. };
  2818. /**
  2819. * Stops and removes all animations that have been applied to the scene
  2820. */
  2821. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2822. if (this._activeAnimatables) {
  2823. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2824. this._activeAnimatables[i].stop();
  2825. }
  2826. this._activeAnimatables = [];
  2827. }
  2828. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2829. var group = _a[_i];
  2830. group.stop();
  2831. }
  2832. };
  2833. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2834. var target = runtimeAnimation.target;
  2835. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2836. if (!target._lateAnimationHolders) {
  2837. target._lateAnimationHolders = {};
  2838. }
  2839. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2840. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2841. totalWeight: 0,
  2842. animations: [],
  2843. originalValue: originalValue
  2844. };
  2845. }
  2846. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2847. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2848. };
  2849. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2850. var normalizer = 1.0;
  2851. var finalPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Vector3[0];
  2852. var finalScaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Vector3[1];
  2853. var finalQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Quaternion[0];
  2854. var startIndex = 0;
  2855. var originalAnimation = holder.animations[0];
  2856. var originalValue = holder.originalValue;
  2857. var scale = 1;
  2858. if (holder.totalWeight < 1.0) {
  2859. // We need to mix the original value in
  2860. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2861. scale = 1.0 - holder.totalWeight;
  2862. }
  2863. else {
  2864. startIndex = 1;
  2865. // We need to normalize the weights
  2866. normalizer = holder.totalWeight;
  2867. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2868. scale = originalAnimation.weight / normalizer;
  2869. if (scale == 1) {
  2870. return originalAnimation.currentValue;
  2871. }
  2872. }
  2873. finalScaling.scaleInPlace(scale);
  2874. finalPosition.scaleInPlace(scale);
  2875. finalQuaternion.scaleInPlace(scale);
  2876. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2877. var runtimeAnimation = holder.animations[animIndex];
  2878. var scale = runtimeAnimation.weight / normalizer;
  2879. var currentPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Vector3[2];
  2880. var currentScaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Vector3[3];
  2881. var currentQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Quaternion[1];
  2882. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2883. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2884. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2885. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2886. }
  2887. var workValue = originalAnimation._animationState.workValue;
  2888. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, workValue);
  2889. return workValue;
  2890. };
  2891. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2892. var originalAnimation = holder.animations[0];
  2893. var originalValue = holder.originalValue;
  2894. if (holder.animations.length === 1) {
  2895. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2896. return refQuaternion;
  2897. }
  2898. var normalizer = 1.0;
  2899. var quaternions;
  2900. var weights;
  2901. if (holder.totalWeight < 1.0) {
  2902. var scale = 1.0 - holder.totalWeight;
  2903. quaternions = [];
  2904. weights = [];
  2905. quaternions.push(originalValue);
  2906. weights.push(scale);
  2907. }
  2908. else {
  2909. if (holder.animations.length === 2) { // Slerp as soon as we can
  2910. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2911. return refQuaternion;
  2912. }
  2913. quaternions = [];
  2914. weights = [];
  2915. normalizer = holder.totalWeight;
  2916. }
  2917. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2918. var runtimeAnimation = holder.animations[animIndex];
  2919. quaternions.push(runtimeAnimation.currentValue);
  2920. weights.push(runtimeAnimation.weight / normalizer);
  2921. }
  2922. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2923. var cumulativeAmount = 0;
  2924. var cumulativeQuaternion = null;
  2925. for (var index = 0; index < quaternions.length;) {
  2926. if (!cumulativeQuaternion) {
  2927. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2928. cumulativeQuaternion = refQuaternion;
  2929. cumulativeAmount = weights[index] + weights[index + 1];
  2930. index += 2;
  2931. continue;
  2932. }
  2933. cumulativeAmount += weights[index];
  2934. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2935. index++;
  2936. }
  2937. return cumulativeQuaternion;
  2938. };
  2939. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2940. if (!this._registeredForLateAnimationBindings.length) {
  2941. return;
  2942. }
  2943. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2944. var target = this._registeredForLateAnimationBindings.data[index];
  2945. for (var path in target._lateAnimationHolders) {
  2946. var holder = target._lateAnimationHolders[path];
  2947. var originalAnimation = holder.animations[0];
  2948. var originalValue = holder.originalValue;
  2949. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2950. var finalValue = target[path];
  2951. if (matrixDecomposeMode) {
  2952. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2953. }
  2954. else {
  2955. var quaternionMode = originalValue.w !== undefined;
  2956. if (quaternionMode) {
  2957. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2958. }
  2959. else {
  2960. var startIndex = 0;
  2961. var normalizer = 1.0;
  2962. if (holder.totalWeight < 1.0) {
  2963. // We need to mix the original value in
  2964. if (originalValue.scale) {
  2965. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2966. }
  2967. else {
  2968. finalValue = originalValue * (1.0 - holder.totalWeight);
  2969. }
  2970. }
  2971. else {
  2972. // We need to normalize the weights
  2973. normalizer = holder.totalWeight;
  2974. var scale_1 = originalAnimation.weight / normalizer;
  2975. if (scale_1 !== 1) {
  2976. if (originalAnimation.currentValue.scale) {
  2977. finalValue = originalAnimation.currentValue.scale(scale_1);
  2978. }
  2979. else {
  2980. finalValue = originalAnimation.currentValue * scale_1;
  2981. }
  2982. }
  2983. else {
  2984. finalValue = originalAnimation.currentValue;
  2985. }
  2986. startIndex = 1;
  2987. }
  2988. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2989. var runtimeAnimation = holder.animations[animIndex];
  2990. var scale = runtimeAnimation.weight / normalizer;
  2991. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2992. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2993. }
  2994. else {
  2995. finalValue += runtimeAnimation.currentValue * scale;
  2996. }
  2997. }
  2998. }
  2999. }
  3000. target[path] = finalValue;
  3001. }
  3002. target._lateAnimationHolders = {};
  3003. }
  3004. this._registeredForLateAnimationBindings.reset();
  3005. };
  3006. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  3007. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  3008. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  3009. // all animation may be coming from a library skeleton, so may need to create animation
  3010. if (this.animations.length === 0) {
  3011. 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));
  3012. this.animations[0].setKeys([]);
  3013. }
  3014. // get animation info / verify there is such a range from the source bone
  3015. var sourceRange = source.animations[0].getRange(rangeName);
  3016. if (!sourceRange) {
  3017. return false;
  3018. }
  3019. var from = sourceRange.from;
  3020. var to = sourceRange.to;
  3021. var sourceKeys = source.animations[0].getKeys();
  3022. // rescaling prep
  3023. var sourceBoneLength = source.length;
  3024. var sourceParent = source.getParent();
  3025. var parent = this.getParent();
  3026. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3027. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3028. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3029. var destKeys = this.animations[0].getKeys();
  3030. // loop vars declaration
  3031. var orig;
  3032. var origTranslation;
  3033. var mat;
  3034. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3035. orig = sourceKeys[key];
  3036. if (orig.frame >= from && orig.frame <= to) {
  3037. if (rescaleAsRequired) {
  3038. mat = orig.value.clone();
  3039. // scale based on parent ratio, when bone has parent
  3040. if (parentScalingReqd) {
  3041. origTranslation = mat.getTranslation();
  3042. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3043. // scale based on skeleton dimension ratio when root bone, and value is passed
  3044. }
  3045. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3046. origTranslation = mat.getTranslation();
  3047. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3048. // use original when root bone, and no data for skelDimensionsRatio
  3049. }
  3050. else {
  3051. mat = orig.value;
  3052. }
  3053. }
  3054. else {
  3055. mat = orig.value;
  3056. }
  3057. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3058. }
  3059. }
  3060. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3061. return true;
  3062. };
  3063. /***/ }),
  3064. /***/ "./Animations/animation.ts":
  3065. /*!*********************************!*\
  3066. !*** ./Animations/animation.ts ***!
  3067. \*********************************/
  3068. /*! exports provided: _IAnimationState, Animation */
  3069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3070. "use strict";
  3071. __webpack_require__.r(__webpack_exports__);
  3072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _IAnimationState; });
  3073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3074. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  3075. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  3076. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3077. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3078. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3079. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3080. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3081. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../node */ "./node.ts");
  3082. /* harmony import */ var _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Maths/math.size */ "./Maths/math.size.ts");
  3083. /**
  3084. * @hidden
  3085. */
  3086. var _IAnimationState = /** @class */ (function () {
  3087. function _IAnimationState() {
  3088. }
  3089. return _IAnimationState;
  3090. }());
  3091. /**
  3092. * Class used to store any kind of animation
  3093. */
  3094. var Animation = /** @class */ (function () {
  3095. /**
  3096. * Initializes the animation
  3097. * @param name Name of the animation
  3098. * @param targetProperty Property to animate
  3099. * @param framePerSecond The frames per second of the animation
  3100. * @param dataType The data type of the animation
  3101. * @param loopMode The loop mode of the animation
  3102. * @param enableBlending Specifies if blending should be enabled
  3103. */
  3104. function Animation(
  3105. /**Name of the animation */
  3106. name,
  3107. /**Property to animate */
  3108. targetProperty,
  3109. /**The frames per second of the animation */
  3110. framePerSecond,
  3111. /**The data type of the animation */
  3112. dataType,
  3113. /**The loop mode of the animation */
  3114. loopMode,
  3115. /**Specifies if blending should be enabled */
  3116. enableBlending) {
  3117. this.name = name;
  3118. this.targetProperty = targetProperty;
  3119. this.framePerSecond = framePerSecond;
  3120. this.dataType = dataType;
  3121. this.loopMode = loopMode;
  3122. this.enableBlending = enableBlending;
  3123. /**
  3124. * @hidden Internal use only
  3125. */
  3126. this._runtimeAnimations = new Array();
  3127. /**
  3128. * The set of event that will be linked to this animation
  3129. */
  3130. this._events = new Array();
  3131. /**
  3132. * Stores the blending speed of the animation
  3133. */
  3134. this.blendingSpeed = 0.01;
  3135. /**
  3136. * Stores the animation ranges for the animation
  3137. */
  3138. this._ranges = {};
  3139. this.targetPropertyPath = targetProperty.split(".");
  3140. this.dataType = dataType;
  3141. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3142. }
  3143. /**
  3144. * @hidden Internal use
  3145. */
  3146. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3147. var dataType = undefined;
  3148. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3149. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3150. }
  3151. else if (from instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3152. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3153. }
  3154. else if (from instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3155. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3156. }
  3157. else if (from instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3158. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3159. }
  3160. else if (from instanceof _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  3161. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3162. }
  3163. else if (from instanceof _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__["Size"]) {
  3164. dataType = Animation.ANIMATIONTYPE_SIZE;
  3165. }
  3166. if (dataType == undefined) {
  3167. return null;
  3168. }
  3169. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3170. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3171. animation.setKeys(keys);
  3172. if (easingFunction !== undefined) {
  3173. animation.setEasingFunction(easingFunction);
  3174. }
  3175. return animation;
  3176. };
  3177. /**
  3178. * Sets up an animation
  3179. * @param property The property to animate
  3180. * @param animationType The animation type to apply
  3181. * @param framePerSecond The frames per second of the animation
  3182. * @param easingFunction The easing function used in the animation
  3183. * @returns The created animation
  3184. */
  3185. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3186. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3187. animation.setEasingFunction(easingFunction);
  3188. return animation;
  3189. };
  3190. /**
  3191. * Create and start an animation on a node
  3192. * @param name defines the name of the global animation that will be run on all nodes
  3193. * @param node defines the root node where the animation will take place
  3194. * @param targetProperty defines property to animate
  3195. * @param framePerSecond defines the number of frame per second yo use
  3196. * @param totalFrame defines the number of frames in total
  3197. * @param from defines the initial value
  3198. * @param to defines the final value
  3199. * @param loopMode defines which loop mode you want to use (off by default)
  3200. * @param easingFunction defines the easing function to use (linear by default)
  3201. * @param onAnimationEnd defines the callback to call when animation end
  3202. * @returns the animatable created for this animation
  3203. */
  3204. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3205. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3206. if (!animation) {
  3207. return null;
  3208. }
  3209. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3210. };
  3211. /**
  3212. * Create and start an animation on a node and its descendants
  3213. * @param name defines the name of the global animation that will be run on all nodes
  3214. * @param node defines the root node where the animation will take place
  3215. * @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
  3216. * @param targetProperty defines property to animate
  3217. * @param framePerSecond defines the number of frame per second to use
  3218. * @param totalFrame defines the number of frames in total
  3219. * @param from defines the initial value
  3220. * @param to defines the final value
  3221. * @param loopMode defines which loop mode you want to use (off by default)
  3222. * @param easingFunction defines the easing function to use (linear by default)
  3223. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3224. * @returns the list of animatables created for all nodes
  3225. * @example https://www.babylonjs-playground.com/#MH0VLI
  3226. */
  3227. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3228. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3229. if (!animation) {
  3230. return null;
  3231. }
  3232. var scene = node.getScene();
  3233. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3234. };
  3235. /**
  3236. * Creates a new animation, merges it with the existing animations and starts it
  3237. * @param name Name of the animation
  3238. * @param node Node which contains the scene that begins the animations
  3239. * @param targetProperty Specifies which property to animate
  3240. * @param framePerSecond The frames per second of the animation
  3241. * @param totalFrame The total number of frames
  3242. * @param from The frame at the beginning of the animation
  3243. * @param to The frame at the end of the animation
  3244. * @param loopMode Specifies the loop mode of the animation
  3245. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3246. * @param onAnimationEnd Callback to run once the animation is complete
  3247. * @returns Nullable animation
  3248. */
  3249. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3250. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3251. if (!animation) {
  3252. return null;
  3253. }
  3254. node.animations.push(animation);
  3255. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3256. };
  3257. /**
  3258. * Transition property of an host to the target Value
  3259. * @param property The property to transition
  3260. * @param targetValue The target Value of the property
  3261. * @param host The object where the property to animate belongs
  3262. * @param scene Scene used to run the animation
  3263. * @param frameRate Framerate (in frame/s) to use
  3264. * @param transition The transition type we want to use
  3265. * @param duration The duration of the animation, in milliseconds
  3266. * @param onAnimationEnd Callback trigger at the end of the animation
  3267. * @returns Nullable animation
  3268. */
  3269. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3270. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3271. if (duration <= 0) {
  3272. host[property] = targetValue;
  3273. if (onAnimationEnd) {
  3274. onAnimationEnd();
  3275. }
  3276. return null;
  3277. }
  3278. var endFrame = frameRate * (duration / 1000);
  3279. transition.setKeys([{
  3280. frame: 0,
  3281. value: host[property].clone ? host[property].clone() : host[property]
  3282. },
  3283. {
  3284. frame: endFrame,
  3285. value: targetValue
  3286. }]);
  3287. if (!host.animations) {
  3288. host.animations = [];
  3289. }
  3290. host.animations.push(transition);
  3291. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3292. animation.onAnimationEnd = onAnimationEnd;
  3293. return animation;
  3294. };
  3295. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3296. /**
  3297. * Return the array of runtime animations currently using this animation
  3298. */
  3299. get: function () {
  3300. return this._runtimeAnimations;
  3301. },
  3302. enumerable: true,
  3303. configurable: true
  3304. });
  3305. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3306. /**
  3307. * Specifies if any of the runtime animations are currently running
  3308. */
  3309. get: function () {
  3310. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3311. var runtimeAnimation = _a[_i];
  3312. if (!runtimeAnimation.isStopped) {
  3313. return true;
  3314. }
  3315. }
  3316. return false;
  3317. },
  3318. enumerable: true,
  3319. configurable: true
  3320. });
  3321. // Methods
  3322. /**
  3323. * Converts the animation to a string
  3324. * @param fullDetails support for multiple levels of logging within scene loading
  3325. * @returns String form of the animation
  3326. */
  3327. Animation.prototype.toString = function (fullDetails) {
  3328. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3329. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3330. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3331. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3332. if (fullDetails) {
  3333. ret += ", Ranges: {";
  3334. var first = true;
  3335. for (var name in this._ranges) {
  3336. if (first) {
  3337. ret += ", ";
  3338. first = false;
  3339. }
  3340. ret += name;
  3341. }
  3342. ret += "}";
  3343. }
  3344. return ret;
  3345. };
  3346. /**
  3347. * Add an event to this animation
  3348. * @param event Event to add
  3349. */
  3350. Animation.prototype.addEvent = function (event) {
  3351. this._events.push(event);
  3352. };
  3353. /**
  3354. * Remove all events found at the given frame
  3355. * @param frame The frame to remove events from
  3356. */
  3357. Animation.prototype.removeEvents = function (frame) {
  3358. for (var index = 0; index < this._events.length; index++) {
  3359. if (this._events[index].frame === frame) {
  3360. this._events.splice(index, 1);
  3361. index--;
  3362. }
  3363. }
  3364. };
  3365. /**
  3366. * Retrieves all the events from the animation
  3367. * @returns Events from the animation
  3368. */
  3369. Animation.prototype.getEvents = function () {
  3370. return this._events;
  3371. };
  3372. /**
  3373. * Creates an animation range
  3374. * @param name Name of the animation range
  3375. * @param from Starting frame of the animation range
  3376. * @param to Ending frame of the animation
  3377. */
  3378. Animation.prototype.createRange = function (name, from, to) {
  3379. // check name not already in use; could happen for bones after serialized
  3380. if (!this._ranges[name]) {
  3381. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_6__["AnimationRange"](name, from, to);
  3382. }
  3383. };
  3384. /**
  3385. * Deletes an animation range by name
  3386. * @param name Name of the animation range to delete
  3387. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3388. */
  3389. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3390. if (deleteFrames === void 0) { deleteFrames = true; }
  3391. var range = this._ranges[name];
  3392. if (!range) {
  3393. return;
  3394. }
  3395. if (deleteFrames) {
  3396. var from = range.from;
  3397. var to = range.to;
  3398. // this loop MUST go high to low for multiple splices to work
  3399. for (var key = this._keys.length - 1; key >= 0; key--) {
  3400. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3401. this._keys.splice(key, 1);
  3402. }
  3403. }
  3404. }
  3405. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3406. };
  3407. /**
  3408. * Gets the animation range by name, or null if not defined
  3409. * @param name Name of the animation range
  3410. * @returns Nullable animation range
  3411. */
  3412. Animation.prototype.getRange = function (name) {
  3413. return this._ranges[name];
  3414. };
  3415. /**
  3416. * Gets the key frames from the animation
  3417. * @returns The key frames of the animation
  3418. */
  3419. Animation.prototype.getKeys = function () {
  3420. return this._keys;
  3421. };
  3422. /**
  3423. * Gets the highest frame rate of the animation
  3424. * @returns Highest frame rate of the animation
  3425. */
  3426. Animation.prototype.getHighestFrame = function () {
  3427. var ret = 0;
  3428. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3429. if (ret < this._keys[key].frame) {
  3430. ret = this._keys[key].frame;
  3431. }
  3432. }
  3433. return ret;
  3434. };
  3435. /**
  3436. * Gets the easing function of the animation
  3437. * @returns Easing function of the animation
  3438. */
  3439. Animation.prototype.getEasingFunction = function () {
  3440. return this._easingFunction;
  3441. };
  3442. /**
  3443. * Sets the easing function of the animation
  3444. * @param easingFunction A custom mathematical formula for animation
  3445. */
  3446. Animation.prototype.setEasingFunction = function (easingFunction) {
  3447. this._easingFunction = easingFunction;
  3448. };
  3449. /**
  3450. * Interpolates a scalar linearly
  3451. * @param startValue Start value of the animation curve
  3452. * @param endValue End value of the animation curve
  3453. * @param gradient Scalar amount to interpolate
  3454. * @returns Interpolated scalar value
  3455. */
  3456. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3457. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(startValue, endValue, gradient);
  3458. };
  3459. /**
  3460. * Interpolates a scalar cubically
  3461. * @param startValue Start value of the animation curve
  3462. * @param outTangent End tangent of the animation
  3463. * @param endValue End value of the animation curve
  3464. * @param inTangent Start tangent of the animation curve
  3465. * @param gradient Scalar amount to interpolate
  3466. * @returns Interpolated scalar value
  3467. */
  3468. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3469. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3470. };
  3471. /**
  3472. * Interpolates a quaternion using a spherical linear interpolation
  3473. * @param startValue Start value of the animation curve
  3474. * @param endValue End value of the animation curve
  3475. * @param gradient Scalar amount to interpolate
  3476. * @returns Interpolated quaternion value
  3477. */
  3478. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3479. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3480. };
  3481. /**
  3482. * Interpolates a quaternion cubically
  3483. * @param startValue Start value of the animation curve
  3484. * @param outTangent End tangent of the animation curve
  3485. * @param endValue End value of the animation curve
  3486. * @param inTangent Start tangent of the animation curve
  3487. * @param gradient Scalar amount to interpolate
  3488. * @returns Interpolated quaternion value
  3489. */
  3490. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3491. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3492. };
  3493. /**
  3494. * Interpolates a Vector3 linearl
  3495. * @param startValue Start value of the animation curve
  3496. * @param endValue End value of the animation curve
  3497. * @param gradient Scalar amount to interpolate
  3498. * @returns Interpolated scalar value
  3499. */
  3500. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3501. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3502. };
  3503. /**
  3504. * Interpolates a Vector3 cubically
  3505. * @param startValue Start value of the animation curve
  3506. * @param outTangent End tangent of the animation
  3507. * @param endValue End value of the animation curve
  3508. * @param inTangent Start tangent of the animation curve
  3509. * @param gradient Scalar amount to interpolate
  3510. * @returns InterpolatedVector3 value
  3511. */
  3512. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3513. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3514. };
  3515. /**
  3516. * Interpolates a Vector2 linearly
  3517. * @param startValue Start value of the animation curve
  3518. * @param endValue End value of the animation curve
  3519. * @param gradient Scalar amount to interpolate
  3520. * @returns Interpolated Vector2 value
  3521. */
  3522. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3523. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3524. };
  3525. /**
  3526. * Interpolates a Vector2 cubically
  3527. * @param startValue Start value of the animation curve
  3528. * @param outTangent End tangent of the animation
  3529. * @param endValue End value of the animation curve
  3530. * @param inTangent Start tangent of the animation curve
  3531. * @param gradient Scalar amount to interpolate
  3532. * @returns Interpolated Vector2 value
  3533. */
  3534. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3535. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3536. };
  3537. /**
  3538. * Interpolates a size linearly
  3539. * @param startValue Start value of the animation curve
  3540. * @param endValue End value of the animation curve
  3541. * @param gradient Scalar amount to interpolate
  3542. * @returns Interpolated Size value
  3543. */
  3544. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3545. return _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__["Size"].Lerp(startValue, endValue, gradient);
  3546. };
  3547. /**
  3548. * Interpolates a Color3 linearly
  3549. * @param startValue Start value of the animation curve
  3550. * @param endValue End value of the animation curve
  3551. * @param gradient Scalar amount to interpolate
  3552. * @returns Interpolated Color3 value
  3553. */
  3554. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3555. return _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].Lerp(startValue, endValue, gradient);
  3556. };
  3557. /**
  3558. * @hidden Internal use only
  3559. */
  3560. Animation.prototype._getKeyValue = function (value) {
  3561. if (typeof value === "function") {
  3562. return value();
  3563. }
  3564. return value;
  3565. };
  3566. /**
  3567. * @hidden Internal use only
  3568. */
  3569. Animation.prototype._interpolate = function (currentFrame, state) {
  3570. if (state.loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && state.repeatCount > 0) {
  3571. return state.highLimitValue.clone ? state.highLimitValue.clone() : state.highLimitValue;
  3572. }
  3573. var keys = this._keys;
  3574. if (keys.length === 1) {
  3575. return this._getKeyValue(keys[0].value);
  3576. }
  3577. var startKeyIndex = state.key;
  3578. if (keys[startKeyIndex].frame >= currentFrame) {
  3579. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3580. startKeyIndex--;
  3581. }
  3582. }
  3583. for (var key = startKeyIndex; key < keys.length; key++) {
  3584. var endKey = keys[key + 1];
  3585. if (endKey.frame >= currentFrame) {
  3586. state.key = key;
  3587. var startKey = keys[key];
  3588. var startValue = this._getKeyValue(startKey.value);
  3589. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_5__["AnimationKeyInterpolation"].STEP) {
  3590. return startValue;
  3591. }
  3592. var endValue = this._getKeyValue(endKey.value);
  3593. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3594. var frameDelta = endKey.frame - startKey.frame;
  3595. // gradient : percent of currentFrame between the frame inf and the frame sup
  3596. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3597. // check for easingFunction and correction of gradient
  3598. var easingFunction = this.getEasingFunction();
  3599. if (easingFunction != null) {
  3600. gradient = easingFunction.ease(gradient);
  3601. }
  3602. switch (this.dataType) {
  3603. // Float
  3604. case Animation.ANIMATIONTYPE_FLOAT:
  3605. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3606. switch (state.loopMode) {
  3607. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3608. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3609. return floatValue;
  3610. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3611. return state.offsetValue * state.repeatCount + floatValue;
  3612. }
  3613. break;
  3614. // Quaternion
  3615. case Animation.ANIMATIONTYPE_QUATERNION:
  3616. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3617. switch (state.loopMode) {
  3618. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3619. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3620. return quatValue;
  3621. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3622. return quatValue.addInPlace(state.offsetValue.scale(state.repeatCount));
  3623. }
  3624. return quatValue;
  3625. // Vector3
  3626. case Animation.ANIMATIONTYPE_VECTOR3:
  3627. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3628. switch (state.loopMode) {
  3629. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3630. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3631. return vec3Value;
  3632. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3633. return vec3Value.add(state.offsetValue.scale(state.repeatCount));
  3634. }
  3635. // Vector2
  3636. case Animation.ANIMATIONTYPE_VECTOR2:
  3637. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3638. switch (state.loopMode) {
  3639. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3640. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3641. return vec2Value;
  3642. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3643. return vec2Value.add(state.offsetValue.scale(state.repeatCount));
  3644. }
  3645. // Size
  3646. case Animation.ANIMATIONTYPE_SIZE:
  3647. switch (state.loopMode) {
  3648. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3649. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3650. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3651. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3652. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3653. }
  3654. // Color3
  3655. case Animation.ANIMATIONTYPE_COLOR3:
  3656. switch (state.loopMode) {
  3657. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3658. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3659. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3660. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3661. return this.color3InterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3662. }
  3663. // Matrix
  3664. case Animation.ANIMATIONTYPE_MATRIX:
  3665. switch (state.loopMode) {
  3666. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3667. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3668. if (Animation.AllowMatricesInterpolation) {
  3669. return this.matrixInterpolateFunction(startValue, endValue, gradient, state.workValue);
  3670. }
  3671. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3672. return startValue;
  3673. }
  3674. default:
  3675. break;
  3676. }
  3677. break;
  3678. }
  3679. }
  3680. return this._getKeyValue(keys[keys.length - 1].value);
  3681. };
  3682. /**
  3683. * Defines the function to use to interpolate matrices
  3684. * @param startValue defines the start matrix
  3685. * @param endValue defines the end matrix
  3686. * @param gradient defines the gradient between both matrices
  3687. * @param result defines an optional target matrix where to store the interpolation
  3688. * @returns the interpolated matrix
  3689. */
  3690. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3691. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3692. if (result) {
  3693. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3694. return result;
  3695. }
  3696. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3697. }
  3698. if (result) {
  3699. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3700. return result;
  3701. }
  3702. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3703. };
  3704. /**
  3705. * Makes a copy of the animation
  3706. * @returns Cloned animation
  3707. */
  3708. Animation.prototype.clone = function () {
  3709. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3710. clone.enableBlending = this.enableBlending;
  3711. clone.blendingSpeed = this.blendingSpeed;
  3712. if (this._keys) {
  3713. clone.setKeys(this._keys);
  3714. }
  3715. if (this._ranges) {
  3716. clone._ranges = {};
  3717. for (var name in this._ranges) {
  3718. var range = this._ranges[name];
  3719. if (!range) {
  3720. continue;
  3721. }
  3722. clone._ranges[name] = range.clone();
  3723. }
  3724. }
  3725. return clone;
  3726. };
  3727. /**
  3728. * Sets the key frames of the animation
  3729. * @param values The animation key frames to set
  3730. */
  3731. Animation.prototype.setKeys = function (values) {
  3732. this._keys = values.slice(0);
  3733. };
  3734. /**
  3735. * Serializes the animation to an object
  3736. * @returns Serialized object
  3737. */
  3738. Animation.prototype.serialize = function () {
  3739. var serializationObject = {};
  3740. serializationObject.name = this.name;
  3741. serializationObject.property = this.targetProperty;
  3742. serializationObject.framePerSecond = this.framePerSecond;
  3743. serializationObject.dataType = this.dataType;
  3744. serializationObject.loopBehavior = this.loopMode;
  3745. serializationObject.enableBlending = this.enableBlending;
  3746. serializationObject.blendingSpeed = this.blendingSpeed;
  3747. var dataType = this.dataType;
  3748. serializationObject.keys = [];
  3749. var keys = this.getKeys();
  3750. for (var index = 0; index < keys.length; index++) {
  3751. var animationKey = keys[index];
  3752. var key = {};
  3753. key.frame = animationKey.frame;
  3754. switch (dataType) {
  3755. case Animation.ANIMATIONTYPE_FLOAT:
  3756. key.values = [animationKey.value];
  3757. break;
  3758. case Animation.ANIMATIONTYPE_QUATERNION:
  3759. case Animation.ANIMATIONTYPE_MATRIX:
  3760. case Animation.ANIMATIONTYPE_VECTOR3:
  3761. case Animation.ANIMATIONTYPE_COLOR3:
  3762. key.values = animationKey.value.asArray();
  3763. break;
  3764. }
  3765. serializationObject.keys.push(key);
  3766. }
  3767. serializationObject.ranges = [];
  3768. for (var name in this._ranges) {
  3769. var source = this._ranges[name];
  3770. if (!source) {
  3771. continue;
  3772. }
  3773. var range = {};
  3774. range.name = name;
  3775. range.from = source.from;
  3776. range.to = source.to;
  3777. serializationObject.ranges.push(range);
  3778. }
  3779. return serializationObject;
  3780. };
  3781. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3782. /**
  3783. * Get the float animation type
  3784. */
  3785. get: function () {
  3786. return Animation._ANIMATIONTYPE_FLOAT;
  3787. },
  3788. enumerable: true,
  3789. configurable: true
  3790. });
  3791. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3792. /**
  3793. * Get the Vector3 animation type
  3794. */
  3795. get: function () {
  3796. return Animation._ANIMATIONTYPE_VECTOR3;
  3797. },
  3798. enumerable: true,
  3799. configurable: true
  3800. });
  3801. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3802. /**
  3803. * Get the Vector2 animation type
  3804. */
  3805. get: function () {
  3806. return Animation._ANIMATIONTYPE_VECTOR2;
  3807. },
  3808. enumerable: true,
  3809. configurable: true
  3810. });
  3811. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3812. /**
  3813. * Get the Size animation type
  3814. */
  3815. get: function () {
  3816. return Animation._ANIMATIONTYPE_SIZE;
  3817. },
  3818. enumerable: true,
  3819. configurable: true
  3820. });
  3821. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3822. /**
  3823. * Get the Quaternion animation type
  3824. */
  3825. get: function () {
  3826. return Animation._ANIMATIONTYPE_QUATERNION;
  3827. },
  3828. enumerable: true,
  3829. configurable: true
  3830. });
  3831. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3832. /**
  3833. * Get the Matrix animation type
  3834. */
  3835. get: function () {
  3836. return Animation._ANIMATIONTYPE_MATRIX;
  3837. },
  3838. enumerable: true,
  3839. configurable: true
  3840. });
  3841. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3842. /**
  3843. * Get the Color3 animation type
  3844. */
  3845. get: function () {
  3846. return Animation._ANIMATIONTYPE_COLOR3;
  3847. },
  3848. enumerable: true,
  3849. configurable: true
  3850. });
  3851. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3852. /**
  3853. * Get the Relative Loop Mode
  3854. */
  3855. get: function () {
  3856. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3857. },
  3858. enumerable: true,
  3859. configurable: true
  3860. });
  3861. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3862. /**
  3863. * Get the Cycle Loop Mode
  3864. */
  3865. get: function () {
  3866. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3867. },
  3868. enumerable: true,
  3869. configurable: true
  3870. });
  3871. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3872. /**
  3873. * Get the Constant Loop Mode
  3874. */
  3875. get: function () {
  3876. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3877. },
  3878. enumerable: true,
  3879. configurable: true
  3880. });
  3881. /** @hidden */
  3882. Animation._UniversalLerp = function (left, right, amount) {
  3883. var constructor = left.constructor;
  3884. if (constructor.Lerp) { // Lerp supported
  3885. return constructor.Lerp(left, right, amount);
  3886. }
  3887. else if (constructor.Slerp) { // Slerp supported
  3888. return constructor.Slerp(left, right, amount);
  3889. }
  3890. else if (left.toFixed) { // Number
  3891. return left * (1.0 - amount) + amount * right;
  3892. }
  3893. else { // Blending not supported
  3894. return right;
  3895. }
  3896. };
  3897. /**
  3898. * Parses an animation object and creates an animation
  3899. * @param parsedAnimation Parsed animation object
  3900. * @returns Animation object
  3901. */
  3902. Animation.Parse = function (parsedAnimation) {
  3903. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3904. var dataType = parsedAnimation.dataType;
  3905. var keys = [];
  3906. var data;
  3907. var index;
  3908. if (parsedAnimation.enableBlending) {
  3909. animation.enableBlending = parsedAnimation.enableBlending;
  3910. }
  3911. if (parsedAnimation.blendingSpeed) {
  3912. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3913. }
  3914. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3915. var key = parsedAnimation.keys[index];
  3916. var inTangent;
  3917. var outTangent;
  3918. switch (dataType) {
  3919. case Animation.ANIMATIONTYPE_FLOAT:
  3920. data = key.values[0];
  3921. if (key.values.length >= 1) {
  3922. inTangent = key.values[1];
  3923. }
  3924. if (key.values.length >= 2) {
  3925. outTangent = key.values[2];
  3926. }
  3927. break;
  3928. case Animation.ANIMATIONTYPE_QUATERNION:
  3929. data = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3930. if (key.values.length >= 8) {
  3931. var _inTangent = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3932. if (!_inTangent.equals(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3933. inTangent = _inTangent;
  3934. }
  3935. }
  3936. if (key.values.length >= 12) {
  3937. var _outTangent = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3938. if (!_outTangent.equals(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3939. outTangent = _outTangent;
  3940. }
  3941. }
  3942. break;
  3943. case Animation.ANIMATIONTYPE_MATRIX:
  3944. data = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3945. break;
  3946. case Animation.ANIMATIONTYPE_COLOR3:
  3947. data = _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(key.values);
  3948. break;
  3949. case Animation.ANIMATIONTYPE_VECTOR3:
  3950. default:
  3951. data = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3952. break;
  3953. }
  3954. var keyData = {};
  3955. keyData.frame = key.frame;
  3956. keyData.value = data;
  3957. if (inTangent != undefined) {
  3958. keyData.inTangent = inTangent;
  3959. }
  3960. if (outTangent != undefined) {
  3961. keyData.outTangent = outTangent;
  3962. }
  3963. keys.push(keyData);
  3964. }
  3965. animation.setKeys(keys);
  3966. if (parsedAnimation.ranges) {
  3967. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3968. data = parsedAnimation.ranges[index];
  3969. animation.createRange(data.name, data.from, data.to);
  3970. }
  3971. }
  3972. return animation;
  3973. };
  3974. /**
  3975. * Appends the serialized animations from the source animations
  3976. * @param source Source containing the animations
  3977. * @param destination Target to store the animations
  3978. */
  3979. Animation.AppendSerializedAnimations = function (source, destination) {
  3980. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3981. };
  3982. /**
  3983. * Use matrix interpolation instead of using direct key value when animating matrices
  3984. */
  3985. Animation.AllowMatricesInterpolation = false;
  3986. /**
  3987. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3988. */
  3989. Animation.AllowMatrixDecomposeForInterpolation = true;
  3990. // Statics
  3991. /**
  3992. * Float animation type
  3993. */
  3994. Animation._ANIMATIONTYPE_FLOAT = 0;
  3995. /**
  3996. * Vector3 animation type
  3997. */
  3998. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3999. /**
  4000. * Quaternion animation type
  4001. */
  4002. Animation._ANIMATIONTYPE_QUATERNION = 2;
  4003. /**
  4004. * Matrix animation type
  4005. */
  4006. Animation._ANIMATIONTYPE_MATRIX = 3;
  4007. /**
  4008. * Color3 animation type
  4009. */
  4010. Animation._ANIMATIONTYPE_COLOR3 = 4;
  4011. /**
  4012. * Vector2 animation type
  4013. */
  4014. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  4015. /**
  4016. * Size animation type
  4017. */
  4018. Animation._ANIMATIONTYPE_SIZE = 6;
  4019. /**
  4020. * Relative Loop Mode
  4021. */
  4022. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  4023. /**
  4024. * Cycle Loop Mode
  4025. */
  4026. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  4027. /**
  4028. * Constant Loop Mode
  4029. */
  4030. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  4031. return Animation;
  4032. }());
  4033. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  4034. _node__WEBPACK_IMPORTED_MODULE_7__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_6__["AnimationRange"](name, from, to); };
  4035. /***/ }),
  4036. /***/ "./Animations/animationEvent.ts":
  4037. /*!**************************************!*\
  4038. !*** ./Animations/animationEvent.ts ***!
  4039. \**************************************/
  4040. /*! exports provided: AnimationEvent */
  4041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4042. "use strict";
  4043. __webpack_require__.r(__webpack_exports__);
  4044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4045. /**
  4046. * Composed of a frame, and an action function
  4047. */
  4048. var AnimationEvent = /** @class */ (function () {
  4049. /**
  4050. * Initializes the animation event
  4051. * @param frame The frame for which the event is triggered
  4052. * @param action The event to perform when triggered
  4053. * @param onlyOnce Specifies if the event should be triggered only once
  4054. */
  4055. function AnimationEvent(
  4056. /** The frame for which the event is triggered **/
  4057. frame,
  4058. /** The event to perform when triggered **/
  4059. action,
  4060. /** Specifies if the event should be triggered only once**/
  4061. onlyOnce) {
  4062. this.frame = frame;
  4063. this.action = action;
  4064. this.onlyOnce = onlyOnce;
  4065. /**
  4066. * Specifies if the animation event is done
  4067. */
  4068. this.isDone = false;
  4069. }
  4070. /** @hidden */
  4071. AnimationEvent.prototype._clone = function () {
  4072. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4073. };
  4074. return AnimationEvent;
  4075. }());
  4076. /***/ }),
  4077. /***/ "./Animations/animationGroup.ts":
  4078. /*!**************************************!*\
  4079. !*** ./Animations/animationGroup.ts ***!
  4080. \**************************************/
  4081. /*! exports provided: TargetedAnimation, AnimationGroup */
  4082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4083. "use strict";
  4084. __webpack_require__.r(__webpack_exports__);
  4085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4087. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4088. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4089. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4090. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4091. /**
  4092. * This class defines the direct association between an animation and a target
  4093. */
  4094. var TargetedAnimation = /** @class */ (function () {
  4095. function TargetedAnimation() {
  4096. }
  4097. /**
  4098. * Serialize the object
  4099. * @returns the JSON object representing the current entity
  4100. */
  4101. TargetedAnimation.prototype.serialize = function () {
  4102. var serializationObject = {};
  4103. serializationObject.animation = this.animation.serialize();
  4104. serializationObject.targetId = this.target.id;
  4105. return serializationObject;
  4106. };
  4107. return TargetedAnimation;
  4108. }());
  4109. /**
  4110. * Use this class to create coordinated animations on multiple targets
  4111. */
  4112. var AnimationGroup = /** @class */ (function () {
  4113. /**
  4114. * Instantiates a new Animation Group.
  4115. * This helps managing several animations at once.
  4116. * @see http://doc.babylonjs.com/how_to/group
  4117. * @param name Defines the name of the group
  4118. * @param scene Defines the scene the group belongs to
  4119. */
  4120. function AnimationGroup(
  4121. /** The name of the animation group */
  4122. name, scene) {
  4123. if (scene === void 0) { scene = null; }
  4124. this.name = name;
  4125. this._targetedAnimations = new Array();
  4126. this._animatables = new Array();
  4127. this._from = Number.MAX_VALUE;
  4128. this._to = -Number.MAX_VALUE;
  4129. this._speedRatio = 1;
  4130. this._loopAnimation = false;
  4131. /**
  4132. * This observable will notify when one animation have ended
  4133. */
  4134. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4135. /**
  4136. * Observer raised when one animation loops
  4137. */
  4138. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4139. /**
  4140. * This observable will notify when all animations have ended.
  4141. */
  4142. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4143. /**
  4144. * This observable will notify when all animations have paused.
  4145. */
  4146. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4147. /**
  4148. * This observable will notify when all animations are playing.
  4149. */
  4150. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4151. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4152. this.uniqueId = this._scene.getUniqueId();
  4153. this._scene.animationGroups.push(this);
  4154. }
  4155. Object.defineProperty(AnimationGroup.prototype, "from", {
  4156. /**
  4157. * Gets the first frame
  4158. */
  4159. get: function () {
  4160. return this._from;
  4161. },
  4162. enumerable: true,
  4163. configurable: true
  4164. });
  4165. Object.defineProperty(AnimationGroup.prototype, "to", {
  4166. /**
  4167. * Gets the last frame
  4168. */
  4169. get: function () {
  4170. return this._to;
  4171. },
  4172. enumerable: true,
  4173. configurable: true
  4174. });
  4175. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4176. /**
  4177. * Define if the animations are started
  4178. */
  4179. get: function () {
  4180. return this._isStarted;
  4181. },
  4182. enumerable: true,
  4183. configurable: true
  4184. });
  4185. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4186. /**
  4187. * Gets a value indicating that the current group is playing
  4188. */
  4189. get: function () {
  4190. return this._isStarted && !this._isPaused;
  4191. },
  4192. enumerable: true,
  4193. configurable: true
  4194. });
  4195. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4196. /**
  4197. * Gets or sets the speed ratio to use for all animations
  4198. */
  4199. get: function () {
  4200. return this._speedRatio;
  4201. },
  4202. /**
  4203. * Gets or sets the speed ratio to use for all animations
  4204. */
  4205. set: function (value) {
  4206. if (this._speedRatio === value) {
  4207. return;
  4208. }
  4209. this._speedRatio = value;
  4210. for (var index = 0; index < this._animatables.length; index++) {
  4211. var animatable = this._animatables[index];
  4212. animatable.speedRatio = this._speedRatio;
  4213. }
  4214. },
  4215. enumerable: true,
  4216. configurable: true
  4217. });
  4218. Object.defineProperty(AnimationGroup.prototype, "loopAnimation", {
  4219. /**
  4220. * Gets or sets if all animations should loop or not
  4221. */
  4222. get: function () {
  4223. return this._loopAnimation;
  4224. },
  4225. set: function (value) {
  4226. if (this._loopAnimation === value) {
  4227. return;
  4228. }
  4229. this._loopAnimation = value;
  4230. for (var index = 0; index < this._animatables.length; index++) {
  4231. var animatable = this._animatables[index];
  4232. animatable.loopAnimation = this._loopAnimation;
  4233. }
  4234. },
  4235. enumerable: true,
  4236. configurable: true
  4237. });
  4238. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4239. /**
  4240. * Gets the targeted animations for this animation group
  4241. */
  4242. get: function () {
  4243. return this._targetedAnimations;
  4244. },
  4245. enumerable: true,
  4246. configurable: true
  4247. });
  4248. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4249. /**
  4250. * returning the list of animatables controlled by this animation group.
  4251. */
  4252. get: function () {
  4253. return this._animatables;
  4254. },
  4255. enumerable: true,
  4256. configurable: true
  4257. });
  4258. /**
  4259. * Add an animation (with its target) in the group
  4260. * @param animation defines the animation we want to add
  4261. * @param target defines the target of the animation
  4262. * @returns the TargetedAnimation object
  4263. */
  4264. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4265. var targetedAnimation = new TargetedAnimation();
  4266. targetedAnimation.animation = animation;
  4267. targetedAnimation.target = target;
  4268. var keys = animation.getKeys();
  4269. if (this._from > keys[0].frame) {
  4270. this._from = keys[0].frame;
  4271. }
  4272. if (this._to < keys[keys.length - 1].frame) {
  4273. this._to = keys[keys.length - 1].frame;
  4274. }
  4275. this._targetedAnimations.push(targetedAnimation);
  4276. return targetedAnimation;
  4277. };
  4278. /**
  4279. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4280. * It can add constant keys at begin or end
  4281. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4282. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4283. * @returns the animation group
  4284. */
  4285. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4286. if (beginFrame === void 0) { beginFrame = null; }
  4287. if (endFrame === void 0) { endFrame = null; }
  4288. if (beginFrame == null) {
  4289. beginFrame = this._from;
  4290. }
  4291. if (endFrame == null) {
  4292. endFrame = this._to;
  4293. }
  4294. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4295. var targetedAnimation = this._targetedAnimations[index];
  4296. var keys = targetedAnimation.animation.getKeys();
  4297. var startKey = keys[0];
  4298. var endKey = keys[keys.length - 1];
  4299. if (startKey.frame > beginFrame) {
  4300. var newKey = {
  4301. frame: beginFrame,
  4302. value: startKey.value,
  4303. inTangent: startKey.inTangent,
  4304. outTangent: startKey.outTangent,
  4305. interpolation: startKey.interpolation
  4306. };
  4307. keys.splice(0, 0, newKey);
  4308. }
  4309. if (endKey.frame < endFrame) {
  4310. var newKey = {
  4311. frame: endFrame,
  4312. value: endKey.value,
  4313. inTangent: endKey.outTangent,
  4314. outTangent: endKey.outTangent,
  4315. interpolation: endKey.interpolation
  4316. };
  4317. keys.push(newKey);
  4318. }
  4319. }
  4320. this._from = beginFrame;
  4321. this._to = endFrame;
  4322. return this;
  4323. };
  4324. /**
  4325. * Start all animations on given targets
  4326. * @param loop defines if animations must loop
  4327. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4328. * @param from defines the from key (optional)
  4329. * @param to defines the to key (optional)
  4330. * @returns the current animation group
  4331. */
  4332. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4333. var _this = this;
  4334. if (loop === void 0) { loop = false; }
  4335. if (speedRatio === void 0) { speedRatio = 1; }
  4336. if (this._isStarted || this._targetedAnimations.length === 0) {
  4337. return this;
  4338. }
  4339. this._loopAnimation = loop;
  4340. var _loop_1 = function (targetedAnimation) {
  4341. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4342. animatable.onAnimationEnd = function () {
  4343. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4344. _this._checkAnimationGroupEnded(animatable);
  4345. };
  4346. animatable.onAnimationLoop = function () {
  4347. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4348. };
  4349. this_1._animatables.push(animatable);
  4350. };
  4351. var this_1 = this;
  4352. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4353. var targetedAnimation = _a[_i];
  4354. _loop_1(targetedAnimation);
  4355. }
  4356. this._speedRatio = speedRatio;
  4357. if (from !== undefined && to !== undefined) {
  4358. if (from < to && this._speedRatio < 0) {
  4359. var temp = to;
  4360. to = from;
  4361. from = temp;
  4362. }
  4363. else if (from > to && this._speedRatio > 0) {
  4364. this._speedRatio = -speedRatio;
  4365. }
  4366. }
  4367. this._isStarted = true;
  4368. this._isPaused = false;
  4369. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4370. return this;
  4371. };
  4372. /**
  4373. * Pause all animations
  4374. * @returns the animation group
  4375. */
  4376. AnimationGroup.prototype.pause = function () {
  4377. if (!this._isStarted) {
  4378. return this;
  4379. }
  4380. this._isPaused = true;
  4381. for (var index = 0; index < this._animatables.length; index++) {
  4382. var animatable = this._animatables[index];
  4383. animatable.pause();
  4384. }
  4385. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4386. return this;
  4387. };
  4388. /**
  4389. * Play all animations to initial state
  4390. * This function will start() the animations if they were not started or will restart() them if they were paused
  4391. * @param loop defines if animations must loop
  4392. * @returns the animation group
  4393. */
  4394. AnimationGroup.prototype.play = function (loop) {
  4395. // only if all animatables are ready and exist
  4396. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4397. if (loop !== undefined) {
  4398. this.loopAnimation = loop;
  4399. }
  4400. this.restart();
  4401. }
  4402. else {
  4403. this.stop();
  4404. this.start(loop, this._speedRatio);
  4405. }
  4406. this._isPaused = false;
  4407. return this;
  4408. };
  4409. /**
  4410. * Reset all animations to initial state
  4411. * @returns the animation group
  4412. */
  4413. AnimationGroup.prototype.reset = function () {
  4414. if (!this._isStarted) {
  4415. return this;
  4416. }
  4417. for (var index = 0; index < this._animatables.length; index++) {
  4418. var animatable = this._animatables[index];
  4419. animatable.reset();
  4420. }
  4421. return this;
  4422. };
  4423. /**
  4424. * Restart animations from key 0
  4425. * @returns the animation group
  4426. */
  4427. AnimationGroup.prototype.restart = function () {
  4428. if (!this._isStarted) {
  4429. return this;
  4430. }
  4431. for (var index = 0; index < this._animatables.length; index++) {
  4432. var animatable = this._animatables[index];
  4433. animatable.restart();
  4434. }
  4435. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4436. return this;
  4437. };
  4438. /**
  4439. * Stop all animations
  4440. * @returns the animation group
  4441. */
  4442. AnimationGroup.prototype.stop = function () {
  4443. if (!this._isStarted) {
  4444. return this;
  4445. }
  4446. var list = this._animatables.slice();
  4447. for (var index = 0; index < list.length; index++) {
  4448. list[index].stop();
  4449. }
  4450. this._isStarted = false;
  4451. return this;
  4452. };
  4453. /**
  4454. * Set animation weight for all animatables
  4455. * @param weight defines the weight to use
  4456. * @return the animationGroup
  4457. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4458. */
  4459. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4460. for (var index = 0; index < this._animatables.length; index++) {
  4461. var animatable = this._animatables[index];
  4462. animatable.weight = weight;
  4463. }
  4464. return this;
  4465. };
  4466. /**
  4467. * Synchronize and normalize all animatables with a source animatable
  4468. * @param root defines the root animatable to synchronize with
  4469. * @return the animationGroup
  4470. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4471. */
  4472. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4473. for (var index = 0; index < this._animatables.length; index++) {
  4474. var animatable = this._animatables[index];
  4475. animatable.syncWith(root);
  4476. }
  4477. return this;
  4478. };
  4479. /**
  4480. * Goes to a specific frame in this animation group
  4481. * @param frame the frame number to go to
  4482. * @return the animationGroup
  4483. */
  4484. AnimationGroup.prototype.goToFrame = function (frame) {
  4485. if (!this._isStarted) {
  4486. return this;
  4487. }
  4488. for (var index = 0; index < this._animatables.length; index++) {
  4489. var animatable = this._animatables[index];
  4490. animatable.goToFrame(frame);
  4491. }
  4492. return this;
  4493. };
  4494. /**
  4495. * Dispose all associated resources
  4496. */
  4497. AnimationGroup.prototype.dispose = function () {
  4498. this._targetedAnimations = [];
  4499. this._animatables = [];
  4500. var index = this._scene.animationGroups.indexOf(this);
  4501. if (index > -1) {
  4502. this._scene.animationGroups.splice(index, 1);
  4503. }
  4504. this.onAnimationEndObservable.clear();
  4505. this.onAnimationGroupEndObservable.clear();
  4506. this.onAnimationGroupPauseObservable.clear();
  4507. this.onAnimationGroupPlayObservable.clear();
  4508. this.onAnimationLoopObservable.clear();
  4509. };
  4510. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4511. // animatable should be taken out of the array
  4512. var idx = this._animatables.indexOf(animatable);
  4513. if (idx > -1) {
  4514. this._animatables.splice(idx, 1);
  4515. }
  4516. // all animatables were removed? animation group ended!
  4517. if (this._animatables.length === 0) {
  4518. this._isStarted = false;
  4519. this.onAnimationGroupEndObservable.notifyObservers(this);
  4520. }
  4521. };
  4522. /**
  4523. * Clone the current animation group and returns a copy
  4524. * @param newName defines the name of the new group
  4525. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4526. * @returns the new aniamtion group
  4527. */
  4528. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4529. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4530. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4531. var targetAnimation = _a[_i];
  4532. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4533. }
  4534. return newGroup;
  4535. };
  4536. /**
  4537. * Serializes the animationGroup to an object
  4538. * @returns Serialized object
  4539. */
  4540. AnimationGroup.prototype.serialize = function () {
  4541. var serializationObject = {};
  4542. serializationObject.name = this.name;
  4543. serializationObject.from = this.from;
  4544. serializationObject.to = this.to;
  4545. serializationObject.targetedAnimations = [];
  4546. for (var targetedAnimationIndex = 0; targetedAnimationIndex < this.targetedAnimations.length; targetedAnimationIndex++) {
  4547. var targetedAnimation = this.targetedAnimations[targetedAnimationIndex];
  4548. serializationObject.targetedAnimations[targetedAnimationIndex] = targetedAnimation.serialize();
  4549. }
  4550. return serializationObject;
  4551. };
  4552. // Statics
  4553. /**
  4554. * Returns a new AnimationGroup object parsed from the source provided.
  4555. * @param parsedAnimationGroup defines the source
  4556. * @param scene defines the scene that will receive the animationGroup
  4557. * @returns a new AnimationGroup
  4558. */
  4559. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4560. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4561. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4562. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4563. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4564. var id = targetedAnimation.targetId;
  4565. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4566. var morphTarget = scene.getMorphTargetById(id);
  4567. if (morphTarget) {
  4568. animationGroup.addTargetedAnimation(animation, morphTarget);
  4569. }
  4570. }
  4571. else {
  4572. var targetNode = scene.getNodeByID(id);
  4573. if (targetNode != null) {
  4574. animationGroup.addTargetedAnimation(animation, targetNode);
  4575. }
  4576. }
  4577. }
  4578. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4579. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4580. }
  4581. return animationGroup;
  4582. };
  4583. /**
  4584. * Returns the string "AnimationGroup"
  4585. * @returns "AnimationGroup"
  4586. */
  4587. AnimationGroup.prototype.getClassName = function () {
  4588. return "AnimationGroup";
  4589. };
  4590. /**
  4591. * Creates a detailled string about the object
  4592. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4593. * @returns a string representing the object
  4594. */
  4595. AnimationGroup.prototype.toString = function (fullDetails) {
  4596. var ret = "Name: " + this.name;
  4597. ret += ", type: " + this.getClassName();
  4598. if (fullDetails) {
  4599. ret += ", from: " + this._from;
  4600. ret += ", to: " + this._to;
  4601. ret += ", isStarted: " + this._isStarted;
  4602. ret += ", speedRatio: " + this._speedRatio;
  4603. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4604. ret += ", animatables length: " + this._animatables;
  4605. }
  4606. return ret;
  4607. };
  4608. return AnimationGroup;
  4609. }());
  4610. /***/ }),
  4611. /***/ "./Animations/animationKey.ts":
  4612. /*!************************************!*\
  4613. !*** ./Animations/animationKey.ts ***!
  4614. \************************************/
  4615. /*! exports provided: AnimationKeyInterpolation */
  4616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4617. "use strict";
  4618. __webpack_require__.r(__webpack_exports__);
  4619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4620. /**
  4621. * Enum for the animation key frame interpolation type
  4622. */
  4623. var AnimationKeyInterpolation;
  4624. (function (AnimationKeyInterpolation) {
  4625. /**
  4626. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4627. */
  4628. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4629. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4630. /***/ }),
  4631. /***/ "./Animations/animationPropertiesOverride.ts":
  4632. /*!***************************************************!*\
  4633. !*** ./Animations/animationPropertiesOverride.ts ***!
  4634. \***************************************************/
  4635. /*! exports provided: AnimationPropertiesOverride */
  4636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4637. "use strict";
  4638. __webpack_require__.r(__webpack_exports__);
  4639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4640. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4641. /**
  4642. * Class used to override all child animations of a given target
  4643. */
  4644. var AnimationPropertiesOverride = /** @class */ (function () {
  4645. function AnimationPropertiesOverride() {
  4646. /**
  4647. * Gets or sets a value indicating if animation blending must be used
  4648. */
  4649. this.enableBlending = false;
  4650. /**
  4651. * Gets or sets the blending speed to use when enableBlending is true
  4652. */
  4653. this.blendingSpeed = 0.01;
  4654. /**
  4655. * Gets or sets the default loop mode to use
  4656. */
  4657. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4658. }
  4659. return AnimationPropertiesOverride;
  4660. }());
  4661. /***/ }),
  4662. /***/ "./Animations/animationRange.ts":
  4663. /*!**************************************!*\
  4664. !*** ./Animations/animationRange.ts ***!
  4665. \**************************************/
  4666. /*! exports provided: AnimationRange */
  4667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4668. "use strict";
  4669. __webpack_require__.r(__webpack_exports__);
  4670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4671. /**
  4672. * Represents the range of an animation
  4673. */
  4674. var AnimationRange = /** @class */ (function () {
  4675. /**
  4676. * Initializes the range of an animation
  4677. * @param name The name of the animation range
  4678. * @param from The starting frame of the animation
  4679. * @param to The ending frame of the animation
  4680. */
  4681. function AnimationRange(
  4682. /**The name of the animation range**/
  4683. name,
  4684. /**The starting frame of the animation */
  4685. from,
  4686. /**The ending frame of the animation*/
  4687. to) {
  4688. this.name = name;
  4689. this.from = from;
  4690. this.to = to;
  4691. }
  4692. /**
  4693. * Makes a copy of the animation range
  4694. * @returns A copy of the animation range
  4695. */
  4696. AnimationRange.prototype.clone = function () {
  4697. return new AnimationRange(this.name, this.from, this.to);
  4698. };
  4699. return AnimationRange;
  4700. }());
  4701. /***/ }),
  4702. /***/ "./Animations/easing.ts":
  4703. /*!******************************!*\
  4704. !*** ./Animations/easing.ts ***!
  4705. \******************************/
  4706. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4708. "use strict";
  4709. __webpack_require__.r(__webpack_exports__);
  4710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4724. /* harmony import */ var _Maths_math_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.path */ "./Maths/math.path.ts");
  4725. /**
  4726. * Base class used for every default easing function.
  4727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4728. */
  4729. var EasingFunction = /** @class */ (function () {
  4730. function EasingFunction() {
  4731. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4732. }
  4733. /**
  4734. * Sets the easing mode of the current function.
  4735. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4736. */
  4737. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4738. var n = Math.min(Math.max(easingMode, 0), 2);
  4739. this._easingMode = n;
  4740. };
  4741. /**
  4742. * Gets the current easing mode.
  4743. * @returns the easing mode
  4744. */
  4745. EasingFunction.prototype.getEasingMode = function () {
  4746. return this._easingMode;
  4747. };
  4748. /**
  4749. * @hidden
  4750. */
  4751. EasingFunction.prototype.easeInCore = function (gradient) {
  4752. throw new Error('You must implement this method');
  4753. };
  4754. /**
  4755. * Given an input gradient between 0 and 1, this returns the corresponding value
  4756. * of the easing function.
  4757. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4758. * @returns the corresponding value on the curve defined by the easing function
  4759. */
  4760. EasingFunction.prototype.ease = function (gradient) {
  4761. switch (this._easingMode) {
  4762. case EasingFunction.EASINGMODE_EASEIN:
  4763. return this.easeInCore(gradient);
  4764. case EasingFunction.EASINGMODE_EASEOUT:
  4765. return (1 - this.easeInCore(1 - gradient));
  4766. }
  4767. if (gradient >= 0.5) {
  4768. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4769. }
  4770. return (this.easeInCore(gradient * 2) * 0.5);
  4771. };
  4772. /**
  4773. * Interpolation follows the mathematical formula associated with the easing function.
  4774. */
  4775. EasingFunction.EASINGMODE_EASEIN = 0;
  4776. /**
  4777. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4778. */
  4779. EasingFunction.EASINGMODE_EASEOUT = 1;
  4780. /**
  4781. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4782. */
  4783. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4784. return EasingFunction;
  4785. }());
  4786. /**
  4787. * Easing function with a circle shape (see link below).
  4788. * @see https://easings.net/#easeInCirc
  4789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4790. */
  4791. var CircleEase = /** @class */ (function (_super) {
  4792. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4793. function CircleEase() {
  4794. return _super !== null && _super.apply(this, arguments) || this;
  4795. }
  4796. /** @hidden */
  4797. CircleEase.prototype.easeInCore = function (gradient) {
  4798. gradient = Math.max(0, Math.min(1, gradient));
  4799. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4800. };
  4801. return CircleEase;
  4802. }(EasingFunction));
  4803. /**
  4804. * Easing function with a ease back shape (see link below).
  4805. * @see https://easings.net/#easeInBack
  4806. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4807. */
  4808. var BackEase = /** @class */ (function (_super) {
  4809. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4810. /**
  4811. * Instantiates a back ease easing
  4812. * @see https://easings.net/#easeInBack
  4813. * @param amplitude Defines the amplitude of the function
  4814. */
  4815. function BackEase(
  4816. /** Defines the amplitude of the function */
  4817. amplitude) {
  4818. if (amplitude === void 0) { amplitude = 1; }
  4819. var _this = _super.call(this) || this;
  4820. _this.amplitude = amplitude;
  4821. return _this;
  4822. }
  4823. /** @hidden */
  4824. BackEase.prototype.easeInCore = function (gradient) {
  4825. var num = Math.max(0, this.amplitude);
  4826. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4827. };
  4828. return BackEase;
  4829. }(EasingFunction));
  4830. /**
  4831. * Easing function with a bouncing shape (see link below).
  4832. * @see https://easings.net/#easeInBounce
  4833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4834. */
  4835. var BounceEase = /** @class */ (function (_super) {
  4836. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4837. /**
  4838. * Instantiates a bounce easing
  4839. * @see https://easings.net/#easeInBounce
  4840. * @param bounces Defines the number of bounces
  4841. * @param bounciness Defines the amplitude of the bounce
  4842. */
  4843. function BounceEase(
  4844. /** Defines the number of bounces */
  4845. bounces,
  4846. /** Defines the amplitude of the bounce */
  4847. bounciness) {
  4848. if (bounces === void 0) { bounces = 3; }
  4849. if (bounciness === void 0) { bounciness = 2; }
  4850. var _this = _super.call(this) || this;
  4851. _this.bounces = bounces;
  4852. _this.bounciness = bounciness;
  4853. return _this;
  4854. }
  4855. /** @hidden */
  4856. BounceEase.prototype.easeInCore = function (gradient) {
  4857. var y = Math.max(0.0, this.bounces);
  4858. var bounciness = this.bounciness;
  4859. if (bounciness <= 1.0) {
  4860. bounciness = 1.001;
  4861. }
  4862. var num9 = Math.pow(bounciness, y);
  4863. var num5 = 1.0 - bounciness;
  4864. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4865. var num15 = gradient * num4;
  4866. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4867. var num3 = Math.floor(num65);
  4868. var num13 = num3 + 1.0;
  4869. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4870. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4871. var num7 = (num8 + num12) * 0.5;
  4872. var num6 = gradient - num7;
  4873. var num2 = num7 - num8;
  4874. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4875. };
  4876. return BounceEase;
  4877. }(EasingFunction));
  4878. /**
  4879. * Easing function with a power of 3 shape (see link below).
  4880. * @see https://easings.net/#easeInCubic
  4881. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4882. */
  4883. var CubicEase = /** @class */ (function (_super) {
  4884. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4885. function CubicEase() {
  4886. return _super !== null && _super.apply(this, arguments) || this;
  4887. }
  4888. /** @hidden */
  4889. CubicEase.prototype.easeInCore = function (gradient) {
  4890. return (gradient * gradient * gradient);
  4891. };
  4892. return CubicEase;
  4893. }(EasingFunction));
  4894. /**
  4895. * Easing function with an elastic shape (see link below).
  4896. * @see https://easings.net/#easeInElastic
  4897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4898. */
  4899. var ElasticEase = /** @class */ (function (_super) {
  4900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4901. /**
  4902. * Instantiates an elastic easing function
  4903. * @see https://easings.net/#easeInElastic
  4904. * @param oscillations Defines the number of oscillations
  4905. * @param springiness Defines the amplitude of the oscillations
  4906. */
  4907. function ElasticEase(
  4908. /** Defines the number of oscillations*/
  4909. oscillations,
  4910. /** Defines the amplitude of the oscillations*/
  4911. springiness) {
  4912. if (oscillations === void 0) { oscillations = 3; }
  4913. if (springiness === void 0) { springiness = 3; }
  4914. var _this = _super.call(this) || this;
  4915. _this.oscillations = oscillations;
  4916. _this.springiness = springiness;
  4917. return _this;
  4918. }
  4919. /** @hidden */
  4920. ElasticEase.prototype.easeInCore = function (gradient) {
  4921. var num2;
  4922. var num3 = Math.max(0.0, this.oscillations);
  4923. var num = Math.max(0.0, this.springiness);
  4924. if (num == 0) {
  4925. num2 = gradient;
  4926. }
  4927. else {
  4928. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4929. }
  4930. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4931. };
  4932. return ElasticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with an exponential shape (see link below).
  4936. * @see https://easings.net/#easeInExpo
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var ExponentialEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4941. /**
  4942. * Instantiates an exponential easing function
  4943. * @see https://easings.net/#easeInExpo
  4944. * @param exponent Defines the exponent of the function
  4945. */
  4946. function ExponentialEase(
  4947. /** Defines the exponent of the function */
  4948. exponent) {
  4949. if (exponent === void 0) { exponent = 2; }
  4950. var _this = _super.call(this) || this;
  4951. _this.exponent = exponent;
  4952. return _this;
  4953. }
  4954. /** @hidden */
  4955. ExponentialEase.prototype.easeInCore = function (gradient) {
  4956. if (this.exponent <= 0) {
  4957. return gradient;
  4958. }
  4959. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4960. };
  4961. return ExponentialEase;
  4962. }(EasingFunction));
  4963. /**
  4964. * Easing function with a power shape (see link below).
  4965. * @see https://easings.net/#easeInQuad
  4966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4967. */
  4968. var PowerEase = /** @class */ (function (_super) {
  4969. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4970. /**
  4971. * Instantiates an power base easing function
  4972. * @see https://easings.net/#easeInQuad
  4973. * @param power Defines the power of the function
  4974. */
  4975. function PowerEase(
  4976. /** Defines the power of the function */
  4977. power) {
  4978. if (power === void 0) { power = 2; }
  4979. var _this = _super.call(this) || this;
  4980. _this.power = power;
  4981. return _this;
  4982. }
  4983. /** @hidden */
  4984. PowerEase.prototype.easeInCore = function (gradient) {
  4985. var y = Math.max(0.0, this.power);
  4986. return Math.pow(gradient, y);
  4987. };
  4988. return PowerEase;
  4989. }(EasingFunction));
  4990. /**
  4991. * Easing function with a power of 2 shape (see link below).
  4992. * @see https://easings.net/#easeInQuad
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. var QuadraticEase = /** @class */ (function (_super) {
  4996. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4997. function QuadraticEase() {
  4998. return _super !== null && _super.apply(this, arguments) || this;
  4999. }
  5000. /** @hidden */
  5001. QuadraticEase.prototype.easeInCore = function (gradient) {
  5002. return (gradient * gradient);
  5003. };
  5004. return QuadraticEase;
  5005. }(EasingFunction));
  5006. /**
  5007. * Easing function with a power of 4 shape (see link below).
  5008. * @see https://easings.net/#easeInQuart
  5009. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5010. */
  5011. var QuarticEase = /** @class */ (function (_super) {
  5012. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  5013. function QuarticEase() {
  5014. return _super !== null && _super.apply(this, arguments) || this;
  5015. }
  5016. /** @hidden */
  5017. QuarticEase.prototype.easeInCore = function (gradient) {
  5018. return (gradient * gradient * gradient * gradient);
  5019. };
  5020. return QuarticEase;
  5021. }(EasingFunction));
  5022. /**
  5023. * Easing function with a power of 5 shape (see link below).
  5024. * @see https://easings.net/#easeInQuint
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. var QuinticEase = /** @class */ (function (_super) {
  5028. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  5029. function QuinticEase() {
  5030. return _super !== null && _super.apply(this, arguments) || this;
  5031. }
  5032. /** @hidden */
  5033. QuinticEase.prototype.easeInCore = function (gradient) {
  5034. return (gradient * gradient * gradient * gradient * gradient);
  5035. };
  5036. return QuinticEase;
  5037. }(EasingFunction));
  5038. /**
  5039. * Easing function with a sin shape (see link below).
  5040. * @see https://easings.net/#easeInSine
  5041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5042. */
  5043. var SineEase = /** @class */ (function (_super) {
  5044. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  5045. function SineEase() {
  5046. return _super !== null && _super.apply(this, arguments) || this;
  5047. }
  5048. /** @hidden */
  5049. SineEase.prototype.easeInCore = function (gradient) {
  5050. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  5051. };
  5052. return SineEase;
  5053. }(EasingFunction));
  5054. /**
  5055. * Easing function with a bezier shape (see link below).
  5056. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. var BezierCurveEase = /** @class */ (function (_super) {
  5060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  5061. /**
  5062. * Instantiates a bezier function
  5063. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5064. * @param x1 Defines the x component of the start tangent in the bezier curve
  5065. * @param y1 Defines the y component of the start tangent in the bezier curve
  5066. * @param x2 Defines the x component of the end tangent in the bezier curve
  5067. * @param y2 Defines the y component of the end tangent in the bezier curve
  5068. */
  5069. function BezierCurveEase(
  5070. /** Defines the x component of the start tangent in the bezier curve */
  5071. x1,
  5072. /** Defines the y component of the start tangent in the bezier curve */
  5073. y1,
  5074. /** Defines the x component of the end tangent in the bezier curve */
  5075. x2,
  5076. /** Defines the y component of the end tangent in the bezier curve */
  5077. y2) {
  5078. if (x1 === void 0) { x1 = 0; }
  5079. if (y1 === void 0) { y1 = 0; }
  5080. if (x2 === void 0) { x2 = 1; }
  5081. if (y2 === void 0) { y2 = 1; }
  5082. var _this = _super.call(this) || this;
  5083. _this.x1 = x1;
  5084. _this.y1 = y1;
  5085. _this.x2 = x2;
  5086. _this.y2 = y2;
  5087. return _this;
  5088. }
  5089. /** @hidden */
  5090. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5091. return _Maths_math_path__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5092. };
  5093. return BezierCurveEase;
  5094. }(EasingFunction));
  5095. /***/ }),
  5096. /***/ "./Animations/index.ts":
  5097. /*!*****************************!*\
  5098. !*** ./Animations/index.ts ***!
  5099. \*****************************/
  5100. /*! 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 */
  5101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5102. "use strict";
  5103. __webpack_require__.r(__webpack_exports__);
  5104. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5106. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["_IAnimationState"]; });
  5108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5109. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5112. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5114. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5128. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5130. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5132. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5134. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5136. /***/ }),
  5137. /***/ "./Animations/runtimeAnimation.ts":
  5138. /*!****************************************!*\
  5139. !*** ./Animations/runtimeAnimation.ts ***!
  5140. \****************************************/
  5141. /*! exports provided: RuntimeAnimation */
  5142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5143. "use strict";
  5144. __webpack_require__.r(__webpack_exports__);
  5145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5146. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  5147. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  5148. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5149. /* harmony import */ var _Maths_math_size__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.size */ "./Maths/math.size.ts");
  5150. // Static values to help the garbage collector
  5151. // Quaternion
  5152. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5153. // Vector3
  5154. var _staticOffsetValueVector3 = Object.freeze(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5155. // Vector2
  5156. var _staticOffsetValueVector2 = Object.freeze(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5157. // Size
  5158. var _staticOffsetValueSize = Object.freeze(_Maths_math_size__WEBPACK_IMPORTED_MODULE_3__["Size"].Zero());
  5159. // Color3
  5160. var _staticOffsetValueColor3 = Object.freeze(_Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black());
  5161. /**
  5162. * Defines a runtime animation
  5163. */
  5164. var RuntimeAnimation = /** @class */ (function () {
  5165. /**
  5166. * Create a new RuntimeAnimation object
  5167. * @param target defines the target of the animation
  5168. * @param animation defines the source animation object
  5169. * @param scene defines the hosting scene
  5170. * @param host defines the initiating Animatable
  5171. */
  5172. function RuntimeAnimation(target, animation, scene, host) {
  5173. var _this = this;
  5174. this._events = new Array();
  5175. /**
  5176. * The current frame of the runtime animation
  5177. */
  5178. this._currentFrame = 0;
  5179. /**
  5180. * The original value of the runtime animation
  5181. */
  5182. this._originalValue = new Array();
  5183. /**
  5184. * The original blend value of the runtime animation
  5185. */
  5186. this._originalBlendValue = null;
  5187. /**
  5188. * The offsets cache of the runtime animation
  5189. */
  5190. this._offsetsCache = {};
  5191. /**
  5192. * The high limits cache of the runtime animation
  5193. */
  5194. this._highLimitsCache = {};
  5195. /**
  5196. * Specifies if the runtime animation has been stopped
  5197. */
  5198. this._stopped = false;
  5199. /**
  5200. * The blending factor of the runtime animation
  5201. */
  5202. this._blendingFactor = 0;
  5203. /**
  5204. * The current value of the runtime animation
  5205. */
  5206. this._currentValue = null;
  5207. this._currentActiveTarget = null;
  5208. this._directTarget = null;
  5209. /**
  5210. * The target path of the runtime animation
  5211. */
  5212. this._targetPath = "";
  5213. /**
  5214. * The weight of the runtime animation
  5215. */
  5216. this._weight = 1.0;
  5217. /**
  5218. * The ratio offset of the runtime animation
  5219. */
  5220. this._ratioOffset = 0;
  5221. /**
  5222. * The previous delay of the runtime animation
  5223. */
  5224. this._previousDelay = 0;
  5225. /**
  5226. * The previous ratio of the runtime animation
  5227. */
  5228. this._previousRatio = 0;
  5229. this._targetIsArray = false;
  5230. this._animation = animation;
  5231. this._target = target;
  5232. this._scene = scene;
  5233. this._host = host;
  5234. this._activeTargets = [];
  5235. animation._runtimeAnimations.push(this);
  5236. // State
  5237. this._animationState = {
  5238. key: 0,
  5239. repeatCount: 0,
  5240. loopMode: this._getCorrectLoopMode()
  5241. };
  5242. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_MATRIX) {
  5243. this._animationState.workValue = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5244. }
  5245. // Limits
  5246. this._keys = this._animation.getKeys();
  5247. this._minFrame = this._keys[0].frame;
  5248. this._maxFrame = this._keys[this._keys.length - 1].frame;
  5249. this._minValue = this._keys[0].value;
  5250. this._maxValue = this._keys[this._keys.length - 1].value;
  5251. // Add a start key at frame 0 if missing
  5252. if (this._minFrame !== 0) {
  5253. var newKey = { frame: 0, value: this._minValue };
  5254. this._keys.splice(0, 0, newKey);
  5255. }
  5256. // Check data
  5257. if (this._target instanceof Array) {
  5258. var index = 0;
  5259. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5260. var target_1 = _a[_i];
  5261. this._preparePath(target_1, index);
  5262. this._getOriginalValues(index);
  5263. index++;
  5264. }
  5265. this._targetIsArray = true;
  5266. }
  5267. else {
  5268. this._preparePath(this._target);
  5269. this._getOriginalValues();
  5270. this._targetIsArray = false;
  5271. this._directTarget = this._activeTargets[0];
  5272. }
  5273. // Cloning events locally
  5274. var events = animation.getEvents();
  5275. if (events && events.length > 0) {
  5276. events.forEach(function (e) {
  5277. _this._events.push(e._clone());
  5278. });
  5279. }
  5280. this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5281. }
  5282. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5283. /**
  5284. * Gets the current frame of the runtime animation
  5285. */
  5286. get: function () {
  5287. return this._currentFrame;
  5288. },
  5289. enumerable: true,
  5290. configurable: true
  5291. });
  5292. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5293. /**
  5294. * Gets the weight of the runtime animation
  5295. */
  5296. get: function () {
  5297. return this._weight;
  5298. },
  5299. enumerable: true,
  5300. configurable: true
  5301. });
  5302. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5303. /**
  5304. * Gets the current value of the runtime animation
  5305. */
  5306. get: function () {
  5307. return this._currentValue;
  5308. },
  5309. enumerable: true,
  5310. configurable: true
  5311. });
  5312. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5313. /**
  5314. * Gets the target path of the runtime animation
  5315. */
  5316. get: function () {
  5317. return this._targetPath;
  5318. },
  5319. enumerable: true,
  5320. configurable: true
  5321. });
  5322. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5323. /**
  5324. * Gets the actual target of the runtime animation
  5325. */
  5326. get: function () {
  5327. return this._currentActiveTarget;
  5328. },
  5329. enumerable: true,
  5330. configurable: true
  5331. });
  5332. RuntimeAnimation.prototype._preparePath = function (target, targetIndex) {
  5333. if (targetIndex === void 0) { targetIndex = 0; }
  5334. var targetPropertyPath = this._animation.targetPropertyPath;
  5335. if (targetPropertyPath.length > 1) {
  5336. var property = target[targetPropertyPath[0]];
  5337. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5338. property = property[targetPropertyPath[index]];
  5339. }
  5340. this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];
  5341. this._activeTargets[targetIndex] = property;
  5342. }
  5343. else {
  5344. this._targetPath = targetPropertyPath[0];
  5345. this._activeTargets[targetIndex] = target;
  5346. }
  5347. };
  5348. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5349. /**
  5350. * Gets the animation from the runtime animation
  5351. */
  5352. get: function () {
  5353. return this._animation;
  5354. },
  5355. enumerable: true,
  5356. configurable: true
  5357. });
  5358. /**
  5359. * Resets the runtime animation to the beginning
  5360. * @param restoreOriginal defines whether to restore the target property to the original value
  5361. */
  5362. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5363. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5364. if (restoreOriginal) {
  5365. if (this._target instanceof Array) {
  5366. var index = 0;
  5367. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5368. var target = _a[_i];
  5369. if (this._originalValue[index] !== undefined) {
  5370. this._setValue(target, this._activeTargets[index], this._originalValue[index], -1, index);
  5371. }
  5372. index++;
  5373. }
  5374. }
  5375. else {
  5376. if (this._originalValue[0] !== undefined) {
  5377. this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
  5378. }
  5379. }
  5380. }
  5381. this._offsetsCache = {};
  5382. this._highLimitsCache = {};
  5383. this._currentFrame = 0;
  5384. this._blendingFactor = 0;
  5385. // Events
  5386. for (var index = 0; index < this._events.length; index++) {
  5387. this._events[index].isDone = false;
  5388. }
  5389. };
  5390. /**
  5391. * Specifies if the runtime animation is stopped
  5392. * @returns Boolean specifying if the runtime animation is stopped
  5393. */
  5394. RuntimeAnimation.prototype.isStopped = function () {
  5395. return this._stopped;
  5396. };
  5397. /**
  5398. * Disposes of the runtime animation
  5399. */
  5400. RuntimeAnimation.prototype.dispose = function () {
  5401. var index = this._animation.runtimeAnimations.indexOf(this);
  5402. if (index > -1) {
  5403. this._animation.runtimeAnimations.splice(index, 1);
  5404. }
  5405. };
  5406. /**
  5407. * Apply the interpolated value to the target
  5408. * @param currentValue defines the value computed by the animation
  5409. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5410. */
  5411. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5412. if (this._targetIsArray) {
  5413. for (var index = 0; index < this._target.length; index++) {
  5414. var target = this._target[index];
  5415. this._setValue(target, this._activeTargets[index], currentValue, weight, index);
  5416. }
  5417. return;
  5418. }
  5419. this._setValue(this._target, this._directTarget, currentValue, weight, 0);
  5420. };
  5421. RuntimeAnimation.prototype._getOriginalValues = function (targetIndex) {
  5422. if (targetIndex === void 0) { targetIndex = 0; }
  5423. var originalValue;
  5424. var target = this._activeTargets[targetIndex];
  5425. if (target.getRestPose && this._targetPath === "_matrix") { // For bones
  5426. originalValue = target.getRestPose();
  5427. }
  5428. else {
  5429. originalValue = target[this._targetPath];
  5430. }
  5431. if (originalValue && originalValue.clone) {
  5432. this._originalValue[targetIndex] = originalValue.clone();
  5433. }
  5434. else {
  5435. this._originalValue[targetIndex] = originalValue;
  5436. }
  5437. };
  5438. RuntimeAnimation.prototype._setValue = function (target, destination, currentValue, weight, targetIndex) {
  5439. // Set value
  5440. this._currentActiveTarget = destination;
  5441. this._weight = weight;
  5442. if (this._enableBlending && this._blendingFactor <= 1.0) {
  5443. if (!this._originalBlendValue) {
  5444. var originalValue = destination[this._targetPath];
  5445. if (originalValue.clone) {
  5446. this._originalBlendValue = originalValue.clone();
  5447. }
  5448. else {
  5449. this._originalBlendValue = originalValue;
  5450. }
  5451. }
  5452. if (this._originalBlendValue.m) { // Matrix
  5453. if (_animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5454. if (this._currentValue) {
  5455. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5456. }
  5457. else {
  5458. this._currentValue = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5459. }
  5460. }
  5461. else {
  5462. if (this._currentValue) {
  5463. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5464. }
  5465. else {
  5466. this._currentValue = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5467. }
  5468. }
  5469. }
  5470. else {
  5471. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5472. }
  5473. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5474. this._blendingFactor += blendingSpeed;
  5475. }
  5476. else {
  5477. this._currentValue = currentValue;
  5478. }
  5479. if (weight !== -1.0) {
  5480. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5481. }
  5482. else {
  5483. destination[this._targetPath] = this._currentValue;
  5484. }
  5485. if (target.markAsDirty) {
  5486. target.markAsDirty(this._animation.targetProperty);
  5487. }
  5488. };
  5489. /**
  5490. * Gets the loop pmode of the runtime animation
  5491. * @returns Loop Mode
  5492. */
  5493. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5494. if (this._target && this._target.animationPropertiesOverride) {
  5495. return this._target.animationPropertiesOverride.loopMode;
  5496. }
  5497. return this._animation.loopMode;
  5498. };
  5499. /**
  5500. * Move the current animation to a given frame
  5501. * @param frame defines the frame to move to
  5502. */
  5503. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5504. var keys = this._animation.getKeys();
  5505. if (frame < keys[0].frame) {
  5506. frame = keys[0].frame;
  5507. }
  5508. else if (frame > keys[keys.length - 1].frame) {
  5509. frame = keys[keys.length - 1].frame;
  5510. }
  5511. // Need to reset animation events
  5512. var events = this._events;
  5513. if (events.length) {
  5514. for (var index = 0; index < events.length; index++) {
  5515. if (!events[index].onlyOnce) {
  5516. // reset events in the future
  5517. events[index].isDone = events[index].frame < frame;
  5518. }
  5519. }
  5520. }
  5521. this._currentFrame = frame;
  5522. var currentValue = this._animation._interpolate(frame, this._animationState);
  5523. this.setValue(currentValue, -1);
  5524. };
  5525. /**
  5526. * @hidden Internal use only
  5527. */
  5528. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5529. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5530. this._ratioOffset = this._previousRatio - newRatio;
  5531. };
  5532. /**
  5533. * Execute the current animation
  5534. * @param delay defines the delay to add to the current frame
  5535. * @param from defines the lower bound of the animation range
  5536. * @param to defines the upper bound of the animation range
  5537. * @param loop defines if the current animation must loop
  5538. * @param speedRatio defines the current speed ratio
  5539. * @param weight defines the weight of the animation (default is -1 so no weight)
  5540. * @param onLoop optional callback called when animation loops
  5541. * @returns a boolean indicating if the animation is running
  5542. */
  5543. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight) {
  5544. if (weight === void 0) { weight = -1.0; }
  5545. var animation = this._animation;
  5546. var targetPropertyPath = animation.targetPropertyPath;
  5547. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5548. this._stopped = true;
  5549. return false;
  5550. }
  5551. var returnValue = true;
  5552. // Check limits
  5553. if (from < this._minFrame || from > this._maxFrame) {
  5554. from = this._minFrame;
  5555. }
  5556. if (to < this._minFrame || to > this._maxFrame) {
  5557. to = this._maxFrame;
  5558. }
  5559. var range = to - from;
  5560. var offsetValue;
  5561. // Compute ratio which represents the frame delta between from and to
  5562. var ratio = (delay * (animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5563. var highLimitValue = 0;
  5564. this._previousDelay = delay;
  5565. this._previousRatio = ratio;
  5566. if (!loop && (to >= from && ratio >= range)) { // If we are out of range and not looping get back to caller
  5567. returnValue = false;
  5568. highLimitValue = animation._getKeyValue(this._maxValue);
  5569. }
  5570. else if (!loop && (from >= to && ratio <= range)) {
  5571. returnValue = false;
  5572. highLimitValue = animation._getKeyValue(this._minValue);
  5573. }
  5574. else if (this._animationState.loopMode !== _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5575. var keyOffset = to.toString() + from.toString();
  5576. if (!this._offsetsCache[keyOffset]) {
  5577. this._animationState.repeatCount = 0;
  5578. this._animationState.loopMode = _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  5579. var fromValue = animation._interpolate(from, this._animationState);
  5580. var toValue = animation._interpolate(to, this._animationState);
  5581. this._animationState.loopMode = this._getCorrectLoopMode();
  5582. switch (animation.dataType) {
  5583. // Float
  5584. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_FLOAT:
  5585. this._offsetsCache[keyOffset] = toValue - fromValue;
  5586. break;
  5587. // Quaternion
  5588. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_QUATERNION:
  5589. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5590. break;
  5591. // Vector3
  5592. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_VECTOR3:
  5593. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5594. // Vector2
  5595. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_VECTOR2:
  5596. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5597. // Size
  5598. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_SIZE:
  5599. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5600. // Color3
  5601. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_COLOR3:
  5602. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5603. default:
  5604. break;
  5605. }
  5606. this._highLimitsCache[keyOffset] = toValue;
  5607. }
  5608. highLimitValue = this._highLimitsCache[keyOffset];
  5609. offsetValue = this._offsetsCache[keyOffset];
  5610. }
  5611. if (offsetValue === undefined) {
  5612. switch (animation.dataType) {
  5613. // Float
  5614. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_FLOAT:
  5615. offsetValue = 0;
  5616. break;
  5617. // Quaternion
  5618. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_QUATERNION:
  5619. offsetValue = _staticOffsetValueQuaternion;
  5620. break;
  5621. // Vector3
  5622. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_VECTOR3:
  5623. offsetValue = _staticOffsetValueVector3;
  5624. break;
  5625. // Vector2
  5626. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_VECTOR2:
  5627. offsetValue = _staticOffsetValueVector2;
  5628. break;
  5629. // Size
  5630. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_SIZE:
  5631. offsetValue = _staticOffsetValueSize;
  5632. break;
  5633. // Color3
  5634. case _animation__WEBPACK_IMPORTED_MODULE_2__["Animation"].ANIMATIONTYPE_COLOR3:
  5635. offsetValue = _staticOffsetValueColor3;
  5636. }
  5637. }
  5638. // Compute value
  5639. var currentFrame;
  5640. if (this._host && this._host.syncRoot) {
  5641. var syncRoot = this._host.syncRoot;
  5642. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5643. currentFrame = from + (to - from) * hostNormalizedFrame;
  5644. }
  5645. else {
  5646. currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5647. }
  5648. // Reset events if looping
  5649. var events = this._events;
  5650. if (range > 0 && this.currentFrame > currentFrame ||
  5651. range < 0 && this.currentFrame < currentFrame) {
  5652. this._onLoop();
  5653. // Need to reset animation events
  5654. if (events.length) {
  5655. for (var index = 0; index < events.length; index++) {
  5656. if (!events[index].onlyOnce) {
  5657. // reset event, the animation is looping
  5658. events[index].isDone = false;
  5659. }
  5660. }
  5661. }
  5662. }
  5663. this._currentFrame = currentFrame;
  5664. this._animationState.repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5665. this._animationState.highLimitValue = highLimitValue;
  5666. this._animationState.offsetValue = offsetValue;
  5667. var currentValue = animation._interpolate(currentFrame, this._animationState);
  5668. // Set value
  5669. this.setValue(currentValue, weight);
  5670. // Check events
  5671. if (events.length) {
  5672. for (var index = 0; index < events.length; index++) {
  5673. // Make sure current frame has passed event frame and that event frame is within the current range
  5674. // Also, handle both forward and reverse animations
  5675. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5676. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5677. var event = events[index];
  5678. if (!event.isDone) {
  5679. // If event should be done only once, remove it.
  5680. if (event.onlyOnce) {
  5681. events.splice(index, 1);
  5682. index--;
  5683. }
  5684. event.isDone = true;
  5685. event.action(currentFrame);
  5686. } // Don't do anything if the event has already be done.
  5687. }
  5688. }
  5689. }
  5690. if (!returnValue) {
  5691. this._stopped = true;
  5692. }
  5693. return returnValue;
  5694. };
  5695. return RuntimeAnimation;
  5696. }());
  5697. /***/ }),
  5698. /***/ "./Audio/analyser.ts":
  5699. /*!***************************!*\
  5700. !*** ./Audio/analyser.ts ***!
  5701. \***************************/
  5702. /*! exports provided: Analyser */
  5703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5704. "use strict";
  5705. __webpack_require__.r(__webpack_exports__);
  5706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5707. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5708. /**
  5709. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5711. */
  5712. var Analyser = /** @class */ (function () {
  5713. /**
  5714. * Creates a new analyser
  5715. * @param scene defines hosting scene
  5716. */
  5717. function Analyser(scene) {
  5718. /**
  5719. * Gets or sets the smoothing
  5720. * @ignorenaming
  5721. */
  5722. this.SMOOTHING = 0.75;
  5723. /**
  5724. * Gets or sets the FFT table size
  5725. * @ignorenaming
  5726. */
  5727. this.FFT_SIZE = 512;
  5728. /**
  5729. * Gets or sets the bar graph amplitude
  5730. * @ignorenaming
  5731. */
  5732. this.BARGRAPHAMPLITUDE = 256;
  5733. /**
  5734. * Gets or sets the position of the debug canvas
  5735. * @ignorenaming
  5736. */
  5737. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5738. /**
  5739. * Gets or sets the debug canvas size
  5740. * @ignorenaming
  5741. */
  5742. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5743. this._scene = scene;
  5744. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5745. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5746. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5747. this._webAudioAnalyser.minDecibels = -140;
  5748. this._webAudioAnalyser.maxDecibels = 0;
  5749. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5750. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5751. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5752. }
  5753. }
  5754. /**
  5755. * Get the number of data values you will have to play with for the visualization
  5756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5757. * @returns a number
  5758. */
  5759. Analyser.prototype.getFrequencyBinCount = function () {
  5760. if (this._audioEngine.canUseWebAudio) {
  5761. return this._webAudioAnalyser.frequencyBinCount;
  5762. }
  5763. else {
  5764. return 0;
  5765. }
  5766. };
  5767. /**
  5768. * Gets the current frequency data as a byte array
  5769. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5770. * @returns a Uint8Array
  5771. */
  5772. Analyser.prototype.getByteFrequencyData = function () {
  5773. if (this._audioEngine.canUseWebAudio) {
  5774. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5775. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5776. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5777. }
  5778. return this._byteFreqs;
  5779. };
  5780. /**
  5781. * Gets the current waveform as a byte array
  5782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5783. * @returns a Uint8Array
  5784. */
  5785. Analyser.prototype.getByteTimeDomainData = function () {
  5786. if (this._audioEngine.canUseWebAudio) {
  5787. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5788. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5789. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5790. }
  5791. return this._byteTime;
  5792. };
  5793. /**
  5794. * Gets the current frequency data as a float array
  5795. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5796. * @returns a Float32Array
  5797. */
  5798. Analyser.prototype.getFloatFrequencyData = function () {
  5799. if (this._audioEngine.canUseWebAudio) {
  5800. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5801. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5802. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5803. }
  5804. return this._floatFreqs;
  5805. };
  5806. /**
  5807. * Renders the debug canvas
  5808. */
  5809. Analyser.prototype.drawDebugCanvas = function () {
  5810. var _this = this;
  5811. if (this._audioEngine.canUseWebAudio) {
  5812. if (!this._debugCanvas) {
  5813. this._debugCanvas = document.createElement("canvas");
  5814. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5815. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5816. this._debugCanvas.style.position = "absolute";
  5817. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5818. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5819. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5820. document.body.appendChild(this._debugCanvas);
  5821. this._registerFunc = function () {
  5822. _this.drawDebugCanvas();
  5823. };
  5824. this._scene.registerBeforeRender(this._registerFunc);
  5825. }
  5826. if (this._registerFunc && this._debugCanvasContext) {
  5827. var workingArray = this.getByteFrequencyData();
  5828. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5829. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5830. // Draw the frequency domain chart.
  5831. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5832. var value = workingArray[i];
  5833. var percent = value / this.BARGRAPHAMPLITUDE;
  5834. var height = this.DEBUGCANVASSIZE.height * percent;
  5835. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5836. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5837. var hue = i / this.getFrequencyBinCount() * 360;
  5838. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5839. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5840. }
  5841. }
  5842. }
  5843. };
  5844. /**
  5845. * Stops rendering the debug canvas and removes it
  5846. */
  5847. Analyser.prototype.stopDebugCanvas = function () {
  5848. if (this._debugCanvas) {
  5849. if (this._registerFunc) {
  5850. this._scene.unregisterBeforeRender(this._registerFunc);
  5851. this._registerFunc = null;
  5852. }
  5853. document.body.removeChild(this._debugCanvas);
  5854. this._debugCanvas = null;
  5855. this._debugCanvasContext = null;
  5856. }
  5857. };
  5858. /**
  5859. * Connects two audio nodes
  5860. * @param inputAudioNode defines first node to connect
  5861. * @param outputAudioNode defines second node to connect
  5862. */
  5863. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5864. if (this._audioEngine.canUseWebAudio) {
  5865. inputAudioNode.connect(this._webAudioAnalyser);
  5866. this._webAudioAnalyser.connect(outputAudioNode);
  5867. }
  5868. };
  5869. /**
  5870. * Releases all associated resources
  5871. */
  5872. Analyser.prototype.dispose = function () {
  5873. if (this._audioEngine.canUseWebAudio) {
  5874. this._webAudioAnalyser.disconnect();
  5875. }
  5876. };
  5877. return Analyser;
  5878. }());
  5879. /***/ }),
  5880. /***/ "./Audio/audioEngine.ts":
  5881. /*!******************************!*\
  5882. !*** ./Audio/audioEngine.ts ***!
  5883. \******************************/
  5884. /*! exports provided: AudioEngine */
  5885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5886. "use strict";
  5887. __webpack_require__.r(__webpack_exports__);
  5888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5889. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5890. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5891. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5892. // Sets the default audio engine to Babylon.js
  5893. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5894. /**
  5895. * This represents the default audio engine used in babylon.
  5896. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5898. */
  5899. var AudioEngine = /** @class */ (function () {
  5900. /**
  5901. * Instantiates a new audio engine.
  5902. *
  5903. * There should be only one per page as some browsers restrict the number
  5904. * of audio contexts you can create.
  5905. * @param hostElement defines the host element where to display the mute icon if necessary
  5906. */
  5907. function AudioEngine(hostElement) {
  5908. var _this = this;
  5909. if (hostElement === void 0) { hostElement = null; }
  5910. this._audioContext = null;
  5911. this._audioContextInitialized = false;
  5912. this._muteButton = null;
  5913. /**
  5914. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5915. */
  5916. this.canUseWebAudio = false;
  5917. /**
  5918. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5919. * @ignoreNaming
  5920. */
  5921. this.WarnedWebAudioUnsupported = false;
  5922. /**
  5923. * Gets whether or not mp3 are supported by your browser.
  5924. */
  5925. this.isMP3supported = false;
  5926. /**
  5927. * Gets whether or not ogg are supported by your browser.
  5928. */
  5929. this.isOGGsupported = false;
  5930. /**
  5931. * Gets whether audio has been unlocked on the device.
  5932. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5933. * a user interaction has happened.
  5934. */
  5935. this.unlocked = true;
  5936. /**
  5937. * Defines if the audio engine relies on a custom unlocked button.
  5938. * In this case, the embedded button will not be displayed.
  5939. */
  5940. this.useCustomUnlockedButton = false;
  5941. /**
  5942. * Event raised when audio has been unlocked on the browser.
  5943. */
  5944. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5945. /**
  5946. * Event raised when audio has been locked on the browser.
  5947. */
  5948. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5949. this._tryToRun = false;
  5950. this._onResize = function () {
  5951. _this._moveButtonToTopLeft();
  5952. };
  5953. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5954. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5955. this.canUseWebAudio = true;
  5956. }
  5957. var audioElem = document.createElement('audio');
  5958. this._hostElement = hostElement;
  5959. try {
  5960. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5961. this.isMP3supported = true;
  5962. }
  5963. }
  5964. catch (e) {
  5965. // protect error during capability check.
  5966. }
  5967. try {
  5968. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5969. this.isOGGsupported = true;
  5970. }
  5971. }
  5972. catch (e) {
  5973. // protect error during capability check.
  5974. }
  5975. }
  5976. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5977. /**
  5978. * Gets the current AudioContext if available.
  5979. */
  5980. get: function () {
  5981. if (!this._audioContextInitialized) {
  5982. this._initializeAudioContext();
  5983. }
  5984. else {
  5985. if (!this.unlocked && !this._muteButton) {
  5986. this._displayMuteButton();
  5987. }
  5988. }
  5989. return this._audioContext;
  5990. },
  5991. enumerable: true,
  5992. configurable: true
  5993. });
  5994. /**
  5995. * Flags the audio engine in Locked state.
  5996. * This happens due to new browser policies preventing audio to autoplay.
  5997. */
  5998. AudioEngine.prototype.lock = function () {
  5999. this._triggerSuspendedState();
  6000. };
  6001. /**
  6002. * Unlocks the audio engine once a user action has been done on the dom.
  6003. * This is helpful to resume play once browser policies have been satisfied.
  6004. */
  6005. AudioEngine.prototype.unlock = function () {
  6006. this._triggerRunningState();
  6007. };
  6008. AudioEngine.prototype._resumeAudioContext = function () {
  6009. var result;
  6010. if (this._audioContext.resume) {
  6011. result = this._audioContext.resume();
  6012. }
  6013. return result || Promise.resolve();
  6014. };
  6015. AudioEngine.prototype._initializeAudioContext = function () {
  6016. try {
  6017. if (this.canUseWebAudio) {
  6018. this._audioContext = new AudioContext();
  6019. // create a global volume gain node
  6020. this.masterGain = this._audioContext.createGain();
  6021. this.masterGain.gain.value = 1;
  6022. this.masterGain.connect(this._audioContext.destination);
  6023. this._audioContextInitialized = true;
  6024. if (this._audioContext.state === "running") {
  6025. // Do not wait for the promise to unlock.
  6026. this._triggerRunningState();
  6027. }
  6028. }
  6029. }
  6030. catch (e) {
  6031. this.canUseWebAudio = false;
  6032. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  6033. }
  6034. };
  6035. AudioEngine.prototype._triggerRunningState = function () {
  6036. var _this = this;
  6037. if (this._tryToRun) {
  6038. return;
  6039. }
  6040. this._tryToRun = true;
  6041. this._resumeAudioContext()
  6042. .then(function () {
  6043. _this._tryToRun = false;
  6044. if (_this._muteButton) {
  6045. _this._hideMuteButton();
  6046. }
  6047. }).catch(function () {
  6048. _this._tryToRun = false;
  6049. _this.unlocked = false;
  6050. });
  6051. // Notify users that the audio stack is unlocked/unmuted
  6052. this.unlocked = true;
  6053. this.onAudioUnlockedObservable.notifyObservers(this);
  6054. };
  6055. AudioEngine.prototype._triggerSuspendedState = function () {
  6056. this.unlocked = false;
  6057. this.onAudioLockedObservable.notifyObservers(this);
  6058. this._displayMuteButton();
  6059. };
  6060. AudioEngine.prototype._displayMuteButton = function () {
  6061. var _this = this;
  6062. if (this.useCustomUnlockedButton || this._muteButton) {
  6063. return;
  6064. }
  6065. this._muteButton = document.createElement("BUTTON");
  6066. this._muteButton.className = "babylonUnmuteIcon";
  6067. this._muteButton.id = "babylonUnmuteIconBtn";
  6068. this._muteButton.title = "Unmute";
  6069. 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) }";
  6070. var style = document.createElement('style');
  6071. style.appendChild(document.createTextNode(css));
  6072. document.getElementsByTagName('head')[0].appendChild(style);
  6073. document.body.appendChild(this._muteButton);
  6074. this._moveButtonToTopLeft();
  6075. this._muteButton.addEventListener('touchend', function () {
  6076. _this._triggerRunningState();
  6077. }, true);
  6078. this._muteButton.addEventListener('click', function () {
  6079. _this._triggerRunningState();
  6080. }, true);
  6081. window.addEventListener("resize", this._onResize);
  6082. };
  6083. AudioEngine.prototype._moveButtonToTopLeft = function () {
  6084. if (this._hostElement && this._muteButton) {
  6085. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  6086. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  6087. }
  6088. };
  6089. AudioEngine.prototype._hideMuteButton = function () {
  6090. if (this._muteButton) {
  6091. document.body.removeChild(this._muteButton);
  6092. this._muteButton = null;
  6093. }
  6094. };
  6095. /**
  6096. * Destroy and release the resources associated with the audio ccontext.
  6097. */
  6098. AudioEngine.prototype.dispose = function () {
  6099. if (this.canUseWebAudio && this._audioContextInitialized) {
  6100. if (this._connectedAnalyser && this._audioContext) {
  6101. this._connectedAnalyser.stopDebugCanvas();
  6102. this._connectedAnalyser.dispose();
  6103. this.masterGain.disconnect();
  6104. this.masterGain.connect(this._audioContext.destination);
  6105. this._connectedAnalyser = null;
  6106. }
  6107. this.masterGain.gain.value = 1;
  6108. }
  6109. this.WarnedWebAudioUnsupported = false;
  6110. this._hideMuteButton();
  6111. window.removeEventListener("resize", this._onResize);
  6112. this.onAudioUnlockedObservable.clear();
  6113. this.onAudioLockedObservable.clear();
  6114. };
  6115. /**
  6116. * Gets the global volume sets on the master gain.
  6117. * @returns the global volume if set or -1 otherwise
  6118. */
  6119. AudioEngine.prototype.getGlobalVolume = function () {
  6120. if (this.canUseWebAudio && this._audioContextInitialized) {
  6121. return this.masterGain.gain.value;
  6122. }
  6123. else {
  6124. return -1;
  6125. }
  6126. };
  6127. /**
  6128. * Sets the global volume of your experience (sets on the master gain).
  6129. * @param newVolume Defines the new global volume of the application
  6130. */
  6131. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6132. if (this.canUseWebAudio && this._audioContextInitialized) {
  6133. this.masterGain.gain.value = newVolume;
  6134. }
  6135. };
  6136. /**
  6137. * Connect the audio engine to an audio analyser allowing some amazing
  6138. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6140. * @param analyser The analyser to connect to the engine
  6141. */
  6142. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6143. if (this._connectedAnalyser) {
  6144. this._connectedAnalyser.stopDebugCanvas();
  6145. }
  6146. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6147. this._connectedAnalyser = analyser;
  6148. this.masterGain.disconnect();
  6149. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6150. }
  6151. };
  6152. return AudioEngine;
  6153. }());
  6154. /***/ }),
  6155. /***/ "./Audio/audioSceneComponent.ts":
  6156. /*!**************************************!*\
  6157. !*** ./Audio/audioSceneComponent.ts ***!
  6158. \**************************************/
  6159. /*! exports provided: AudioSceneComponent */
  6160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6161. "use strict";
  6162. __webpack_require__.r(__webpack_exports__);
  6163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6164. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6165. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6166. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6167. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  6168. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6169. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6170. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6171. // Adds the parser to the scene parsers.
  6172. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6173. // TODO: add sound
  6174. var loadedSounds = [];
  6175. var loadedSound;
  6176. container.sounds = container.sounds || [];
  6177. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6178. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6179. var parsedSound = parsedData.sounds[index];
  6180. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6181. if (!parsedSound.url) {
  6182. parsedSound.url = parsedSound.name;
  6183. }
  6184. if (!loadedSounds[parsedSound.url]) {
  6185. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6186. loadedSounds[parsedSound.url] = loadedSound;
  6187. container.sounds.push(loadedSound);
  6188. }
  6189. else {
  6190. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6191. }
  6192. }
  6193. else {
  6194. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6195. }
  6196. }
  6197. }
  6198. loadedSounds = [];
  6199. });
  6200. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6201. get: function () {
  6202. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6203. if (!compo) {
  6204. compo = new AudioSceneComponent(this);
  6205. this._addComponent(compo);
  6206. }
  6207. if (!this._mainSoundTrack) {
  6208. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6209. }
  6210. return this._mainSoundTrack;
  6211. },
  6212. enumerable: true,
  6213. configurable: true
  6214. });
  6215. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6216. var index;
  6217. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6218. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6219. return this.mainSoundTrack.soundCollection[index];
  6220. }
  6221. }
  6222. if (this.soundTracks) {
  6223. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6224. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6225. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6226. return this.soundTracks[sdIndex].soundCollection[index];
  6227. }
  6228. }
  6229. }
  6230. }
  6231. return null;
  6232. };
  6233. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6234. get: function () {
  6235. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6236. if (!compo) {
  6237. compo = new AudioSceneComponent(this);
  6238. this._addComponent(compo);
  6239. }
  6240. return compo.audioEnabled;
  6241. },
  6242. set: function (value) {
  6243. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6244. if (!compo) {
  6245. compo = new AudioSceneComponent(this);
  6246. this._addComponent(compo);
  6247. }
  6248. if (value) {
  6249. compo.enableAudio();
  6250. }
  6251. else {
  6252. compo.disableAudio();
  6253. }
  6254. },
  6255. enumerable: true,
  6256. configurable: true
  6257. });
  6258. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6259. get: function () {
  6260. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6261. if (!compo) {
  6262. compo = new AudioSceneComponent(this);
  6263. this._addComponent(compo);
  6264. }
  6265. return compo.headphone;
  6266. },
  6267. set: function (value) {
  6268. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6269. if (!compo) {
  6270. compo = new AudioSceneComponent(this);
  6271. this._addComponent(compo);
  6272. }
  6273. if (value) {
  6274. compo.switchAudioModeForHeadphones();
  6275. }
  6276. else {
  6277. compo.switchAudioModeForNormalSpeakers();
  6278. }
  6279. },
  6280. enumerable: true,
  6281. configurable: true
  6282. });
  6283. /**
  6284. * Defines the sound scene component responsible to manage any sounds
  6285. * in a given scene.
  6286. */
  6287. var AudioSceneComponent = /** @class */ (function () {
  6288. /**
  6289. * Creates a new instance of the component for the given scene
  6290. * @param scene Defines the scene to register the component in
  6291. */
  6292. function AudioSceneComponent(scene) {
  6293. /**
  6294. * The component name helpfull to identify the component in the list of scene components.
  6295. */
  6296. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6297. this._audioEnabled = true;
  6298. this._headphone = false;
  6299. this.scene = scene;
  6300. scene.soundTracks = new Array();
  6301. scene.sounds = new Array();
  6302. }
  6303. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6304. /**
  6305. * Gets whether audio is enabled or not.
  6306. * Please use related enable/disable method to switch state.
  6307. */
  6308. get: function () {
  6309. return this._audioEnabled;
  6310. },
  6311. enumerable: true,
  6312. configurable: true
  6313. });
  6314. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6315. /**
  6316. * Gets whether audio is outputing to headphone or not.
  6317. * Please use the according Switch methods to change output.
  6318. */
  6319. get: function () {
  6320. return this._headphone;
  6321. },
  6322. enumerable: true,
  6323. configurable: true
  6324. });
  6325. /**
  6326. * Registers the component in a given scene
  6327. */
  6328. AudioSceneComponent.prototype.register = function () {
  6329. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6330. };
  6331. /**
  6332. * Rebuilds the elements related to this component in case of
  6333. * context lost for instance.
  6334. */
  6335. AudioSceneComponent.prototype.rebuild = function () {
  6336. // Nothing to do here. (Not rendering related)
  6337. };
  6338. /**
  6339. * Serializes the component data to the specified json object
  6340. * @param serializationObject The object to serialize to
  6341. */
  6342. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6343. serializationObject.sounds = [];
  6344. if (this.scene.soundTracks) {
  6345. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6346. var soundtrack = this.scene.soundTracks[index];
  6347. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6348. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6349. }
  6350. }
  6351. }
  6352. };
  6353. /**
  6354. * Adds all the elements from the container to the scene
  6355. * @param container the container holding the elements
  6356. */
  6357. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6358. var _this = this;
  6359. if (!container.sounds) {
  6360. return;
  6361. }
  6362. container.sounds.forEach(function (sound) {
  6363. sound.play();
  6364. sound.autoplay = true;
  6365. _this.scene.mainSoundTrack.AddSound(sound);
  6366. });
  6367. };
  6368. /**
  6369. * Removes all the elements in the container from the scene
  6370. * @param container contains the elements to remove
  6371. * @param dispose if the removed element should be disposed (default: false)
  6372. */
  6373. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6374. var _this = this;
  6375. if (dispose === void 0) { dispose = false; }
  6376. if (!container.sounds) {
  6377. return;
  6378. }
  6379. container.sounds.forEach(function (sound) {
  6380. sound.stop();
  6381. sound.autoplay = false;
  6382. _this.scene.mainSoundTrack.RemoveSound(sound);
  6383. if (dispose) {
  6384. sound.dispose();
  6385. }
  6386. });
  6387. };
  6388. /**
  6389. * Disposes the component and the associated ressources.
  6390. */
  6391. AudioSceneComponent.prototype.dispose = function () {
  6392. var scene = this.scene;
  6393. if (scene._mainSoundTrack) {
  6394. scene.mainSoundTrack.dispose();
  6395. }
  6396. if (scene.soundTracks) {
  6397. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6398. scene.soundTracks[scIndex].dispose();
  6399. }
  6400. }
  6401. };
  6402. /**
  6403. * Disables audio in the associated scene.
  6404. */
  6405. AudioSceneComponent.prototype.disableAudio = function () {
  6406. var scene = this.scene;
  6407. this._audioEnabled = false;
  6408. var i;
  6409. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6410. scene.mainSoundTrack.soundCollection[i].pause();
  6411. }
  6412. if (scene.soundTracks) {
  6413. for (i = 0; i < scene.soundTracks.length; i++) {
  6414. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6415. scene.soundTracks[i].soundCollection[j].pause();
  6416. }
  6417. }
  6418. }
  6419. };
  6420. /**
  6421. * Enables audio in the associated scene.
  6422. */
  6423. AudioSceneComponent.prototype.enableAudio = function () {
  6424. var scene = this.scene;
  6425. this._audioEnabled = true;
  6426. var i;
  6427. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6428. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6429. scene.mainSoundTrack.soundCollection[i].play();
  6430. }
  6431. }
  6432. if (scene.soundTracks) {
  6433. for (i = 0; i < scene.soundTracks.length; i++) {
  6434. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6435. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6436. scene.soundTracks[i].soundCollection[j].play();
  6437. }
  6438. }
  6439. }
  6440. }
  6441. };
  6442. /**
  6443. * Switch audio to headphone output.
  6444. */
  6445. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6446. var scene = this.scene;
  6447. this._headphone = true;
  6448. scene.mainSoundTrack.switchPanningModelToHRTF();
  6449. if (scene.soundTracks) {
  6450. for (var i = 0; i < scene.soundTracks.length; i++) {
  6451. scene.soundTracks[i].switchPanningModelToHRTF();
  6452. }
  6453. }
  6454. };
  6455. /**
  6456. * Switch audio to normal speakers.
  6457. */
  6458. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6459. var scene = this.scene;
  6460. this._headphone = false;
  6461. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6462. if (scene.soundTracks) {
  6463. for (var i = 0; i < scene.soundTracks.length; i++) {
  6464. scene.soundTracks[i].switchPanningModelToEqualPower();
  6465. }
  6466. }
  6467. };
  6468. AudioSceneComponent.prototype._afterRender = function () {
  6469. var scene = this.scene;
  6470. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6471. return;
  6472. }
  6473. var listeningCamera;
  6474. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6475. if (scene.activeCameras.length > 0) {
  6476. listeningCamera = scene.activeCameras[0];
  6477. }
  6478. else {
  6479. listeningCamera = scene.activeCamera;
  6480. }
  6481. if (listeningCamera && audioEngine.audioContext) {
  6482. audioEngine.audioContext.listener.setPosition(listeningCamera.globalPosition.x, listeningCamera.globalPosition.y, listeningCamera.globalPosition.z);
  6483. // for VR cameras
  6484. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6485. listeningCamera = listeningCamera.rigCameras[0];
  6486. }
  6487. var mat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6488. var cameraDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6489. cameraDirection.normalize();
  6490. // To avoid some errors on GearVR
  6491. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6492. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6493. }
  6494. var i;
  6495. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6496. var sound = scene.mainSoundTrack.soundCollection[i];
  6497. if (sound.useCustomAttenuation) {
  6498. sound.updateDistanceFromListener();
  6499. }
  6500. }
  6501. if (scene.soundTracks) {
  6502. for (i = 0; i < scene.soundTracks.length; i++) {
  6503. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6504. sound = scene.soundTracks[i].soundCollection[j];
  6505. if (sound.useCustomAttenuation) {
  6506. sound.updateDistanceFromListener();
  6507. }
  6508. }
  6509. }
  6510. }
  6511. }
  6512. };
  6513. return AudioSceneComponent;
  6514. }());
  6515. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6516. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6517. if (!compo) {
  6518. compo = new AudioSceneComponent(scene);
  6519. scene._addComponent(compo);
  6520. }
  6521. };
  6522. /***/ }),
  6523. /***/ "./Audio/index.ts":
  6524. /*!************************!*\
  6525. !*** ./Audio/index.ts ***!
  6526. \************************/
  6527. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6529. "use strict";
  6530. __webpack_require__.r(__webpack_exports__);
  6531. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6533. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6535. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6537. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6539. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6541. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6543. /***/ }),
  6544. /***/ "./Audio/sound.ts":
  6545. /*!************************!*\
  6546. !*** ./Audio/sound.ts ***!
  6547. \************************/
  6548. /*! exports provided: Sound */
  6549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6550. "use strict";
  6551. __webpack_require__.r(__webpack_exports__);
  6552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6553. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6554. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6555. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  6556. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6557. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6558. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6559. /**
  6560. * Defines a sound that can be played in the application.
  6561. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6563. */
  6564. var Sound = /** @class */ (function () {
  6565. /**
  6566. * Create a sound and attach it to a scene
  6567. * @param name Name of your sound
  6568. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6569. * @param scene defines the scene the sound belongs to
  6570. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6571. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6572. */
  6573. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6574. var _this = this;
  6575. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6576. /**
  6577. * Does the sound autoplay once loaded.
  6578. */
  6579. this.autoplay = false;
  6580. /**
  6581. * Does the sound loop after it finishes playing once.
  6582. */
  6583. this.loop = false;
  6584. /**
  6585. * Does the sound use a custom attenuation curve to simulate the falloff
  6586. * happening when the source gets further away from the camera.
  6587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6588. */
  6589. this.useCustomAttenuation = false;
  6590. /**
  6591. * Is this sound currently played.
  6592. */
  6593. this.isPlaying = false;
  6594. /**
  6595. * Is this sound currently paused.
  6596. */
  6597. this.isPaused = false;
  6598. /**
  6599. * Does this sound enables spatial sound.
  6600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6601. */
  6602. this.spatialSound = false;
  6603. /**
  6604. * Define the reference distance the sound should be heard perfectly.
  6605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6606. */
  6607. this.refDistance = 1;
  6608. /**
  6609. * Define the roll off factor of spatial sounds.
  6610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6611. */
  6612. this.rolloffFactor = 1;
  6613. /**
  6614. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6616. */
  6617. this.maxDistance = 100;
  6618. /**
  6619. * Define the distance attenuation model the sound will follow.
  6620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6621. */
  6622. this.distanceModel = "linear";
  6623. /**
  6624. * Observable event when the current playing sound finishes.
  6625. */
  6626. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6627. this._panningModel = "equalpower";
  6628. this._playbackRate = 1;
  6629. this._streaming = false;
  6630. this._startTime = 0;
  6631. this._startOffset = 0;
  6632. this._position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6633. /** @hidden */
  6634. this._positionInEmitterSpace = false;
  6635. this._localDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6636. this._volume = 1;
  6637. this._isReadyToPlay = false;
  6638. this._isDirectional = false;
  6639. // Used if you'd like to create a directional sound.
  6640. // If not set, the sound will be omnidirectional
  6641. this._coneInnerAngle = 360;
  6642. this._coneOuterAngle = 360;
  6643. this._coneOuterGain = 0;
  6644. this._isOutputConnected = false;
  6645. this._urlType = "Unknown";
  6646. this.name = name;
  6647. this._scene = scene;
  6648. Sound._SceneComponentInitialization(scene);
  6649. this._readyToPlayCallback = readyToPlayCallback;
  6650. // Default custom attenuation function is a linear attenuation
  6651. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6652. if (currentDistance < maxDistance) {
  6653. return currentVolume * (1 - currentDistance / maxDistance);
  6654. }
  6655. else {
  6656. return 0;
  6657. }
  6658. };
  6659. if (options) {
  6660. this.autoplay = options.autoplay || false;
  6661. this.loop = options.loop || false;
  6662. // if volume === 0, we need another way to check this option
  6663. if (options.volume !== undefined) {
  6664. this._volume = options.volume;
  6665. }
  6666. this.spatialSound = options.spatialSound || false;
  6667. this.maxDistance = options.maxDistance || 100;
  6668. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6669. this.rolloffFactor = options.rolloffFactor || 1;
  6670. this.refDistance = options.refDistance || 1;
  6671. this.distanceModel = options.distanceModel || "linear";
  6672. this._playbackRate = options.playbackRate || 1;
  6673. this._streaming = options.streaming || false;
  6674. this._length = options.length;
  6675. this._offset = options.offset;
  6676. }
  6677. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6678. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6679. this._soundGain.gain.value = this._volume;
  6680. this._inputAudioNode = this._soundGain;
  6681. this._outputAudioNode = this._soundGain;
  6682. if (this.spatialSound) {
  6683. this._createSpatialParameters();
  6684. }
  6685. this._scene.mainSoundTrack.AddSound(this);
  6686. var validParameter = true;
  6687. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6688. if (urlOrArrayBuffer) {
  6689. try {
  6690. if (typeof (urlOrArrayBuffer) === "string") {
  6691. this._urlType = "String";
  6692. }
  6693. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6694. this._urlType = "ArrayBuffer";
  6695. }
  6696. else if (urlOrArrayBuffer instanceof MediaStream) {
  6697. this._urlType = "MediaStream";
  6698. }
  6699. else if (Array.isArray(urlOrArrayBuffer)) {
  6700. this._urlType = "Array";
  6701. }
  6702. var urls = [];
  6703. var codecSupportedFound = false;
  6704. switch (this._urlType) {
  6705. case "MediaStream":
  6706. this._streaming = true;
  6707. this._isReadyToPlay = true;
  6708. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);
  6709. if (this.autoplay) {
  6710. this.play(0, this._offset, this._length);
  6711. }
  6712. if (this._readyToPlayCallback) {
  6713. this._readyToPlayCallback();
  6714. }
  6715. break;
  6716. case "ArrayBuffer":
  6717. if (urlOrArrayBuffer.byteLength > 0) {
  6718. codecSupportedFound = true;
  6719. this._soundLoaded(urlOrArrayBuffer);
  6720. }
  6721. break;
  6722. case "String":
  6723. urls.push(urlOrArrayBuffer);
  6724. case "Array":
  6725. if (urls.length === 0) {
  6726. urls = urlOrArrayBuffer;
  6727. }
  6728. // If we found a supported format, we load it immediately and stop the loop
  6729. for (var i = 0; i < urls.length; i++) {
  6730. var url = urls[i];
  6731. codecSupportedFound = (options && options.skipCodecCheck) ||
  6732. (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) ||
  6733. (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) ||
  6734. (url.indexOf(".wav", url.length - 4) !== -1) ||
  6735. (url.indexOf("blob:") !== -1);
  6736. if (codecSupportedFound) {
  6737. // Loading sound using XHR2
  6738. if (!this._streaming) {
  6739. this._scene._loadFile(url, function (data) {
  6740. _this._soundLoaded(data);
  6741. }, undefined, true, true, function (exception) {
  6742. if (exception) {
  6743. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6744. }
  6745. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6746. _this._scene.mainSoundTrack.RemoveSound(_this);
  6747. });
  6748. }
  6749. // Streaming sound using HTML5 Audio tag
  6750. else {
  6751. this._htmlAudioElement = new Audio(url);
  6752. this._htmlAudioElement.controls = false;
  6753. this._htmlAudioElement.loop = this.loop;
  6754. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6755. this._htmlAudioElement.preload = "auto";
  6756. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6757. _this._isReadyToPlay = true;
  6758. if (_this.autoplay) {
  6759. _this.play(0, _this._offset, _this._length);
  6760. }
  6761. if (_this._readyToPlayCallback) {
  6762. _this._readyToPlayCallback();
  6763. }
  6764. });
  6765. document.body.appendChild(this._htmlAudioElement);
  6766. this._htmlAudioElement.load();
  6767. }
  6768. break;
  6769. }
  6770. }
  6771. break;
  6772. default:
  6773. validParameter = false;
  6774. break;
  6775. }
  6776. if (!validParameter) {
  6777. _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.");
  6778. }
  6779. else {
  6780. if (!codecSupportedFound) {
  6781. this._isReadyToPlay = true;
  6782. // Simulating a ready to play event to avoid breaking code path
  6783. if (this._readyToPlayCallback) {
  6784. window.setTimeout(function () {
  6785. if (_this._readyToPlayCallback) {
  6786. _this._readyToPlayCallback();
  6787. }
  6788. }, 1000);
  6789. }
  6790. }
  6791. }
  6792. }
  6793. catch (ex) {
  6794. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6795. this._scene.mainSoundTrack.RemoveSound(this);
  6796. }
  6797. }
  6798. }
  6799. else {
  6800. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6801. this._scene.mainSoundTrack.AddSound(this);
  6802. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6803. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6804. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6805. }
  6806. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6807. if (this._readyToPlayCallback) {
  6808. window.setTimeout(function () {
  6809. if (_this._readyToPlayCallback) {
  6810. _this._readyToPlayCallback();
  6811. }
  6812. }, 1000);
  6813. }
  6814. }
  6815. }
  6816. /**
  6817. * Release the sound and its associated resources
  6818. */
  6819. Sound.prototype.dispose = function () {
  6820. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6821. if (this.isPlaying) {
  6822. this.stop();
  6823. }
  6824. this._isReadyToPlay = false;
  6825. if (this.soundTrackId === -1) {
  6826. this._scene.mainSoundTrack.RemoveSound(this);
  6827. }
  6828. else if (this._scene.soundTracks) {
  6829. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6830. }
  6831. if (this._soundGain) {
  6832. this._soundGain.disconnect();
  6833. this._soundGain = null;
  6834. }
  6835. if (this._soundPanner) {
  6836. this._soundPanner.disconnect();
  6837. this._soundPanner = null;
  6838. }
  6839. if (this._soundSource) {
  6840. this._soundSource.disconnect();
  6841. this._soundSource = null;
  6842. }
  6843. this._audioBuffer = null;
  6844. if (this._htmlAudioElement) {
  6845. this._htmlAudioElement.pause();
  6846. this._htmlAudioElement.src = "";
  6847. document.body.removeChild(this._htmlAudioElement);
  6848. }
  6849. if (this._streamingSource) {
  6850. this._streamingSource.disconnect();
  6851. }
  6852. if (this._connectedTransformNode && this._registerFunc) {
  6853. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6854. this._connectedTransformNode = null;
  6855. }
  6856. }
  6857. };
  6858. /**
  6859. * Gets if the sounds is ready to be played or not.
  6860. * @returns true if ready, otherwise false
  6861. */
  6862. Sound.prototype.isReady = function () {
  6863. return this._isReadyToPlay;
  6864. };
  6865. Sound.prototype._soundLoaded = function (audioData) {
  6866. var _this = this;
  6867. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6868. return;
  6869. }
  6870. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6871. _this._audioBuffer = buffer;
  6872. _this._isReadyToPlay = true;
  6873. if (_this.autoplay) {
  6874. _this.play(0, _this._offset, _this._length);
  6875. }
  6876. if (_this._readyToPlayCallback) {
  6877. _this._readyToPlayCallback();
  6878. }
  6879. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6880. };
  6881. /**
  6882. * Sets the data of the sound from an audiobuffer
  6883. * @param audioBuffer The audioBuffer containing the data
  6884. */
  6885. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6886. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6887. this._audioBuffer = audioBuffer;
  6888. this._isReadyToPlay = true;
  6889. }
  6890. };
  6891. /**
  6892. * Updates the current sounds options such as maxdistance, loop...
  6893. * @param options A JSON object containing values named as the object properties
  6894. */
  6895. Sound.prototype.updateOptions = function (options) {
  6896. if (options) {
  6897. this.loop = options.loop || this.loop;
  6898. this.maxDistance = options.maxDistance || this.maxDistance;
  6899. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6900. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6901. this.refDistance = options.refDistance || this.refDistance;
  6902. this.distanceModel = options.distanceModel || this.distanceModel;
  6903. this._playbackRate = options.playbackRate || this._playbackRate;
  6904. this._length = options.length ? options.length / 1000 : undefined;
  6905. this._offset = options.offset ? options.offset / 1000 : undefined;
  6906. this._updateSpatialParameters();
  6907. if (this.isPlaying) {
  6908. if (this._streaming && this._htmlAudioElement) {
  6909. this._htmlAudioElement.playbackRate = this._playbackRate;
  6910. }
  6911. else {
  6912. if (this._soundSource) {
  6913. this._soundSource.playbackRate.value = this._playbackRate;
  6914. }
  6915. }
  6916. }
  6917. }
  6918. };
  6919. Sound.prototype._createSpatialParameters = function () {
  6920. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6921. if (this._scene.headphone) {
  6922. this._panningModel = "HRTF";
  6923. }
  6924. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6925. this._updateSpatialParameters();
  6926. this._soundPanner.connect(this._outputAudioNode);
  6927. this._inputAudioNode = this._soundPanner;
  6928. }
  6929. };
  6930. Sound.prototype._updateSpatialParameters = function () {
  6931. if (this.spatialSound && this._soundPanner) {
  6932. if (this.useCustomAttenuation) {
  6933. // Tricks to disable in a way embedded Web Audio attenuation
  6934. this._soundPanner.distanceModel = "linear";
  6935. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6936. this._soundPanner.refDistance = 1;
  6937. this._soundPanner.rolloffFactor = 1;
  6938. this._soundPanner.panningModel = this._panningModel;
  6939. }
  6940. else {
  6941. this._soundPanner.distanceModel = this.distanceModel;
  6942. this._soundPanner.maxDistance = this.maxDistance;
  6943. this._soundPanner.refDistance = this.refDistance;
  6944. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6945. this._soundPanner.panningModel = this._panningModel;
  6946. }
  6947. }
  6948. };
  6949. /**
  6950. * Switch the panning model to HRTF:
  6951. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6953. */
  6954. Sound.prototype.switchPanningModelToHRTF = function () {
  6955. this._panningModel = "HRTF";
  6956. this._switchPanningModel();
  6957. };
  6958. /**
  6959. * Switch the panning model to Equal Power:
  6960. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6962. */
  6963. Sound.prototype.switchPanningModelToEqualPower = function () {
  6964. this._panningModel = "equalpower";
  6965. this._switchPanningModel();
  6966. };
  6967. Sound.prototype._switchPanningModel = function () {
  6968. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6969. this._soundPanner.panningModel = this._panningModel;
  6970. }
  6971. };
  6972. /**
  6973. * Connect this sound to a sound track audio node like gain...
  6974. * @param soundTrackAudioNode the sound track audio node to connect to
  6975. */
  6976. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6977. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6978. if (this._isOutputConnected) {
  6979. this._outputAudioNode.disconnect();
  6980. }
  6981. this._outputAudioNode.connect(soundTrackAudioNode);
  6982. this._isOutputConnected = true;
  6983. }
  6984. };
  6985. /**
  6986. * Transform this sound into a directional source
  6987. * @param coneInnerAngle Size of the inner cone in degree
  6988. * @param coneOuterAngle Size of the outer cone in degree
  6989. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6990. */
  6991. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6992. if (coneOuterAngle < coneInnerAngle) {
  6993. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6994. return;
  6995. }
  6996. this._coneInnerAngle = coneInnerAngle;
  6997. this._coneOuterAngle = coneOuterAngle;
  6998. this._coneOuterGain = coneOuterGain;
  6999. this._isDirectional = true;
  7000. if (this.isPlaying && this.loop) {
  7001. this.stop();
  7002. this.play(0, this._offset, this._length);
  7003. }
  7004. };
  7005. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  7006. /**
  7007. * Gets or sets the inner angle for the directional cone.
  7008. */
  7009. get: function () {
  7010. return this._coneInnerAngle;
  7011. },
  7012. /**
  7013. * Gets or sets the inner angle for the directional cone.
  7014. */
  7015. set: function (value) {
  7016. if (value != this._coneInnerAngle) {
  7017. if (this._coneOuterAngle < value) {
  7018. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7019. return;
  7020. }
  7021. this._coneInnerAngle = value;
  7022. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  7023. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  7024. }
  7025. }
  7026. },
  7027. enumerable: true,
  7028. configurable: true
  7029. });
  7030. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  7031. /**
  7032. * Gets or sets the outer angle for the directional cone.
  7033. */
  7034. get: function () {
  7035. return this._coneOuterAngle;
  7036. },
  7037. /**
  7038. * Gets or sets the outer angle for the directional cone.
  7039. */
  7040. set: function (value) {
  7041. if (value != this._coneOuterAngle) {
  7042. if (value < this._coneInnerAngle) {
  7043. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7044. return;
  7045. }
  7046. this._coneOuterAngle = value;
  7047. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  7048. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  7049. }
  7050. }
  7051. },
  7052. enumerable: true,
  7053. configurable: true
  7054. });
  7055. /**
  7056. * Sets the position of the emitter if spatial sound is enabled
  7057. * @param newPosition Defines the new posisiton
  7058. */
  7059. Sound.prototype.setPosition = function (newPosition) {
  7060. this._position = newPosition;
  7061. 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)) {
  7062. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7063. }
  7064. };
  7065. /**
  7066. * Sets the local direction of the emitter if spatial sound is enabled
  7067. * @param newLocalDirection Defines the new local direction
  7068. */
  7069. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  7070. this._localDirection = newLocalDirection;
  7071. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  7072. this._updateDirection();
  7073. }
  7074. };
  7075. Sound.prototype._updateDirection = function () {
  7076. if (!this._connectedTransformNode || !this._soundPanner) {
  7077. return;
  7078. }
  7079. var mat = this._connectedTransformNode.getWorldMatrix();
  7080. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  7081. direction.normalize();
  7082. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  7083. };
  7084. /** @hidden */
  7085. Sound.prototype.updateDistanceFromListener = function () {
  7086. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  7087. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  7088. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  7089. }
  7090. };
  7091. /**
  7092. * Sets a new custom attenuation function for the sound.
  7093. * @param callback Defines the function used for the attenuation
  7094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  7095. */
  7096. Sound.prototype.setAttenuationFunction = function (callback) {
  7097. this._customAttenuationFunction = callback;
  7098. };
  7099. /**
  7100. * Play the sound
  7101. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  7102. * @param offset (optional) Start the sound at a specific time in seconds
  7103. * @param length (optional) Sound duration (in seconds)
  7104. */
  7105. Sound.prototype.play = function (time, offset, length) {
  7106. var _this = this;
  7107. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7108. try {
  7109. if (this._startOffset < 0) {
  7110. time = -this._startOffset;
  7111. this._startOffset = 0;
  7112. }
  7113. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7114. if (!this._soundSource || !this._streamingSource) {
  7115. if (this.spatialSound && this._soundPanner) {
  7116. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  7117. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7118. }
  7119. if (this._isDirectional) {
  7120. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  7121. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  7122. this._soundPanner.coneOuterGain = this._coneOuterGain;
  7123. if (this._connectedTransformNode) {
  7124. this._updateDirection();
  7125. }
  7126. else {
  7127. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  7128. }
  7129. }
  7130. }
  7131. }
  7132. if (this._streaming) {
  7133. if (!this._streamingSource) {
  7134. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7135. this._htmlAudioElement.onended = function () { _this._onended(); };
  7136. this._htmlAudioElement.playbackRate = this._playbackRate;
  7137. }
  7138. this._streamingSource.disconnect();
  7139. this._streamingSource.connect(this._inputAudioNode);
  7140. if (this._htmlAudioElement) {
  7141. // required to manage properly the new suspended default state of Chrome
  7142. // When the option 'streaming: true' is used, we need first to wait for
  7143. // the audio engine to be unlocked by a user gesture before trying to play
  7144. // an HTML Audio elememt
  7145. var tryToPlay = function () {
  7146. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7147. var playPromise = _this._htmlAudioElement.play();
  7148. // In browsers that don’t yet support this functionality,
  7149. // playPromise won’t be defined.
  7150. if (playPromise !== undefined) {
  7151. playPromise.catch(function (error) {
  7152. // Automatic playback failed.
  7153. // Waiting for the audio engine to be unlocked by user click on unmute
  7154. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7155. if (_this.loop || _this.autoplay) {
  7156. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7157. }
  7158. });
  7159. }
  7160. }
  7161. else {
  7162. if (_this.loop || _this.autoplay) {
  7163. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7164. }
  7165. }
  7166. };
  7167. tryToPlay();
  7168. }
  7169. }
  7170. else {
  7171. var tryToPlay = function () {
  7172. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7173. length = length || _this._length;
  7174. offset = offset || _this._offset;
  7175. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7176. _this._soundSource.buffer = _this._audioBuffer;
  7177. _this._soundSource.connect(_this._inputAudioNode);
  7178. _this._soundSource.loop = _this.loop;
  7179. if (offset !== undefined) {
  7180. _this._soundSource.loopStart = offset;
  7181. }
  7182. if (length !== undefined) {
  7183. _this._soundSource.loopEnd = (offset | 0) + length;
  7184. }
  7185. _this._soundSource.playbackRate.value = _this._playbackRate;
  7186. _this._soundSource.onended = function () { _this._onended(); };
  7187. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7188. var actualOffset = _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0;
  7189. _this._soundSource.start(startTime, actualOffset, _this.loop ? undefined : length);
  7190. }
  7191. };
  7192. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7193. // Wait a bit for FF as context seems late to be ready.
  7194. setTimeout(function () {
  7195. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7196. // Automatic playback failed.
  7197. // Waiting for the audio engine to be unlocked by user click on unmute
  7198. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7199. if (_this.loop || _this.autoplay) {
  7200. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7201. }
  7202. }
  7203. else {
  7204. tryToPlay();
  7205. }
  7206. }, 500);
  7207. }
  7208. else {
  7209. tryToPlay();
  7210. }
  7211. }
  7212. this._startTime = startTime;
  7213. this.isPlaying = true;
  7214. this.isPaused = false;
  7215. }
  7216. catch (ex) {
  7217. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7218. }
  7219. }
  7220. };
  7221. Sound.prototype._onended = function () {
  7222. this.isPlaying = false;
  7223. if (this.onended) {
  7224. this.onended();
  7225. }
  7226. this.onEndedObservable.notifyObservers(this);
  7227. };
  7228. /**
  7229. * Stop the sound
  7230. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7231. */
  7232. Sound.prototype.stop = function (time) {
  7233. var _this = this;
  7234. if (this.isPlaying) {
  7235. if (this._streaming) {
  7236. if (this._htmlAudioElement) {
  7237. this._htmlAudioElement.pause();
  7238. // Test needed for Firefox or it will generate an Invalid State Error
  7239. if (this._htmlAudioElement.currentTime > 0) {
  7240. this._htmlAudioElement.currentTime = 0;
  7241. }
  7242. }
  7243. else {
  7244. this._streamingSource.disconnect();
  7245. }
  7246. this.isPlaying = false;
  7247. }
  7248. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7249. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7250. this._soundSource.stop(stopTime);
  7251. this._soundSource.onended = function () { _this.isPlaying = false; };
  7252. if (!this.isPaused) {
  7253. this._startOffset = 0;
  7254. }
  7255. }
  7256. }
  7257. };
  7258. /**
  7259. * Put the sound in pause
  7260. */
  7261. Sound.prototype.pause = function () {
  7262. if (this.isPlaying) {
  7263. this.isPaused = true;
  7264. if (this._streaming) {
  7265. if (this._htmlAudioElement) {
  7266. this._htmlAudioElement.pause();
  7267. }
  7268. else {
  7269. this._streamingSource.disconnect();
  7270. }
  7271. }
  7272. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7273. this.stop(0);
  7274. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7275. }
  7276. }
  7277. };
  7278. /**
  7279. * Sets a dedicated volume for this sounds
  7280. * @param newVolume Define the new volume of the sound
  7281. * @param time Define time for gradual change to new volume
  7282. */
  7283. Sound.prototype.setVolume = function (newVolume, time) {
  7284. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7285. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7286. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7287. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7288. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7289. }
  7290. else {
  7291. this._soundGain.gain.value = newVolume;
  7292. }
  7293. }
  7294. this._volume = newVolume;
  7295. };
  7296. /**
  7297. * Set the sound play back rate
  7298. * @param newPlaybackRate Define the playback rate the sound should be played at
  7299. */
  7300. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7301. this._playbackRate = newPlaybackRate;
  7302. if (this.isPlaying) {
  7303. if (this._streaming && this._htmlAudioElement) {
  7304. this._htmlAudioElement.playbackRate = this._playbackRate;
  7305. }
  7306. else if (this._soundSource) {
  7307. this._soundSource.playbackRate.value = this._playbackRate;
  7308. }
  7309. }
  7310. };
  7311. /**
  7312. * Gets the volume of the sound.
  7313. * @returns the volume of the sound
  7314. */
  7315. Sound.prototype.getVolume = function () {
  7316. return this._volume;
  7317. };
  7318. /**
  7319. * Attach the sound to a dedicated mesh
  7320. * @param transformNode The transform node to connect the sound with
  7321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7322. */
  7323. Sound.prototype.attachToMesh = function (transformNode) {
  7324. var _this = this;
  7325. if (this._connectedTransformNode && this._registerFunc) {
  7326. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7327. this._registerFunc = null;
  7328. }
  7329. this._connectedTransformNode = transformNode;
  7330. if (!this.spatialSound) {
  7331. this.spatialSound = true;
  7332. this._createSpatialParameters();
  7333. if (this.isPlaying && this.loop) {
  7334. this.stop();
  7335. this.play(0, this._offset, this._length);
  7336. }
  7337. }
  7338. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7339. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7340. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7341. };
  7342. /**
  7343. * Detach the sound from the previously attached mesh
  7344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7345. */
  7346. Sound.prototype.detachFromMesh = function () {
  7347. if (this._connectedTransformNode && this._registerFunc) {
  7348. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7349. this._registerFunc = null;
  7350. this._connectedTransformNode = null;
  7351. }
  7352. };
  7353. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7354. if (!node.getBoundingInfo) {
  7355. return;
  7356. }
  7357. var mesh = node;
  7358. if (this._positionInEmitterSpace) {
  7359. mesh.worldMatrixFromCache.invertToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Matrix[0]);
  7360. this.setPosition(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Matrix[0].getTranslation());
  7361. }
  7362. else {
  7363. var boundingInfo = mesh.getBoundingInfo();
  7364. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7365. }
  7366. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7367. this._updateDirection();
  7368. }
  7369. };
  7370. /**
  7371. * Clone the current sound in the scene.
  7372. * @returns the new sound clone
  7373. */
  7374. Sound.prototype.clone = function () {
  7375. var _this = this;
  7376. if (!this._streaming) {
  7377. var setBufferAndRun = function () {
  7378. if (_this._isReadyToPlay) {
  7379. clonedSound._audioBuffer = _this.getAudioBuffer();
  7380. clonedSound._isReadyToPlay = true;
  7381. if (clonedSound.autoplay) {
  7382. clonedSound.play(0, _this._offset, _this._length);
  7383. }
  7384. }
  7385. else {
  7386. window.setTimeout(setBufferAndRun, 300);
  7387. }
  7388. };
  7389. var currentOptions = {
  7390. autoplay: this.autoplay, loop: this.loop,
  7391. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7392. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7393. refDistance: this.refDistance, distanceModel: this.distanceModel
  7394. };
  7395. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7396. if (this.useCustomAttenuation) {
  7397. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7398. }
  7399. clonedSound.setPosition(this._position);
  7400. clonedSound.setPlaybackRate(this._playbackRate);
  7401. setBufferAndRun();
  7402. return clonedSound;
  7403. }
  7404. // Can't clone a streaming sound
  7405. else {
  7406. return null;
  7407. }
  7408. };
  7409. /**
  7410. * Gets the current underlying audio buffer containing the data
  7411. * @returns the audio buffer
  7412. */
  7413. Sound.prototype.getAudioBuffer = function () {
  7414. return this._audioBuffer;
  7415. };
  7416. /**
  7417. * Serializes the Sound in a JSON representation
  7418. * @returns the JSON representation of the sound
  7419. */
  7420. Sound.prototype.serialize = function () {
  7421. var serializationObject = {
  7422. name: this.name,
  7423. url: this.name,
  7424. autoplay: this.autoplay,
  7425. loop: this.loop,
  7426. volume: this._volume,
  7427. spatialSound: this.spatialSound,
  7428. maxDistance: this.maxDistance,
  7429. rolloffFactor: this.rolloffFactor,
  7430. refDistance: this.refDistance,
  7431. distanceModel: this.distanceModel,
  7432. playbackRate: this._playbackRate,
  7433. panningModel: this._panningModel,
  7434. soundTrackId: this.soundTrackId
  7435. };
  7436. if (this.spatialSound) {
  7437. if (this._connectedTransformNode) {
  7438. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7439. }
  7440. serializationObject.position = this._position.asArray();
  7441. serializationObject.refDistance = this.refDistance;
  7442. serializationObject.distanceModel = this.distanceModel;
  7443. serializationObject.isDirectional = this._isDirectional;
  7444. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7445. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7446. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7447. serializationObject.coneOuterGain = this._coneOuterGain;
  7448. }
  7449. return serializationObject;
  7450. };
  7451. /**
  7452. * Parse a JSON representation of a sound to innstantiate in a given scene
  7453. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7454. * @param scene Define the scene the new parsed sound should be created in
  7455. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7456. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7457. * @returns the newly parsed sound
  7458. */
  7459. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7460. var soundName = parsedSound.name;
  7461. var soundUrl;
  7462. if (parsedSound.url) {
  7463. soundUrl = rootUrl + parsedSound.url;
  7464. }
  7465. else {
  7466. soundUrl = rootUrl + soundName;
  7467. }
  7468. var options = {
  7469. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7470. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7471. rolloffFactor: parsedSound.rolloffFactor,
  7472. refDistance: parsedSound.refDistance,
  7473. distanceModel: parsedSound.distanceModel,
  7474. playbackRate: parsedSound.playbackRate
  7475. };
  7476. var newSound;
  7477. if (!sourceSound) {
  7478. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7479. scene._addPendingData(newSound);
  7480. }
  7481. else {
  7482. var setBufferAndRun = function () {
  7483. if (sourceSound._isReadyToPlay) {
  7484. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7485. newSound._isReadyToPlay = true;
  7486. if (newSound.autoplay) {
  7487. newSound.play(0, newSound._offset, newSound._length);
  7488. }
  7489. }
  7490. else {
  7491. window.setTimeout(setBufferAndRun, 300);
  7492. }
  7493. };
  7494. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7495. setBufferAndRun();
  7496. }
  7497. if (parsedSound.position) {
  7498. var soundPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7499. newSound.setPosition(soundPosition);
  7500. }
  7501. if (parsedSound.isDirectional) {
  7502. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7503. if (parsedSound.localDirectionToMesh) {
  7504. var localDirectionToMesh = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7505. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7506. }
  7507. }
  7508. if (parsedSound.connectedMeshId) {
  7509. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7510. if (connectedMesh) {
  7511. newSound.attachToMesh(connectedMesh);
  7512. }
  7513. }
  7514. return newSound;
  7515. };
  7516. /** @hidden */
  7517. Sound._SceneComponentInitialization = function (_) {
  7518. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7519. };
  7520. return Sound;
  7521. }());
  7522. /***/ }),
  7523. /***/ "./Audio/soundTrack.ts":
  7524. /*!*****************************!*\
  7525. !*** ./Audio/soundTrack.ts ***!
  7526. \*****************************/
  7527. /*! exports provided: SoundTrack */
  7528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7529. "use strict";
  7530. __webpack_require__.r(__webpack_exports__);
  7531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7532. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7533. /**
  7534. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7535. * It will be also used in a future release to apply effects on a specific track.
  7536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7537. */
  7538. var SoundTrack = /** @class */ (function () {
  7539. /**
  7540. * Creates a new sound track.
  7541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7542. * @param scene Define the scene the sound track belongs to
  7543. * @param options
  7544. */
  7545. function SoundTrack(scene, options) {
  7546. if (options === void 0) { options = {}; }
  7547. /**
  7548. * The unique identifier of the sound track in the scene.
  7549. */
  7550. this.id = -1;
  7551. this._isMainTrack = false;
  7552. this._isInitialized = false;
  7553. this._scene = scene;
  7554. this.soundCollection = new Array();
  7555. this._options = options;
  7556. if (!this._isMainTrack && this._scene.soundTracks) {
  7557. this._scene.soundTracks.push(this);
  7558. this.id = this._scene.soundTracks.length - 1;
  7559. }
  7560. }
  7561. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7562. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7563. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7564. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7565. if (this._options) {
  7566. if (this._options.volume) {
  7567. this._outputAudioNode.gain.value = this._options.volume;
  7568. }
  7569. if (this._options.mainTrack) {
  7570. this._isMainTrack = this._options.mainTrack;
  7571. }
  7572. }
  7573. this._isInitialized = true;
  7574. }
  7575. };
  7576. /**
  7577. * Release the sound track and its associated resources
  7578. */
  7579. SoundTrack.prototype.dispose = function () {
  7580. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7581. if (this._connectedAnalyser) {
  7582. this._connectedAnalyser.stopDebugCanvas();
  7583. }
  7584. while (this.soundCollection.length) {
  7585. this.soundCollection[0].dispose();
  7586. }
  7587. if (this._outputAudioNode) {
  7588. this._outputAudioNode.disconnect();
  7589. }
  7590. this._outputAudioNode = null;
  7591. }
  7592. };
  7593. /**
  7594. * Adds a sound to this sound track
  7595. * @param sound define the cound to add
  7596. * @ignoreNaming
  7597. */
  7598. SoundTrack.prototype.AddSound = function (sound) {
  7599. if (!this._isInitialized) {
  7600. this._initializeSoundTrackAudioGraph();
  7601. }
  7602. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7603. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7604. }
  7605. if (sound.soundTrackId) {
  7606. if (sound.soundTrackId === -1) {
  7607. this._scene.mainSoundTrack.RemoveSound(sound);
  7608. }
  7609. else if (this._scene.soundTracks) {
  7610. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7611. }
  7612. }
  7613. this.soundCollection.push(sound);
  7614. sound.soundTrackId = this.id;
  7615. };
  7616. /**
  7617. * Removes a sound to this sound track
  7618. * @param sound define the cound to remove
  7619. * @ignoreNaming
  7620. */
  7621. SoundTrack.prototype.RemoveSound = function (sound) {
  7622. var index = this.soundCollection.indexOf(sound);
  7623. if (index !== -1) {
  7624. this.soundCollection.splice(index, 1);
  7625. }
  7626. };
  7627. /**
  7628. * Set a global volume for the full sound track.
  7629. * @param newVolume Define the new volume of the sound track
  7630. */
  7631. SoundTrack.prototype.setVolume = function (newVolume) {
  7632. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7633. this._outputAudioNode.gain.value = newVolume;
  7634. }
  7635. };
  7636. /**
  7637. * Switch the panning model to HRTF:
  7638. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7640. */
  7641. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7642. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7643. for (var i = 0; i < this.soundCollection.length; i++) {
  7644. this.soundCollection[i].switchPanningModelToHRTF();
  7645. }
  7646. }
  7647. };
  7648. /**
  7649. * Switch the panning model to Equal Power:
  7650. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7652. */
  7653. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7654. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7655. for (var i = 0; i < this.soundCollection.length; i++) {
  7656. this.soundCollection[i].switchPanningModelToEqualPower();
  7657. }
  7658. }
  7659. };
  7660. /**
  7661. * Connect the sound track to an audio analyser allowing some amazing
  7662. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7664. * @param analyser The analyser to connect to the engine
  7665. */
  7666. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7667. if (this._connectedAnalyser) {
  7668. this._connectedAnalyser.stopDebugCanvas();
  7669. }
  7670. this._connectedAnalyser = analyser;
  7671. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7672. this._outputAudioNode.disconnect();
  7673. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7674. }
  7675. };
  7676. return SoundTrack;
  7677. }());
  7678. /***/ }),
  7679. /***/ "./Audio/weightedsound.ts":
  7680. /*!********************************!*\
  7681. !*** ./Audio/weightedsound.ts ***!
  7682. \********************************/
  7683. /*! exports provided: WeightedSound */
  7684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7685. "use strict";
  7686. __webpack_require__.r(__webpack_exports__);
  7687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7688. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7689. /**
  7690. * Wraps one or more Sound objects and selects one with random weight for playback.
  7691. */
  7692. var WeightedSound = /** @class */ (function () {
  7693. /**
  7694. * Creates a new WeightedSound from the list of sounds given.
  7695. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7696. * @param sounds Array of Sounds that will be selected from.
  7697. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7698. */
  7699. function WeightedSound(loop, sounds, weights) {
  7700. var _this = this;
  7701. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7702. this.loop = false;
  7703. this._coneInnerAngle = 360;
  7704. this._coneOuterAngle = 360;
  7705. this._volume = 1;
  7706. /** A Sound is currently playing. */
  7707. this.isPlaying = false;
  7708. /** A Sound is currently paused. */
  7709. this.isPaused = false;
  7710. this._sounds = [];
  7711. this._weights = [];
  7712. if (sounds.length !== weights.length) {
  7713. throw new Error('Sounds length does not equal weights length');
  7714. }
  7715. this.loop = loop;
  7716. this._weights = weights;
  7717. // Normalize the weights
  7718. var weightSum = 0;
  7719. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7720. var weight = weights_1[_i];
  7721. weightSum += weight;
  7722. }
  7723. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7724. for (var i = 0; i < this._weights.length; i++) {
  7725. this._weights[i] *= invWeightSum;
  7726. }
  7727. this._sounds = sounds;
  7728. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7729. var sound = _b[_a];
  7730. sound.onEndedObservable.add(function () { _this._onended(); });
  7731. }
  7732. }
  7733. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7734. /**
  7735. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7736. */
  7737. get: function () {
  7738. return this._coneInnerAngle;
  7739. },
  7740. /**
  7741. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7742. */
  7743. set: function (value) {
  7744. if (value !== this._coneInnerAngle) {
  7745. if (this._coneOuterAngle < value) {
  7746. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7747. return;
  7748. }
  7749. this._coneInnerAngle = value;
  7750. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7751. var sound = _a[_i];
  7752. sound.directionalConeInnerAngle = value;
  7753. }
  7754. }
  7755. },
  7756. enumerable: true,
  7757. configurable: true
  7758. });
  7759. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7760. /**
  7761. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7762. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7763. */
  7764. get: function () {
  7765. return this._coneOuterAngle;
  7766. },
  7767. /**
  7768. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7769. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7770. */
  7771. set: function (value) {
  7772. if (value !== this._coneOuterAngle) {
  7773. if (value < this._coneInnerAngle) {
  7774. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7775. return;
  7776. }
  7777. this._coneOuterAngle = value;
  7778. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7779. var sound = _a[_i];
  7780. sound.directionalConeOuterAngle = value;
  7781. }
  7782. }
  7783. },
  7784. enumerable: true,
  7785. configurable: true
  7786. });
  7787. Object.defineProperty(WeightedSound.prototype, "volume", {
  7788. /**
  7789. * Playback volume.
  7790. */
  7791. get: function () {
  7792. return this._volume;
  7793. },
  7794. /**
  7795. * Playback volume.
  7796. */
  7797. set: function (value) {
  7798. if (value !== this._volume) {
  7799. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7800. var sound = _a[_i];
  7801. sound.setVolume(value);
  7802. }
  7803. }
  7804. },
  7805. enumerable: true,
  7806. configurable: true
  7807. });
  7808. WeightedSound.prototype._onended = function () {
  7809. if (this._currentIndex !== undefined) {
  7810. this._sounds[this._currentIndex].autoplay = false;
  7811. }
  7812. if (this.loop && this.isPlaying) {
  7813. this.play();
  7814. }
  7815. else {
  7816. this.isPlaying = false;
  7817. }
  7818. };
  7819. /**
  7820. * Suspend playback
  7821. */
  7822. WeightedSound.prototype.pause = function () {
  7823. this.isPaused = true;
  7824. if (this._currentIndex !== undefined) {
  7825. this._sounds[this._currentIndex].pause();
  7826. }
  7827. };
  7828. /**
  7829. * Stop playback
  7830. */
  7831. WeightedSound.prototype.stop = function () {
  7832. this.isPlaying = false;
  7833. if (this._currentIndex !== undefined) {
  7834. this._sounds[this._currentIndex].stop();
  7835. }
  7836. };
  7837. /**
  7838. * Start playback.
  7839. * @param startOffset Position the clip head at a specific time in seconds.
  7840. */
  7841. WeightedSound.prototype.play = function (startOffset) {
  7842. if (!this.isPaused) {
  7843. this.stop();
  7844. var randomValue = Math.random();
  7845. var total = 0;
  7846. for (var i = 0; i < this._weights.length; i++) {
  7847. total += this._weights[i];
  7848. if (randomValue <= total) {
  7849. this._currentIndex = i;
  7850. break;
  7851. }
  7852. }
  7853. }
  7854. var sound = this._sounds[this._currentIndex];
  7855. if (sound.isReady()) {
  7856. sound.play(0, this.isPaused ? undefined : startOffset);
  7857. }
  7858. else {
  7859. sound.autoplay = true;
  7860. }
  7861. this.isPlaying = true;
  7862. this.isPaused = false;
  7863. };
  7864. return WeightedSound;
  7865. }());
  7866. /***/ }),
  7867. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7868. /*!***************************************************!*\
  7869. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7870. \***************************************************/
  7871. /*! exports provided: AutoRotationBehavior */
  7872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7873. "use strict";
  7874. __webpack_require__.r(__webpack_exports__);
  7875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7876. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7877. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7878. /**
  7879. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7881. */
  7882. var AutoRotationBehavior = /** @class */ (function () {
  7883. function AutoRotationBehavior() {
  7884. this._zoomStopsAnimation = false;
  7885. this._idleRotationSpeed = 0.05;
  7886. this._idleRotationWaitTime = 2000;
  7887. this._idleRotationSpinupTime = 2000;
  7888. this._isPointerDown = false;
  7889. this._lastFrameTime = null;
  7890. this._lastInteractionTime = -Infinity;
  7891. this._cameraRotationSpeed = 0;
  7892. this._lastFrameRadius = 0;
  7893. }
  7894. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7895. /**
  7896. * Gets the name of the behavior.
  7897. */
  7898. get: function () {
  7899. return "AutoRotation";
  7900. },
  7901. enumerable: true,
  7902. configurable: true
  7903. });
  7904. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7905. /**
  7906. * Gets the flag that indicates if user zooming should stop animation.
  7907. */
  7908. get: function () {
  7909. return this._zoomStopsAnimation;
  7910. },
  7911. /**
  7912. * Sets the flag that indicates if user zooming should stop animation.
  7913. */
  7914. set: function (flag) {
  7915. this._zoomStopsAnimation = flag;
  7916. },
  7917. enumerable: true,
  7918. configurable: true
  7919. });
  7920. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7921. /**
  7922. * Gets the default speed at which the camera rotates around the model.
  7923. */
  7924. get: function () {
  7925. return this._idleRotationSpeed;
  7926. },
  7927. /**
  7928. * Sets the default speed at which the camera rotates around the model.
  7929. */
  7930. set: function (speed) {
  7931. this._idleRotationSpeed = speed;
  7932. },
  7933. enumerable: true,
  7934. configurable: true
  7935. });
  7936. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7937. /**
  7938. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7939. */
  7940. get: function () {
  7941. return this._idleRotationWaitTime;
  7942. },
  7943. /**
  7944. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7945. */
  7946. set: function (time) {
  7947. this._idleRotationWaitTime = time;
  7948. },
  7949. enumerable: true,
  7950. configurable: true
  7951. });
  7952. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7953. /**
  7954. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7955. */
  7956. get: function () {
  7957. return this._idleRotationSpinupTime;
  7958. },
  7959. /**
  7960. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7961. */
  7962. set: function (time) {
  7963. this._idleRotationSpinupTime = time;
  7964. },
  7965. enumerable: true,
  7966. configurable: true
  7967. });
  7968. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7969. /**
  7970. * Gets a value indicating if the camera is currently rotating because of this behavior
  7971. */
  7972. get: function () {
  7973. return Math.abs(this._cameraRotationSpeed) > 0;
  7974. },
  7975. enumerable: true,
  7976. configurable: true
  7977. });
  7978. /**
  7979. * Initializes the behavior.
  7980. */
  7981. AutoRotationBehavior.prototype.init = function () {
  7982. // Do notihng
  7983. };
  7984. /**
  7985. * Attaches the behavior to its arc rotate camera.
  7986. * @param camera Defines the camera to attach the behavior to
  7987. */
  7988. AutoRotationBehavior.prototype.attach = function (camera) {
  7989. var _this = this;
  7990. this._attachedCamera = camera;
  7991. var scene = this._attachedCamera.getScene();
  7992. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7993. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7994. _this._isPointerDown = true;
  7995. return;
  7996. }
  7997. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7998. _this._isPointerDown = false;
  7999. }
  8000. });
  8001. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8002. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  8003. var dt = 0;
  8004. if (_this._lastFrameTime != null) {
  8005. dt = now - _this._lastFrameTime;
  8006. }
  8007. _this._lastFrameTime = now;
  8008. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8009. _this._applyUserInteraction();
  8010. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  8011. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  8012. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  8013. // Step camera rotation by rotation speed
  8014. if (_this._attachedCamera) {
  8015. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  8016. }
  8017. });
  8018. };
  8019. /**
  8020. * Detaches the behavior from its current arc rotate camera.
  8021. */
  8022. AutoRotationBehavior.prototype.detach = function () {
  8023. if (!this._attachedCamera) {
  8024. return;
  8025. }
  8026. var scene = this._attachedCamera.getScene();
  8027. if (this._onPrePointerObservableObserver) {
  8028. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8029. }
  8030. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8031. this._attachedCamera = null;
  8032. };
  8033. /**
  8034. * Returns true if user is scrolling.
  8035. * @return true if user is scrolling.
  8036. */
  8037. AutoRotationBehavior.prototype._userIsZooming = function () {
  8038. if (!this._attachedCamera) {
  8039. return false;
  8040. }
  8041. return this._attachedCamera.inertialRadiusOffset !== 0;
  8042. };
  8043. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  8044. if (!this._attachedCamera) {
  8045. return false;
  8046. }
  8047. var zoomHasHitLimit = false;
  8048. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  8049. zoomHasHitLimit = true;
  8050. }
  8051. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  8052. this._lastFrameRadius = this._attachedCamera.radius;
  8053. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  8054. };
  8055. /**
  8056. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8057. */
  8058. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  8059. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  8060. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  8061. }
  8062. };
  8063. // Tools
  8064. AutoRotationBehavior.prototype._userIsMoving = function () {
  8065. if (!this._attachedCamera) {
  8066. return false;
  8067. }
  8068. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8069. this._attachedCamera.inertialBetaOffset !== 0 ||
  8070. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8071. this._attachedCamera.inertialPanningX !== 0 ||
  8072. this._attachedCamera.inertialPanningY !== 0 ||
  8073. this._isPointerDown;
  8074. };
  8075. return AutoRotationBehavior;
  8076. }());
  8077. /***/ }),
  8078. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  8079. /*!***********************************************!*\
  8080. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  8081. \***********************************************/
  8082. /*! exports provided: BouncingBehavior */
  8083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8084. "use strict";
  8085. __webpack_require__.r(__webpack_exports__);
  8086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  8087. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8088. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8089. /**
  8090. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  8091. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8092. */
  8093. var BouncingBehavior = /** @class */ (function () {
  8094. function BouncingBehavior() {
  8095. /**
  8096. * The duration of the animation, in milliseconds
  8097. */
  8098. this.transitionDuration = 450;
  8099. /**
  8100. * Length of the distance animated by the transition when lower radius is reached
  8101. */
  8102. this.lowerRadiusTransitionRange = 2;
  8103. /**
  8104. * Length of the distance animated by the transition when upper radius is reached
  8105. */
  8106. this.upperRadiusTransitionRange = -2;
  8107. this._autoTransitionRange = false;
  8108. // Animations
  8109. this._radiusIsAnimating = false;
  8110. this._radiusBounceTransition = null;
  8111. this._animatables = new Array();
  8112. }
  8113. Object.defineProperty(BouncingBehavior.prototype, "name", {
  8114. /**
  8115. * Gets the name of the behavior.
  8116. */
  8117. get: function () {
  8118. return "Bouncing";
  8119. },
  8120. enumerable: true,
  8121. configurable: true
  8122. });
  8123. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  8124. /**
  8125. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8126. */
  8127. get: function () {
  8128. return this._autoTransitionRange;
  8129. },
  8130. /**
  8131. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8132. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  8133. */
  8134. set: function (value) {
  8135. var _this = this;
  8136. if (this._autoTransitionRange === value) {
  8137. return;
  8138. }
  8139. this._autoTransitionRange = value;
  8140. var camera = this._attachedCamera;
  8141. if (!camera) {
  8142. return;
  8143. }
  8144. if (value) {
  8145. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8146. if (!mesh) {
  8147. return;
  8148. }
  8149. mesh.computeWorldMatrix(true);
  8150. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8151. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8152. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8153. });
  8154. }
  8155. else if (this._onMeshTargetChangedObserver) {
  8156. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8157. }
  8158. },
  8159. enumerable: true,
  8160. configurable: true
  8161. });
  8162. /**
  8163. * Initializes the behavior.
  8164. */
  8165. BouncingBehavior.prototype.init = function () {
  8166. // Do notihng
  8167. };
  8168. /**
  8169. * Attaches the behavior to its arc rotate camera.
  8170. * @param camera Defines the camera to attach the behavior to
  8171. */
  8172. BouncingBehavior.prototype.attach = function (camera) {
  8173. var _this = this;
  8174. this._attachedCamera = camera;
  8175. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8176. if (!_this._attachedCamera) {
  8177. return;
  8178. }
  8179. // Add the bounce animation to the lower radius limit
  8180. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8181. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8182. }
  8183. // Add the bounce animation to the upper radius limit
  8184. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8185. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8186. }
  8187. });
  8188. };
  8189. /**
  8190. * Detaches the behavior from its current arc rotate camera.
  8191. */
  8192. BouncingBehavior.prototype.detach = function () {
  8193. if (!this._attachedCamera) {
  8194. return;
  8195. }
  8196. if (this._onAfterCheckInputsObserver) {
  8197. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8198. }
  8199. if (this._onMeshTargetChangedObserver) {
  8200. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8201. }
  8202. this._attachedCamera = null;
  8203. };
  8204. /**
  8205. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8206. * @param radiusLimit The limit to check against.
  8207. * @return Bool to indicate if at limit.
  8208. */
  8209. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8210. if (!this._attachedCamera) {
  8211. return false;
  8212. }
  8213. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8214. return true;
  8215. }
  8216. return false;
  8217. };
  8218. /**
  8219. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8220. * @param radiusDelta The delta by which to animate to. Can be negative.
  8221. */
  8222. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8223. var _this = this;
  8224. if (!this._attachedCamera) {
  8225. return;
  8226. }
  8227. if (!this._radiusBounceTransition) {
  8228. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8229. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8230. }
  8231. // Prevent zoom until bounce has completed
  8232. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8233. this._attachedCamera.wheelPrecision = Infinity;
  8234. this._attachedCamera.inertialRadiusOffset = 0;
  8235. // Animate to the radius limit
  8236. this.stopAllAnimations();
  8237. this._radiusIsAnimating = true;
  8238. 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(); });
  8239. if (animatable) {
  8240. this._animatables.push(animatable);
  8241. }
  8242. };
  8243. /**
  8244. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8245. */
  8246. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8247. this._radiusIsAnimating = false;
  8248. if (this._attachedCamera) {
  8249. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8250. }
  8251. };
  8252. /**
  8253. * Stops and removes all animations that have been applied to the camera
  8254. */
  8255. BouncingBehavior.prototype.stopAllAnimations = function () {
  8256. if (this._attachedCamera) {
  8257. this._attachedCamera.animations = [];
  8258. }
  8259. while (this._animatables.length) {
  8260. this._animatables[0].onAnimationEnd = null;
  8261. this._animatables[0].stop();
  8262. this._animatables.shift();
  8263. }
  8264. };
  8265. /**
  8266. * The easing function used by animations
  8267. */
  8268. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8269. /**
  8270. * The easing mode used by animations
  8271. */
  8272. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8273. return BouncingBehavior;
  8274. }());
  8275. /***/ }),
  8276. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8277. /*!**********************************************!*\
  8278. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8279. \**********************************************/
  8280. /*! exports provided: FramingBehavior */
  8281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8282. "use strict";
  8283. __webpack_require__.r(__webpack_exports__);
  8284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8285. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8286. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8287. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8288. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  8289. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8290. /**
  8291. * 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.
  8292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8293. */
  8294. var FramingBehavior = /** @class */ (function () {
  8295. function FramingBehavior() {
  8296. this._mode = FramingBehavior.FitFrustumSidesMode;
  8297. this._radiusScale = 1.0;
  8298. this._positionScale = 0.5;
  8299. this._defaultElevation = 0.3;
  8300. this._elevationReturnTime = 1500;
  8301. this._elevationReturnWaitTime = 1000;
  8302. this._zoomStopsAnimation = false;
  8303. this._framingTime = 1500;
  8304. /**
  8305. * Define if the behavior should automatically change the configured
  8306. * camera limits and sensibilities.
  8307. */
  8308. this.autoCorrectCameraLimitsAndSensibility = true;
  8309. this._isPointerDown = false;
  8310. this._lastInteractionTime = -Infinity;
  8311. // Framing control
  8312. this._animatables = new Array();
  8313. this._betaIsAnimating = false;
  8314. }
  8315. Object.defineProperty(FramingBehavior.prototype, "name", {
  8316. /**
  8317. * Gets the name of the behavior.
  8318. */
  8319. get: function () {
  8320. return "Framing";
  8321. },
  8322. enumerable: true,
  8323. configurable: true
  8324. });
  8325. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8326. /**
  8327. * Gets current mode used by the behavior.
  8328. */
  8329. get: function () {
  8330. return this._mode;
  8331. },
  8332. /**
  8333. * Sets the current mode used by the behavior
  8334. */
  8335. set: function (mode) {
  8336. this._mode = mode;
  8337. },
  8338. enumerable: true,
  8339. configurable: true
  8340. });
  8341. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8342. /**
  8343. * Gets the scale applied to the radius
  8344. */
  8345. get: function () {
  8346. return this._radiusScale;
  8347. },
  8348. /**
  8349. * Sets the scale applied to the radius (1 by default)
  8350. */
  8351. set: function (radius) {
  8352. this._radiusScale = radius;
  8353. },
  8354. enumerable: true,
  8355. configurable: true
  8356. });
  8357. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8358. /**
  8359. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8360. */
  8361. get: function () {
  8362. return this._positionScale;
  8363. },
  8364. /**
  8365. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8366. */
  8367. set: function (scale) {
  8368. this._positionScale = scale;
  8369. },
  8370. enumerable: true,
  8371. configurable: true
  8372. });
  8373. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8374. /**
  8375. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8376. * behaviour is triggered, in radians.
  8377. */
  8378. get: function () {
  8379. return this._defaultElevation;
  8380. },
  8381. /**
  8382. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8383. * behaviour is triggered, in radians.
  8384. */
  8385. set: function (elevation) {
  8386. this._defaultElevation = elevation;
  8387. },
  8388. enumerable: true,
  8389. configurable: true
  8390. });
  8391. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8392. /**
  8393. * Gets the time (in milliseconds) taken to return to the default beta position.
  8394. * Negative value indicates camera should not return to default.
  8395. */
  8396. get: function () {
  8397. return this._elevationReturnTime;
  8398. },
  8399. /**
  8400. * Sets the time (in milliseconds) taken to return to the default beta position.
  8401. * Negative value indicates camera should not return to default.
  8402. */
  8403. set: function (speed) {
  8404. this._elevationReturnTime = speed;
  8405. },
  8406. enumerable: true,
  8407. configurable: true
  8408. });
  8409. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8410. /**
  8411. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8412. */
  8413. get: function () {
  8414. return this._elevationReturnWaitTime;
  8415. },
  8416. /**
  8417. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8418. */
  8419. set: function (time) {
  8420. this._elevationReturnWaitTime = time;
  8421. },
  8422. enumerable: true,
  8423. configurable: true
  8424. });
  8425. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8426. /**
  8427. * Gets the flag that indicates if user zooming should stop animation.
  8428. */
  8429. get: function () {
  8430. return this._zoomStopsAnimation;
  8431. },
  8432. /**
  8433. * Sets the flag that indicates if user zooming should stop animation.
  8434. */
  8435. set: function (flag) {
  8436. this._zoomStopsAnimation = flag;
  8437. },
  8438. enumerable: true,
  8439. configurable: true
  8440. });
  8441. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8442. /**
  8443. * Gets the transition time when framing the mesh, in milliseconds
  8444. */
  8445. get: function () {
  8446. return this._framingTime;
  8447. },
  8448. /**
  8449. * Sets the transition time when framing the mesh, in milliseconds
  8450. */
  8451. set: function (time) {
  8452. this._framingTime = time;
  8453. },
  8454. enumerable: true,
  8455. configurable: true
  8456. });
  8457. /**
  8458. * Initializes the behavior.
  8459. */
  8460. FramingBehavior.prototype.init = function () {
  8461. // Do notihng
  8462. };
  8463. /**
  8464. * Attaches the behavior to its arc rotate camera.
  8465. * @param camera Defines the camera to attach the behavior to
  8466. */
  8467. FramingBehavior.prototype.attach = function (camera) {
  8468. var _this = this;
  8469. this._attachedCamera = camera;
  8470. var scene = this._attachedCamera.getScene();
  8471. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8472. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8473. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8474. _this._isPointerDown = true;
  8475. return;
  8476. }
  8477. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8478. _this._isPointerDown = false;
  8479. }
  8480. });
  8481. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8482. if (mesh) {
  8483. _this.zoomOnMesh(mesh);
  8484. }
  8485. });
  8486. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8487. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8488. _this._applyUserInteraction();
  8489. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8490. // back to the default position after a given timeout
  8491. _this._maintainCameraAboveGround();
  8492. });
  8493. };
  8494. /**
  8495. * Detaches the behavior from its current arc rotate camera.
  8496. */
  8497. FramingBehavior.prototype.detach = function () {
  8498. if (!this._attachedCamera) {
  8499. return;
  8500. }
  8501. var scene = this._attachedCamera.getScene();
  8502. if (this._onPrePointerObservableObserver) {
  8503. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8504. }
  8505. if (this._onAfterCheckInputsObserver) {
  8506. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8507. }
  8508. if (this._onMeshTargetChangedObserver) {
  8509. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8510. }
  8511. this._attachedCamera = null;
  8512. };
  8513. /**
  8514. * Targets the given mesh and updates zoom level accordingly.
  8515. * @param mesh The mesh to target.
  8516. * @param radius Optional. If a cached radius position already exists, overrides default.
  8517. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8518. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8519. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8520. */
  8521. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8522. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8523. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8524. mesh.computeWorldMatrix(true);
  8525. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8526. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8527. };
  8528. /**
  8529. * Targets the given mesh with its children and updates zoom level accordingly.
  8530. * @param mesh The mesh to target.
  8531. * @param radius Optional. If a cached radius position already exists, overrides default.
  8532. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8533. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8534. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8535. */
  8536. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8537. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8538. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8539. mesh.computeWorldMatrix(true);
  8540. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8541. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8542. };
  8543. /**
  8544. * Targets the given meshes with their children and updates zoom level accordingly.
  8545. * @param meshes The mesh to target.
  8546. * @param radius Optional. If a cached radius position already exists, overrides default.
  8547. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8548. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8549. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8550. */
  8551. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8552. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8553. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8554. var min = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8555. var max = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8556. for (var i = 0; i < meshes.length; i++) {
  8557. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8558. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CheckExtends(boundingInfo.min, min, max);
  8559. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CheckExtends(boundingInfo.max, min, max);
  8560. }
  8561. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8562. };
  8563. /**
  8564. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8565. * @param minimumWorld Determines the smaller position of the bounding box extend
  8566. * @param maximumWorld Determines the bigger position of the bounding box extend
  8567. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8568. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8569. */
  8570. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8571. var _this = this;
  8572. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8573. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8574. var zoomTarget;
  8575. if (!this._attachedCamera) {
  8576. return;
  8577. }
  8578. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8579. var bottom = minimumWorld.y;
  8580. var top = maximumWorld.y;
  8581. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8582. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8583. if (focusOnOriginXZ) {
  8584. zoomTarget = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, zoomTargetY, 0);
  8585. }
  8586. else {
  8587. var centerWorld = minimumWorld.add(radiusWorld);
  8588. zoomTarget = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8589. }
  8590. if (!this._vectorTransition) {
  8591. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8592. }
  8593. this._betaIsAnimating = true;
  8594. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8595. if (animatable) {
  8596. this._animatables.push(animatable);
  8597. }
  8598. // sets the radius and lower radius bounds
  8599. // Small delta ensures camera is not always at lower zoom limit.
  8600. var radius = 0;
  8601. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8602. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8603. if (this.autoCorrectCameraLimitsAndSensibility) {
  8604. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8605. }
  8606. radius = position;
  8607. }
  8608. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8609. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8610. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8611. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8612. }
  8613. }
  8614. // Set sensibilities
  8615. if (this.autoCorrectCameraLimitsAndSensibility) {
  8616. var extend = maximumWorld.subtract(minimumWorld).length();
  8617. this._attachedCamera.panningSensibility = 5000 / extend;
  8618. this._attachedCamera.wheelPrecision = 100 / radius;
  8619. }
  8620. // transition to new radius
  8621. if (!this._radiusTransition) {
  8622. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8623. }
  8624. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8625. _this.stopAllAnimations();
  8626. if (onAnimationEnd) {
  8627. onAnimationEnd();
  8628. }
  8629. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8630. _this._attachedCamera.storeState();
  8631. }
  8632. });
  8633. if (animatable) {
  8634. this._animatables.push(animatable);
  8635. }
  8636. };
  8637. /**
  8638. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8639. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8640. * frustum width.
  8641. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8642. * to fully enclose the mesh in the viewing frustum.
  8643. */
  8644. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8645. var size = maximumWorld.subtract(minimumWorld);
  8646. var boxVectorGlobalDiagonal = size.length();
  8647. var frustumSlope = this._getFrustumSlope();
  8648. // Formula for setting distance
  8649. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8650. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8651. // Horizon distance
  8652. var radius = radiusWithoutFraming * this._radiusScale;
  8653. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8654. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8655. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8656. var camera = this._attachedCamera;
  8657. if (!camera) {
  8658. return 0;
  8659. }
  8660. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8661. // Don't exceed the requested limit
  8662. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8663. }
  8664. // Don't exceed the upper radius limit
  8665. if (camera.upperRadiusLimit) {
  8666. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8667. }
  8668. return distance;
  8669. };
  8670. /**
  8671. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8672. * is automatically returned to its default position (expected to be above ground plane).
  8673. */
  8674. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8675. var _this = this;
  8676. if (this._elevationReturnTime < 0) {
  8677. return;
  8678. }
  8679. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now - this._lastInteractionTime;
  8680. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8681. var limitBeta = Math.PI * 0.5;
  8682. // Bring the camera back up if below the ground plane
  8683. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8684. this._betaIsAnimating = true;
  8685. //Transition to new position
  8686. this.stopAllAnimations();
  8687. if (!this._betaTransition) {
  8688. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8689. }
  8690. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8691. _this._clearAnimationLocks();
  8692. _this.stopAllAnimations();
  8693. });
  8694. if (animatabe) {
  8695. this._animatables.push(animatabe);
  8696. }
  8697. }
  8698. };
  8699. /**
  8700. * Returns the frustum slope based on the canvas ratio and camera FOV
  8701. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8702. */
  8703. FramingBehavior.prototype._getFrustumSlope = function () {
  8704. // Calculate the viewport ratio
  8705. // Aspect Ratio is Height/Width.
  8706. var camera = this._attachedCamera;
  8707. if (!camera) {
  8708. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  8709. }
  8710. var engine = camera.getScene().getEngine();
  8711. var aspectRatio = engine.getAspectRatio(camera);
  8712. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8713. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8714. var frustumSlopeY = Math.tan(camera.fov / 2);
  8715. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8716. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8717. // along the forward vector.
  8718. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8719. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](frustumSlopeX, frustumSlopeY);
  8720. };
  8721. /**
  8722. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8723. */
  8724. FramingBehavior.prototype._clearAnimationLocks = function () {
  8725. this._betaIsAnimating = false;
  8726. };
  8727. /**
  8728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8729. */
  8730. FramingBehavior.prototype._applyUserInteraction = function () {
  8731. if (this.isUserIsMoving) {
  8732. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  8733. this.stopAllAnimations();
  8734. this._clearAnimationLocks();
  8735. }
  8736. };
  8737. /**
  8738. * Stops and removes all animations that have been applied to the camera
  8739. */
  8740. FramingBehavior.prototype.stopAllAnimations = function () {
  8741. if (this._attachedCamera) {
  8742. this._attachedCamera.animations = [];
  8743. }
  8744. while (this._animatables.length) {
  8745. if (this._animatables[0]) {
  8746. this._animatables[0].onAnimationEnd = null;
  8747. this._animatables[0].stop();
  8748. }
  8749. this._animatables.shift();
  8750. }
  8751. };
  8752. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8753. /**
  8754. * Gets a value indicating if the user is moving the camera
  8755. */
  8756. get: function () {
  8757. if (!this._attachedCamera) {
  8758. return false;
  8759. }
  8760. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8761. this._attachedCamera.inertialBetaOffset !== 0 ||
  8762. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8763. this._attachedCamera.inertialPanningX !== 0 ||
  8764. this._attachedCamera.inertialPanningY !== 0 ||
  8765. this._isPointerDown;
  8766. },
  8767. enumerable: true,
  8768. configurable: true
  8769. });
  8770. /**
  8771. * The easing function used by animations
  8772. */
  8773. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8774. /**
  8775. * The easing mode used by animations
  8776. */
  8777. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8778. // Statics
  8779. /**
  8780. * The camera can move all the way towards the mesh.
  8781. */
  8782. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8783. /**
  8784. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8785. */
  8786. FramingBehavior.FitFrustumSidesMode = 1;
  8787. return FramingBehavior;
  8788. }());
  8789. /***/ }),
  8790. /***/ "./Behaviors/Cameras/index.ts":
  8791. /*!************************************!*\
  8792. !*** ./Behaviors/Cameras/index.ts ***!
  8793. \************************************/
  8794. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8795. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8796. "use strict";
  8797. __webpack_require__.r(__webpack_exports__);
  8798. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8800. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8802. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8804. /***/ }),
  8805. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8806. /*!*************************************************!*\
  8807. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8808. \*************************************************/
  8809. /*! exports provided: AttachToBoxBehavior */
  8810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8811. "use strict";
  8812. __webpack_require__.r(__webpack_exports__);
  8813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8814. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  8815. /**
  8816. * @hidden
  8817. */
  8818. var FaceDirectionInfo = /** @class */ (function () {
  8819. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8820. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8821. if (diff === void 0) { diff = 0; }
  8822. if (ignore === void 0) { ignore = false; }
  8823. this.direction = direction;
  8824. this.rotatedDirection = rotatedDirection;
  8825. this.diff = diff;
  8826. this.ignore = ignore;
  8827. }
  8828. return FaceDirectionInfo;
  8829. }());
  8830. /**
  8831. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8832. */
  8833. var AttachToBoxBehavior = /** @class */ (function () {
  8834. /**
  8835. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8836. * @param ui The transform node that should be attched to the mesh
  8837. */
  8838. function AttachToBoxBehavior(ui) {
  8839. this.ui = ui;
  8840. /**
  8841. * The name of the behavior
  8842. */
  8843. this.name = "AttachToBoxBehavior";
  8844. /**
  8845. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8846. */
  8847. this.distanceAwayFromFace = 0.15;
  8848. /**
  8849. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8850. */
  8851. this.distanceAwayFromBottomOfFace = 0.15;
  8852. this._faceVectors = [new FaceDirectionInfo(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up()), new FaceDirectionInfo(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Down()), new FaceDirectionInfo(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Left()), new FaceDirectionInfo(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right()), new FaceDirectionInfo(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward()), new FaceDirectionInfo(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward().scaleInPlace(-1))];
  8853. this._tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8854. this._tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8855. this._zeroVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8856. this._lookAtTmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8857. /* Does nothing */
  8858. }
  8859. /**
  8860. * Initializes the behavior
  8861. */
  8862. AttachToBoxBehavior.prototype.init = function () {
  8863. /* Does nothing */
  8864. };
  8865. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8866. var _this = this;
  8867. // Go over each face and calculate the angle between the face's normal and targetDirection
  8868. this._faceVectors.forEach(function (v) {
  8869. if (!_this._target.rotationQuaternion) {
  8870. _this._target.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8871. }
  8872. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8873. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8874. v.diff = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8875. });
  8876. // Return the face information of the one with the normal closeset to target direction
  8877. return this._faceVectors.reduce(function (min, p) {
  8878. if (min.ignore) {
  8879. return p;
  8880. }
  8881. else if (p.ignore) {
  8882. return min;
  8883. }
  8884. else {
  8885. return min.diff < p.diff ? min : p;
  8886. }
  8887. }, this._faceVectors[0]);
  8888. };
  8889. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8890. if (up === void 0) { up = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8891. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8892. this._lookAtTmpMatrix.invert();
  8893. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8894. };
  8895. /**
  8896. * Attaches the AttachToBoxBehavior to the passed in mesh
  8897. * @param target The mesh that the specified node will be attached to
  8898. */
  8899. AttachToBoxBehavior.prototype.attach = function (target) {
  8900. var _this = this;
  8901. this._target = target;
  8902. this._scene = this._target.getScene();
  8903. // Every frame, update the app bars position
  8904. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8905. if (!_this._scene.activeCamera) {
  8906. return;
  8907. }
  8908. // Find the face closest to the cameras position
  8909. var cameraPos = _this._scene.activeCamera.position;
  8910. if (_this._scene.activeCamera.devicePosition) {
  8911. cameraPos = _this._scene.activeCamera.devicePosition;
  8912. }
  8913. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8914. if (_this._scene.activeCamera.leftCamera) {
  8915. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8916. }
  8917. else {
  8918. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8919. }
  8920. // Get camera up direction
  8921. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8922. // Ignore faces to not select a parrelel face for the up vector of the UI
  8923. _this._faceVectors.forEach(function (v) {
  8924. if (facing.direction.x && v.direction.x) {
  8925. v.ignore = true;
  8926. }
  8927. if (facing.direction.y && v.direction.y) {
  8928. v.ignore = true;
  8929. }
  8930. if (facing.direction.z && v.direction.z) {
  8931. v.ignore = true;
  8932. }
  8933. });
  8934. var facingUp = _this._closestFace(_this._tmpVector);
  8935. // Unignore faces
  8936. _this._faceVectors.forEach(function (v) {
  8937. v.ignore = false;
  8938. });
  8939. // Position the app bar on that face
  8940. _this.ui.position.copyFrom(target.position);
  8941. if (facing.direction.x) {
  8942. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8943. _this.ui.position.addInPlace(_this._tmpVector);
  8944. }
  8945. if (facing.direction.y) {
  8946. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8947. _this.ui.position.addInPlace(_this._tmpVector);
  8948. }
  8949. if (facing.direction.z) {
  8950. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8951. _this.ui.position.addInPlace(_this._tmpVector);
  8952. }
  8953. // Rotate to be oriented properly to the camera
  8954. if (!_this.ui.rotationQuaternion) {
  8955. _this.ui.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8956. }
  8957. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8958. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8959. // Place ui the correct distance from the bottom of the mesh
  8960. if (facingUp.direction.x) {
  8961. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8962. }
  8963. if (facingUp.direction.y) {
  8964. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8965. }
  8966. if (facingUp.direction.z) {
  8967. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8968. }
  8969. _this.ui.position.addInPlace(_this._tmpVector);
  8970. });
  8971. };
  8972. /**
  8973. * Detaches the behavior from the mesh
  8974. */
  8975. AttachToBoxBehavior.prototype.detach = function () {
  8976. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8977. };
  8978. return AttachToBoxBehavior;
  8979. }());
  8980. /***/ }),
  8981. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8982. /*!***********************************************!*\
  8983. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8984. \***********************************************/
  8985. /*! exports provided: FadeInOutBehavior */
  8986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8987. "use strict";
  8988. __webpack_require__.r(__webpack_exports__);
  8989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8990. /**
  8991. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8992. */
  8993. var FadeInOutBehavior = /** @class */ (function () {
  8994. /**
  8995. * Instatiates the FadeInOutBehavior
  8996. */
  8997. function FadeInOutBehavior() {
  8998. var _this = this;
  8999. /**
  9000. * Time in milliseconds to delay before fading in (Default: 0)
  9001. */
  9002. this.delay = 0;
  9003. /**
  9004. * Time in milliseconds for the mesh to fade in (Default: 300)
  9005. */
  9006. this.fadeInTime = 300;
  9007. this._millisecondsPerFrame = 1000 / 60;
  9008. this._hovered = false;
  9009. this._hoverValue = 0;
  9010. this._ownerNode = null;
  9011. this._update = function () {
  9012. if (_this._ownerNode) {
  9013. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  9014. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  9015. if (_this._ownerNode.visibility > 1) {
  9016. _this._setAllVisibility(_this._ownerNode, 1);
  9017. _this._hoverValue = _this.fadeInTime + _this.delay;
  9018. return;
  9019. }
  9020. else if (_this._ownerNode.visibility < 0) {
  9021. _this._setAllVisibility(_this._ownerNode, 0);
  9022. if (_this._hoverValue < 0) {
  9023. _this._hoverValue = 0;
  9024. return;
  9025. }
  9026. }
  9027. setTimeout(_this._update, _this._millisecondsPerFrame);
  9028. }
  9029. };
  9030. }
  9031. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  9032. /**
  9033. * The name of the behavior
  9034. */
  9035. get: function () {
  9036. return "FadeInOut";
  9037. },
  9038. enumerable: true,
  9039. configurable: true
  9040. });
  9041. /**
  9042. * Initializes the behavior
  9043. */
  9044. FadeInOutBehavior.prototype.init = function () {
  9045. };
  9046. /**
  9047. * Attaches the fade behavior on the passed in mesh
  9048. * @param ownerNode The mesh that will be faded in/out once attached
  9049. */
  9050. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  9051. this._ownerNode = ownerNode;
  9052. this._setAllVisibility(this._ownerNode, 0);
  9053. };
  9054. /**
  9055. * Detaches the behavior from the mesh
  9056. */
  9057. FadeInOutBehavior.prototype.detach = function () {
  9058. this._ownerNode = null;
  9059. };
  9060. /**
  9061. * Triggers the mesh to begin fading in or out
  9062. * @param value if the object should fade in or out (true to fade in)
  9063. */
  9064. FadeInOutBehavior.prototype.fadeIn = function (value) {
  9065. this._hovered = value;
  9066. this._update();
  9067. };
  9068. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  9069. var _this = this;
  9070. mesh.visibility = value;
  9071. mesh.getChildMeshes().forEach(function (c) {
  9072. _this._setAllVisibility(c, value);
  9073. });
  9074. };
  9075. return FadeInOutBehavior;
  9076. }());
  9077. /***/ }),
  9078. /***/ "./Behaviors/Meshes/index.ts":
  9079. /*!***********************************!*\
  9080. !*** ./Behaviors/Meshes/index.ts ***!
  9081. \***********************************/
  9082. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9084. "use strict";
  9085. __webpack_require__.r(__webpack_exports__);
  9086. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  9087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  9088. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  9089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9090. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  9091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  9092. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  9094. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  9095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  9096. /***/ }),
  9097. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  9098. /*!*******************************************************!*\
  9099. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  9100. \*******************************************************/
  9101. /*! exports provided: MultiPointerScaleBehavior */
  9102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9103. "use strict";
  9104. __webpack_require__.r(__webpack_exports__);
  9105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  9106. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9107. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  9108. /**
  9109. * A behavior that when attached to a mesh will allow the mesh to be scaled
  9110. */
  9111. var MultiPointerScaleBehavior = /** @class */ (function () {
  9112. /**
  9113. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  9114. */
  9115. function MultiPointerScaleBehavior() {
  9116. this._startDistance = 0;
  9117. this._initialScale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9118. this._targetScale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9119. this._sceneRenderObserver = null;
  9120. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9121. this._dragBehaviorA.moveAttached = false;
  9122. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9123. this._dragBehaviorB.moveAttached = false;
  9124. }
  9125. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  9126. /**
  9127. * The name of the behavior
  9128. */
  9129. get: function () {
  9130. return "MultiPointerScale";
  9131. },
  9132. enumerable: true,
  9133. configurable: true
  9134. });
  9135. /**
  9136. * Initializes the behavior
  9137. */
  9138. MultiPointerScaleBehavior.prototype.init = function () { };
  9139. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9140. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9141. };
  9142. /**
  9143. * Attaches the scale behavior the passed in mesh
  9144. * @param ownerNode The mesh that will be scaled around once attached
  9145. */
  9146. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9147. var _this = this;
  9148. this._ownerNode = ownerNode;
  9149. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9150. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9151. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9152. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9153. _this._dragBehaviorA.releaseDrag();
  9154. }
  9155. else {
  9156. _this._initialScale.copyFrom(ownerNode.scaling);
  9157. _this._startDistance = _this._getCurrentDistance();
  9158. }
  9159. }
  9160. });
  9161. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9162. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9163. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9164. _this._dragBehaviorB.releaseDrag();
  9165. }
  9166. else {
  9167. _this._initialScale.copyFrom(ownerNode.scaling);
  9168. _this._startDistance = _this._getCurrentDistance();
  9169. }
  9170. }
  9171. });
  9172. // Once both drag behaviors are active scale based on the distance between the two pointers
  9173. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9174. behavior.onDragObservable.add(function () {
  9175. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9176. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9177. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9178. }
  9179. });
  9180. });
  9181. ownerNode.addBehavior(this._dragBehaviorA);
  9182. ownerNode.addBehavior(this._dragBehaviorB);
  9183. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9184. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9185. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9186. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9187. if (change.length() > 0.01) {
  9188. ownerNode.scaling.addInPlace(change);
  9189. }
  9190. }
  9191. });
  9192. };
  9193. /**
  9194. * Detaches the behavior from the mesh
  9195. */
  9196. MultiPointerScaleBehavior.prototype.detach = function () {
  9197. var _this = this;
  9198. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9199. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9200. behavior.onDragStartObservable.clear();
  9201. behavior.onDragObservable.clear();
  9202. _this._ownerNode.removeBehavior(behavior);
  9203. });
  9204. };
  9205. return MultiPointerScaleBehavior;
  9206. }());
  9207. /***/ }),
  9208. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9209. /*!*************************************************!*\
  9210. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9211. \*************************************************/
  9212. /*! exports provided: PointerDragBehavior */
  9213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9214. "use strict";
  9215. __webpack_require__.r(__webpack_exports__);
  9216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9217. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9218. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9219. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9220. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  9221. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9222. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9223. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9224. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9225. /**
  9226. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9227. */
  9228. var PointerDragBehavior = /** @class */ (function () {
  9229. /**
  9230. * Creates a pointer drag behavior that can be attached to a mesh
  9231. * @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)
  9232. */
  9233. function PointerDragBehavior(options) {
  9234. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9235. /**
  9236. * 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)
  9237. */
  9238. this.maxDragAngle = 0;
  9239. /**
  9240. * @hidden
  9241. */
  9242. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9243. /**
  9244. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9245. */
  9246. this.currentDraggingPointerID = -1;
  9247. /**
  9248. * If the behavior is currently in a dragging state
  9249. */
  9250. this.dragging = false;
  9251. /**
  9252. * 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)
  9253. */
  9254. this.dragDeltaRatio = 0.2;
  9255. /**
  9256. * If the drag plane orientation should be updated during the dragging (Default: true)
  9257. */
  9258. this.updateDragPlane = true;
  9259. // Debug mode will display drag planes to help visualize behavior
  9260. this._debugMode = false;
  9261. this._moving = false;
  9262. /**
  9263. * Fires each time the attached mesh is dragged with the pointer
  9264. * * delta between last drag position and current drag position in world space
  9265. * * dragDistance along the drag axis
  9266. * * dragPlaneNormal normal of the current drag plane used during the drag
  9267. * * dragPlanePoint in world space where the drag intersects the drag plane
  9268. */
  9269. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9270. /**
  9271. * Fires each time a drag begins (eg. mouse down on mesh)
  9272. */
  9273. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9274. /**
  9275. * Fires each time a drag ends (eg. mouse release after drag)
  9276. */
  9277. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9278. /**
  9279. * If the attached mesh should be moved when dragged
  9280. */
  9281. this.moveAttached = true;
  9282. /**
  9283. * If the drag behavior will react to drag events (Default: true)
  9284. */
  9285. this.enabled = true;
  9286. /**
  9287. * If pointer events should start and release the drag (Default: true)
  9288. */
  9289. this.startAndReleaseDragOnPointerEvents = true;
  9290. /**
  9291. * If camera controls should be detached during the drag
  9292. */
  9293. this.detachCameraControls = true;
  9294. /**
  9295. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9296. */
  9297. this.useObjectOrienationForDragging = true;
  9298. /**
  9299. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9300. */
  9301. this.validateDrag = function (targetPosition) { return true; };
  9302. this._tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9303. this._alternatePickedPoint = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9304. this._worldDragAxis = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9305. this._targetPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9306. this._attachedElement = null;
  9307. this._startDragRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9308. this._lastPointerRay = {};
  9309. this._dragDelta = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9310. // Variables to avoid instantiation in the below method
  9311. this._pointA = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9312. this._pointB = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9313. this._pointC = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9314. this._lineA = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9315. this._lineB = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9316. this._localAxis = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9317. this._lookAt = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9318. this._options = options ? options : {};
  9319. var optionCount = 0;
  9320. if (this._options.dragAxis) {
  9321. optionCount++;
  9322. }
  9323. if (this._options.dragPlaneNormal) {
  9324. optionCount++;
  9325. }
  9326. if (optionCount > 1) {
  9327. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9328. }
  9329. }
  9330. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9331. /**
  9332. * The name of the behavior
  9333. */
  9334. get: function () {
  9335. return "PointerDrag";
  9336. },
  9337. enumerable: true,
  9338. configurable: true
  9339. });
  9340. /**
  9341. * Initializes the behavior
  9342. */
  9343. PointerDragBehavior.prototype.init = function () { };
  9344. /**
  9345. * Attaches the drag behavior the passed in mesh
  9346. * @param ownerNode The mesh that will be dragged around once attached
  9347. */
  9348. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9349. var _this = this;
  9350. this._scene = ownerNode.getScene();
  9351. this.attachedNode = ownerNode;
  9352. // Initialize drag plane to not interfere with existing scene
  9353. if (!PointerDragBehavior._planeScene) {
  9354. if (this._debugMode) {
  9355. PointerDragBehavior._planeScene = this._scene;
  9356. }
  9357. else {
  9358. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine(), { virtual: true });
  9359. PointerDragBehavior._planeScene.detachControl();
  9360. this._scene.onDisposeObservable.addOnce(function () {
  9361. PointerDragBehavior._planeScene.dispose();
  9362. PointerDragBehavior._planeScene = null;
  9363. });
  9364. }
  9365. }
  9366. 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);
  9367. // State of the drag
  9368. this.lastDragPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9369. var pickPredicate = function (m) {
  9370. return _this.attachedNode == m || m.isDescendantOf(_this.attachedNode);
  9371. };
  9372. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9373. if (!_this.enabled) {
  9374. return;
  9375. }
  9376. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9377. if (_this.startAndReleaseDragOnPointerEvents && !_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9378. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9379. }
  9380. }
  9381. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9382. if (_this.startAndReleaseDragOnPointerEvents && _this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9383. _this.releaseDrag();
  9384. }
  9385. }
  9386. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9387. var pointerId = pointerInfo.event.pointerId;
  9388. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9389. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9390. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9391. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9392. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9393. }
  9394. _this.currentDraggingPointerID = pointerId;
  9395. }
  9396. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9397. if (!_this._lastPointerRay[pointerId]) {
  9398. _this._lastPointerRay[pointerId] = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9399. }
  9400. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9401. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9402. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9403. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9404. _this._moveDrag(pointerInfo.pickInfo.ray);
  9405. }
  9406. }
  9407. }
  9408. });
  9409. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9410. if (_this._moving && _this.moveAttached) {
  9411. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedNode);
  9412. // Slowly move mesh to avoid jitter
  9413. _this._targetPosition.subtractToRef((_this.attachedNode).absolutePosition, _this._tmpVector);
  9414. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9415. (_this.attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9416. if (_this.validateDrag(_this._tmpVector)) {
  9417. (_this.attachedNode).setAbsolutePosition(_this._tmpVector);
  9418. }
  9419. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this.attachedNode);
  9420. }
  9421. });
  9422. };
  9423. /**
  9424. * Force relase the drag action by code.
  9425. */
  9426. PointerDragBehavior.prototype.releaseDrag = function () {
  9427. this.dragging = false;
  9428. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9429. this.currentDraggingPointerID = -1;
  9430. this._moving = false;
  9431. // Reattach camera controls
  9432. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9433. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9434. }
  9435. };
  9436. /**
  9437. * Simulates the start of a pointer drag event on the behavior
  9438. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9439. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9440. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9441. */
  9442. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9443. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9444. this._startDrag(pointerId, fromRay, startPickedPoint);
  9445. var lastRay = this._lastPointerRay[pointerId];
  9446. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9447. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9448. }
  9449. if (lastRay) {
  9450. // if there was a last pointer ray drag the object there
  9451. this._moveDrag(lastRay);
  9452. }
  9453. };
  9454. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9455. if (!this._scene.activeCamera || this.dragging || !this.attachedNode) {
  9456. return;
  9457. }
  9458. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedNode);
  9459. // Create start ray from the camera to the object
  9460. if (fromRay) {
  9461. this._startDragRay.direction.copyFrom(fromRay.direction);
  9462. this._startDragRay.origin.copyFrom(fromRay.origin);
  9463. }
  9464. else {
  9465. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9466. this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9467. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9468. }
  9469. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9470. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9471. if (pickedPoint) {
  9472. this.dragging = true;
  9473. this.currentDraggingPointerID = pointerId;
  9474. this.lastDragPosition.copyFrom(pickedPoint);
  9475. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9476. this._targetPosition.copyFrom((this.attachedNode).absolutePosition);
  9477. // Detatch camera controls
  9478. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9479. if (this._scene.activeCamera.inputs.attachedElement) {
  9480. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9481. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9482. }
  9483. else {
  9484. this._attachedElement = null;
  9485. }
  9486. }
  9487. }
  9488. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this.attachedNode);
  9489. };
  9490. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9491. this._moving = true;
  9492. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9493. if (pickedPoint) {
  9494. if (this.updateDragPlane) {
  9495. this._updateDragPlanePosition(ray, pickedPoint);
  9496. }
  9497. var dragLength = 0;
  9498. // depending on the drag mode option drag accordingly
  9499. if (this._options.dragAxis) {
  9500. // Convert local drag axis to world if useObjectOrienationForDragging
  9501. this.useObjectOrienationForDragging ? _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis);
  9502. // Project delta drag from the drag plane onto the drag axis
  9503. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9504. dragLength = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9505. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9506. }
  9507. else {
  9508. dragLength = this._dragDelta.length();
  9509. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9510. }
  9511. this._targetPosition.addInPlace(this._dragDelta);
  9512. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9513. this.lastDragPosition.copyFrom(pickedPoint);
  9514. }
  9515. };
  9516. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9517. var _this = this;
  9518. if (!ray) {
  9519. return null;
  9520. }
  9521. // Calculate angle between plane normal and ray
  9522. var angle = Math.acos(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9523. // Correct if ray is casted from oposite side
  9524. if (angle > Math.PI / 2) {
  9525. angle = Math.PI - angle;
  9526. }
  9527. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9528. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9529. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9530. // Invert ray direction along the towards object axis
  9531. this._tmpVector.copyFrom(ray.direction);
  9532. (this.attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9533. this._alternatePickedPoint.normalize();
  9534. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9535. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9536. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9537. var dot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9538. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9539. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9540. this._alternatePickedPoint.addInPlace((this.attachedNode).absolutePosition);
  9541. return this._alternatePickedPoint;
  9542. }
  9543. else {
  9544. return null;
  9545. }
  9546. }
  9547. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9548. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9549. return pickResult.pickedPoint;
  9550. }
  9551. else {
  9552. return null;
  9553. }
  9554. };
  9555. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9556. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9557. this._pointA.copyFrom(dragPlanePosition);
  9558. if (this._options.dragAxis) {
  9559. this.useObjectOrienationForDragging ? _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
  9560. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9561. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9562. ray.origin.subtractToRef(this._pointA, this._pointC);
  9563. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9564. // Get perpendicular line from direction to camera and drag axis
  9565. this._pointB.subtractToRef(this._pointA, this._lineA);
  9566. this._pointC.subtractToRef(this._pointA, this._lineB);
  9567. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9568. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9569. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9570. this._lookAt.normalize();
  9571. this._dragPlane.position.copyFrom(this._pointA);
  9572. this._pointA.addToRef(this._lookAt, this._lookAt);
  9573. this._dragPlane.lookAt(this._lookAt);
  9574. }
  9575. else if (this._options.dragPlaneNormal) {
  9576. this.useObjectOrienationForDragging ? _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
  9577. this._dragPlane.position.copyFrom(this._pointA);
  9578. this._pointA.addToRef(this._localAxis, this._lookAt);
  9579. this._dragPlane.lookAt(this._lookAt);
  9580. }
  9581. else {
  9582. this._dragPlane.position.copyFrom(this._pointA);
  9583. this._dragPlane.lookAt(ray.origin);
  9584. }
  9585. // 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)
  9586. this._dragPlane.position.copyFrom(this.attachedNode.absolutePosition);
  9587. this._dragPlane.computeWorldMatrix(true);
  9588. };
  9589. /**
  9590. * Detaches the behavior from the mesh
  9591. */
  9592. PointerDragBehavior.prototype.detach = function () {
  9593. if (this._pointerObserver) {
  9594. this._scene.onPointerObservable.remove(this._pointerObserver);
  9595. }
  9596. if (this._beforeRenderObserver) {
  9597. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9598. }
  9599. this.releaseDrag();
  9600. };
  9601. PointerDragBehavior._AnyMouseID = -2;
  9602. return PointerDragBehavior;
  9603. }());
  9604. /***/ }),
  9605. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9606. /*!************************************************!*\
  9607. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9608. \************************************************/
  9609. /*! exports provided: SixDofDragBehavior */
  9610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9611. "use strict";
  9612. __webpack_require__.r(__webpack_exports__);
  9613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9614. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9615. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9616. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9617. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  9618. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9619. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9620. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9621. /**
  9622. * 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
  9623. */
  9624. var SixDofDragBehavior = /** @class */ (function () {
  9625. /**
  9626. * 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
  9627. */
  9628. function SixDofDragBehavior() {
  9629. this._sceneRenderObserver = null;
  9630. this._targetPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9631. this._moving = false;
  9632. this._startingOrientation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9633. /**
  9634. * 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)
  9635. */
  9636. this.zDragFactor = 3;
  9637. /**
  9638. * If the object should rotate to face the drag origin
  9639. */
  9640. this.rotateDraggedObject = true;
  9641. /**
  9642. * If the behavior is currently in a dragging state
  9643. */
  9644. this.dragging = false;
  9645. /**
  9646. * 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)
  9647. */
  9648. this.dragDeltaRatio = 0.2;
  9649. /**
  9650. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9651. */
  9652. this.currentDraggingPointerID = -1;
  9653. /**
  9654. * If camera controls should be detached during the drag
  9655. */
  9656. this.detachCameraControls = true;
  9657. /**
  9658. * Fires each time a drag starts
  9659. */
  9660. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9661. /**
  9662. * Fires each time a drag ends (eg. mouse release after drag)
  9663. */
  9664. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9665. }
  9666. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9667. /**
  9668. * The name of the behavior
  9669. */
  9670. get: function () {
  9671. return "SixDofDrag";
  9672. },
  9673. enumerable: true,
  9674. configurable: true
  9675. });
  9676. /**
  9677. * Initializes the behavior
  9678. */
  9679. SixDofDragBehavior.prototype.init = function () { };
  9680. Object.defineProperty(SixDofDragBehavior.prototype, "_pointerCamera", {
  9681. /**
  9682. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  9683. */
  9684. get: function () {
  9685. if (this._scene.cameraToUseForPointers) {
  9686. return this._scene.cameraToUseForPointers;
  9687. }
  9688. else {
  9689. return this._scene.activeCamera;
  9690. }
  9691. },
  9692. enumerable: true,
  9693. configurable: true
  9694. });
  9695. /**
  9696. * Attaches the scale behavior the passed in mesh
  9697. * @param ownerNode The mesh that will be scaled around once attached
  9698. */
  9699. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9700. var _this = this;
  9701. this._ownerNode = ownerNode;
  9702. this._scene = this._ownerNode.getScene();
  9703. if (!SixDofDragBehavior._virtualScene) {
  9704. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9705. SixDofDragBehavior._virtualScene.detachControl();
  9706. this._scene.getEngine().scenes.pop();
  9707. }
  9708. var pickedMesh = null;
  9709. var lastSixDofOriginPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9710. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9711. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9712. this._virtualOriginMesh.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9713. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9714. this._virtualDragMesh.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9715. var pickPredicate = function (m) {
  9716. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9717. };
  9718. var attachedElement = null;
  9719. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9720. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9721. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9722. if (_this._pointerCamera && _this._pointerCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9723. pointerInfo.pickInfo.ray.origin.copyFrom(_this._pointerCamera.globalPosition);
  9724. }
  9725. pickedMesh = _this._ownerNode;
  9726. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9727. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9728. // Set position and orientation of the controller
  9729. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9730. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9731. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9732. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9733. pickedMesh.computeWorldMatrix();
  9734. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9735. if (!pickedMesh.rotationQuaternion) {
  9736. pickedMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9737. }
  9738. var oldParent = pickedMesh.parent;
  9739. pickedMesh.setParent(null);
  9740. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9741. pickedMesh.setParent(oldParent);
  9742. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9743. // Update state
  9744. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9745. _this.dragging = true;
  9746. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9747. // Detatch camera controls
  9748. if (_this.detachCameraControls && _this._pointerCamera && !_this._pointerCamera.leftCamera) {
  9749. if (_this._pointerCamera.inputs.attachedElement) {
  9750. attachedElement = _this._pointerCamera.inputs.attachedElement;
  9751. _this._pointerCamera.detachControl(_this._pointerCamera.inputs.attachedElement);
  9752. }
  9753. else {
  9754. attachedElement = null;
  9755. }
  9756. }
  9757. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9758. _this.onDragStartObservable.notifyObservers({});
  9759. }
  9760. }
  9761. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9762. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9763. _this.dragging = false;
  9764. _this._moving = false;
  9765. _this.currentDraggingPointerID = -1;
  9766. pickedMesh = null;
  9767. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9768. // Reattach camera controls
  9769. if (_this.detachCameraControls && attachedElement && _this._pointerCamera && !_this._pointerCamera.leftCamera) {
  9770. _this._pointerCamera.attachControl(attachedElement, true);
  9771. }
  9772. _this.onDragEndObservable.notifyObservers({});
  9773. }
  9774. }
  9775. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9776. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9777. var zDragFactor = _this.zDragFactor;
  9778. if (_this._pointerCamera && _this._pointerCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9779. pointerInfo.pickInfo.ray.origin.copyFrom(_this._pointerCamera.globalPosition);
  9780. zDragFactor = 0;
  9781. }
  9782. // Calculate controller drag distance in controller space
  9783. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9784. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9785. var localOriginDragDifference = -_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9786. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9787. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9788. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9789. if (_this._virtualDragMesh.position.z < 0) {
  9790. _this._virtualDragMesh.position.z = 0;
  9791. }
  9792. // Update the controller position
  9793. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9794. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9795. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9796. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9797. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9798. if (pickedMesh.parent) {
  9799. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9800. }
  9801. if (!_this._moving) {
  9802. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9803. }
  9804. _this._moving = true;
  9805. }
  9806. }
  9807. });
  9808. var tmpQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9809. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9810. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9811. if (_this.dragging && _this._moving && pickedMesh) {
  9812. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9813. // Slowly move mesh to avoid jitter
  9814. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9815. if (_this.rotateDraggedObject) {
  9816. // Get change in rotation
  9817. tmpQuaternion.copyFrom(_this._startingOrientation);
  9818. tmpQuaternion.x = -tmpQuaternion.x;
  9819. tmpQuaternion.y = -tmpQuaternion.y;
  9820. tmpQuaternion.z = -tmpQuaternion.z;
  9821. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9822. // Convert change in rotation to only y axis rotation
  9823. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9824. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9825. // Slowly move mesh to avoid jitter
  9826. var oldParent = pickedMesh.parent;
  9827. // Only rotate the mesh if it's parent has uniform scaling
  9828. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9829. pickedMesh.setParent(null);
  9830. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9831. pickedMesh.setParent(oldParent);
  9832. }
  9833. }
  9834. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9835. }
  9836. });
  9837. };
  9838. /**
  9839. * Detaches the behavior from the mesh
  9840. */
  9841. SixDofDragBehavior.prototype.detach = function () {
  9842. if (this._scene) {
  9843. this._scene.onPointerObservable.remove(this._pointerObserver);
  9844. }
  9845. if (this._ownerNode) {
  9846. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9847. }
  9848. if (this._virtualOriginMesh) {
  9849. this._virtualOriginMesh.dispose();
  9850. }
  9851. if (this._virtualDragMesh) {
  9852. this._virtualDragMesh.dispose();
  9853. }
  9854. this.onDragEndObservable.clear();
  9855. this.onDragStartObservable.clear();
  9856. };
  9857. return SixDofDragBehavior;
  9858. }());
  9859. /***/ }),
  9860. /***/ "./Behaviors/index.ts":
  9861. /*!****************************!*\
  9862. !*** ./Behaviors/index.ts ***!
  9863. \****************************/
  9864. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9866. "use strict";
  9867. __webpack_require__.r(__webpack_exports__);
  9868. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9872. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9878. /***/ }),
  9879. /***/ "./Bones/bone.ts":
  9880. /*!***********************!*\
  9881. !*** ./Bones/bone.ts ***!
  9882. \***********************/
  9883. /*! exports provided: Bone */
  9884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9885. "use strict";
  9886. __webpack_require__.r(__webpack_exports__);
  9887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9888. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9889. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  9890. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9891. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9892. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  9893. /**
  9894. * Class used to store bone information
  9895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9896. */
  9897. var Bone = /** @class */ (function (_super) {
  9898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9899. /**
  9900. * Create a new bone
  9901. * @param name defines the bone name
  9902. * @param skeleton defines the parent skeleton
  9903. * @param parentBone defines the parent (can be null if the bone is the root)
  9904. * @param localMatrix defines the local matrix
  9905. * @param restPose defines the rest pose matrix
  9906. * @param baseMatrix defines the base matrix
  9907. * @param index defines index of the bone in the hiearchy
  9908. */
  9909. function Bone(
  9910. /**
  9911. * defines the bone name
  9912. */
  9913. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9914. if (parentBone === void 0) { parentBone = null; }
  9915. if (localMatrix === void 0) { localMatrix = null; }
  9916. if (restPose === void 0) { restPose = null; }
  9917. if (baseMatrix === void 0) { baseMatrix = null; }
  9918. if (index === void 0) { index = null; }
  9919. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9920. _this.name = name;
  9921. /**
  9922. * Gets the list of child bones
  9923. */
  9924. _this.children = new Array();
  9925. /** Gets the animations associated with this bone */
  9926. _this.animations = new Array();
  9927. /**
  9928. * @hidden Internal only
  9929. * Set this value to map this bone to a different index in the transform matrices
  9930. * Set this value to -1 to exclude the bone from the transform matrices
  9931. */
  9932. _this._index = null;
  9933. _this._absoluteTransform = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9934. _this._invertedAbsoluteTransform = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9935. _this._scalingDeterminant = 1;
  9936. _this._worldTransform = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9937. _this._needToDecompose = true;
  9938. _this._needToCompose = false;
  9939. /** @hidden */
  9940. _this._linkedTransformNode = null;
  9941. /** @hidden */
  9942. _this._waitingTransformNodeId = null;
  9943. _this._skeleton = skeleton;
  9944. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9945. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9946. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9947. _this._index = index;
  9948. skeleton.bones.push(_this);
  9949. _this.setParent(parentBone, false);
  9950. if (baseMatrix || localMatrix) {
  9951. _this._updateDifferenceMatrix();
  9952. }
  9953. return _this;
  9954. }
  9955. Object.defineProperty(Bone.prototype, "_matrix", {
  9956. /** @hidden */
  9957. get: function () {
  9958. this._compose();
  9959. return this._localMatrix;
  9960. },
  9961. /** @hidden */
  9962. set: function (value) {
  9963. this._localMatrix.copyFrom(value);
  9964. this._needToDecompose = true;
  9965. },
  9966. enumerable: true,
  9967. configurable: true
  9968. });
  9969. /**
  9970. * Gets the current object class name.
  9971. * @return the class name
  9972. */
  9973. Bone.prototype.getClassName = function () {
  9974. return "Bone";
  9975. };
  9976. // Members
  9977. /**
  9978. * Gets the parent skeleton
  9979. * @returns a skeleton
  9980. */
  9981. Bone.prototype.getSkeleton = function () {
  9982. return this._skeleton;
  9983. };
  9984. /**
  9985. * Gets parent bone
  9986. * @returns a bone or null if the bone is the root of the bone hierarchy
  9987. */
  9988. Bone.prototype.getParent = function () {
  9989. return this._parent;
  9990. };
  9991. /**
  9992. * Returns an array containing the root bones
  9993. * @returns an array containing the root bones
  9994. */
  9995. Bone.prototype.getChildren = function () {
  9996. return this.children;
  9997. };
  9998. /**
  9999. * Sets the parent bone
  10000. * @param parent defines the parent (can be null if the bone is the root)
  10001. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10002. */
  10003. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  10004. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10005. if (this._parent === parent) {
  10006. return;
  10007. }
  10008. if (this._parent) {
  10009. var index = this._parent.children.indexOf(this);
  10010. if (index !== -1) {
  10011. this._parent.children.splice(index, 1);
  10012. }
  10013. }
  10014. this._parent = parent;
  10015. if (this._parent) {
  10016. this._parent.children.push(this);
  10017. }
  10018. if (updateDifferenceMatrix) {
  10019. this._updateDifferenceMatrix();
  10020. }
  10021. this.markAsDirty();
  10022. };
  10023. /**
  10024. * Gets the local matrix
  10025. * @returns a matrix
  10026. */
  10027. Bone.prototype.getLocalMatrix = function () {
  10028. this._compose();
  10029. return this._localMatrix;
  10030. };
  10031. /**
  10032. * Gets the base matrix (initial matrix which remains unchanged)
  10033. * @returns a matrix
  10034. */
  10035. Bone.prototype.getBaseMatrix = function () {
  10036. return this._baseMatrix;
  10037. };
  10038. /**
  10039. * Gets the rest pose matrix
  10040. * @returns a matrix
  10041. */
  10042. Bone.prototype.getRestPose = function () {
  10043. return this._restPose;
  10044. };
  10045. /**
  10046. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  10047. */
  10048. Bone.prototype.getWorldMatrix = function () {
  10049. return this._worldTransform;
  10050. };
  10051. /**
  10052. * Sets the local matrix to rest pose matrix
  10053. */
  10054. Bone.prototype.returnToRest = function () {
  10055. this.updateMatrix(this._restPose.clone());
  10056. };
  10057. /**
  10058. * Gets the inverse of the absolute transform matrix.
  10059. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  10060. * @returns a matrix
  10061. */
  10062. Bone.prototype.getInvertedAbsoluteTransform = function () {
  10063. return this._invertedAbsoluteTransform;
  10064. };
  10065. /**
  10066. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  10067. * @returns a matrix
  10068. */
  10069. Bone.prototype.getAbsoluteTransform = function () {
  10070. return this._absoluteTransform;
  10071. };
  10072. /**
  10073. * Links with the given transform node.
  10074. * The local matrix of this bone is copied from the transform node every frame.
  10075. * @param transformNode defines the transform node to link to
  10076. */
  10077. Bone.prototype.linkTransformNode = function (transformNode) {
  10078. if (this._linkedTransformNode) {
  10079. this._skeleton._numBonesWithLinkedTransformNode--;
  10080. }
  10081. this._linkedTransformNode = transformNode;
  10082. if (this._linkedTransformNode) {
  10083. this._skeleton._numBonesWithLinkedTransformNode++;
  10084. }
  10085. };
  10086. // Properties (matches AbstractMesh properties)
  10087. /**
  10088. * Gets the node used to drive the bone's transformation
  10089. * @returns a transform node or null
  10090. */
  10091. Bone.prototype.getTransformNode = function () {
  10092. return this._linkedTransformNode;
  10093. };
  10094. Object.defineProperty(Bone.prototype, "position", {
  10095. /** Gets or sets current position (in local space) */
  10096. get: function () {
  10097. this._decompose();
  10098. return this._localPosition;
  10099. },
  10100. set: function (newPosition) {
  10101. this._decompose();
  10102. this._localPosition.copyFrom(newPosition);
  10103. this._markAsDirtyAndCompose();
  10104. },
  10105. enumerable: true,
  10106. configurable: true
  10107. });
  10108. Object.defineProperty(Bone.prototype, "rotation", {
  10109. /** Gets or sets current rotation (in local space) */
  10110. get: function () {
  10111. return this.getRotation();
  10112. },
  10113. set: function (newRotation) {
  10114. this.setRotation(newRotation);
  10115. },
  10116. enumerable: true,
  10117. configurable: true
  10118. });
  10119. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  10120. /** Gets or sets current rotation quaternion (in local space) */
  10121. get: function () {
  10122. this._decompose();
  10123. return this._localRotation;
  10124. },
  10125. set: function (newRotation) {
  10126. this.setRotationQuaternion(newRotation);
  10127. },
  10128. enumerable: true,
  10129. configurable: true
  10130. });
  10131. Object.defineProperty(Bone.prototype, "scaling", {
  10132. /** Gets or sets current scaling (in local space) */
  10133. get: function () {
  10134. return this.getScale();
  10135. },
  10136. set: function (newScaling) {
  10137. this.setScale(newScaling);
  10138. },
  10139. enumerable: true,
  10140. configurable: true
  10141. });
  10142. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  10143. /**
  10144. * Gets the animation properties override
  10145. */
  10146. get: function () {
  10147. return this._skeleton.animationPropertiesOverride;
  10148. },
  10149. enumerable: true,
  10150. configurable: true
  10151. });
  10152. // Methods
  10153. Bone.prototype._decompose = function () {
  10154. if (!this._needToDecompose) {
  10155. return;
  10156. }
  10157. this._needToDecompose = false;
  10158. if (!this._localScaling) {
  10159. this._localScaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10160. this._localRotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  10161. this._localPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10162. }
  10163. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  10164. };
  10165. Bone.prototype._compose = function () {
  10166. if (!this._needToCompose) {
  10167. return;
  10168. }
  10169. if (!this._localScaling) {
  10170. this._needToCompose = false;
  10171. return;
  10172. }
  10173. this._needToCompose = false;
  10174. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10175. };
  10176. /**
  10177. * Update the base and local matrices
  10178. * @param matrix defines the new base or local matrix
  10179. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10180. * @param updateLocalMatrix defines if the local matrix should be updated
  10181. */
  10182. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10183. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10184. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10185. this._baseMatrix.copyFrom(matrix);
  10186. if (updateDifferenceMatrix) {
  10187. this._updateDifferenceMatrix();
  10188. }
  10189. if (updateLocalMatrix) {
  10190. this._localMatrix.copyFrom(matrix);
  10191. this._markAsDirtyAndDecompose();
  10192. }
  10193. else {
  10194. this.markAsDirty();
  10195. }
  10196. };
  10197. /** @hidden */
  10198. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10199. if (updateChildren === void 0) { updateChildren = true; }
  10200. if (!rootMatrix) {
  10201. rootMatrix = this._baseMatrix;
  10202. }
  10203. if (this._parent) {
  10204. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10205. }
  10206. else {
  10207. this._absoluteTransform.copyFrom(rootMatrix);
  10208. }
  10209. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10210. if (updateChildren) {
  10211. for (var index = 0; index < this.children.length; index++) {
  10212. this.children[index]._updateDifferenceMatrix();
  10213. }
  10214. }
  10215. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10216. };
  10217. /**
  10218. * Flag the bone as dirty (Forcing it to update everything)
  10219. */
  10220. Bone.prototype.markAsDirty = function () {
  10221. this._currentRenderId++;
  10222. this._childUpdateId++;
  10223. this._skeleton._markAsDirty();
  10224. };
  10225. /** @hidden */
  10226. Bone.prototype._markAsDirtyAndCompose = function () {
  10227. this.markAsDirty();
  10228. this._needToCompose = true;
  10229. };
  10230. Bone.prototype._markAsDirtyAndDecompose = function () {
  10231. this.markAsDirty();
  10232. this._needToDecompose = true;
  10233. };
  10234. /**
  10235. * Translate the bone in local or world space
  10236. * @param vec The amount to translate the bone
  10237. * @param space The space that the translation is in
  10238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10239. */
  10240. Bone.prototype.translate = function (vec, space, mesh) {
  10241. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10242. var lm = this.getLocalMatrix();
  10243. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10244. lm.addAtIndex(12, vec.x);
  10245. lm.addAtIndex(13, vec.y);
  10246. lm.addAtIndex(14, vec.z);
  10247. }
  10248. else {
  10249. var wm = null;
  10250. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10251. if (mesh) {
  10252. wm = mesh.getWorldMatrix();
  10253. }
  10254. this._skeleton.computeAbsoluteTransforms();
  10255. var tmat = Bone._tmpMats[0];
  10256. var tvec = Bone._tmpVecs[0];
  10257. if (this._parent) {
  10258. if (mesh && wm) {
  10259. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10260. tmat.multiplyToRef(wm, tmat);
  10261. }
  10262. else {
  10263. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10264. }
  10265. }
  10266. tmat.setTranslationFromFloats(0, 0, 0);
  10267. tmat.invert();
  10268. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10269. lm.addAtIndex(12, tvec.x);
  10270. lm.addAtIndex(13, tvec.y);
  10271. lm.addAtIndex(14, tvec.z);
  10272. }
  10273. this._markAsDirtyAndDecompose();
  10274. };
  10275. /**
  10276. * Set the postion of the bone in local or world space
  10277. * @param position The position to set the bone
  10278. * @param space The space that the position is in
  10279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10280. */
  10281. Bone.prototype.setPosition = function (position, space, mesh) {
  10282. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10283. var lm = this.getLocalMatrix();
  10284. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10285. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10286. }
  10287. else {
  10288. var wm = null;
  10289. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10290. if (mesh) {
  10291. wm = mesh.getWorldMatrix();
  10292. }
  10293. this._skeleton.computeAbsoluteTransforms();
  10294. var tmat = Bone._tmpMats[0];
  10295. var vec = Bone._tmpVecs[0];
  10296. if (this._parent) {
  10297. if (mesh && wm) {
  10298. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10299. tmat.multiplyToRef(wm, tmat);
  10300. }
  10301. else {
  10302. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10303. }
  10304. }
  10305. tmat.invert();
  10306. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10307. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10308. }
  10309. this._markAsDirtyAndDecompose();
  10310. };
  10311. /**
  10312. * Set the absolute position of the bone (world space)
  10313. * @param position The position to set the bone
  10314. * @param mesh The mesh that this bone is attached to
  10315. */
  10316. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10317. this.setPosition(position, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD, mesh);
  10318. };
  10319. /**
  10320. * Scale the bone on the x, y and z axes (in local space)
  10321. * @param x The amount to scale the bone on the x axis
  10322. * @param y The amount to scale the bone on the y axis
  10323. * @param z The amount to scale the bone on the z axis
  10324. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10325. */
  10326. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10327. if (scaleChildren === void 0) { scaleChildren = false; }
  10328. var locMat = this.getLocalMatrix();
  10329. // Apply new scaling on top of current local matrix
  10330. var scaleMat = Bone._tmpMats[0];
  10331. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10332. scaleMat.multiplyToRef(locMat, locMat);
  10333. // Invert scaling matrix and apply the inverse to all children
  10334. scaleMat.invert();
  10335. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10336. var child = _a[_i];
  10337. var cm = child.getLocalMatrix();
  10338. cm.multiplyToRef(scaleMat, cm);
  10339. cm.multiplyAtIndex(12, x);
  10340. cm.multiplyAtIndex(13, y);
  10341. cm.multiplyAtIndex(14, z);
  10342. child._markAsDirtyAndDecompose();
  10343. }
  10344. this._markAsDirtyAndDecompose();
  10345. if (scaleChildren) {
  10346. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10347. var child = _c[_b];
  10348. child.scale(x, y, z, scaleChildren);
  10349. }
  10350. }
  10351. };
  10352. /**
  10353. * Set the bone scaling in local space
  10354. * @param scale defines the scaling vector
  10355. */
  10356. Bone.prototype.setScale = function (scale) {
  10357. this._decompose();
  10358. this._localScaling.copyFrom(scale);
  10359. this._markAsDirtyAndCompose();
  10360. };
  10361. /**
  10362. * Gets the current scaling in local space
  10363. * @returns the current scaling vector
  10364. */
  10365. Bone.prototype.getScale = function () {
  10366. this._decompose();
  10367. return this._localScaling;
  10368. };
  10369. /**
  10370. * Gets the current scaling in local space and stores it in a target vector
  10371. * @param result defines the target vector
  10372. */
  10373. Bone.prototype.getScaleToRef = function (result) {
  10374. this._decompose();
  10375. result.copyFrom(this._localScaling);
  10376. };
  10377. /**
  10378. * Set the yaw, pitch, and roll of the bone in local or world space
  10379. * @param yaw The rotation of the bone on the y axis
  10380. * @param pitch The rotation of the bone on the x axis
  10381. * @param roll The rotation of the bone on the z axis
  10382. * @param space The space that the axes of rotation are in
  10383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10384. */
  10385. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10386. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10387. if (space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10388. var quat = Bone._tmpQuat;
  10389. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10390. this.setRotationQuaternion(quat, space, mesh);
  10391. return;
  10392. }
  10393. var rotMatInv = Bone._tmpMats[0];
  10394. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10395. return;
  10396. }
  10397. var rotMat = Bone._tmpMats[1];
  10398. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10399. rotMatInv.multiplyToRef(rotMat, rotMat);
  10400. this._rotateWithMatrix(rotMat, space, mesh);
  10401. };
  10402. /**
  10403. * Add a rotation to the bone on an axis in local or world space
  10404. * @param axis The axis to rotate the bone on
  10405. * @param amount The amount to rotate the bone
  10406. * @param space The space that the axis is in
  10407. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10408. */
  10409. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10410. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10411. var rmat = Bone._tmpMats[0];
  10412. rmat.setTranslationFromFloats(0, 0, 0);
  10413. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10414. this._rotateWithMatrix(rmat, space, mesh);
  10415. };
  10416. /**
  10417. * Set the rotation of the bone to a particular axis angle in local or world space
  10418. * @param axis The axis to rotate the bone on
  10419. * @param angle The angle that the bone should be rotated to
  10420. * @param space The space that the axis is in
  10421. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10422. */
  10423. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10424. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10425. if (space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10426. var quat = Bone._tmpQuat;
  10427. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10428. this.setRotationQuaternion(quat, space, mesh);
  10429. return;
  10430. }
  10431. var rotMatInv = Bone._tmpMats[0];
  10432. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10433. return;
  10434. }
  10435. var rotMat = Bone._tmpMats[1];
  10436. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10437. rotMatInv.multiplyToRef(rotMat, rotMat);
  10438. this._rotateWithMatrix(rotMat, space, mesh);
  10439. };
  10440. /**
  10441. * Set the euler rotation of the bone in local of world space
  10442. * @param rotation The euler rotation that the bone should be set to
  10443. * @param space The space that the rotation is in
  10444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10445. */
  10446. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10447. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10448. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10449. };
  10450. /**
  10451. * Set the quaternion rotation of the bone in local of world space
  10452. * @param quat The quaternion rotation that the bone should be set to
  10453. * @param space The space that the rotation is in
  10454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10455. */
  10456. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10457. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10458. if (space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10459. this._decompose();
  10460. this._localRotation.copyFrom(quat);
  10461. this._markAsDirtyAndCompose();
  10462. return;
  10463. }
  10464. var rotMatInv = Bone._tmpMats[0];
  10465. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10466. return;
  10467. }
  10468. var rotMat = Bone._tmpMats[1];
  10469. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10470. rotMatInv.multiplyToRef(rotMat, rotMat);
  10471. this._rotateWithMatrix(rotMat, space, mesh);
  10472. };
  10473. /**
  10474. * Set the rotation matrix of the bone in local of world space
  10475. * @param rotMat The rotation matrix that the bone should be set to
  10476. * @param space The space that the rotation is in
  10477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10478. */
  10479. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10480. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10481. if (space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10482. var quat = Bone._tmpQuat;
  10483. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10484. this.setRotationQuaternion(quat, space, mesh);
  10485. return;
  10486. }
  10487. var rotMatInv = Bone._tmpMats[0];
  10488. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10489. return;
  10490. }
  10491. var rotMat2 = Bone._tmpMats[1];
  10492. rotMat2.copyFrom(rotMat);
  10493. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10494. this._rotateWithMatrix(rotMat2, space, mesh);
  10495. };
  10496. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10497. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10498. var lmat = this.getLocalMatrix();
  10499. var lx = lmat.m[12];
  10500. var ly = lmat.m[13];
  10501. var lz = lmat.m[14];
  10502. var parent = this.getParent();
  10503. var parentScale = Bone._tmpMats[3];
  10504. var parentScaleInv = Bone._tmpMats[4];
  10505. if (parent && space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD) {
  10506. if (mesh) {
  10507. parentScale.copyFrom(mesh.getWorldMatrix());
  10508. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10509. }
  10510. else {
  10511. parentScale.copyFrom(parent.getAbsoluteTransform());
  10512. }
  10513. parentScaleInv.copyFrom(parentScale);
  10514. parentScaleInv.invert();
  10515. lmat.multiplyToRef(parentScale, lmat);
  10516. lmat.multiplyToRef(rmat, lmat);
  10517. lmat.multiplyToRef(parentScaleInv, lmat);
  10518. }
  10519. else {
  10520. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD && mesh) {
  10521. parentScale.copyFrom(mesh.getWorldMatrix());
  10522. parentScaleInv.copyFrom(parentScale);
  10523. parentScaleInv.invert();
  10524. lmat.multiplyToRef(parentScale, lmat);
  10525. lmat.multiplyToRef(rmat, lmat);
  10526. lmat.multiplyToRef(parentScaleInv, lmat);
  10527. }
  10528. else {
  10529. lmat.multiplyToRef(rmat, lmat);
  10530. }
  10531. }
  10532. lmat.setTranslationFromFloats(lx, ly, lz);
  10533. this.computeAbsoluteTransforms();
  10534. this._markAsDirtyAndDecompose();
  10535. };
  10536. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10537. var scaleMatrix = Bone._tmpMats[2];
  10538. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10539. if (mesh) {
  10540. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10541. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10542. }
  10543. rotMatInv.invert();
  10544. if (isNaN(rotMatInv.m[0])) {
  10545. // Matrix failed to invert.
  10546. // This can happen if scale is zero for example.
  10547. return false;
  10548. }
  10549. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10550. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10551. return true;
  10552. };
  10553. /**
  10554. * Get the position of the bone in local or world space
  10555. * @param space The space that the returned position is in
  10556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10557. * @returns The position of the bone
  10558. */
  10559. Bone.prototype.getPosition = function (space, mesh) {
  10560. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10561. if (mesh === void 0) { mesh = null; }
  10562. var pos = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10563. this.getPositionToRef(space, mesh, pos);
  10564. return pos;
  10565. };
  10566. /**
  10567. * Copy the position of the bone to a vector3 in local or world space
  10568. * @param space The space that the returned position is in
  10569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10570. * @param result The vector3 to copy the position to
  10571. */
  10572. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10573. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10574. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10575. var lm = this.getLocalMatrix();
  10576. result.x = lm.m[12];
  10577. result.y = lm.m[13];
  10578. result.z = lm.m[14];
  10579. }
  10580. else {
  10581. var wm = null;
  10582. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10583. if (mesh) {
  10584. wm = mesh.getWorldMatrix();
  10585. }
  10586. this._skeleton.computeAbsoluteTransforms();
  10587. var tmat = Bone._tmpMats[0];
  10588. if (mesh && wm) {
  10589. tmat.copyFrom(this.getAbsoluteTransform());
  10590. tmat.multiplyToRef(wm, tmat);
  10591. }
  10592. else {
  10593. tmat = this.getAbsoluteTransform();
  10594. }
  10595. result.x = tmat.m[12];
  10596. result.y = tmat.m[13];
  10597. result.z = tmat.m[14];
  10598. }
  10599. };
  10600. /**
  10601. * Get the absolute position of the bone (world space)
  10602. * @param mesh The mesh that this bone is attached to
  10603. * @returns The absolute position of the bone
  10604. */
  10605. Bone.prototype.getAbsolutePosition = function (mesh) {
  10606. if (mesh === void 0) { mesh = null; }
  10607. var pos = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10608. this.getPositionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD, mesh, pos);
  10609. return pos;
  10610. };
  10611. /**
  10612. * Copy the absolute position of the bone (world space) to the result param
  10613. * @param mesh The mesh that this bone is attached to
  10614. * @param result The vector3 to copy the absolute position to
  10615. */
  10616. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10617. this.getPositionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD, mesh, result);
  10618. };
  10619. /**
  10620. * Compute the absolute transforms of this bone and its children
  10621. */
  10622. Bone.prototype.computeAbsoluteTransforms = function () {
  10623. this._compose();
  10624. if (this._parent) {
  10625. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10626. }
  10627. else {
  10628. this._absoluteTransform.copyFrom(this._localMatrix);
  10629. var poseMatrix = this._skeleton.getPoseMatrix();
  10630. if (poseMatrix) {
  10631. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10632. }
  10633. }
  10634. var children = this.children;
  10635. var len = children.length;
  10636. for (var i = 0; i < len; i++) {
  10637. children[i].computeAbsoluteTransforms();
  10638. }
  10639. };
  10640. /**
  10641. * Get the world direction from an axis that is in the local space of the bone
  10642. * @param localAxis The local direction that is used to compute the world direction
  10643. * @param mesh The mesh that this bone is attached to
  10644. * @returns The world direction
  10645. */
  10646. Bone.prototype.getDirection = function (localAxis, mesh) {
  10647. if (mesh === void 0) { mesh = null; }
  10648. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10649. this.getDirectionToRef(localAxis, mesh, result);
  10650. return result;
  10651. };
  10652. /**
  10653. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10654. * @param localAxis The local direction that is used to compute the world direction
  10655. * @param mesh The mesh that this bone is attached to
  10656. * @param result The vector3 that the world direction will be copied to
  10657. */
  10658. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10659. if (mesh === void 0) { mesh = null; }
  10660. var wm = null;
  10661. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10662. if (mesh) {
  10663. wm = mesh.getWorldMatrix();
  10664. }
  10665. this._skeleton.computeAbsoluteTransforms();
  10666. var mat = Bone._tmpMats[0];
  10667. mat.copyFrom(this.getAbsoluteTransform());
  10668. if (mesh && wm) {
  10669. mat.multiplyToRef(wm, mat);
  10670. }
  10671. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10672. result.normalize();
  10673. };
  10674. /**
  10675. * Get the euler rotation of the bone in local or world space
  10676. * @param space The space that the rotation should be in
  10677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10678. * @returns The euler rotation
  10679. */
  10680. Bone.prototype.getRotation = function (space, mesh) {
  10681. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10682. if (mesh === void 0) { mesh = null; }
  10683. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10684. this.getRotationToRef(space, mesh, result);
  10685. return result;
  10686. };
  10687. /**
  10688. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10689. * @param space The space that the rotation should be in
  10690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10691. * @param result The vector3 that the rotation should be copied to
  10692. */
  10693. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10694. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10695. if (mesh === void 0) { mesh = null; }
  10696. var quat = Bone._tmpQuat;
  10697. this.getRotationQuaternionToRef(space, mesh, quat);
  10698. quat.toEulerAnglesToRef(result);
  10699. };
  10700. /**
  10701. * Get the quaternion rotation of the bone in either local or world space
  10702. * @param space The space that the rotation should be in
  10703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10704. * @returns The quaternion rotation
  10705. */
  10706. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10707. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10708. if (mesh === void 0) { mesh = null; }
  10709. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10710. this.getRotationQuaternionToRef(space, mesh, result);
  10711. return result;
  10712. };
  10713. /**
  10714. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10715. * @param space The space that the rotation should be in
  10716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10717. * @param result The quaternion that the rotation should be copied to
  10718. */
  10719. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10720. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10721. if (mesh === void 0) { mesh = null; }
  10722. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10723. this._decompose();
  10724. result.copyFrom(this._localRotation);
  10725. }
  10726. else {
  10727. var mat = Bone._tmpMats[0];
  10728. var amat = this.getAbsoluteTransform();
  10729. if (mesh) {
  10730. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10731. }
  10732. else {
  10733. mat.copyFrom(amat);
  10734. }
  10735. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10736. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10737. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10738. mat.decompose(undefined, result, undefined);
  10739. }
  10740. };
  10741. /**
  10742. * Get the rotation matrix of the bone in local or world space
  10743. * @param space The space that the rotation should be in
  10744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10745. * @returns The rotation matrix
  10746. */
  10747. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10748. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10749. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10750. this.getRotationMatrixToRef(space, mesh, result);
  10751. return result;
  10752. };
  10753. /**
  10754. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10755. * @param space The space that the rotation should be in
  10756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10757. * @param result The quaternion that the rotation should be copied to
  10758. */
  10759. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10760. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  10761. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  10762. this.getLocalMatrix().getRotationMatrixToRef(result);
  10763. }
  10764. else {
  10765. var mat = Bone._tmpMats[0];
  10766. var amat = this.getAbsoluteTransform();
  10767. if (mesh) {
  10768. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10769. }
  10770. else {
  10771. mat.copyFrom(amat);
  10772. }
  10773. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10774. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10775. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10776. mat.getRotationMatrixToRef(result);
  10777. }
  10778. };
  10779. /**
  10780. * Get the world position of a point that is in the local space of the bone
  10781. * @param position The local position
  10782. * @param mesh The mesh that this bone is attached to
  10783. * @returns The world position
  10784. */
  10785. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10786. if (mesh === void 0) { mesh = null; }
  10787. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10788. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10789. return result;
  10790. };
  10791. /**
  10792. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10793. * @param position The local position
  10794. * @param mesh The mesh that this bone is attached to
  10795. * @param result The vector3 that the world position should be copied to
  10796. */
  10797. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10798. if (mesh === void 0) { mesh = null; }
  10799. var wm = null;
  10800. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10801. if (mesh) {
  10802. wm = mesh.getWorldMatrix();
  10803. }
  10804. this._skeleton.computeAbsoluteTransforms();
  10805. var tmat = Bone._tmpMats[0];
  10806. if (mesh && wm) {
  10807. tmat.copyFrom(this.getAbsoluteTransform());
  10808. tmat.multiplyToRef(wm, tmat);
  10809. }
  10810. else {
  10811. tmat = this.getAbsoluteTransform();
  10812. }
  10813. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10814. };
  10815. /**
  10816. * Get the local position of a point that is in world space
  10817. * @param position The world position
  10818. * @param mesh The mesh that this bone is attached to
  10819. * @returns The local position
  10820. */
  10821. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10822. if (mesh === void 0) { mesh = null; }
  10823. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10824. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10825. return result;
  10826. };
  10827. /**
  10828. * Get the local position of a point that is in world space and copy it to the result param
  10829. * @param position The world position
  10830. * @param mesh The mesh that this bone is attached to
  10831. * @param result The vector3 that the local position should be copied to
  10832. */
  10833. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10834. if (mesh === void 0) { mesh = null; }
  10835. var wm = null;
  10836. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10837. if (mesh) {
  10838. wm = mesh.getWorldMatrix();
  10839. }
  10840. this._skeleton.computeAbsoluteTransforms();
  10841. var tmat = Bone._tmpMats[0];
  10842. tmat.copyFrom(this.getAbsoluteTransform());
  10843. if (mesh && wm) {
  10844. tmat.multiplyToRef(wm, tmat);
  10845. }
  10846. tmat.invert();
  10847. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10848. };
  10849. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10850. Bone._tmpQuat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10851. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10852. return Bone;
  10853. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10854. /***/ }),
  10855. /***/ "./Bones/boneIKController.ts":
  10856. /*!***********************************!*\
  10857. !*** ./Bones/boneIKController.ts ***!
  10858. \***********************************/
  10859. /*! exports provided: BoneIKController */
  10860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10861. "use strict";
  10862. __webpack_require__.r(__webpack_exports__);
  10863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10864. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  10865. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  10866. /**
  10867. * Class used to apply inverse kinematics to bones
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10869. */
  10870. var BoneIKController = /** @class */ (function () {
  10871. /**
  10872. * Creates a new BoneIKController
  10873. * @param mesh defines the mesh to control
  10874. * @param bone defines the bone to control
  10875. * @param options defines options to set up the controller
  10876. */
  10877. function BoneIKController(mesh, bone, options) {
  10878. /**
  10879. * Gets or sets the target position
  10880. */
  10881. this.targetPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10882. /**
  10883. * Gets or sets the pole target position
  10884. */
  10885. this.poleTargetPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10886. /**
  10887. * Gets or sets the pole target local offset
  10888. */
  10889. this.poleTargetLocalOffset = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10890. /**
  10891. * Gets or sets the pole angle
  10892. */
  10893. this.poleAngle = 0;
  10894. /**
  10895. * 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)
  10896. */
  10897. this.slerpAmount = 1;
  10898. this._bone1Quat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10899. this._bone1Mat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10900. this._bone2Ang = Math.PI;
  10901. this._maxAngle = Math.PI;
  10902. this._rightHandedSystem = false;
  10903. this._bendAxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10904. this._slerping = false;
  10905. this._adjustRoll = 0;
  10906. this._bone2 = bone;
  10907. this._bone1 = bone.getParent();
  10908. if (!this._bone1) {
  10909. return;
  10910. }
  10911. this.mesh = mesh;
  10912. var bonePos = bone.getPosition();
  10913. if (bone.getAbsoluteTransform().determinant() > 0) {
  10914. this._rightHandedSystem = true;
  10915. this._bendAxis.x = 0;
  10916. this._bendAxis.y = 0;
  10917. this._bendAxis.z = -1;
  10918. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10919. this._adjustRoll = Math.PI * .5;
  10920. this._bendAxis.z = 1;
  10921. }
  10922. }
  10923. if (this._bone1.length) {
  10924. var boneScale1 = this._bone1.getScale();
  10925. var boneScale2 = this._bone2.getScale();
  10926. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10927. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10928. }
  10929. else if (this._bone1.children[0]) {
  10930. mesh.computeWorldMatrix(true);
  10931. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10932. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10933. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10934. this._bone1Length = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10935. this._bone2Length = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10936. }
  10937. this._bone1.getRotationMatrixToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, this._bone1Mat);
  10938. this.maxAngle = Math.PI;
  10939. if (options) {
  10940. if (options.targetMesh) {
  10941. this.targetMesh = options.targetMesh;
  10942. this.targetMesh.computeWorldMatrix(true);
  10943. }
  10944. if (options.poleTargetMesh) {
  10945. this.poleTargetMesh = options.poleTargetMesh;
  10946. this.poleTargetMesh.computeWorldMatrix(true);
  10947. }
  10948. else if (options.poleTargetBone) {
  10949. this.poleTargetBone = options.poleTargetBone;
  10950. }
  10951. else if (this._bone1.getParent()) {
  10952. this.poleTargetBone = this._bone1.getParent();
  10953. }
  10954. if (options.poleTargetLocalOffset) {
  10955. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10956. }
  10957. if (options.poleAngle) {
  10958. this.poleAngle = options.poleAngle;
  10959. }
  10960. if (options.bendAxis) {
  10961. this._bendAxis.copyFrom(options.bendAxis);
  10962. }
  10963. if (options.maxAngle) {
  10964. this.maxAngle = options.maxAngle;
  10965. }
  10966. if (options.slerpAmount) {
  10967. this.slerpAmount = options.slerpAmount;
  10968. }
  10969. }
  10970. }
  10971. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10972. /**
  10973. * Gets or sets maximum allowed angle
  10974. */
  10975. get: function () {
  10976. return this._maxAngle;
  10977. },
  10978. set: function (value) {
  10979. this._setMaxAngle(value);
  10980. },
  10981. enumerable: true,
  10982. configurable: true
  10983. });
  10984. BoneIKController.prototype._setMaxAngle = function (ang) {
  10985. if (ang < 0) {
  10986. ang = 0;
  10987. }
  10988. if (ang > Math.PI || ang == undefined) {
  10989. ang = Math.PI;
  10990. }
  10991. this._maxAngle = ang;
  10992. var a = this._bone1Length;
  10993. var b = this._bone2Length;
  10994. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10995. };
  10996. /**
  10997. * Force the controller to update the bones
  10998. */
  10999. BoneIKController.prototype.update = function () {
  11000. var bone1 = this._bone1;
  11001. if (!bone1) {
  11002. return;
  11003. }
  11004. var target = this.targetPosition;
  11005. var poleTarget = this.poleTargetPosition;
  11006. var mat1 = BoneIKController._tmpMats[0];
  11007. var mat2 = BoneIKController._tmpMats[1];
  11008. if (this.targetMesh) {
  11009. target.copyFrom(this.targetMesh.getAbsolutePosition());
  11010. }
  11011. if (this.poleTargetBone) {
  11012. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  11013. }
  11014. else if (this.poleTargetMesh) {
  11015. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  11016. }
  11017. var bonePos = BoneIKController._tmpVecs[0];
  11018. var zaxis = BoneIKController._tmpVecs[1];
  11019. var xaxis = BoneIKController._tmpVecs[2];
  11020. var yaxis = BoneIKController._tmpVecs[3];
  11021. var upAxis = BoneIKController._tmpVecs[4];
  11022. var _tmpQuat = BoneIKController._tmpQuat;
  11023. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  11024. poleTarget.subtractToRef(bonePos, upAxis);
  11025. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  11026. upAxis.y = 1;
  11027. }
  11028. else {
  11029. upAxis.normalize();
  11030. }
  11031. target.subtractToRef(bonePos, yaxis);
  11032. yaxis.normalize();
  11033. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  11034. zaxis.normalize();
  11035. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  11036. xaxis.normalize();
  11037. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  11038. var a = this._bone1Length;
  11039. var b = this._bone2Length;
  11040. var c = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  11041. if (this._maxReach > 0) {
  11042. c = Math.min(this._maxReach, c);
  11043. }
  11044. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  11045. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  11046. if (acosa > 1) {
  11047. acosa = 1;
  11048. }
  11049. if (acosb > 1) {
  11050. acosb = 1;
  11051. }
  11052. if (acosa < -1) {
  11053. acosa = -1;
  11054. }
  11055. if (acosb < -1) {
  11056. acosb = -1;
  11057. }
  11058. var angA = Math.acos(acosa);
  11059. var angB = Math.acos(acosb);
  11060. var angC = -angA - angB;
  11061. if (this._rightHandedSystem) {
  11062. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  11063. mat2.multiplyToRef(mat1, mat1);
  11064. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  11065. mat2.multiplyToRef(mat1, mat1);
  11066. }
  11067. else {
  11068. var _tmpVec = BoneIKController._tmpVecs[5];
  11069. _tmpVec.copyFrom(this._bendAxis);
  11070. _tmpVec.x *= -1;
  11071. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  11072. mat2.multiplyToRef(mat1, mat1);
  11073. }
  11074. if (this.poleAngle) {
  11075. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  11076. mat1.multiplyToRef(mat2, mat1);
  11077. }
  11078. if (this._bone1) {
  11079. if (this.slerpAmount < 1) {
  11080. if (!this._slerping) {
  11081. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  11082. }
  11083. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  11084. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  11085. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  11086. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11087. this._slerping = true;
  11088. }
  11089. else {
  11090. this._bone1.setRotationMatrix(mat1, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11091. this._bone1Mat.copyFrom(mat1);
  11092. this._slerping = false;
  11093. }
  11094. }
  11095. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  11096. this._bone2Ang = angC;
  11097. };
  11098. BoneIKController._tmpVecs = [_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  11099. BoneIKController._tmpQuat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  11100. BoneIKController._tmpMats = [_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  11101. return BoneIKController;
  11102. }());
  11103. /***/ }),
  11104. /***/ "./Bones/boneLookController.ts":
  11105. /*!*************************************!*\
  11106. !*** ./Bones/boneLookController.ts ***!
  11107. \*************************************/
  11108. /*! exports provided: BoneLookController */
  11109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11110. "use strict";
  11111. __webpack_require__.r(__webpack_exports__);
  11112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  11113. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  11114. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  11115. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  11116. /**
  11117. * Class used to make a bone look toward a point in space
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  11119. */
  11120. var BoneLookController = /** @class */ (function () {
  11121. /**
  11122. * Create a BoneLookController
  11123. * @param mesh the mesh that the bone belongs to
  11124. * @param bone the bone that will be looking to the target
  11125. * @param target the target Vector3 to look at
  11126. * @param options optional settings:
  11127. * * maxYaw: the maximum angle the bone will yaw to
  11128. * * minYaw: the minimum angle the bone will yaw to
  11129. * * maxPitch: the maximum angle the bone will pitch to
  11130. * * minPitch: the minimum angle the bone will yaw to
  11131. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  11132. * * upAxis: the up axis of the coordinate system
  11133. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  11134. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  11135. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  11136. * * adjustYaw: used to make an adjustment to the yaw of the bone
  11137. * * adjustPitch: used to make an adjustment to the pitch of the bone
  11138. * * adjustRoll: used to make an adjustment to the roll of the bone
  11139. **/
  11140. function BoneLookController(mesh, bone, target, options) {
  11141. /**
  11142. * The up axis of the coordinate system that is used when the bone is rotated
  11143. */
  11144. this.upAxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  11145. /**
  11146. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  11147. */
  11148. this.upAxisSpace = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].LOCAL;
  11149. /**
  11150. * Used to make an adjustment to the yaw of the bone
  11151. */
  11152. this.adjustYaw = 0;
  11153. /**
  11154. * Used to make an adjustment to the pitch of the bone
  11155. */
  11156. this.adjustPitch = 0;
  11157. /**
  11158. * Used to make an adjustment to the roll of the bone
  11159. */
  11160. this.adjustRoll = 0;
  11161. /**
  11162. * 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)
  11163. */
  11164. this.slerpAmount = 1;
  11165. this._boneQuat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11166. this._slerping = false;
  11167. this._firstFrameSkipped = false;
  11168. this._fowardAxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  11169. this.mesh = mesh;
  11170. this.bone = bone;
  11171. this.target = target;
  11172. if (options) {
  11173. if (options.adjustYaw) {
  11174. this.adjustYaw = options.adjustYaw;
  11175. }
  11176. if (options.adjustPitch) {
  11177. this.adjustPitch = options.adjustPitch;
  11178. }
  11179. if (options.adjustRoll) {
  11180. this.adjustRoll = options.adjustRoll;
  11181. }
  11182. if (options.maxYaw != null) {
  11183. this.maxYaw = options.maxYaw;
  11184. }
  11185. else {
  11186. this.maxYaw = Math.PI;
  11187. }
  11188. if (options.minYaw != null) {
  11189. this.minYaw = options.minYaw;
  11190. }
  11191. else {
  11192. this.minYaw = -Math.PI;
  11193. }
  11194. if (options.maxPitch != null) {
  11195. this.maxPitch = options.maxPitch;
  11196. }
  11197. else {
  11198. this.maxPitch = Math.PI;
  11199. }
  11200. if (options.minPitch != null) {
  11201. this.minPitch = options.minPitch;
  11202. }
  11203. else {
  11204. this.minPitch = -Math.PI;
  11205. }
  11206. if (options.slerpAmount != null) {
  11207. this.slerpAmount = options.slerpAmount;
  11208. }
  11209. if (options.upAxis != null) {
  11210. this.upAxis = options.upAxis;
  11211. }
  11212. if (options.upAxisSpace != null) {
  11213. this.upAxisSpace = options.upAxisSpace;
  11214. }
  11215. if (options.yawAxis != null || options.pitchAxis != null) {
  11216. var newYawAxis = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y;
  11217. var newPitchAxis = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Axis"].X;
  11218. if (options.yawAxis != null) {
  11219. newYawAxis = options.yawAxis.clone();
  11220. newYawAxis.normalize();
  11221. }
  11222. if (options.pitchAxis != null) {
  11223. newPitchAxis = options.pitchAxis.clone();
  11224. newPitchAxis.normalize();
  11225. }
  11226. var newRollAxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11227. this._transformYawPitch = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11228. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11229. this._transformYawPitchInv = this._transformYawPitch.clone();
  11230. this._transformYawPitch.invert();
  11231. }
  11232. }
  11233. if (!bone.getParent() && this.upAxisSpace == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].BONE) {
  11234. this.upAxisSpace = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].LOCAL;
  11235. }
  11236. }
  11237. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11238. /**
  11239. * Gets or sets the minimum yaw angle that the bone can look to
  11240. */
  11241. get: function () {
  11242. return this._minYaw;
  11243. },
  11244. set: function (value) {
  11245. this._minYaw = value;
  11246. this._minYawSin = Math.sin(value);
  11247. this._minYawCos = Math.cos(value);
  11248. if (this._maxYaw != null) {
  11249. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11250. this._yawRange = this._maxYaw - this._minYaw;
  11251. }
  11252. },
  11253. enumerable: true,
  11254. configurable: true
  11255. });
  11256. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11257. /**
  11258. * Gets or sets the maximum yaw angle that the bone can look to
  11259. */
  11260. get: function () {
  11261. return this._maxYaw;
  11262. },
  11263. set: function (value) {
  11264. this._maxYaw = value;
  11265. this._maxYawSin = Math.sin(value);
  11266. this._maxYawCos = Math.cos(value);
  11267. if (this._minYaw != null) {
  11268. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11269. this._yawRange = this._maxYaw - this._minYaw;
  11270. }
  11271. },
  11272. enumerable: true,
  11273. configurable: true
  11274. });
  11275. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11276. /**
  11277. * Gets or sets the minimum pitch angle that the bone can look to
  11278. */
  11279. get: function () {
  11280. return this._minPitch;
  11281. },
  11282. set: function (value) {
  11283. this._minPitch = value;
  11284. this._minPitchTan = Math.tan(value);
  11285. },
  11286. enumerable: true,
  11287. configurable: true
  11288. });
  11289. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11290. /**
  11291. * Gets or sets the maximum pitch angle that the bone can look to
  11292. */
  11293. get: function () {
  11294. return this._maxPitch;
  11295. },
  11296. set: function (value) {
  11297. this._maxPitch = value;
  11298. this._maxPitchTan = Math.tan(value);
  11299. },
  11300. enumerable: true,
  11301. configurable: true
  11302. });
  11303. /**
  11304. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11305. */
  11306. BoneLookController.prototype.update = function () {
  11307. //skip the first frame when slerping so that the mesh rotation is correct
  11308. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11309. this._firstFrameSkipped = true;
  11310. return;
  11311. }
  11312. var bone = this.bone;
  11313. var bonePos = BoneLookController._tmpVecs[0];
  11314. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11315. var target = this.target;
  11316. var _tmpMat1 = BoneLookController._tmpMats[0];
  11317. var _tmpMat2 = BoneLookController._tmpMats[1];
  11318. var mesh = this.mesh;
  11319. var parentBone = bone.getParent();
  11320. var upAxis = BoneLookController._tmpVecs[1];
  11321. upAxis.copyFrom(this.upAxis);
  11322. if (this.upAxisSpace == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].BONE && parentBone) {
  11323. if (this._transformYawPitch) {
  11324. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11325. }
  11326. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11327. }
  11328. else if (this.upAxisSpace == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].LOCAL) {
  11329. mesh.getDirectionToRef(upAxis, upAxis);
  11330. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11331. upAxis.normalize();
  11332. }
  11333. }
  11334. var checkYaw = false;
  11335. var checkPitch = false;
  11336. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11337. checkYaw = true;
  11338. }
  11339. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11340. checkPitch = true;
  11341. }
  11342. if (checkYaw || checkPitch) {
  11343. var spaceMat = BoneLookController._tmpMats[2];
  11344. var spaceMatInv = BoneLookController._tmpMats[3];
  11345. if (this.upAxisSpace == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11346. parentBone.getRotationMatrixToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, this.mesh, spaceMat);
  11347. }
  11348. else if (this.upAxisSpace == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11349. spaceMat.copyFrom(mesh.getWorldMatrix());
  11350. }
  11351. else {
  11352. var forwardAxis = BoneLookController._tmpVecs[2];
  11353. forwardAxis.copyFrom(this._fowardAxis);
  11354. if (this._transformYawPitch) {
  11355. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11356. }
  11357. if (parentBone) {
  11358. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11359. }
  11360. else {
  11361. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11362. }
  11363. var rightAxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11364. rightAxis.normalize();
  11365. var forwardAxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11366. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11367. }
  11368. spaceMat.invertToRef(spaceMatInv);
  11369. var xzlen = null;
  11370. if (checkPitch) {
  11371. var localTarget = BoneLookController._tmpVecs[3];
  11372. target.subtractToRef(bonePos, localTarget);
  11373. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11374. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11375. var pitch = Math.atan2(localTarget.y, xzlen);
  11376. var newPitch = pitch;
  11377. if (pitch > this._maxPitch) {
  11378. localTarget.y = this._maxPitchTan * xzlen;
  11379. newPitch = this._maxPitch;
  11380. }
  11381. else if (pitch < this._minPitch) {
  11382. localTarget.y = this._minPitchTan * xzlen;
  11383. newPitch = this._minPitch;
  11384. }
  11385. if (pitch != newPitch) {
  11386. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11387. localTarget.addInPlace(bonePos);
  11388. target = localTarget;
  11389. }
  11390. }
  11391. if (checkYaw) {
  11392. var localTarget = BoneLookController._tmpVecs[4];
  11393. target.subtractToRef(bonePos, localTarget);
  11394. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11395. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11396. var newYaw = yaw;
  11397. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11398. if (xzlen == null) {
  11399. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11400. }
  11401. if (this._yawRange > Math.PI) {
  11402. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11403. localTarget.z = this._maxYawCos * xzlen;
  11404. localTarget.x = this._maxYawSin * xzlen;
  11405. newYaw = this._maxYaw;
  11406. }
  11407. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11408. localTarget.z = this._minYawCos * xzlen;
  11409. localTarget.x = this._minYawSin * xzlen;
  11410. newYaw = this._minYaw;
  11411. }
  11412. }
  11413. else {
  11414. if (yaw > this._maxYaw) {
  11415. localTarget.z = this._maxYawCos * xzlen;
  11416. localTarget.x = this._maxYawSin * xzlen;
  11417. newYaw = this._maxYaw;
  11418. }
  11419. else if (yaw < this._minYaw) {
  11420. localTarget.z = this._minYawCos * xzlen;
  11421. localTarget.x = this._minYawSin * xzlen;
  11422. newYaw = this._minYaw;
  11423. }
  11424. }
  11425. }
  11426. if (this._slerping && this._yawRange > Math.PI) {
  11427. //are we going to be crossing into the min/max region?
  11428. var boneFwd = BoneLookController._tmpVecs[8];
  11429. boneFwd.copyFrom(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z);
  11430. if (this._transformYawPitch) {
  11431. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11432. }
  11433. var boneRotMat = BoneLookController._tmpMats[4];
  11434. this._boneQuat.toRotationMatrix(boneRotMat);
  11435. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11436. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11437. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11438. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11439. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11440. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11441. if (angBtwTar > angBtwMidYaw) {
  11442. if (xzlen == null) {
  11443. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11444. }
  11445. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11446. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11447. if (angBtwMin < angBtwMax) {
  11448. newYaw = boneYaw + Math.PI * .75;
  11449. localTarget.z = Math.cos(newYaw) * xzlen;
  11450. localTarget.x = Math.sin(newYaw) * xzlen;
  11451. }
  11452. else {
  11453. newYaw = boneYaw - Math.PI * .75;
  11454. localTarget.z = Math.cos(newYaw) * xzlen;
  11455. localTarget.x = Math.sin(newYaw) * xzlen;
  11456. }
  11457. }
  11458. }
  11459. if (yaw != newYaw) {
  11460. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11461. localTarget.addInPlace(bonePos);
  11462. target = localTarget;
  11463. }
  11464. }
  11465. }
  11466. var zaxis = BoneLookController._tmpVecs[5];
  11467. var xaxis = BoneLookController._tmpVecs[6];
  11468. var yaxis = BoneLookController._tmpVecs[7];
  11469. var _tmpQuat = BoneLookController._tmpQuat;
  11470. target.subtractToRef(bonePos, zaxis);
  11471. zaxis.normalize();
  11472. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11473. xaxis.normalize();
  11474. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11475. yaxis.normalize();
  11476. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11477. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11478. return;
  11479. }
  11480. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11481. return;
  11482. }
  11483. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11484. return;
  11485. }
  11486. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11487. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11488. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11489. }
  11490. if (this.slerpAmount < 1) {
  11491. if (!this._slerping) {
  11492. this.bone.getRotationQuaternionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, this.mesh, this._boneQuat);
  11493. }
  11494. if (this._transformYawPitch) {
  11495. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11496. }
  11497. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11498. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11499. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, this.mesh);
  11500. this._slerping = true;
  11501. }
  11502. else {
  11503. if (this._transformYawPitch) {
  11504. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11505. }
  11506. this.bone.setRotationMatrix(_tmpMat1, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, this.mesh);
  11507. this._slerping = false;
  11508. }
  11509. };
  11510. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11511. var angDiff = ang2 - ang1;
  11512. angDiff %= Math.PI * 2;
  11513. if (angDiff > Math.PI) {
  11514. angDiff -= Math.PI * 2;
  11515. }
  11516. else if (angDiff < -Math.PI) {
  11517. angDiff += Math.PI * 2;
  11518. }
  11519. return angDiff;
  11520. };
  11521. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11522. ang1 %= (2 * Math.PI);
  11523. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11524. ang2 %= (2 * Math.PI);
  11525. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11526. var ab = 0;
  11527. if (ang1 < ang2) {
  11528. ab = ang2 - ang1;
  11529. }
  11530. else {
  11531. ab = ang1 - ang2;
  11532. }
  11533. if (ab > Math.PI) {
  11534. ab = Math.PI * 2 - ab;
  11535. }
  11536. return ab;
  11537. };
  11538. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11539. ang %= (2 * Math.PI);
  11540. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11541. ang1 %= (2 * Math.PI);
  11542. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11543. ang2 %= (2 * Math.PI);
  11544. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11545. if (ang1 < ang2) {
  11546. if (ang > ang1 && ang < ang2) {
  11547. return true;
  11548. }
  11549. }
  11550. else {
  11551. if (ang > ang2 && ang < ang1) {
  11552. return true;
  11553. }
  11554. }
  11555. return false;
  11556. };
  11557. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11558. BoneLookController._tmpQuat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11559. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11560. return BoneLookController;
  11561. }());
  11562. /***/ }),
  11563. /***/ "./Bones/index.ts":
  11564. /*!************************!*\
  11565. !*** ./Bones/index.ts ***!
  11566. \************************/
  11567. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11569. "use strict";
  11570. __webpack_require__.r(__webpack_exports__);
  11571. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11573. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11575. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11577. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11579. /***/ }),
  11580. /***/ "./Bones/skeleton.ts":
  11581. /*!***************************!*\
  11582. !*** ./Bones/skeleton.ts ***!
  11583. \***************************/
  11584. /*! exports provided: Skeleton */
  11585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11586. "use strict";
  11587. __webpack_require__.r(__webpack_exports__);
  11588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11589. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11590. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11591. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  11592. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11593. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11594. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11595. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11596. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11597. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11598. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11599. /**
  11600. * Class used to handle skinning animations
  11601. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11602. */
  11603. var Skeleton = /** @class */ (function () {
  11604. /**
  11605. * Creates a new skeleton
  11606. * @param name defines the skeleton name
  11607. * @param id defines the skeleton Id
  11608. * @param scene defines the hosting scene
  11609. */
  11610. function Skeleton(
  11611. /** defines the skeleton name */
  11612. name,
  11613. /** defines the skeleton Id */
  11614. id, scene) {
  11615. this.name = name;
  11616. this.id = id;
  11617. /**
  11618. * Defines the list of child bones
  11619. */
  11620. this.bones = new Array();
  11621. /**
  11622. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11623. */
  11624. this.needInitialSkinMatrix = false;
  11625. /**
  11626. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11627. */
  11628. this.overrideMesh = null;
  11629. this._isDirty = true;
  11630. this._meshesWithPoseMatrix = new Array();
  11631. this._identity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11632. this._ranges = {};
  11633. this._lastAbsoluteTransformsUpdateId = -1;
  11634. this._canUseTextureForBones = false;
  11635. this._uniqueId = 0;
  11636. /** @hidden */
  11637. this._numBonesWithLinkedTransformNode = 0;
  11638. /** @hidden */
  11639. this._hasWaitingData = null;
  11640. /**
  11641. * Specifies if the skeleton should be serialized
  11642. */
  11643. this.doNotSerialize = false;
  11644. this._useTextureToStoreBoneMatrices = true;
  11645. this._animationPropertiesOverride = null;
  11646. // Events
  11647. /**
  11648. * An observable triggered before computing the skeleton's matrices
  11649. */
  11650. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11651. this.bones = [];
  11652. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11653. this._uniqueId = this._scene.getUniqueId();
  11654. this._scene.addSkeleton(this);
  11655. //make sure it will recalculate the matrix next time prepare is called.
  11656. this._isDirty = true;
  11657. var engineCaps = this._scene.getEngine().getCaps();
  11658. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11659. }
  11660. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11661. /**
  11662. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11663. * Please note that this option is not available if the hardware does not support it
  11664. */
  11665. get: function () {
  11666. return this._useTextureToStoreBoneMatrices;
  11667. },
  11668. set: function (value) {
  11669. this._useTextureToStoreBoneMatrices = value;
  11670. this._markAsDirty();
  11671. },
  11672. enumerable: true,
  11673. configurable: true
  11674. });
  11675. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11676. /**
  11677. * Gets or sets the animation properties override
  11678. */
  11679. get: function () {
  11680. if (!this._animationPropertiesOverride) {
  11681. return this._scene.animationPropertiesOverride;
  11682. }
  11683. return this._animationPropertiesOverride;
  11684. },
  11685. set: function (value) {
  11686. this._animationPropertiesOverride = value;
  11687. },
  11688. enumerable: true,
  11689. configurable: true
  11690. });
  11691. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11692. /**
  11693. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11694. */
  11695. get: function () {
  11696. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones;
  11697. },
  11698. enumerable: true,
  11699. configurable: true
  11700. });
  11701. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11702. /**
  11703. * Gets the unique ID of this skeleton
  11704. */
  11705. get: function () {
  11706. return this._uniqueId;
  11707. },
  11708. enumerable: true,
  11709. configurable: true
  11710. });
  11711. /**
  11712. * Gets the current object class name.
  11713. * @return the class name
  11714. */
  11715. Skeleton.prototype.getClassName = function () {
  11716. return "Skeleton";
  11717. };
  11718. /**
  11719. * Returns an array containing the root bones
  11720. * @returns an array containing the root bones
  11721. */
  11722. Skeleton.prototype.getChildren = function () {
  11723. return this.bones.filter(function (b) { return !b.getParent(); });
  11724. };
  11725. // Members
  11726. /**
  11727. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11728. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11729. * @returns a Float32Array containing matrices data
  11730. */
  11731. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11732. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11733. return mesh._bonesTransformMatrices;
  11734. }
  11735. if (!this._transformMatrices) {
  11736. this.prepare();
  11737. }
  11738. return this._transformMatrices;
  11739. };
  11740. /**
  11741. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11742. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11743. * @returns a raw texture containing the data
  11744. */
  11745. Skeleton.prototype.getTransformMatrixTexture = function (mesh) {
  11746. if (this.needInitialSkinMatrix && mesh._transformMatrixTexture) {
  11747. return mesh._transformMatrixTexture;
  11748. }
  11749. return this._transformMatrixTexture;
  11750. };
  11751. /**
  11752. * Gets the current hosting scene
  11753. * @returns a scene object
  11754. */
  11755. Skeleton.prototype.getScene = function () {
  11756. return this._scene;
  11757. };
  11758. // Methods
  11759. /**
  11760. * Gets a string representing the current skeleton data
  11761. * @param fullDetails defines a boolean indicating if we want a verbose version
  11762. * @returns a string representing the current skeleton data
  11763. */
  11764. Skeleton.prototype.toString = function (fullDetails) {
  11765. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11766. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11767. if (fullDetails) {
  11768. ret += ", Ranges: {";
  11769. var first = true;
  11770. for (var name_1 in this._ranges) {
  11771. if (first) {
  11772. ret += ", ";
  11773. first = false;
  11774. }
  11775. ret += name_1;
  11776. }
  11777. ret += "}";
  11778. }
  11779. return ret;
  11780. };
  11781. /**
  11782. * Get bone's index searching by name
  11783. * @param name defines bone's name to search for
  11784. * @return the indice of the bone. Returns -1 if not found
  11785. */
  11786. Skeleton.prototype.getBoneIndexByName = function (name) {
  11787. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11788. if (this.bones[boneIndex].name === name) {
  11789. return boneIndex;
  11790. }
  11791. }
  11792. return -1;
  11793. };
  11794. /**
  11795. * Creater a new animation range
  11796. * @param name defines the name of the range
  11797. * @param from defines the start key
  11798. * @param to defines the end key
  11799. */
  11800. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11801. // check name not already in use
  11802. if (!this._ranges[name]) {
  11803. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11804. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11805. if (this.bones[i].animations[0]) {
  11806. this.bones[i].animations[0].createRange(name, from, to);
  11807. }
  11808. }
  11809. }
  11810. };
  11811. /**
  11812. * Delete a specific animation range
  11813. * @param name defines the name of the range
  11814. * @param deleteFrames defines if frames must be removed as well
  11815. */
  11816. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11817. if (deleteFrames === void 0) { deleteFrames = true; }
  11818. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11819. if (this.bones[i].animations[0]) {
  11820. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11821. }
  11822. }
  11823. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11824. };
  11825. /**
  11826. * Gets a specific animation range
  11827. * @param name defines the name of the range to look for
  11828. * @returns the requested animation range or null if not found
  11829. */
  11830. Skeleton.prototype.getAnimationRange = function (name) {
  11831. return this._ranges[name];
  11832. };
  11833. /**
  11834. * Gets the list of all animation ranges defined on this skeleton
  11835. * @returns an array
  11836. */
  11837. Skeleton.prototype.getAnimationRanges = function () {
  11838. var animationRanges = [];
  11839. var name;
  11840. for (name in this._ranges) {
  11841. animationRanges.push(this._ranges[name]);
  11842. }
  11843. return animationRanges;
  11844. };
  11845. /**
  11846. * Copy animation range from a source skeleton.
  11847. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11848. * @param source defines the source skeleton
  11849. * @param name defines the name of the range to copy
  11850. * @param rescaleAsRequired defines if rescaling must be applied if required
  11851. * @returns true if operation was successful
  11852. */
  11853. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11854. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11855. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11856. return false;
  11857. }
  11858. var ret = true;
  11859. var frameOffset = this._getHighestAnimationFrame() + 1;
  11860. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11861. var boneDict = {};
  11862. var sourceBones = source.bones;
  11863. var nBones;
  11864. var i;
  11865. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11866. boneDict[sourceBones[i].name] = sourceBones[i];
  11867. }
  11868. if (this.bones.length !== sourceBones.length) {
  11869. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11870. ret = false;
  11871. }
  11872. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11873. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11874. var boneName = this.bones[i].name;
  11875. var sourceBone = boneDict[boneName];
  11876. if (sourceBone) {
  11877. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11878. }
  11879. else {
  11880. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11881. ret = false;
  11882. }
  11883. }
  11884. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11885. var range = source.getAnimationRange(name);
  11886. if (range) {
  11887. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11888. }
  11889. return ret;
  11890. };
  11891. /**
  11892. * Forces the skeleton to go to rest pose
  11893. */
  11894. Skeleton.prototype.returnToRest = function () {
  11895. for (var index = 0; index < this.bones.length; index++) {
  11896. this.bones[index].returnToRest();
  11897. }
  11898. };
  11899. Skeleton.prototype._getHighestAnimationFrame = function () {
  11900. var ret = 0;
  11901. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11902. if (this.bones[i].animations[0]) {
  11903. var highest = this.bones[i].animations[0].getHighestFrame();
  11904. if (ret < highest) {
  11905. ret = highest;
  11906. }
  11907. }
  11908. }
  11909. return ret;
  11910. };
  11911. /**
  11912. * Begin a specific animation range
  11913. * @param name defines the name of the range to start
  11914. * @param loop defines if looping must be turned on (false by default)
  11915. * @param speedRatio defines the speed ratio to apply (1 by default)
  11916. * @param onAnimationEnd defines a callback which will be called when animation will end
  11917. * @returns a new animatable
  11918. */
  11919. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11920. var range = this.getAnimationRange(name);
  11921. if (!range) {
  11922. return null;
  11923. }
  11924. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11925. };
  11926. /** @hidden */
  11927. Skeleton.prototype._markAsDirty = function () {
  11928. this._isDirty = true;
  11929. };
  11930. /** @hidden */
  11931. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11932. this._meshesWithPoseMatrix.push(mesh);
  11933. };
  11934. /** @hidden */
  11935. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11936. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11937. if (index > -1) {
  11938. this._meshesWithPoseMatrix.splice(index, 1);
  11939. }
  11940. };
  11941. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11942. this.onBeforeComputeObservable.notifyObservers(this);
  11943. for (var index = 0; index < this.bones.length; index++) {
  11944. var bone = this.bones[index];
  11945. bone._childUpdateId++;
  11946. var parentBone = bone.getParent();
  11947. if (parentBone) {
  11948. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11949. }
  11950. else {
  11951. if (initialSkinMatrix) {
  11952. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11953. }
  11954. else {
  11955. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11956. }
  11957. }
  11958. if (bone._index !== -1) {
  11959. var mappedIndex = bone._index === null ? index : bone._index;
  11960. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11961. }
  11962. }
  11963. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11964. };
  11965. /**
  11966. * Build all resources required to render a skeleton
  11967. */
  11968. Skeleton.prototype.prepare = function () {
  11969. // Update the local matrix of bones with linked transform nodes.
  11970. if (this._numBonesWithLinkedTransformNode > 0) {
  11971. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11972. var bone_1 = _a[_i];
  11973. if (bone_1._linkedTransformNode) {
  11974. // Computing the world matrix also computes the local matrix.
  11975. bone_1._linkedTransformNode.computeWorldMatrix();
  11976. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11977. bone_1.markAsDirty();
  11978. }
  11979. }
  11980. }
  11981. if (!this._isDirty) {
  11982. return;
  11983. }
  11984. if (this.needInitialSkinMatrix) {
  11985. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11986. var mesh = this._meshesWithPoseMatrix[index];
  11987. var poseMatrix = mesh.getPoseMatrix();
  11988. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11989. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11990. }
  11991. if (this._synchronizedWithMesh !== mesh) {
  11992. this._synchronizedWithMesh = mesh;
  11993. // Prepare bones
  11994. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11995. var bone = this.bones[boneIndex];
  11996. if (!bone.getParent()) {
  11997. var matrix = bone.getBaseMatrix();
  11998. matrix.multiplyToRef(poseMatrix, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Matrix[1]);
  11999. bone._updateDifferenceMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Matrix[1]);
  12000. }
  12001. }
  12002. if (this.isUsingTextureForMatrices) {
  12003. var textureWidth = (this.bones.length + 1) * 4;
  12004. if (!mesh._transformMatrixTexture || mesh._transformMatrixTexture.getSize().width !== textureWidth) {
  12005. if (mesh._transformMatrixTexture) {
  12006. mesh._transformMatrixTexture.dispose();
  12007. }
  12008. mesh._transformMatrixTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__["RawTexture"].CreateRGBATexture(mesh._bonesTransformMatrices, (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);
  12009. }
  12010. }
  12011. }
  12012. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  12013. if (this.isUsingTextureForMatrices && mesh._transformMatrixTexture) {
  12014. mesh._transformMatrixTexture.update(mesh._bonesTransformMatrices);
  12015. }
  12016. }
  12017. }
  12018. else {
  12019. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  12020. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  12021. if (this.isUsingTextureForMatrices) {
  12022. if (this._transformMatrixTexture) {
  12023. this._transformMatrixTexture.dispose();
  12024. }
  12025. 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);
  12026. }
  12027. }
  12028. this._computeTransformMatrices(this._transformMatrices, null);
  12029. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  12030. this._transformMatrixTexture.update(this._transformMatrices);
  12031. }
  12032. }
  12033. this._isDirty = false;
  12034. this._scene._activeBones.addCount(this.bones.length, false);
  12035. };
  12036. /**
  12037. * Gets the list of animatables currently running for this skeleton
  12038. * @returns an array of animatables
  12039. */
  12040. Skeleton.prototype.getAnimatables = function () {
  12041. if (!this._animatables || this._animatables.length !== this.bones.length) {
  12042. this._animatables = [];
  12043. for (var index = 0; index < this.bones.length; index++) {
  12044. this._animatables.push(this.bones[index]);
  12045. }
  12046. }
  12047. return this._animatables;
  12048. };
  12049. /**
  12050. * Clone the current skeleton
  12051. * @param name defines the name of the new skeleton
  12052. * @param id defines the id of the new skeleton
  12053. * @returns the new skeleton
  12054. */
  12055. Skeleton.prototype.clone = function (name, id) {
  12056. var result = new Skeleton(name, id || name, this._scene);
  12057. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  12058. for (var index = 0; index < this.bones.length; index++) {
  12059. var source = this.bones[index];
  12060. var parentBone = null;
  12061. var parent_1 = source.getParent();
  12062. if (parent_1) {
  12063. var parentIndex = this.bones.indexOf(parent_1);
  12064. parentBone = result.bones[parentIndex];
  12065. }
  12066. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  12067. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  12068. }
  12069. if (this._ranges) {
  12070. result._ranges = {};
  12071. for (var rangeName in this._ranges) {
  12072. var range = this._ranges[rangeName];
  12073. if (range) {
  12074. result._ranges[rangeName] = range.clone();
  12075. }
  12076. }
  12077. }
  12078. this._isDirty = true;
  12079. return result;
  12080. };
  12081. /**
  12082. * Enable animation blending for this skeleton
  12083. * @param blendingSpeed defines the blending speed to apply
  12084. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12085. */
  12086. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  12087. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  12088. this.bones.forEach(function (bone) {
  12089. bone.animations.forEach(function (animation) {
  12090. animation.enableBlending = true;
  12091. animation.blendingSpeed = blendingSpeed;
  12092. });
  12093. });
  12094. };
  12095. /**
  12096. * Releases all resources associated with the current skeleton
  12097. */
  12098. Skeleton.prototype.dispose = function () {
  12099. this._meshesWithPoseMatrix = [];
  12100. // Animations
  12101. this.getScene().stopAnimation(this);
  12102. // Remove from scene
  12103. this.getScene().removeSkeleton(this);
  12104. if (this._transformMatrixTexture) {
  12105. this._transformMatrixTexture.dispose();
  12106. this._transformMatrixTexture = null;
  12107. }
  12108. };
  12109. /**
  12110. * Serialize the skeleton in a JSON object
  12111. * @returns a JSON object
  12112. */
  12113. Skeleton.prototype.serialize = function () {
  12114. var serializationObject = {};
  12115. serializationObject.name = this.name;
  12116. serializationObject.id = this.id;
  12117. if (this.dimensionsAtRest) {
  12118. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  12119. }
  12120. serializationObject.bones = [];
  12121. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  12122. for (var index = 0; index < this.bones.length; index++) {
  12123. var bone = this.bones[index];
  12124. var parent_2 = bone.getParent();
  12125. var serializedBone = {
  12126. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  12127. name: bone.name,
  12128. matrix: bone.getBaseMatrix().toArray(),
  12129. rest: bone.getRestPose().toArray()
  12130. };
  12131. serializationObject.bones.push(serializedBone);
  12132. if (bone.length) {
  12133. serializedBone.length = bone.length;
  12134. }
  12135. if (bone.metadata) {
  12136. serializedBone.metadata = bone.metadata;
  12137. }
  12138. if (bone.animations && bone.animations.length > 0) {
  12139. serializedBone.animation = bone.animations[0].serialize();
  12140. }
  12141. serializationObject.ranges = [];
  12142. for (var name in this._ranges) {
  12143. var source = this._ranges[name];
  12144. if (!source) {
  12145. continue;
  12146. }
  12147. var range = {};
  12148. range.name = name;
  12149. range.from = source.from;
  12150. range.to = source.to;
  12151. serializationObject.ranges.push(range);
  12152. }
  12153. }
  12154. return serializationObject;
  12155. };
  12156. /**
  12157. * Creates a new skeleton from serialized data
  12158. * @param parsedSkeleton defines the serialized data
  12159. * @param scene defines the hosting scene
  12160. * @returns a new skeleton
  12161. */
  12162. Skeleton.Parse = function (parsedSkeleton, scene) {
  12163. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  12164. if (parsedSkeleton.dimensionsAtRest) {
  12165. skeleton.dimensionsAtRest = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  12166. }
  12167. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  12168. var index;
  12169. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  12170. var parsedBone = parsedSkeleton.bones[index];
  12171. var parentBone = null;
  12172. if (parsedBone.parentBoneIndex > -1) {
  12173. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  12174. }
  12175. var rest = parsedBone.rest ? _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  12176. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  12177. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  12178. bone.id = parsedBone.id;
  12179. }
  12180. if (parsedBone.length) {
  12181. bone.length = parsedBone.length;
  12182. }
  12183. if (parsedBone.metadata) {
  12184. bone.metadata = parsedBone.metadata;
  12185. }
  12186. if (parsedBone.animation) {
  12187. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  12188. }
  12189. if (parsedBone.linkedTransformNodeId !== undefined && parsedBone.linkedTransformNodeId !== null) {
  12190. skeleton._hasWaitingData = true;
  12191. bone._waitingTransformNodeId = parsedBone.linkedTransformNodeId;
  12192. }
  12193. }
  12194. // placed after bones, so createAnimationRange can cascade down
  12195. if (parsedSkeleton.ranges) {
  12196. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  12197. var data = parsedSkeleton.ranges[index];
  12198. skeleton.createAnimationRange(data.name, data.from, data.to);
  12199. }
  12200. }
  12201. return skeleton;
  12202. };
  12203. /**
  12204. * Compute all node absolute transforms
  12205. * @param forceUpdate defines if computation must be done even if cache is up to date
  12206. */
  12207. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12208. if (forceUpdate === void 0) { forceUpdate = false; }
  12209. var renderId = this._scene.getRenderId();
  12210. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12211. this.bones[0].computeAbsoluteTransforms();
  12212. this._lastAbsoluteTransformsUpdateId = renderId;
  12213. }
  12214. };
  12215. /**
  12216. * Gets the root pose matrix
  12217. * @returns a matrix
  12218. */
  12219. Skeleton.prototype.getPoseMatrix = function () {
  12220. var poseMatrix = null;
  12221. if (this._meshesWithPoseMatrix.length > 0) {
  12222. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12223. }
  12224. return poseMatrix;
  12225. };
  12226. /**
  12227. * Sorts bones per internal index
  12228. */
  12229. Skeleton.prototype.sortBones = function () {
  12230. var bones = new Array();
  12231. var visited = new Array(this.bones.length);
  12232. for (var index = 0; index < this.bones.length; index++) {
  12233. this._sortBones(index, bones, visited);
  12234. }
  12235. this.bones = bones;
  12236. };
  12237. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12238. if (visited[index]) {
  12239. return;
  12240. }
  12241. visited[index] = true;
  12242. var bone = this.bones[index];
  12243. if (bone._index === undefined) {
  12244. bone._index = index;
  12245. }
  12246. var parentBone = bone.getParent();
  12247. if (parentBone) {
  12248. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12249. }
  12250. bones.push(bone);
  12251. };
  12252. return Skeleton;
  12253. }());
  12254. /***/ }),
  12255. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12256. /*!***************************************************!*\
  12257. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12258. \***************************************************/
  12259. /*! exports provided: BaseCameraPointersInput */
  12260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12261. "use strict";
  12262. __webpack_require__.r(__webpack_exports__);
  12263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12264. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12265. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12266. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12267. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12268. /**
  12269. * Base class for Camera Pointer Inputs.
  12270. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12271. * for example usage.
  12272. */
  12273. var BaseCameraPointersInput = /** @class */ (function () {
  12274. function BaseCameraPointersInput() {
  12275. /**
  12276. * Defines the buttons associated with the input to handle camera move.
  12277. */
  12278. this.buttons = [0, 1, 2];
  12279. }
  12280. /**
  12281. * Attach the input controls to a specific dom element to get the input from.
  12282. * @param element Defines the element the controls should be listened from
  12283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12284. */
  12285. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12286. var _this = this;
  12287. var engine = this.camera.getEngine();
  12288. var previousPinchSquaredDistance = 0;
  12289. var previousMultiTouchPanPosition = null;
  12290. this.pointA = null;
  12291. this.pointB = null;
  12292. this._altKey = false;
  12293. this._ctrlKey = false;
  12294. this._metaKey = false;
  12295. this._shiftKey = false;
  12296. this._buttonsPressed = 0;
  12297. this._pointerInput = function (p, s) {
  12298. var evt = p.event;
  12299. var isTouch = evt.pointerType === "touch";
  12300. if (engine.isInVRExclusivePointerMode) {
  12301. return;
  12302. }
  12303. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12304. _this.buttons.indexOf(evt.button) === -1) {
  12305. return;
  12306. }
  12307. var srcElement = (evt.srcElement || evt.target);
  12308. _this._altKey = evt.altKey;
  12309. _this._ctrlKey = evt.ctrlKey;
  12310. _this._metaKey = evt.metaKey;
  12311. _this._shiftKey = evt.shiftKey;
  12312. _this._buttonsPressed = evt.buttons;
  12313. if (engine.isPointerLock) {
  12314. var offsetX = evt.movementX ||
  12315. evt.mozMovementX ||
  12316. evt.webkitMovementX ||
  12317. evt.msMovementX ||
  12318. 0;
  12319. var offsetY = evt.movementY ||
  12320. evt.mozMovementY ||
  12321. evt.webkitMovementY ||
  12322. evt.msMovementY ||
  12323. 0;
  12324. _this.onTouch(null, offsetX, offsetY);
  12325. _this.pointA = null;
  12326. _this.pointB = null;
  12327. }
  12328. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12329. try {
  12330. srcElement.setPointerCapture(evt.pointerId);
  12331. }
  12332. catch (e) {
  12333. //Nothing to do with the error. Execution will continue.
  12334. }
  12335. if (_this.pointA === null) {
  12336. _this.pointA = { x: evt.clientX,
  12337. y: evt.clientY,
  12338. pointerId: evt.pointerId,
  12339. type: evt.pointerType };
  12340. }
  12341. else if (_this.pointB === null) {
  12342. _this.pointB = { x: evt.clientX,
  12343. y: evt.clientY,
  12344. pointerId: evt.pointerId,
  12345. type: evt.pointerType };
  12346. }
  12347. _this.onButtonDown(evt);
  12348. if (!noPreventDefault) {
  12349. evt.preventDefault();
  12350. element.focus();
  12351. }
  12352. }
  12353. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12354. _this.onDoubleTap(evt.pointerType);
  12355. }
  12356. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12357. try {
  12358. srcElement.releasePointerCapture(evt.pointerId);
  12359. }
  12360. catch (e) {
  12361. //Nothing to do with the error.
  12362. }
  12363. if (!isTouch) {
  12364. _this.pointB = null; // Mouse and pen are mono pointer
  12365. }
  12366. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12367. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12368. //when changing orientation while pinching camera,
  12369. //one pointer stay pressed forever if we don't release all pointers
  12370. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12371. if (engine._badOS) {
  12372. _this.pointA = _this.pointB = null;
  12373. }
  12374. else {
  12375. //only remove the impacted pointer in case of multitouch allowing on most
  12376. //platforms switching from rotate to zoom and pan seamlessly.
  12377. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12378. _this.pointA = _this.pointB;
  12379. _this.pointB = null;
  12380. }
  12381. else if (_this.pointA && _this.pointB &&
  12382. _this.pointB.pointerId == evt.pointerId) {
  12383. _this.pointB = null;
  12384. }
  12385. else {
  12386. _this.pointA = _this.pointB = null;
  12387. }
  12388. }
  12389. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12390. // Previous pinch data is populated but a button has been lifted
  12391. // so pinch has ended.
  12392. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12393. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12394. );
  12395. previousPinchSquaredDistance = 0;
  12396. previousMultiTouchPanPosition = null;
  12397. }
  12398. _this.onButtonUp(evt);
  12399. if (!noPreventDefault) {
  12400. evt.preventDefault();
  12401. }
  12402. }
  12403. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12404. if (!noPreventDefault) {
  12405. evt.preventDefault();
  12406. }
  12407. // One button down
  12408. if (_this.pointA && _this.pointB === null) {
  12409. var offsetX = evt.clientX - _this.pointA.x;
  12410. var offsetY = evt.clientY - _this.pointA.y;
  12411. _this.onTouch(_this.pointA, offsetX, offsetY);
  12412. _this.pointA.x = evt.clientX;
  12413. _this.pointA.y = evt.clientY;
  12414. }
  12415. // Two buttons down: pinch
  12416. else if (_this.pointA && _this.pointB) {
  12417. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12418. _this.pointA : _this.pointB;
  12419. ed.x = evt.clientX;
  12420. ed.y = evt.clientY;
  12421. var distX = _this.pointA.x - _this.pointB.x;
  12422. var distY = _this.pointA.y - _this.pointB.y;
  12423. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12424. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12425. y: (_this.pointA.y + _this.pointB.y) / 2,
  12426. pointerId: evt.pointerId,
  12427. type: p.type };
  12428. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12429. previousMultiTouchPanPosition = multiTouchPanPosition;
  12430. previousPinchSquaredDistance = pinchSquaredDistance;
  12431. }
  12432. }
  12433. };
  12434. 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 |
  12435. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12436. this._onLostFocus = function () {
  12437. _this.pointA = _this.pointB = null;
  12438. previousPinchSquaredDistance = 0;
  12439. previousMultiTouchPanPosition = null;
  12440. _this.onLostFocus();
  12441. };
  12442. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12443. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12444. { name: "blur", handler: this._onLostFocus }
  12445. ]);
  12446. };
  12447. /**
  12448. * Detach the current controls from the specified dom element.
  12449. * @param element Defines the element to stop listening the inputs from
  12450. */
  12451. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12452. if (this._onLostFocus) {
  12453. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12454. { name: "blur", handler: this._onLostFocus }
  12455. ]);
  12456. }
  12457. if (element && this._observer) {
  12458. this.camera.getScene().onPointerObservable.remove(this._observer);
  12459. this._observer = null;
  12460. if (this.onContextMenu) {
  12461. element.removeEventListener("contextmenu", this.onContextMenu);
  12462. }
  12463. this._onLostFocus = null;
  12464. }
  12465. this._altKey = false;
  12466. this._ctrlKey = false;
  12467. this._metaKey = false;
  12468. this._shiftKey = false;
  12469. this._buttonsPressed = 0;
  12470. };
  12471. /**
  12472. * Gets the class name of the current input.
  12473. * @returns the class name
  12474. */
  12475. BaseCameraPointersInput.prototype.getClassName = function () {
  12476. return "BaseCameraPointersInput";
  12477. };
  12478. /**
  12479. * Get the friendly name associated with the input class.
  12480. * @returns the input friendly name
  12481. */
  12482. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12483. return "pointers";
  12484. };
  12485. /**
  12486. * Called on pointer POINTERDOUBLETAP event.
  12487. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12488. */
  12489. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12490. };
  12491. /**
  12492. * Called on pointer POINTERMOVE event if only a single touch is active.
  12493. * Override this method to provide functionality.
  12494. */
  12495. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12496. };
  12497. /**
  12498. * Called on pointer POINTERMOVE event if multiple touches are active.
  12499. * Override this method to provide functionality.
  12500. */
  12501. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12502. };
  12503. /**
  12504. * Called on JS contextmenu event.
  12505. * Override this method to provide functionality.
  12506. */
  12507. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12508. evt.preventDefault();
  12509. };
  12510. /**
  12511. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12512. * press.
  12513. * Override this method to provide functionality.
  12514. */
  12515. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12516. };
  12517. /**
  12518. * Called each time a new POINTERUP event occurs. Ie, for each button
  12519. * release.
  12520. * Override this method to provide functionality.
  12521. */
  12522. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12523. };
  12524. /**
  12525. * Called when window becomes inactive.
  12526. * Override this method to provide functionality.
  12527. */
  12528. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12529. };
  12530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12532. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12533. return BaseCameraPointersInput;
  12534. }());
  12535. /***/ }),
  12536. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12537. /*!*******************************************************!*\
  12538. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12539. \*******************************************************/
  12540. /*! exports provided: ArcRotateCameraGamepadInput */
  12541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12542. "use strict";
  12543. __webpack_require__.r(__webpack_exports__);
  12544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12545. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12546. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12547. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12548. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12549. /**
  12550. * Manage the gamepad inputs to control an arc rotate camera.
  12551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12552. */
  12553. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12554. function ArcRotateCameraGamepadInput() {
  12555. /**
  12556. * Defines the gamepad rotation sensiblity.
  12557. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12558. */
  12559. this.gamepadRotationSensibility = 80;
  12560. /**
  12561. * Defines the gamepad move sensiblity.
  12562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12563. */
  12564. this.gamepadMoveSensibility = 40;
  12565. }
  12566. /**
  12567. * Attach the input controls to a specific dom element to get the input from.
  12568. * @param element Defines the element the controls should be listened from
  12569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12570. */
  12571. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12572. var _this = this;
  12573. var manager = this.camera.getScene().gamepadManager;
  12574. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12575. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12576. // prioritize XBOX gamepads.
  12577. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12578. _this.gamepad = gamepad;
  12579. }
  12580. }
  12581. });
  12582. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12583. if (_this.gamepad === gamepad) {
  12584. _this.gamepad = null;
  12585. }
  12586. });
  12587. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12588. };
  12589. /**
  12590. * Detach the current controls from the specified dom element.
  12591. * @param element Defines the element to stop listening the inputs from
  12592. */
  12593. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12594. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12595. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12596. this.gamepad = null;
  12597. };
  12598. /**
  12599. * Update the current camera state depending on the inputs that have been used this frame.
  12600. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12601. */
  12602. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12603. if (this.gamepad) {
  12604. var camera = this.camera;
  12605. var RSValues = this.gamepad.rightStick;
  12606. if (RSValues) {
  12607. if (RSValues.x != 0) {
  12608. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12609. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12610. camera.inertialAlphaOffset += normalizedRX;
  12611. }
  12612. }
  12613. if (RSValues.y != 0) {
  12614. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12615. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12616. camera.inertialBetaOffset += normalizedRY;
  12617. }
  12618. }
  12619. }
  12620. var LSValues = this.gamepad.leftStick;
  12621. if (LSValues && LSValues.y != 0) {
  12622. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12623. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12624. this.camera.inertialRadiusOffset -= normalizedLY;
  12625. }
  12626. }
  12627. }
  12628. };
  12629. /**
  12630. * Gets the class name of the current intput.
  12631. * @returns the class name
  12632. */
  12633. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12634. return "ArcRotateCameraGamepadInput";
  12635. };
  12636. /**
  12637. * Get the friendly name associated with the input class.
  12638. * @returns the input friendly name
  12639. */
  12640. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12641. return "gamepad";
  12642. };
  12643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12645. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12648. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12649. return ArcRotateCameraGamepadInput;
  12650. }());
  12651. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12652. /***/ }),
  12653. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12654. /*!************************************************************!*\
  12655. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12656. \************************************************************/
  12657. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12659. "use strict";
  12660. __webpack_require__.r(__webpack_exports__);
  12661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12662. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12663. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12664. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12665. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12666. /**
  12667. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12669. */
  12670. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12671. function ArcRotateCameraKeyboardMoveInput() {
  12672. /**
  12673. * Defines the list of key codes associated with the up action (increase alpha)
  12674. */
  12675. this.keysUp = [38];
  12676. /**
  12677. * Defines the list of key codes associated with the down action (decrease alpha)
  12678. */
  12679. this.keysDown = [40];
  12680. /**
  12681. * Defines the list of key codes associated with the left action (increase beta)
  12682. */
  12683. this.keysLeft = [37];
  12684. /**
  12685. * Defines the list of key codes associated with the right action (decrease beta)
  12686. */
  12687. this.keysRight = [39];
  12688. /**
  12689. * Defines the list of key codes associated with the reset action.
  12690. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12691. */
  12692. this.keysReset = [220];
  12693. /**
  12694. * Defines the panning sensibility of the inputs.
  12695. * (How fast is the camera paning)
  12696. */
  12697. this.panningSensibility = 50.0;
  12698. /**
  12699. * Defines the zooming sensibility of the inputs.
  12700. * (How fast is the camera zooming)
  12701. */
  12702. this.zoomingSensibility = 25.0;
  12703. /**
  12704. * Defines wether maintaining the alt key down switch the movement mode from
  12705. * orientation to zoom.
  12706. */
  12707. this.useAltToZoom = true;
  12708. /**
  12709. * Rotation speed of the camera
  12710. */
  12711. this.angularSpeed = 0.01;
  12712. this._keys = new Array();
  12713. }
  12714. /**
  12715. * Attach the input controls to a specific dom element to get the input from.
  12716. * @param element Defines the element the controls should be listened from
  12717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12718. */
  12719. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12720. var _this = this;
  12721. if (this._onCanvasBlurObserver) {
  12722. return;
  12723. }
  12724. this._scene = this.camera.getScene();
  12725. this._engine = this._scene.getEngine();
  12726. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12727. _this._keys = [];
  12728. });
  12729. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12730. var evt = info.event;
  12731. if (!evt.metaKey) {
  12732. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12733. _this._ctrlPressed = evt.ctrlKey;
  12734. _this._altPressed = evt.altKey;
  12735. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12736. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12737. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12738. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12739. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12740. var index = _this._keys.indexOf(evt.keyCode);
  12741. if (index === -1) {
  12742. _this._keys.push(evt.keyCode);
  12743. }
  12744. if (evt.preventDefault) {
  12745. if (!noPreventDefault) {
  12746. evt.preventDefault();
  12747. }
  12748. }
  12749. }
  12750. }
  12751. else {
  12752. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12753. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12754. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12755. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12756. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12757. var index = _this._keys.indexOf(evt.keyCode);
  12758. if (index >= 0) {
  12759. _this._keys.splice(index, 1);
  12760. }
  12761. if (evt.preventDefault) {
  12762. if (!noPreventDefault) {
  12763. evt.preventDefault();
  12764. }
  12765. }
  12766. }
  12767. }
  12768. }
  12769. });
  12770. };
  12771. /**
  12772. * Detach the current controls from the specified dom element.
  12773. * @param element Defines the element to stop listening the inputs from
  12774. */
  12775. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12776. if (this._scene) {
  12777. if (this._onKeyboardObserver) {
  12778. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12779. }
  12780. if (this._onCanvasBlurObserver) {
  12781. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12782. }
  12783. this._onKeyboardObserver = null;
  12784. this._onCanvasBlurObserver = null;
  12785. }
  12786. this._keys = [];
  12787. };
  12788. /**
  12789. * Update the current camera state depending on the inputs that have been used this frame.
  12790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12791. */
  12792. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12793. if (this._onKeyboardObserver) {
  12794. var camera = this.camera;
  12795. for (var index = 0; index < this._keys.length; index++) {
  12796. var keyCode = this._keys[index];
  12797. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12798. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12799. camera.inertialPanningX -= 1 / this.panningSensibility;
  12800. }
  12801. else {
  12802. camera.inertialAlphaOffset -= this.angularSpeed;
  12803. }
  12804. }
  12805. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12806. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12807. camera.inertialPanningY += 1 / this.panningSensibility;
  12808. }
  12809. else if (this._altPressed && this.useAltToZoom) {
  12810. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12811. }
  12812. else {
  12813. camera.inertialBetaOffset -= this.angularSpeed;
  12814. }
  12815. }
  12816. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12817. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12818. camera.inertialPanningX += 1 / this.panningSensibility;
  12819. }
  12820. else {
  12821. camera.inertialAlphaOffset += this.angularSpeed;
  12822. }
  12823. }
  12824. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12825. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12826. camera.inertialPanningY -= 1 / this.panningSensibility;
  12827. }
  12828. else if (this._altPressed && this.useAltToZoom) {
  12829. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12830. }
  12831. else {
  12832. camera.inertialBetaOffset += this.angularSpeed;
  12833. }
  12834. }
  12835. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12836. if (camera.useInputToRestoreState) {
  12837. camera.restoreState();
  12838. }
  12839. }
  12840. }
  12841. }
  12842. };
  12843. /**
  12844. * Gets the class name of the current intput.
  12845. * @returns the class name
  12846. */
  12847. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12848. return "ArcRotateCameraKeyboardMoveInput";
  12849. };
  12850. /**
  12851. * Get the friendly name associated with the input class.
  12852. * @returns the input friendly name
  12853. */
  12854. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12855. return "keyboard";
  12856. };
  12857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12859. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12862. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12865. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12868. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12871. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12874. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12877. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12880. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12883. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12884. return ArcRotateCameraKeyboardMoveInput;
  12885. }());
  12886. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12887. /***/ }),
  12888. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12889. /*!**********************************************************!*\
  12890. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12891. \**********************************************************/
  12892. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12894. "use strict";
  12895. __webpack_require__.r(__webpack_exports__);
  12896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12897. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12898. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12899. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12900. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12901. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  12902. /**
  12903. * Manage the mouse wheel inputs to control an arc rotate camera.
  12904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12905. */
  12906. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12907. function ArcRotateCameraMouseWheelInput() {
  12908. /**
  12909. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12910. */
  12911. this.wheelPrecision = 3.0;
  12912. /**
  12913. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12914. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12915. */
  12916. this.wheelDeltaPercentage = 0;
  12917. }
  12918. ArcRotateCameraMouseWheelInput.prototype.computeDeltaFromMouseWheelLegacyEvent = function (mouseWheelLegacyEvent, radius) {
  12919. var delta = 0;
  12920. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * this.wheelDeltaPercentage) * radius;
  12921. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12922. delta = wheelDelta / (1.0 + this.wheelDeltaPercentage);
  12923. }
  12924. else {
  12925. delta = wheelDelta * (1.0 + this.wheelDeltaPercentage);
  12926. }
  12927. return delta;
  12928. };
  12929. /**
  12930. * Attach the input controls to a specific dom element to get the input from.
  12931. * @param element Defines the element the controls should be listened from
  12932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12933. */
  12934. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12935. var _this = this;
  12936. this._wheel = function (p, s) {
  12937. //sanity check - this should be a PointerWheel event.
  12938. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12939. return;
  12940. }
  12941. var event = p.event;
  12942. var delta = 0;
  12943. var mouseWheelLegacyEvent = event;
  12944. if (mouseWheelLegacyEvent.wheelDelta) {
  12945. if (_this.wheelDeltaPercentage) {
  12946. delta = _this.computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent, _this.camera.radius);
  12947. // If zooming in, estimate the target radius and use that to compute the delta for inertia
  12948. // this will stop multiple scroll events zooming in from adding too much inertia
  12949. if (delta > 0) {
  12950. var estimatedTargetRadius = _this.camera.radius;
  12951. var targetInertia = _this.camera.inertialRadiusOffset + delta;
  12952. for (var i = 0; i < 20 && Math.abs(targetInertia) > 0.001; i++) {
  12953. estimatedTargetRadius -= targetInertia;
  12954. targetInertia *= _this.camera.inertia;
  12955. }
  12956. estimatedTargetRadius = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(estimatedTargetRadius, 0, Number.MAX_VALUE);
  12957. delta = _this.computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent, estimatedTargetRadius);
  12958. }
  12959. }
  12960. else {
  12961. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12962. }
  12963. }
  12964. else {
  12965. var deltaValue = event.deltaY || event.detail;
  12966. delta = -deltaValue / _this.wheelPrecision;
  12967. }
  12968. if (delta) {
  12969. _this.camera.inertialRadiusOffset += delta;
  12970. }
  12971. if (event.preventDefault) {
  12972. if (!noPreventDefault) {
  12973. event.preventDefault();
  12974. }
  12975. }
  12976. };
  12977. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12978. };
  12979. /**
  12980. * Detach the current controls from the specified dom element.
  12981. * @param element Defines the element to stop listening the inputs from
  12982. */
  12983. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12984. if (this._observer && element) {
  12985. this.camera.getScene().onPointerObservable.remove(this._observer);
  12986. this._observer = null;
  12987. this._wheel = null;
  12988. }
  12989. };
  12990. /**
  12991. * Gets the class name of the current intput.
  12992. * @returns the class name
  12993. */
  12994. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12995. return "ArcRotateCameraMouseWheelInput";
  12996. };
  12997. /**
  12998. * Get the friendly name associated with the input class.
  12999. * @returns the input friendly name
  13000. */
  13001. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  13002. return "mousewheel";
  13003. };
  13004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13006. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13009. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13010. return ArcRotateCameraMouseWheelInput;
  13011. }());
  13012. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  13013. /***/ }),
  13014. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  13015. /*!********************************************************!*\
  13016. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  13017. \********************************************************/
  13018. /*! exports provided: ArcRotateCameraPointersInput */
  13019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13020. "use strict";
  13021. __webpack_require__.r(__webpack_exports__);
  13022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  13023. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13024. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13025. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13026. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  13027. /**
  13028. * Manage the pointers inputs to control an arc rotate camera.
  13029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13030. */
  13031. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  13032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  13033. function ArcRotateCameraPointersInput() {
  13034. var _this = _super !== null && _super.apply(this, arguments) || this;
  13035. /**
  13036. * Defines the buttons associated with the input to handle camera move.
  13037. */
  13038. _this.buttons = [0, 1, 2];
  13039. /**
  13040. * Defines the pointer angular sensibility along the X axis or how fast is
  13041. * the camera rotating.
  13042. */
  13043. _this.angularSensibilityX = 1000.0;
  13044. /**
  13045. * Defines the pointer angular sensibility along the Y axis or how fast is
  13046. * the camera rotating.
  13047. */
  13048. _this.angularSensibilityY = 1000.0;
  13049. /**
  13050. * Defines the pointer pinch precision or how fast is the camera zooming.
  13051. */
  13052. _this.pinchPrecision = 12.0;
  13053. /**
  13054. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  13055. * from 0.
  13056. * It defines the percentage of current camera.radius to use as delta when
  13057. * pinch zoom is used.
  13058. */
  13059. _this.pinchDeltaPercentage = 0;
  13060. /**
  13061. * Defines the pointer panning sensibility or how fast is the camera moving.
  13062. */
  13063. _this.panningSensibility = 1000.0;
  13064. /**
  13065. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  13066. */
  13067. _this.multiTouchPanning = true;
  13068. /**
  13069. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  13070. * zoom (pinch) through multitouch.
  13071. */
  13072. _this.multiTouchPanAndZoom = true;
  13073. /**
  13074. * Revers pinch action direction.
  13075. */
  13076. _this.pinchInwards = true;
  13077. _this._isPanClick = false;
  13078. _this._twoFingerActivityCount = 0;
  13079. _this._isPinching = false;
  13080. return _this;
  13081. }
  13082. /**
  13083. * Gets the class name of the current input.
  13084. * @returns the class name
  13085. */
  13086. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  13087. return "ArcRotateCameraPointersInput";
  13088. };
  13089. /**
  13090. * Called on pointer POINTERMOVE event if only a single touch is active.
  13091. */
  13092. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  13093. if (this.panningSensibility !== 0 &&
  13094. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  13095. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  13096. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  13097. }
  13098. else {
  13099. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  13100. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  13101. }
  13102. };
  13103. /**
  13104. * Called on pointer POINTERDOUBLETAP event.
  13105. */
  13106. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  13107. if (this.camera.useInputToRestoreState) {
  13108. this.camera.restoreState();
  13109. }
  13110. };
  13111. /**
  13112. * Called on pointer POINTERMOVE event if multiple touches are active.
  13113. */
  13114. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  13115. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  13116. // First time this method is called for new pinch.
  13117. // Next time this is called there will be a
  13118. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  13119. return;
  13120. }
  13121. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  13122. // Last time this method is called at the end of a pinch.
  13123. return;
  13124. }
  13125. var direction = this.pinchInwards ? 1 : -1;
  13126. if (this.multiTouchPanAndZoom) {
  13127. if (this.pinchDeltaPercentage) {
  13128. this.camera.inertialRadiusOffset +=
  13129. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  13130. this.camera.radius * this.pinchDeltaPercentage;
  13131. }
  13132. else {
  13133. this.camera.inertialRadiusOffset +=
  13134. (pinchSquaredDistance - previousPinchSquaredDistance) /
  13135. (this.pinchPrecision * direction *
  13136. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  13137. }
  13138. if (this.panningSensibility !== 0 &&
  13139. previousMultiTouchPanPosition && multiTouchPanPosition) {
  13140. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  13141. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  13142. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  13143. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  13144. }
  13145. }
  13146. else {
  13147. this._twoFingerActivityCount++;
  13148. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  13149. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  13150. if (this._isPinching ||
  13151. (this._twoFingerActivityCount < 20 &&
  13152. Math.abs(pinchDistance - previousPinchDistance) >
  13153. this.camera.pinchToPanMaxDistance)) {
  13154. // Since pinch has not been active long, assume we intend to zoom.
  13155. if (this.pinchDeltaPercentage) {
  13156. this.camera.inertialRadiusOffset +=
  13157. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  13158. this.camera.radius * this.pinchDeltaPercentage;
  13159. }
  13160. else {
  13161. this.camera.inertialRadiusOffset +=
  13162. (pinchSquaredDistance - previousPinchSquaredDistance) /
  13163. (this.pinchPrecision * direction *
  13164. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  13165. }
  13166. // Since we are pinching, remain pinching on next iteration.
  13167. this._isPinching = true;
  13168. }
  13169. else {
  13170. // Pause between pinch starting and moving implies not a zoom event.
  13171. // Pan instead.
  13172. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  13173. multiTouchPanPosition && previousMultiTouchPanPosition) {
  13174. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  13175. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  13176. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  13177. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  13178. }
  13179. }
  13180. }
  13181. };
  13182. /**
  13183. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  13184. * press.
  13185. */
  13186. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  13187. this._isPanClick = evt.button === this.camera._panningMouseButton;
  13188. };
  13189. /**
  13190. * Called each time a new POINTERUP event occurs. Ie, for each button
  13191. * release.
  13192. */
  13193. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  13194. this._twoFingerActivityCount = 0;
  13195. this._isPinching = false;
  13196. };
  13197. /**
  13198. * Called when window becomes inactive.
  13199. */
  13200. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  13201. this._isPanClick = false;
  13202. this._twoFingerActivityCount = 0;
  13203. this._isPinching = false;
  13204. };
  13205. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13206. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13207. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  13208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13210. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  13211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13213. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  13214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13216. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13219. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13222. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13225. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13228. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13229. return ArcRotateCameraPointersInput;
  13230. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13231. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13232. ArcRotateCameraPointersInput;
  13233. /***/ }),
  13234. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13235. /*!*******************************************************************!*\
  13236. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13237. \*******************************************************************/
  13238. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13240. "use strict";
  13241. __webpack_require__.r(__webpack_exports__);
  13242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13243. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13244. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13245. /**
  13246. * Add orientation input support to the input manager.
  13247. * @returns the current input manager
  13248. */
  13249. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13250. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13251. return this;
  13252. };
  13253. /**
  13254. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13256. */
  13257. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13258. /**
  13259. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13260. */
  13261. function ArcRotateCameraVRDeviceOrientationInput() {
  13262. /**
  13263. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13264. */
  13265. this.alphaCorrection = 1;
  13266. /**
  13267. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13268. */
  13269. this.gammaCorrection = 1;
  13270. this._alpha = 0;
  13271. this._gamma = 0;
  13272. this._dirty = false;
  13273. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13274. }
  13275. /**
  13276. * Attach the input controls to a specific dom element to get the input from.
  13277. * @param element Defines the element the controls should be listened from
  13278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13279. */
  13280. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13281. this.camera.attachControl(element, noPreventDefault);
  13282. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13283. };
  13284. /** @hidden */
  13285. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13286. if (evt.alpha !== null) {
  13287. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13288. }
  13289. if (evt.gamma !== null) {
  13290. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13291. }
  13292. this._dirty = true;
  13293. };
  13294. /**
  13295. * Update the current camera state depending on the inputs that have been used this frame.
  13296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13297. */
  13298. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13299. if (this._dirty) {
  13300. this._dirty = false;
  13301. if (this._gamma < 0) {
  13302. this._gamma = 180 + this._gamma;
  13303. }
  13304. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13305. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13306. }
  13307. };
  13308. /**
  13309. * Detach the current controls from the specified dom element.
  13310. * @param element Defines the element to stop listening the inputs from
  13311. */
  13312. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13313. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13314. };
  13315. /**
  13316. * Gets the class name of the current intput.
  13317. * @returns the class name
  13318. */
  13319. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13320. return "ArcRotateCameraVRDeviceOrientationInput";
  13321. };
  13322. /**
  13323. * Get the friendly name associated with the input class.
  13324. * @returns the input friendly name
  13325. */
  13326. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13327. return "VRDeviceOrientation";
  13328. };
  13329. return ArcRotateCameraVRDeviceOrientationInput;
  13330. }());
  13331. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13332. /***/ }),
  13333. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13334. /*!**************************************************!*\
  13335. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13336. \**************************************************/
  13337. /*! exports provided: FlyCameraKeyboardInput */
  13338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13339. "use strict";
  13340. __webpack_require__.r(__webpack_exports__);
  13341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13342. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13343. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13344. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13345. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13346. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  13347. /**
  13348. * Listen to keyboard events to control the camera.
  13349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13350. */
  13351. var FlyCameraKeyboardInput = /** @class */ (function () {
  13352. function FlyCameraKeyboardInput() {
  13353. /**
  13354. * The list of keyboard keys used to control the forward move of the camera.
  13355. */
  13356. this.keysForward = [87];
  13357. /**
  13358. * The list of keyboard keys used to control the backward move of the camera.
  13359. */
  13360. this.keysBackward = [83];
  13361. /**
  13362. * The list of keyboard keys used to control the forward move of the camera.
  13363. */
  13364. this.keysUp = [69];
  13365. /**
  13366. * The list of keyboard keys used to control the backward move of the camera.
  13367. */
  13368. this.keysDown = [81];
  13369. /**
  13370. * The list of keyboard keys used to control the right strafe move of the camera.
  13371. */
  13372. this.keysRight = [68];
  13373. /**
  13374. * The list of keyboard keys used to control the left strafe move of the camera.
  13375. */
  13376. this.keysLeft = [65];
  13377. this._keys = new Array();
  13378. }
  13379. /**
  13380. * Attach the input controls to a specific dom element to get the input from.
  13381. * @param element Defines the element the controls should be listened from
  13382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13383. */
  13384. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13385. var _this = this;
  13386. if (this._onCanvasBlurObserver) {
  13387. return;
  13388. }
  13389. this._scene = this.camera.getScene();
  13390. this._engine = this._scene.getEngine();
  13391. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13392. _this._keys = [];
  13393. });
  13394. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13395. var evt = info.event;
  13396. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13397. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13398. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13399. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13400. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13401. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13402. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13403. var index = _this._keys.indexOf(evt.keyCode);
  13404. if (index === -1) {
  13405. _this._keys.push(evt.keyCode);
  13406. }
  13407. if (!noPreventDefault) {
  13408. evt.preventDefault();
  13409. }
  13410. }
  13411. }
  13412. else {
  13413. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13414. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13415. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13416. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13417. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13418. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13419. var index = _this._keys.indexOf(evt.keyCode);
  13420. if (index >= 0) {
  13421. _this._keys.splice(index, 1);
  13422. }
  13423. if (!noPreventDefault) {
  13424. evt.preventDefault();
  13425. }
  13426. }
  13427. }
  13428. });
  13429. };
  13430. /**
  13431. * Detach the current controls from the specified dom element.
  13432. * @param element Defines the element to stop listening the inputs from
  13433. */
  13434. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13435. if (this._scene) {
  13436. if (this._onKeyboardObserver) {
  13437. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13438. }
  13439. if (this._onCanvasBlurObserver) {
  13440. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13441. }
  13442. this._onKeyboardObserver = null;
  13443. this._onCanvasBlurObserver = null;
  13444. }
  13445. this._keys = [];
  13446. };
  13447. /**
  13448. * Gets the class name of the current intput.
  13449. * @returns the class name
  13450. */
  13451. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13452. return "FlyCameraKeyboardInput";
  13453. };
  13454. /** @hidden */
  13455. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13456. this._keys = [];
  13457. };
  13458. /**
  13459. * Get the friendly name associated with the input class.
  13460. * @returns the input friendly name
  13461. */
  13462. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13463. return "keyboard";
  13464. };
  13465. /**
  13466. * Update the current camera state depending on the inputs that have been used this frame.
  13467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13468. */
  13469. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13470. if (this._onKeyboardObserver) {
  13471. var camera = this.camera;
  13472. // Keyboard
  13473. for (var index = 0; index < this._keys.length; index++) {
  13474. var keyCode = this._keys[index];
  13475. var speed = camera._computeLocalCameraSpeed();
  13476. if (this.keysForward.indexOf(keyCode) !== -1) {
  13477. camera._localDirection.copyFromFloats(0, 0, speed);
  13478. }
  13479. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13480. camera._localDirection.copyFromFloats(0, 0, -speed);
  13481. }
  13482. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13483. camera._localDirection.copyFromFloats(0, speed, 0);
  13484. }
  13485. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13486. camera._localDirection.copyFromFloats(0, -speed, 0);
  13487. }
  13488. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13489. camera._localDirection.copyFromFloats(speed, 0, 0);
  13490. }
  13491. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13492. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13493. }
  13494. if (camera.getScene().useRightHandedSystem) {
  13495. camera._localDirection.z *= -1;
  13496. }
  13497. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13498. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13499. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13500. }
  13501. }
  13502. };
  13503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13505. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13508. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13511. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13514. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13517. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13520. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13521. return FlyCameraKeyboardInput;
  13522. }());
  13523. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13524. /***/ }),
  13525. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13526. /*!***********************************************!*\
  13527. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13528. \***********************************************/
  13529. /*! exports provided: FlyCameraMouseInput */
  13530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13531. "use strict";
  13532. __webpack_require__.r(__webpack_exports__);
  13533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13534. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13535. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13536. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13537. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13538. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  13539. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math.axis */ "./Maths/math.axis.ts");
  13540. /**
  13541. * Listen to mouse events to control the camera.
  13542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13543. */
  13544. var FlyCameraMouseInput = /** @class */ (function () {
  13545. /**
  13546. * Listen to mouse events to control the camera.
  13547. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13549. */
  13550. function FlyCameraMouseInput(touchEnabled) {
  13551. if (touchEnabled === void 0) { touchEnabled = true; }
  13552. /**
  13553. * Defines the buttons associated with the input to handle camera rotation.
  13554. */
  13555. this.buttons = [0, 1, 2];
  13556. /**
  13557. * Assign buttons for Yaw control.
  13558. */
  13559. this.buttonsYaw = [-1, 0, 1];
  13560. /**
  13561. * Assign buttons for Pitch control.
  13562. */
  13563. this.buttonsPitch = [-1, 0, 1];
  13564. /**
  13565. * Assign buttons for Roll control.
  13566. */
  13567. this.buttonsRoll = [2];
  13568. /**
  13569. * Detect if any button is being pressed while mouse is moved.
  13570. * -1 = Mouse locked.
  13571. * 0 = Left button.
  13572. * 1 = Middle Button.
  13573. * 2 = Right Button.
  13574. */
  13575. this.activeButton = -1;
  13576. /**
  13577. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13578. * Higher values reduce its sensitivity.
  13579. */
  13580. this.angularSensibility = 1000.0;
  13581. this.previousPosition = null;
  13582. }
  13583. /**
  13584. * Attach the mouse control to the HTML DOM element.
  13585. * @param element Defines the element that listens to the input events.
  13586. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13587. */
  13588. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13589. var _this = this;
  13590. this.element = element;
  13591. this.noPreventDefault = noPreventDefault;
  13592. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13593. _this._pointerInput(p, s);
  13594. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13595. // Correct Roll by rate, if enabled.
  13596. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13597. if (_this.camera.rollCorrect) {
  13598. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13599. }
  13600. });
  13601. // Helper function to keep 'this'.
  13602. this._mousemoveCallback = function (e) {
  13603. _this._onMouseMove(e);
  13604. };
  13605. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13606. };
  13607. /**
  13608. * Detach the current controls from the specified dom element.
  13609. * @param element Defines the element to stop listening the inputs from
  13610. */
  13611. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13612. if (this._observer && element) {
  13613. this.camera.getScene().onPointerObservable.remove(this._observer);
  13614. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13615. if (this._mousemoveCallback) {
  13616. element.removeEventListener("mousemove", this._mousemoveCallback);
  13617. }
  13618. this._observer = null;
  13619. this._rollObserver = null;
  13620. this.previousPosition = null;
  13621. this.noPreventDefault = undefined;
  13622. }
  13623. };
  13624. /**
  13625. * Gets the class name of the current input.
  13626. * @returns the class name.
  13627. */
  13628. FlyCameraMouseInput.prototype.getClassName = function () {
  13629. return "FlyCameraMouseInput";
  13630. };
  13631. /**
  13632. * Get the friendly name associated with the input class.
  13633. * @returns the input's friendly name.
  13634. */
  13635. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13636. return "mouse";
  13637. };
  13638. // Track mouse movement, when the pointer is not locked.
  13639. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13640. var e = p.event;
  13641. var camera = this.camera;
  13642. var engine = camera.getEngine();
  13643. if (engine.isInVRExclusivePointerMode) {
  13644. return;
  13645. }
  13646. if (!this.touchEnabled && e.pointerType === "touch") {
  13647. return;
  13648. }
  13649. // Mouse is moved but an unknown mouse button is pressed.
  13650. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13651. return;
  13652. }
  13653. var srcElement = (e.srcElement || e.target);
  13654. // Mouse down.
  13655. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13656. try {
  13657. srcElement.setPointerCapture(e.pointerId);
  13658. }
  13659. catch (e) {
  13660. // Nothing to do with the error. Execution continues.
  13661. }
  13662. this.previousPosition = {
  13663. x: e.clientX,
  13664. y: e.clientY
  13665. };
  13666. this.activeButton = e.button;
  13667. if (!this.noPreventDefault) {
  13668. e.preventDefault();
  13669. this.element.focus();
  13670. }
  13671. }
  13672. else
  13673. // Mouse up.
  13674. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13675. try {
  13676. srcElement.releasePointerCapture(e.pointerId);
  13677. }
  13678. catch (e) {
  13679. // Nothing to do with the error. Execution continues.
  13680. }
  13681. this.activeButton = -1;
  13682. this.previousPosition = null;
  13683. if (!this.noPreventDefault) {
  13684. e.preventDefault();
  13685. }
  13686. }
  13687. else
  13688. // Mouse move.
  13689. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13690. if (!this.previousPosition || engine.isPointerLock) {
  13691. return;
  13692. }
  13693. var offsetX = e.clientX - this.previousPosition.x;
  13694. var offsetY = e.clientY - this.previousPosition.y;
  13695. this.rotateCamera(offsetX, offsetY);
  13696. this.previousPosition = {
  13697. x: e.clientX,
  13698. y: e.clientY
  13699. };
  13700. if (!this.noPreventDefault) {
  13701. e.preventDefault();
  13702. }
  13703. }
  13704. };
  13705. // Track mouse movement, when pointer is locked.
  13706. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13707. var camera = this.camera;
  13708. var engine = camera.getEngine();
  13709. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13710. return;
  13711. }
  13712. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13713. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13714. this.rotateCamera(offsetX, offsetY);
  13715. this.previousPosition = null;
  13716. if (!this.noPreventDefault) {
  13717. e.preventDefault();
  13718. }
  13719. };
  13720. /**
  13721. * Rotate camera by mouse offset.
  13722. */
  13723. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13724. var _this = this;
  13725. var camera = this.camera;
  13726. var scene = this.camera.getScene();
  13727. if (scene.useRightHandedSystem) {
  13728. offsetX *= -1;
  13729. }
  13730. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13731. offsetX *= -1;
  13732. }
  13733. var x = offsetX / this.angularSensibility;
  13734. var y = offsetY / this.angularSensibility;
  13735. // Initialize to current rotation.
  13736. var currentRotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13737. var rotationChange;
  13738. // Pitch.
  13739. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13740. // Apply change in Radians to vector Angle.
  13741. rotationChange = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].X, y);
  13742. // Apply Pitch to quaternion.
  13743. currentRotation.multiplyInPlace(rotationChange);
  13744. }
  13745. // Yaw.
  13746. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13747. // Apply change in Radians to vector Angle.
  13748. rotationChange = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Y, x);
  13749. // Apply Yaw to quaternion.
  13750. currentRotation.multiplyInPlace(rotationChange);
  13751. // Add Roll, if banked turning is enabled, within Roll limit.
  13752. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13753. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13754. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13755. // Apply change in Radians to vector Angle.
  13756. rotationChange = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Z, bankingDelta);
  13757. // Apply Yaw to quaternion.
  13758. currentRotation.multiplyInPlace(rotationChange);
  13759. }
  13760. }
  13761. // Roll.
  13762. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13763. // Apply change in Radians to vector Angle.
  13764. rotationChange = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Z, -x);
  13765. // Track Rolling.
  13766. camera._trackRoll -= x;
  13767. // Apply Pitch to quaternion.
  13768. currentRotation.multiplyInPlace(rotationChange);
  13769. }
  13770. // Apply rotationQuaternion to Euler camera.rotation.
  13771. currentRotation.toEulerAnglesToRef(camera.rotation);
  13772. };
  13773. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13774. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13775. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13776. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13778. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13779. return FlyCameraMouseInput;
  13780. }());
  13781. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13782. /***/ }),
  13783. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13784. /*!*********************************************************!*\
  13785. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13786. \*********************************************************/
  13787. /*! exports provided: FollowCameraKeyboardMoveInput */
  13788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13789. "use strict";
  13790. __webpack_require__.r(__webpack_exports__);
  13791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13792. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13793. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13794. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13795. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13796. /**
  13797. * Manage the keyboard inputs to control the movement of a follow camera.
  13798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13799. */
  13800. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13801. function FollowCameraKeyboardMoveInput() {
  13802. /**
  13803. * Defines the list of key codes associated with the up action (increase heightOffset)
  13804. */
  13805. this.keysHeightOffsetIncr = [38];
  13806. /**
  13807. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13808. */
  13809. this.keysHeightOffsetDecr = [40];
  13810. /**
  13811. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13812. */
  13813. this.keysHeightOffsetModifierAlt = false;
  13814. /**
  13815. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13816. */
  13817. this.keysHeightOffsetModifierCtrl = false;
  13818. /**
  13819. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13820. */
  13821. this.keysHeightOffsetModifierShift = false;
  13822. /**
  13823. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13824. */
  13825. this.keysRotationOffsetIncr = [37];
  13826. /**
  13827. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13828. */
  13829. this.keysRotationOffsetDecr = [39];
  13830. /**
  13831. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13832. */
  13833. this.keysRotationOffsetModifierAlt = false;
  13834. /**
  13835. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13836. */
  13837. this.keysRotationOffsetModifierCtrl = false;
  13838. /**
  13839. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13840. */
  13841. this.keysRotationOffsetModifierShift = false;
  13842. /**
  13843. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13844. */
  13845. this.keysRadiusIncr = [40];
  13846. /**
  13847. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13848. */
  13849. this.keysRadiusDecr = [38];
  13850. /**
  13851. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13852. */
  13853. this.keysRadiusModifierAlt = true;
  13854. /**
  13855. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13856. */
  13857. this.keysRadiusModifierCtrl = false;
  13858. /**
  13859. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13860. */
  13861. this.keysRadiusModifierShift = false;
  13862. /**
  13863. * Defines the rate of change of heightOffset.
  13864. */
  13865. this.heightSensibility = 1;
  13866. /**
  13867. * Defines the rate of change of rotationOffset.
  13868. */
  13869. this.rotationSensibility = 1;
  13870. /**
  13871. * Defines the rate of change of radius.
  13872. */
  13873. this.radiusSensibility = 1;
  13874. this._keys = new Array();
  13875. }
  13876. /**
  13877. * Attach the input controls to a specific dom element to get the input from.
  13878. * @param element Defines the element the controls should be listened from
  13879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13880. */
  13881. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13882. var _this = this;
  13883. if (this._onCanvasBlurObserver) {
  13884. return;
  13885. }
  13886. this._scene = this.camera.getScene();
  13887. this._engine = this._scene.getEngine();
  13888. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13889. _this._keys = [];
  13890. });
  13891. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13892. var evt = info.event;
  13893. if (!evt.metaKey) {
  13894. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13895. _this._ctrlPressed = evt.ctrlKey;
  13896. _this._altPressed = evt.altKey;
  13897. _this._shiftPressed = evt.shiftKey;
  13898. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13899. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13900. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13901. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13902. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13903. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13904. var index = _this._keys.indexOf(evt.keyCode);
  13905. if (index === -1) {
  13906. _this._keys.push(evt.keyCode);
  13907. }
  13908. if (evt.preventDefault) {
  13909. if (!noPreventDefault) {
  13910. evt.preventDefault();
  13911. }
  13912. }
  13913. }
  13914. }
  13915. else {
  13916. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13917. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13918. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13919. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13920. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13921. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13922. var index = _this._keys.indexOf(evt.keyCode);
  13923. if (index >= 0) {
  13924. _this._keys.splice(index, 1);
  13925. }
  13926. if (evt.preventDefault) {
  13927. if (!noPreventDefault) {
  13928. evt.preventDefault();
  13929. }
  13930. }
  13931. }
  13932. }
  13933. }
  13934. });
  13935. };
  13936. /**
  13937. * Detach the current controls from the specified dom element.
  13938. * @param element Defines the element to stop listening the inputs from
  13939. */
  13940. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13941. if (this._scene) {
  13942. if (this._onKeyboardObserver) {
  13943. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13944. }
  13945. if (this._onCanvasBlurObserver) {
  13946. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13947. }
  13948. this._onKeyboardObserver = null;
  13949. this._onCanvasBlurObserver = null;
  13950. }
  13951. this._keys = [];
  13952. };
  13953. /**
  13954. * Update the current camera state depending on the inputs that have been used this frame.
  13955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13956. */
  13957. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13958. var _this = this;
  13959. if (this._onKeyboardObserver) {
  13960. this._keys.forEach(function (keyCode) {
  13961. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13962. _this._modifierHeightOffset()) {
  13963. _this.camera.heightOffset += _this.heightSensibility;
  13964. }
  13965. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13966. _this._modifierHeightOffset()) {
  13967. _this.camera.heightOffset -= _this.heightSensibility;
  13968. }
  13969. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13970. _this._modifierRotationOffset()) {
  13971. _this.camera.rotationOffset += _this.rotationSensibility;
  13972. _this.camera.rotationOffset %= 360;
  13973. }
  13974. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13975. _this._modifierRotationOffset()) {
  13976. _this.camera.rotationOffset -= _this.rotationSensibility;
  13977. _this.camera.rotationOffset %= 360;
  13978. }
  13979. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13980. _this._modifierRadius()) {
  13981. _this.camera.radius += _this.radiusSensibility;
  13982. }
  13983. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13984. _this._modifierRadius()) {
  13985. _this.camera.radius -= _this.radiusSensibility;
  13986. }
  13987. });
  13988. }
  13989. };
  13990. /**
  13991. * Gets the class name of the current input.
  13992. * @returns the class name
  13993. */
  13994. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13995. return "FollowCameraKeyboardMoveInput";
  13996. };
  13997. /**
  13998. * Get the friendly name associated with the input class.
  13999. * @returns the input friendly name
  14000. */
  14001. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14002. return "keyboard";
  14003. };
  14004. /**
  14005. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  14006. * allow modification of the heightOffset value.
  14007. */
  14008. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  14009. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  14010. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  14011. this.keysHeightOffsetModifierShift === this._shiftPressed);
  14012. };
  14013. /**
  14014. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  14015. * allow modification of the rotationOffset value.
  14016. */
  14017. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  14018. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  14019. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  14020. this.keysRotationOffsetModifierShift === this._shiftPressed);
  14021. };
  14022. /**
  14023. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  14024. * allow modification of the radius value.
  14025. */
  14026. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  14027. return (this.keysRadiusModifierAlt === this._altPressed &&
  14028. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  14029. this.keysRadiusModifierShift === this._shiftPressed);
  14030. };
  14031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14033. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  14034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14036. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  14037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14039. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  14040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14042. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  14043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14045. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  14046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14048. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  14049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14051. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  14052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14054. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  14055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14057. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  14058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14060. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  14061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14063. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  14064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14066. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  14067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14069. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  14070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14072. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  14073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14075. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  14076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14078. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  14079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14081. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  14082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14084. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  14085. return FollowCameraKeyboardMoveInput;
  14086. }());
  14087. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  14088. /***/ }),
  14089. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  14090. /*!*******************************************************!*\
  14091. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  14092. \*******************************************************/
  14093. /*! exports provided: FollowCameraMouseWheelInput */
  14094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14095. "use strict";
  14096. __webpack_require__.r(__webpack_exports__);
  14097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  14098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14099. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14100. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14101. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14102. /**
  14103. * Manage the mouse wheel inputs to control a follow camera.
  14104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14105. */
  14106. var FollowCameraMouseWheelInput = /** @class */ (function () {
  14107. function FollowCameraMouseWheelInput() {
  14108. /**
  14109. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  14110. */
  14111. this.axisControlRadius = true;
  14112. /**
  14113. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  14114. */
  14115. this.axisControlHeight = false;
  14116. /**
  14117. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  14118. */
  14119. this.axisControlRotation = false;
  14120. /**
  14121. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  14122. * relation to mouseWheel events.
  14123. */
  14124. this.wheelPrecision = 3.0;
  14125. /**
  14126. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  14127. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  14128. */
  14129. this.wheelDeltaPercentage = 0;
  14130. }
  14131. /**
  14132. * Attach the input controls to a specific dom element to get the input from.
  14133. * @param element Defines the element the controls should be listened from
  14134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14135. */
  14136. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  14137. var _this = this;
  14138. this._wheel = function (p, s) {
  14139. // sanity check - this should be a PointerWheel event.
  14140. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  14141. return;
  14142. }
  14143. var event = p.event;
  14144. var delta = 0;
  14145. // Chrome, Safari: event.deltaY
  14146. // IE: event.wheelDelta
  14147. // Firefox: event.detail (inverted)
  14148. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  14149. if (_this.wheelDeltaPercentage) {
  14150. console.assert((_this.axisControlRadius +
  14151. _this.axisControlHeight +
  14152. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  14153. "controlls ONE axis. " +
  14154. "Currently enabled: " +
  14155. "axisControlRadius: " + _this.axisControlRadius +
  14156. ", axisControlHeightOffset: " + _this.axisControlHeight +
  14157. ", axisControlRotationOffset: " + _this.axisControlRotation);
  14158. if (_this.axisControlRadius) {
  14159. delta =
  14160. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14161. _this.camera.radius;
  14162. }
  14163. else if (_this.axisControlHeight) {
  14164. delta =
  14165. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14166. _this.camera.heightOffset;
  14167. }
  14168. else if (_this.axisControlRotation) {
  14169. delta =
  14170. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14171. _this.camera.rotationOffset;
  14172. }
  14173. }
  14174. else {
  14175. delta = wheelDelta * _this.wheelPrecision;
  14176. }
  14177. if (delta) {
  14178. if (_this.axisControlRadius) {
  14179. _this.camera.radius += delta;
  14180. }
  14181. else if (_this.axisControlHeight) {
  14182. _this.camera.heightOffset -= delta;
  14183. }
  14184. else if (_this.axisControlRotation) {
  14185. _this.camera.rotationOffset -= delta;
  14186. }
  14187. }
  14188. if (event.preventDefault) {
  14189. if (!noPreventDefault) {
  14190. event.preventDefault();
  14191. }
  14192. }
  14193. };
  14194. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  14195. };
  14196. /**
  14197. * Detach the current controls from the specified dom element.
  14198. * @param element Defines the element to stop listening the inputs from
  14199. */
  14200. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  14201. if (this._observer && element) {
  14202. this.camera.getScene().onPointerObservable.remove(this._observer);
  14203. this._observer = null;
  14204. this._wheel = null;
  14205. }
  14206. };
  14207. /**
  14208. * Gets the class name of the current intput.
  14209. * @returns the class name
  14210. */
  14211. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  14212. return "ArcRotateCameraMouseWheelInput";
  14213. };
  14214. /**
  14215. * Get the friendly name associated with the input class.
  14216. * @returns the input friendly name
  14217. */
  14218. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14219. return "mousewheel";
  14220. };
  14221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14223. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14226. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14229. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14232. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14235. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14236. return FollowCameraMouseWheelInput;
  14237. }());
  14238. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14239. /***/ }),
  14240. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14241. /*!*****************************************************!*\
  14242. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14243. \*****************************************************/
  14244. /*! exports provided: FollowCameraPointersInput */
  14245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14246. "use strict";
  14247. __webpack_require__.r(__webpack_exports__);
  14248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14249. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14250. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14251. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14252. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14253. /**
  14254. * Manage the pointers inputs to control an follow camera.
  14255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14256. */
  14257. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14258. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14259. function FollowCameraPointersInput() {
  14260. var _this = _super !== null && _super.apply(this, arguments) || this;
  14261. /**
  14262. * Defines the pointer angular sensibility along the X axis or how fast is
  14263. * the camera rotating.
  14264. * A negative number will reverse the axis direction.
  14265. */
  14266. _this.angularSensibilityX = 1;
  14267. /**
  14268. * Defines the pointer angular sensibility along the Y axis or how fast is
  14269. * the camera rotating.
  14270. * A negative number will reverse the axis direction.
  14271. */
  14272. _this.angularSensibilityY = 1;
  14273. /**
  14274. * Defines the pointer pinch precision or how fast is the camera zooming.
  14275. * A negative number will reverse the axis direction.
  14276. */
  14277. _this.pinchPrecision = 10000.0;
  14278. /**
  14279. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14280. * from 0.
  14281. * It defines the percentage of current camera.radius to use as delta when
  14282. * pinch zoom is used.
  14283. */
  14284. _this.pinchDeltaPercentage = 0;
  14285. /**
  14286. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14287. */
  14288. _this.axisXControlRadius = false;
  14289. /**
  14290. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14291. */
  14292. _this.axisXControlHeight = false;
  14293. /**
  14294. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14295. */
  14296. _this.axisXControlRotation = true;
  14297. /**
  14298. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14299. */
  14300. _this.axisYControlRadius = false;
  14301. /**
  14302. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14303. */
  14304. _this.axisYControlHeight = true;
  14305. /**
  14306. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14307. */
  14308. _this.axisYControlRotation = false;
  14309. /**
  14310. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14311. */
  14312. _this.axisPinchControlRadius = true;
  14313. /**
  14314. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14315. */
  14316. _this.axisPinchControlHeight = false;
  14317. /**
  14318. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14319. */
  14320. _this.axisPinchControlRotation = false;
  14321. /**
  14322. * Log error messages if basic misconfiguration has occurred.
  14323. */
  14324. _this.warningEnable = true;
  14325. /* Check for obvious misconfiguration. */
  14326. _this._warningCounter = 0;
  14327. return _this;
  14328. }
  14329. /**
  14330. * Gets the class name of the current input.
  14331. * @returns the class name
  14332. */
  14333. FollowCameraPointersInput.prototype.getClassName = function () {
  14334. return "FollowCameraPointersInput";
  14335. };
  14336. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14337. this._warning();
  14338. if (this.axisXControlRotation) {
  14339. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14340. }
  14341. else if (this.axisYControlRotation) {
  14342. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14343. }
  14344. if (this.axisXControlHeight) {
  14345. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14346. }
  14347. else if (this.axisYControlHeight) {
  14348. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14349. }
  14350. if (this.axisXControlRadius) {
  14351. this.camera.radius -= offsetX / this.angularSensibilityY;
  14352. }
  14353. else if (this.axisYControlRadius) {
  14354. this.camera.radius -= offsetY / this.angularSensibilityY;
  14355. }
  14356. };
  14357. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14358. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14359. // First time this method is called for new pinch.
  14360. // Next time this is called there will be a
  14361. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14362. return;
  14363. }
  14364. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14365. // Last time this method is called at the end of a pinch.
  14366. return;
  14367. }
  14368. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14369. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14370. if (this.pinchDeltaPercentage) {
  14371. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14372. if (this.axisPinchControlRotation) {
  14373. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14374. }
  14375. if (this.axisPinchControlHeight) {
  14376. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14377. }
  14378. if (this.axisPinchControlRadius) {
  14379. this.camera.radius -= pinchDelta * this.camera.radius;
  14380. }
  14381. }
  14382. else {
  14383. if (this.axisPinchControlRotation) {
  14384. this.camera.rotationOffset += pinchDelta;
  14385. }
  14386. if (this.axisPinchControlHeight) {
  14387. this.camera.heightOffset += pinchDelta;
  14388. }
  14389. if (this.axisPinchControlRadius) {
  14390. this.camera.radius -= pinchDelta;
  14391. }
  14392. }
  14393. };
  14394. FollowCameraPointersInput.prototype._warning = function () {
  14395. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14396. return;
  14397. }
  14398. var warn = "It probably only makes sense to control ONE camera " +
  14399. "property with each pointer axis. Set 'warningEnable = false' " +
  14400. "if you are sure. Currently enabled: ";
  14401. console.assert((this.axisXControlRotation +
  14402. this.axisXControlHeight +
  14403. this.axisXControlRadius) <= 1, warn +
  14404. "axisXControlRotation: " + this.axisXControlRotation +
  14405. ", axisXControlHeight: " + this.axisXControlHeight +
  14406. ", axisXControlRadius: " + this.axisXControlRadius);
  14407. console.assert((this.axisYControlRotation +
  14408. this.axisYControlHeight +
  14409. this.axisYControlRadius) <= 1, warn +
  14410. "axisYControlRotation: " + this.axisYControlRotation +
  14411. ", axisYControlHeight: " + this.axisYControlHeight +
  14412. ", axisYControlRadius: " + this.axisYControlRadius);
  14413. console.assert((this.axisPinchControlRotation +
  14414. this.axisPinchControlHeight +
  14415. this.axisPinchControlRadius) <= 1, warn +
  14416. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14417. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14418. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14419. };
  14420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14422. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14425. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14428. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14431. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14434. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14437. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14440. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14443. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14446. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14449. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14452. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14455. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14458. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14459. return FollowCameraPointersInput;
  14460. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14461. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14462. /***/ }),
  14463. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14464. /*!************************************************************!*\
  14465. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14466. \************************************************************/
  14467. /*! exports provided: FreeCameraDeviceOrientationInput */
  14468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14469. "use strict";
  14470. __webpack_require__.r(__webpack_exports__);
  14471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14472. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14473. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  14474. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14475. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14476. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14477. /**
  14478. * Add orientation input support to the input manager.
  14479. * @returns the current input manager
  14480. */
  14481. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14482. if (!this._deviceOrientationInput) {
  14483. this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();
  14484. this.add(this._deviceOrientationInput);
  14485. }
  14486. return this;
  14487. };
  14488. /**
  14489. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14490. * Screen rotation is taken into account.
  14491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14492. */
  14493. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14494. /**
  14495. * Instantiates a new input
  14496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14497. */
  14498. function FreeCameraDeviceOrientationInput() {
  14499. var _this = this;
  14500. this._screenOrientationAngle = 0;
  14501. this._screenQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14502. this._alpha = 0;
  14503. this._beta = 0;
  14504. this._gamma = 0;
  14505. /**
  14506. * @hidden
  14507. */
  14508. this._onDeviceOrientationChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  14509. this._orientationChanged = function () {
  14510. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14511. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14512. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14513. };
  14514. this._deviceOrientation = function (evt) {
  14515. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14516. _this._beta = evt.beta !== null ? evt.beta : 0;
  14517. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14518. if (evt.alpha !== null) {
  14519. _this._onDeviceOrientationChangedObservable.notifyObservers();
  14520. }
  14521. };
  14522. this._constantTranform = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14523. this._orientationChanged();
  14524. }
  14525. /**
  14526. * Can be used to detect if a device orientation sensor is availible on a device
  14527. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  14528. * @returns a promise that will resolve on orientation change
  14529. */
  14530. FreeCameraDeviceOrientationInput.WaitForOrientationChangeAsync = function (timeout) {
  14531. return new Promise(function (res, rej) {
  14532. var gotValue = false;
  14533. var eventHandler = function () {
  14534. window.removeEventListener("deviceorientation", eventHandler);
  14535. gotValue = true;
  14536. res();
  14537. };
  14538. // If timeout is pupulated reject the promise
  14539. if (timeout) {
  14540. setTimeout(function () {
  14541. if (!gotValue) {
  14542. window.removeEventListener("deviceorientation", eventHandler);
  14543. rej("WaitForOrientationChangeAsync timed out");
  14544. }
  14545. }, timeout);
  14546. }
  14547. window.addEventListener("deviceorientation", eventHandler);
  14548. });
  14549. };
  14550. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14551. /**
  14552. * Define the camera controlled by the input.
  14553. */
  14554. get: function () {
  14555. return this._camera;
  14556. },
  14557. set: function (camera) {
  14558. var _this = this;
  14559. this._camera = camera;
  14560. if (this._camera != null && !this._camera.rotationQuaternion) {
  14561. this._camera.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14562. }
  14563. if (this._camera) {
  14564. this._camera.onDisposeObservable.add(function () {
  14565. _this._onDeviceOrientationChangedObservable.clear();
  14566. });
  14567. }
  14568. },
  14569. enumerable: true,
  14570. configurable: true
  14571. });
  14572. /**
  14573. * Attach the input controls to a specific dom element to get the input from.
  14574. * @param element Defines the element the controls should be listened from
  14575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14576. */
  14577. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14578. window.addEventListener("orientationchange", this._orientationChanged);
  14579. window.addEventListener("deviceorientation", this._deviceOrientation);
  14580. //In certain cases, the attach control is called AFTER orientation was changed,
  14581. //So this is needed.
  14582. this._orientationChanged();
  14583. };
  14584. /**
  14585. * Detach the current controls from the specified dom element.
  14586. * @param element Defines the element to stop listening the inputs from
  14587. */
  14588. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14589. window.removeEventListener("orientationchange", this._orientationChanged);
  14590. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14591. this._alpha = 0;
  14592. };
  14593. /**
  14594. * Update the current camera state depending on the inputs that have been used this frame.
  14595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14596. */
  14597. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14598. //if no device orientation provided, don't update the rotation.
  14599. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14600. if (!this._alpha) {
  14601. return;
  14602. }
  14603. _Maths_math_vector__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);
  14604. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14605. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14606. //Mirror on XY Plane
  14607. this._camera.rotationQuaternion.z *= -1;
  14608. this._camera.rotationQuaternion.w *= -1;
  14609. };
  14610. /**
  14611. * Gets the class name of the current intput.
  14612. * @returns the class name
  14613. */
  14614. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14615. return "FreeCameraDeviceOrientationInput";
  14616. };
  14617. /**
  14618. * Get the friendly name associated with the input class.
  14619. * @returns the input friendly name
  14620. */
  14621. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14622. return "deviceOrientation";
  14623. };
  14624. return FreeCameraDeviceOrientationInput;
  14625. }());
  14626. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14627. /***/ }),
  14628. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14629. /*!**************************************************!*\
  14630. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14631. \**************************************************/
  14632. /*! exports provided: FreeCameraGamepadInput */
  14633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14634. "use strict";
  14635. __webpack_require__.r(__webpack_exports__);
  14636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14637. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14638. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14639. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14640. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  14641. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14642. /**
  14643. * Manage the gamepad inputs to control a free camera.
  14644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14645. */
  14646. var FreeCameraGamepadInput = /** @class */ (function () {
  14647. function FreeCameraGamepadInput() {
  14648. /**
  14649. * Defines the gamepad rotation sensiblity.
  14650. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14651. */
  14652. this.gamepadAngularSensibility = 200;
  14653. /**
  14654. * Defines the gamepad move sensiblity.
  14655. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14656. */
  14657. this.gamepadMoveSensibility = 40;
  14658. this._cameraTransform = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14659. this._deltaTransform = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14660. this._vector3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14661. this._vector2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14662. }
  14663. /**
  14664. * Attach the input controls to a specific dom element to get the input from.
  14665. * @param element Defines the element the controls should be listened from
  14666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14667. */
  14668. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14669. var _this = this;
  14670. var manager = this.camera.getScene().gamepadManager;
  14671. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14672. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14673. // prioritize XBOX gamepads.
  14674. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14675. _this.gamepad = gamepad;
  14676. }
  14677. }
  14678. });
  14679. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14680. if (_this.gamepad === gamepad) {
  14681. _this.gamepad = null;
  14682. }
  14683. });
  14684. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14685. };
  14686. /**
  14687. * Detach the current controls from the specified dom element.
  14688. * @param element Defines the element to stop listening the inputs from
  14689. */
  14690. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14691. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14692. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14693. this.gamepad = null;
  14694. };
  14695. /**
  14696. * Update the current camera state depending on the inputs that have been used this frame.
  14697. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14698. */
  14699. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14700. if (this.gamepad && this.gamepad.leftStick) {
  14701. var camera = this.camera;
  14702. var LSValues = this.gamepad.leftStick;
  14703. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14704. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14705. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14706. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14707. var RSValues = this.gamepad.rightStick;
  14708. if (RSValues) {
  14709. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14710. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14711. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14712. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14713. }
  14714. else {
  14715. RSValues = { x: 0, y: 0 };
  14716. }
  14717. if (!camera.rotationQuaternion) {
  14718. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14719. }
  14720. else {
  14721. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14722. }
  14723. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14724. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14725. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14726. camera.cameraDirection.addInPlace(this._deltaTransform);
  14727. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14728. camera.cameraRotation.addInPlace(this._vector2);
  14729. }
  14730. };
  14731. /**
  14732. * Gets the class name of the current intput.
  14733. * @returns the class name
  14734. */
  14735. FreeCameraGamepadInput.prototype.getClassName = function () {
  14736. return "FreeCameraGamepadInput";
  14737. };
  14738. /**
  14739. * Get the friendly name associated with the input class.
  14740. * @returns the input friendly name
  14741. */
  14742. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14743. return "gamepad";
  14744. };
  14745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14747. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14750. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14751. return FreeCameraGamepadInput;
  14752. }());
  14753. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14754. /***/ }),
  14755. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14756. /*!*******************************************************!*\
  14757. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14758. \*******************************************************/
  14759. /*! exports provided: FreeCameraKeyboardMoveInput */
  14760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14761. "use strict";
  14762. __webpack_require__.r(__webpack_exports__);
  14763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14764. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14765. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14766. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14767. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14768. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  14769. /**
  14770. * Manage the keyboard inputs to control the movement of a free camera.
  14771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14772. */
  14773. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14774. function FreeCameraKeyboardMoveInput() {
  14775. /**
  14776. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14777. */
  14778. this.keysUp = [38];
  14779. /**
  14780. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14781. */
  14782. this.keysDown = [40];
  14783. /**
  14784. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14785. */
  14786. this.keysLeft = [37];
  14787. /**
  14788. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14789. */
  14790. this.keysRight = [39];
  14791. this._keys = new Array();
  14792. }
  14793. /**
  14794. * Attach the input controls to a specific dom element to get the input from.
  14795. * @param element Defines the element the controls should be listened from
  14796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14797. */
  14798. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14799. var _this = this;
  14800. if (this._onCanvasBlurObserver) {
  14801. return;
  14802. }
  14803. this._scene = this.camera.getScene();
  14804. this._engine = this._scene.getEngine();
  14805. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14806. _this._keys = [];
  14807. });
  14808. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14809. var evt = info.event;
  14810. if (!evt.metaKey) {
  14811. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14812. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14813. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14814. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14815. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14816. var index = _this._keys.indexOf(evt.keyCode);
  14817. if (index === -1) {
  14818. _this._keys.push(evt.keyCode);
  14819. }
  14820. if (!noPreventDefault) {
  14821. evt.preventDefault();
  14822. }
  14823. }
  14824. }
  14825. else {
  14826. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14827. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14828. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14829. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14830. var index = _this._keys.indexOf(evt.keyCode);
  14831. if (index >= 0) {
  14832. _this._keys.splice(index, 1);
  14833. }
  14834. if (!noPreventDefault) {
  14835. evt.preventDefault();
  14836. }
  14837. }
  14838. }
  14839. }
  14840. });
  14841. };
  14842. /**
  14843. * Detach the current controls from the specified dom element.
  14844. * @param element Defines the element to stop listening the inputs from
  14845. */
  14846. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14847. if (this._scene) {
  14848. if (this._onKeyboardObserver) {
  14849. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14850. }
  14851. if (this._onCanvasBlurObserver) {
  14852. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14853. }
  14854. this._onKeyboardObserver = null;
  14855. this._onCanvasBlurObserver = null;
  14856. }
  14857. this._keys = [];
  14858. };
  14859. /**
  14860. * Update the current camera state depending on the inputs that have been used this frame.
  14861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14862. */
  14863. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14864. if (this._onKeyboardObserver) {
  14865. var camera = this.camera;
  14866. // Keyboard
  14867. for (var index = 0; index < this._keys.length; index++) {
  14868. var keyCode = this._keys[index];
  14869. var speed = camera._computeLocalCameraSpeed();
  14870. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14871. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14872. }
  14873. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14874. camera._localDirection.copyFromFloats(0, 0, speed);
  14875. }
  14876. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14877. camera._localDirection.copyFromFloats(speed, 0, 0);
  14878. }
  14879. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14880. camera._localDirection.copyFromFloats(0, 0, -speed);
  14881. }
  14882. if (camera.getScene().useRightHandedSystem) {
  14883. camera._localDirection.z *= -1;
  14884. }
  14885. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14886. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14887. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14888. }
  14889. }
  14890. };
  14891. /**
  14892. * Gets the class name of the current intput.
  14893. * @returns the class name
  14894. */
  14895. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14896. return "FreeCameraKeyboardMoveInput";
  14897. };
  14898. /** @hidden */
  14899. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14900. this._keys = [];
  14901. };
  14902. /**
  14903. * Get the friendly name associated with the input class.
  14904. * @returns the input friendly name
  14905. */
  14906. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14907. return "keyboard";
  14908. };
  14909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14911. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14914. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14917. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14920. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14921. return FreeCameraKeyboardMoveInput;
  14922. }());
  14923. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14924. /***/ }),
  14925. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14926. /*!************************************************!*\
  14927. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14928. \************************************************/
  14929. /*! exports provided: FreeCameraMouseInput */
  14930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14931. "use strict";
  14932. __webpack_require__.r(__webpack_exports__);
  14933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14935. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14936. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14937. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14938. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14939. /**
  14940. * Manage the mouse inputs to control the movement of a free camera.
  14941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14942. */
  14943. var FreeCameraMouseInput = /** @class */ (function () {
  14944. /**
  14945. * Manage the mouse inputs to control the movement of a free camera.
  14946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14947. * @param touchEnabled Defines if touch is enabled or not
  14948. */
  14949. function FreeCameraMouseInput(
  14950. /**
  14951. * Define if touch is enabled in the mouse input
  14952. */
  14953. touchEnabled) {
  14954. if (touchEnabled === void 0) { touchEnabled = true; }
  14955. this.touchEnabled = touchEnabled;
  14956. /**
  14957. * Defines the buttons associated with the input to handle camera move.
  14958. */
  14959. this.buttons = [0, 1, 2];
  14960. /**
  14961. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14962. */
  14963. this.angularSensibility = 2000.0;
  14964. this.previousPosition = null;
  14965. /**
  14966. * Observable for when a pointer move event occurs containing the move offset
  14967. */
  14968. this.onPointerMovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  14969. /**
  14970. * @hidden
  14971. * If the camera should be rotated automatically based on pointer movement
  14972. */
  14973. this._allowCameraRotation = true;
  14974. }
  14975. /**
  14976. * Attach the input controls to a specific dom element to get the input from.
  14977. * @param element Defines the element the controls should be listened from
  14978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14979. */
  14980. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14981. var _this = this;
  14982. var engine = this.camera.getEngine();
  14983. if (!this._pointerInput) {
  14984. this._pointerInput = function (p) {
  14985. var evt = p.event;
  14986. if (engine.isInVRExclusivePointerMode) {
  14987. return;
  14988. }
  14989. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14990. return;
  14991. }
  14992. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14993. return;
  14994. }
  14995. var srcElement = (evt.srcElement || evt.target);
  14996. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14997. try {
  14998. srcElement.setPointerCapture(evt.pointerId);
  14999. }
  15000. catch (e) {
  15001. //Nothing to do with the error. Execution will continue.
  15002. }
  15003. _this.previousPosition = {
  15004. x: evt.clientX,
  15005. y: evt.clientY
  15006. };
  15007. if (!noPreventDefault) {
  15008. evt.preventDefault();
  15009. element.focus();
  15010. }
  15011. }
  15012. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  15013. try {
  15014. srcElement.releasePointerCapture(evt.pointerId);
  15015. }
  15016. catch (e) {
  15017. //Nothing to do with the error.
  15018. }
  15019. _this.previousPosition = null;
  15020. if (!noPreventDefault) {
  15021. evt.preventDefault();
  15022. }
  15023. }
  15024. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  15025. if (!_this.previousPosition || engine.isPointerLock) {
  15026. return;
  15027. }
  15028. var offsetX = evt.clientX - _this.previousPosition.x;
  15029. var offsetY = evt.clientY - _this.previousPosition.y;
  15030. if (_this.camera.getScene().useRightHandedSystem) {
  15031. offsetX *= -1;
  15032. }
  15033. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  15034. offsetX *= -1;
  15035. }
  15036. if (_this._allowCameraRotation) {
  15037. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  15038. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  15039. }
  15040. _this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });
  15041. _this.previousPosition = {
  15042. x: evt.clientX,
  15043. y: evt.clientY
  15044. };
  15045. if (!noPreventDefault) {
  15046. evt.preventDefault();
  15047. }
  15048. }
  15049. };
  15050. }
  15051. this._onMouseMove = function (evt) {
  15052. if (!engine.isPointerLock) {
  15053. return;
  15054. }
  15055. if (engine.isInVRExclusivePointerMode) {
  15056. return;
  15057. }
  15058. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  15059. if (_this.camera.getScene().useRightHandedSystem) {
  15060. offsetX *= -1;
  15061. }
  15062. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  15063. offsetX *= -1;
  15064. }
  15065. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  15066. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  15067. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  15068. _this.previousPosition = null;
  15069. if (!noPreventDefault) {
  15070. evt.preventDefault();
  15071. }
  15072. };
  15073. 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);
  15074. element.addEventListener("mousemove", this._onMouseMove, false);
  15075. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  15076. };
  15077. /**
  15078. * Called on JS contextmenu event.
  15079. * Override this method to provide functionality.
  15080. */
  15081. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  15082. evt.preventDefault();
  15083. };
  15084. /**
  15085. * Detach the current controls from the specified dom element.
  15086. * @param element Defines the element to stop listening the inputs from
  15087. */
  15088. FreeCameraMouseInput.prototype.detachControl = function (element) {
  15089. if (this._observer && element) {
  15090. this.camera.getScene().onPointerObservable.remove(this._observer);
  15091. if (this._onMouseMove) {
  15092. element.removeEventListener("mousemove", this._onMouseMove);
  15093. }
  15094. if (this.onContextMenu) {
  15095. element.removeEventListener("contextmenu", this.onContextMenu);
  15096. }
  15097. if (this.onPointerMovedObservable) {
  15098. this.onPointerMovedObservable.clear();
  15099. }
  15100. this._observer = null;
  15101. this._onMouseMove = null;
  15102. this.previousPosition = null;
  15103. }
  15104. };
  15105. /**
  15106. * Gets the class name of the current intput.
  15107. * @returns the class name
  15108. */
  15109. FreeCameraMouseInput.prototype.getClassName = function () {
  15110. return "FreeCameraMouseInput";
  15111. };
  15112. /**
  15113. * Get the friendly name associated with the input class.
  15114. * @returns the input friendly name
  15115. */
  15116. FreeCameraMouseInput.prototype.getSimpleName = function () {
  15117. return "mouse";
  15118. };
  15119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  15121. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  15122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  15124. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  15125. return FreeCameraMouseInput;
  15126. }());
  15127. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  15128. /***/ }),
  15129. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  15130. /*!************************************************!*\
  15131. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  15132. \************************************************/
  15133. /*! exports provided: FreeCameraTouchInput */
  15134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15135. "use strict";
  15136. __webpack_require__.r(__webpack_exports__);
  15137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  15138. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15139. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  15140. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15141. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15142. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15143. /**
  15144. * Manage the touch inputs to control the movement of a free camera.
  15145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15146. */
  15147. var FreeCameraTouchInput = /** @class */ (function () {
  15148. function FreeCameraTouchInput() {
  15149. /**
  15150. * Defines the touch sensibility for rotation.
  15151. * The higher the faster.
  15152. */
  15153. this.touchAngularSensibility = 200000.0;
  15154. /**
  15155. * Defines the touch sensibility for move.
  15156. * The higher the faster.
  15157. */
  15158. this.touchMoveSensibility = 250.0;
  15159. this._offsetX = null;
  15160. this._offsetY = null;
  15161. this._pointerPressed = new Array();
  15162. }
  15163. /**
  15164. * Attach the input controls to a specific dom element to get the input from.
  15165. * @param element Defines the element the controls should be listened from
  15166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15167. */
  15168. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  15169. var _this = this;
  15170. var previousPosition = null;
  15171. if (this._pointerInput === undefined) {
  15172. this._onLostFocus = function () {
  15173. _this._offsetX = null;
  15174. _this._offsetY = null;
  15175. };
  15176. this._pointerInput = function (p) {
  15177. var evt = p.event;
  15178. if (evt.pointerType === "mouse") {
  15179. return;
  15180. }
  15181. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  15182. if (!noPreventDefault) {
  15183. evt.preventDefault();
  15184. }
  15185. _this._pointerPressed.push(evt.pointerId);
  15186. if (_this._pointerPressed.length !== 1) {
  15187. return;
  15188. }
  15189. previousPosition = {
  15190. x: evt.clientX,
  15191. y: evt.clientY
  15192. };
  15193. }
  15194. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  15195. if (!noPreventDefault) {
  15196. evt.preventDefault();
  15197. }
  15198. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15199. if (index === -1) {
  15200. return;
  15201. }
  15202. _this._pointerPressed.splice(index, 1);
  15203. if (index != 0) {
  15204. return;
  15205. }
  15206. previousPosition = null;
  15207. _this._offsetX = null;
  15208. _this._offsetY = null;
  15209. }
  15210. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  15211. if (!noPreventDefault) {
  15212. evt.preventDefault();
  15213. }
  15214. if (!previousPosition) {
  15215. return;
  15216. }
  15217. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15218. if (index != 0) {
  15219. return;
  15220. }
  15221. _this._offsetX = evt.clientX - previousPosition.x;
  15222. _this._offsetY = -(evt.clientY - previousPosition.y);
  15223. }
  15224. };
  15225. }
  15226. 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);
  15227. if (this._onLostFocus) {
  15228. element.addEventListener("blur", this._onLostFocus);
  15229. }
  15230. };
  15231. /**
  15232. * Detach the current controls from the specified dom element.
  15233. * @param element Defines the element to stop listening the inputs from
  15234. */
  15235. FreeCameraTouchInput.prototype.detachControl = function (element) {
  15236. if (this._pointerInput && element) {
  15237. if (this._observer) {
  15238. this.camera.getScene().onPointerObservable.remove(this._observer);
  15239. this._observer = null;
  15240. }
  15241. if (this._onLostFocus) {
  15242. element.removeEventListener("blur", this._onLostFocus);
  15243. this._onLostFocus = null;
  15244. }
  15245. this._pointerPressed = [];
  15246. this._offsetX = null;
  15247. this._offsetY = null;
  15248. }
  15249. };
  15250. /**
  15251. * Update the current camera state depending on the inputs that have been used this frame.
  15252. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15253. */
  15254. FreeCameraTouchInput.prototype.checkInputs = function () {
  15255. if (this._offsetX && this._offsetY) {
  15256. var camera = this.camera;
  15257. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  15258. if (this._pointerPressed.length > 1) {
  15259. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  15260. }
  15261. else {
  15262. var speed = camera._computeLocalCameraSpeed();
  15263. var direction = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  15264. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  15265. camera.cameraDirection.addInPlace(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  15266. }
  15267. }
  15268. };
  15269. /**
  15270. * Gets the class name of the current intput.
  15271. * @returns the class name
  15272. */
  15273. FreeCameraTouchInput.prototype.getClassName = function () {
  15274. return "FreeCameraTouchInput";
  15275. };
  15276. /**
  15277. * Get the friendly name associated with the input class.
  15278. * @returns the input friendly name
  15279. */
  15280. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15281. return "touch";
  15282. };
  15283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15285. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15288. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15289. return FreeCameraTouchInput;
  15290. }());
  15291. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15292. /***/ }),
  15293. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15294. /*!**********************************************************!*\
  15295. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15296. \**********************************************************/
  15297. /*! exports provided: FreeCameraVirtualJoystickInput */
  15298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15299. "use strict";
  15300. __webpack_require__.r(__webpack_exports__);
  15301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15302. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15303. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15304. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15305. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15306. /**
  15307. * Add virtual joystick input support to the input manager.
  15308. * @returns the current input manager
  15309. */
  15310. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15311. this.add(new FreeCameraVirtualJoystickInput());
  15312. return this;
  15313. };
  15314. /**
  15315. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15317. */
  15318. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15319. function FreeCameraVirtualJoystickInput() {
  15320. }
  15321. /**
  15322. * Gets the left stick of the virtual joystick.
  15323. * @returns The virtual Joystick
  15324. */
  15325. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15326. return this._leftjoystick;
  15327. };
  15328. /**
  15329. * Gets the right stick of the virtual joystick.
  15330. * @returns The virtual Joystick
  15331. */
  15332. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15333. return this._rightjoystick;
  15334. };
  15335. /**
  15336. * Update the current camera state depending on the inputs that have been used this frame.
  15337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15338. */
  15339. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15340. if (this._leftjoystick) {
  15341. var camera = this.camera;
  15342. var speed = camera._computeLocalCameraSpeed() * 50;
  15343. var cameraTransform = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15344. var deltaTransform = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._leftjoystick.deltaPosition.x * speed, this._leftjoystick.deltaPosition.y * speed, this._leftjoystick.deltaPosition.z * speed), cameraTransform);
  15345. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15346. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15347. if (!this._leftjoystick.pressed) {
  15348. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15349. }
  15350. if (!this._rightjoystick.pressed) {
  15351. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15352. }
  15353. }
  15354. };
  15355. /**
  15356. * Attach the input controls to a specific dom element to get the input from.
  15357. * @param element Defines the element the controls should be listened from
  15358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15359. */
  15360. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15361. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15362. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15363. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15364. this._leftjoystick.setJoystickSensibility(0.15);
  15365. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15366. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15367. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15368. this._rightjoystick.reverseUpDown = true;
  15369. this._rightjoystick.setJoystickSensibility(0.05);
  15370. this._rightjoystick.setJoystickColor("yellow");
  15371. };
  15372. /**
  15373. * Detach the current controls from the specified dom element.
  15374. * @param element Defines the element to stop listening the inputs from
  15375. */
  15376. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15377. this._leftjoystick.releaseCanvas();
  15378. this._rightjoystick.releaseCanvas();
  15379. };
  15380. /**
  15381. * Gets the class name of the current intput.
  15382. * @returns the class name
  15383. */
  15384. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15385. return "FreeCameraVirtualJoystickInput";
  15386. };
  15387. /**
  15388. * Get the friendly name associated with the input class.
  15389. * @returns the input friendly name
  15390. */
  15391. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15392. return "virtualJoystick";
  15393. };
  15394. return FreeCameraVirtualJoystickInput;
  15395. }());
  15396. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15397. /***/ }),
  15398. /***/ "./Cameras/Inputs/index.ts":
  15399. /*!*********************************!*\
  15400. !*** ./Cameras/Inputs/index.ts ***!
  15401. \*********************************/
  15402. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15404. "use strict";
  15405. __webpack_require__.r(__webpack_exports__);
  15406. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15408. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15410. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15412. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15414. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15416. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15418. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15420. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15422. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15424. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15426. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15428. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15430. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15432. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15434. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15436. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15438. /***/ }),
  15439. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15440. /*!*********************************************************!*\
  15441. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15442. \*********************************************************/
  15443. /*! no exports provided */
  15444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15445. "use strict";
  15446. __webpack_require__.r(__webpack_exports__);
  15447. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15448. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15449. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15450. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15451. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15452. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15453. };
  15454. /***/ }),
  15455. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15456. /*!*************************************************!*\
  15457. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15458. \*************************************************/
  15459. /*! no exports provided */
  15460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15461. "use strict";
  15462. __webpack_require__.r(__webpack_exports__);
  15463. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15464. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15465. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15466. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15467. 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;
  15468. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15469. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15470. };
  15471. /***/ }),
  15472. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15473. /*!***************************************!*\
  15474. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15475. \***************************************/
  15476. /*! no exports provided */
  15477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15478. "use strict";
  15479. __webpack_require__.r(__webpack_exports__);
  15480. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15481. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15482. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15483. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  15484. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15485. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15486. /* harmony import */ var _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math.viewport */ "./Maths/math.viewport.ts");
  15487. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15488. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__["VRCameraMetrics"].GetDefault();
  15489. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15490. camera._rigCameras[0].viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_6__["Viewport"](0, 0, 0.5, 1.0);
  15491. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15492. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15493. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15494. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15495. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15496. camera._rigCameras[1].viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_6__["Viewport"](0.5, 0, 0.5, 1.0);
  15497. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15498. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15499. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15500. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15501. // For multiview on a webVR camera
  15502. // First multiview will be rendered to camera._multiviewTexture
  15503. // Then this postprocess will run on each eye to copy the right texture to each eye
  15504. if (metrics.multiviewEnabled) {
  15505. if (!camera.getScene().getEngine().getCaps().multiview) {
  15506. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15507. metrics.multiviewEnabled = false;
  15508. }
  15509. else {
  15510. camera._useMultiviewToSingleView = true;
  15511. camera._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", camera, metrics.postProcessScaleFactor);
  15512. }
  15513. }
  15514. if (metrics.compensateDistortion) {
  15515. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15516. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15517. }
  15518. };
  15519. /***/ }),
  15520. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15521. /*!******************************************!*\
  15522. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15523. \******************************************/
  15524. /*! no exports provided */
  15525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15526. "use strict";
  15527. __webpack_require__.r(__webpack_exports__);
  15528. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15529. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15530. /* harmony import */ var _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.viewport */ "./Maths/math.viewport.ts");
  15531. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15532. if (rigParams.vrDisplay) {
  15533. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15534. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15535. //Left eye
  15536. camera._rigCameras[0].viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_2__["Viewport"](0, 0, 0.5, 1.0);
  15537. camera._rigCameras[0].setCameraRigParameter("left", true);
  15538. //leaving this for future reference
  15539. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15540. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15541. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15542. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15543. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15544. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15545. camera._rigCameras[0].parent = camera;
  15546. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15547. //Right eye
  15548. camera._rigCameras[1].viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_2__["Viewport"](0.5, 0, 0.5, 1.0);
  15549. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15550. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15551. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15552. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15553. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15554. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15555. camera._rigCameras[1].parent = camera;
  15556. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15557. }
  15558. };
  15559. /***/ }),
  15560. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15561. /*!*********************************************************!*\
  15562. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15563. \*********************************************************/
  15564. /*! exports provided: AnaglyphArcRotateCamera */
  15565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15566. "use strict";
  15567. __webpack_require__.r(__webpack_exports__);
  15568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15570. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15571. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15572. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15573. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15574. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15575. // Side effect import to define the stereoscopic mode.
  15576. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15577. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15578. });
  15579. /**
  15580. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15581. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15582. */
  15583. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15584. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15585. /**
  15586. * Creates a new AnaglyphArcRotateCamera
  15587. * @param name defines camera name
  15588. * @param alpha defines alpha angle (in radians)
  15589. * @param beta defines beta angle (in radians)
  15590. * @param radius defines radius
  15591. * @param target defines camera target
  15592. * @param interaxialDistance defines distance between each color axis
  15593. * @param scene defines the hosting scene
  15594. */
  15595. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15596. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15597. _this.interaxialDistance = interaxialDistance;
  15598. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15599. return _this;
  15600. }
  15601. /**
  15602. * Gets camera class name
  15603. * @returns AnaglyphArcRotateCamera
  15604. */
  15605. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15606. return "AnaglyphArcRotateCamera";
  15607. };
  15608. return AnaglyphArcRotateCamera;
  15609. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15610. /***/ }),
  15611. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15612. /*!****************************************************!*\
  15613. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15614. \****************************************************/
  15615. /*! exports provided: AnaglyphFreeCamera */
  15616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15617. "use strict";
  15618. __webpack_require__.r(__webpack_exports__);
  15619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15621. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15622. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15623. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15624. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15625. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15626. // Side effect import to define the stereoscopic mode.
  15627. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15628. return function () { return new AnaglyphFreeCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15629. });
  15630. /**
  15631. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15632. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15633. */
  15634. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15635. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15636. /**
  15637. * Creates a new AnaglyphFreeCamera
  15638. * @param name defines camera name
  15639. * @param position defines initial position
  15640. * @param interaxialDistance defines distance between each color axis
  15641. * @param scene defines the hosting scene
  15642. */
  15643. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15644. var _this = _super.call(this, name, position, scene) || this;
  15645. _this.interaxialDistance = interaxialDistance;
  15646. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15647. return _this;
  15648. }
  15649. /**
  15650. * Gets camera class name
  15651. * @returns AnaglyphFreeCamera
  15652. */
  15653. AnaglyphFreeCamera.prototype.getClassName = function () {
  15654. return "AnaglyphFreeCamera";
  15655. };
  15656. return AnaglyphFreeCamera;
  15657. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15658. /***/ }),
  15659. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15660. /*!*******************************************************!*\
  15661. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15662. \*******************************************************/
  15663. /*! exports provided: AnaglyphGamepadCamera */
  15664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15665. "use strict";
  15666. __webpack_require__.r(__webpack_exports__);
  15667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15668. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15669. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15670. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15671. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15672. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15673. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15674. // Side effect import to define the stereoscopic mode.
  15675. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15676. return function () { return new AnaglyphGamepadCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15677. });
  15678. /**
  15679. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15680. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15681. */
  15682. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15684. /**
  15685. * Creates a new AnaglyphGamepadCamera
  15686. * @param name defines camera name
  15687. * @param position defines initial position
  15688. * @param interaxialDistance defines distance between each color axis
  15689. * @param scene defines the hosting scene
  15690. */
  15691. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15692. var _this = _super.call(this, name, position, scene) || this;
  15693. _this.interaxialDistance = interaxialDistance;
  15694. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15695. return _this;
  15696. }
  15697. /**
  15698. * Gets camera class name
  15699. * @returns AnaglyphGamepadCamera
  15700. */
  15701. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15702. return "AnaglyphGamepadCamera";
  15703. };
  15704. return AnaglyphGamepadCamera;
  15705. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15706. /***/ }),
  15707. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15708. /*!*********************************************************!*\
  15709. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15710. \*********************************************************/
  15711. /*! exports provided: AnaglyphUniversalCamera */
  15712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15713. "use strict";
  15714. __webpack_require__.r(__webpack_exports__);
  15715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15717. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15718. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15719. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15720. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15721. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15722. // Side effect import to define the stereoscopic mode.
  15723. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15724. return function () { return new AnaglyphUniversalCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15725. });
  15726. /**
  15727. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15728. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15729. */
  15730. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15732. /**
  15733. * Creates a new AnaglyphUniversalCamera
  15734. * @param name defines camera name
  15735. * @param position defines initial position
  15736. * @param interaxialDistance defines distance between each color axis
  15737. * @param scene defines the hosting scene
  15738. */
  15739. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15740. var _this = _super.call(this, name, position, scene) || this;
  15741. _this.interaxialDistance = interaxialDistance;
  15742. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15743. return _this;
  15744. }
  15745. /**
  15746. * Gets camera class name
  15747. * @returns AnaglyphUniversalCamera
  15748. */
  15749. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15750. return "AnaglyphUniversalCamera";
  15751. };
  15752. return AnaglyphUniversalCamera;
  15753. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15754. /***/ }),
  15755. /***/ "./Cameras/Stereoscopic/index.ts":
  15756. /*!***************************************!*\
  15757. !*** ./Cameras/Stereoscopic/index.ts ***!
  15758. \***************************************/
  15759. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15761. "use strict";
  15762. __webpack_require__.r(__webpack_exports__);
  15763. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15765. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15767. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15769. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15771. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15773. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15775. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15777. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15779. /***/ }),
  15780. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15781. /*!*************************************************************!*\
  15782. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15783. \*************************************************************/
  15784. /*! exports provided: StereoscopicArcRotateCamera */
  15785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15786. "use strict";
  15787. __webpack_require__.r(__webpack_exports__);
  15788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15789. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15790. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15791. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15792. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15793. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15794. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15795. // Side effect import to define the stereoscopic mode.
  15796. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15797. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15798. });
  15799. /**
  15800. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15801. * @see http://doc.babylonjs.com/features/cameras
  15802. */
  15803. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15804. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15805. /**
  15806. * Creates a new StereoscopicArcRotateCamera
  15807. * @param name defines camera name
  15808. * @param alpha defines alpha angle (in radians)
  15809. * @param beta defines beta angle (in radians)
  15810. * @param radius defines radius
  15811. * @param target defines camera target
  15812. * @param interaxialDistance defines distance between each color axis
  15813. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15814. * @param scene defines the hosting scene
  15815. */
  15816. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15817. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15818. _this.interaxialDistance = interaxialDistance;
  15819. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15820. _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 });
  15821. return _this;
  15822. }
  15823. /**
  15824. * Gets camera class name
  15825. * @returns StereoscopicArcRotateCamera
  15826. */
  15827. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15828. return "StereoscopicArcRotateCamera";
  15829. };
  15830. return StereoscopicArcRotateCamera;
  15831. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15832. /***/ }),
  15833. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15834. /*!********************************************************!*\
  15835. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15836. \********************************************************/
  15837. /*! exports provided: StereoscopicFreeCamera */
  15838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15839. "use strict";
  15840. __webpack_require__.r(__webpack_exports__);
  15841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15842. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15843. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15844. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15845. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15846. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15847. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15848. // Side effect import to define the stereoscopic mode.
  15849. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15850. return function () { return new StereoscopicFreeCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15851. });
  15852. /**
  15853. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15854. * @see http://doc.babylonjs.com/features/cameras
  15855. */
  15856. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15858. /**
  15859. * Creates a new StereoscopicFreeCamera
  15860. * @param name defines camera name
  15861. * @param position defines initial position
  15862. * @param interaxialDistance defines distance between each color axis
  15863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15864. * @param scene defines the hosting scene
  15865. */
  15866. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15867. var _this = _super.call(this, name, position, scene) || this;
  15868. _this.interaxialDistance = interaxialDistance;
  15869. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15870. _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 });
  15871. return _this;
  15872. }
  15873. /**
  15874. * Gets camera class name
  15875. * @returns StereoscopicFreeCamera
  15876. */
  15877. StereoscopicFreeCamera.prototype.getClassName = function () {
  15878. return "StereoscopicFreeCamera";
  15879. };
  15880. return StereoscopicFreeCamera;
  15881. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15882. /***/ }),
  15883. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15884. /*!***********************************************************!*\
  15885. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15886. \***********************************************************/
  15887. /*! exports provided: StereoscopicGamepadCamera */
  15888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15889. "use strict";
  15890. __webpack_require__.r(__webpack_exports__);
  15891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15892. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15893. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15894. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15895. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15896. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15897. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15898. // Side effect import to define the stereoscopic mode.
  15899. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15900. return function () { return new StereoscopicGamepadCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15901. });
  15902. /**
  15903. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15904. * @see http://doc.babylonjs.com/features/cameras
  15905. */
  15906. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15907. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15908. /**
  15909. * Creates a new StereoscopicGamepadCamera
  15910. * @param name defines camera name
  15911. * @param position defines initial position
  15912. * @param interaxialDistance defines distance between each color axis
  15913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15914. * @param scene defines the hosting scene
  15915. */
  15916. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15917. var _this = _super.call(this, name, position, scene) || this;
  15918. _this.interaxialDistance = interaxialDistance;
  15919. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15920. _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 });
  15921. return _this;
  15922. }
  15923. /**
  15924. * Gets camera class name
  15925. * @returns StereoscopicGamepadCamera
  15926. */
  15927. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15928. return "StereoscopicGamepadCamera";
  15929. };
  15930. return StereoscopicGamepadCamera;
  15931. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15932. /***/ }),
  15933. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15934. /*!*************************************************************!*\
  15935. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15936. \*************************************************************/
  15937. /*! exports provided: StereoscopicUniversalCamera */
  15938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15939. "use strict";
  15940. __webpack_require__.r(__webpack_exports__);
  15941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15942. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15943. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15944. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15945. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  15946. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15947. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15948. // Side effect import to define the stereoscopic mode.
  15949. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15950. return function () { return new StereoscopicUniversalCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15951. });
  15952. /**
  15953. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15954. * @see http://doc.babylonjs.com/features/cameras
  15955. */
  15956. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15958. /**
  15959. * Creates a new StereoscopicUniversalCamera
  15960. * @param name defines camera name
  15961. * @param position defines initial position
  15962. * @param interaxialDistance defines distance between each color axis
  15963. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15964. * @param scene defines the hosting scene
  15965. */
  15966. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15967. var _this = _super.call(this, name, position, scene) || this;
  15968. _this.interaxialDistance = interaxialDistance;
  15969. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15970. _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 });
  15971. return _this;
  15972. }
  15973. /**
  15974. * Gets camera class name
  15975. * @returns StereoscopicUniversalCamera
  15976. */
  15977. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15978. return "StereoscopicUniversalCamera";
  15979. };
  15980. return StereoscopicUniversalCamera;
  15981. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15982. /***/ }),
  15983. /***/ "./Cameras/VR/index.ts":
  15984. /*!*****************************!*\
  15985. !*** ./Cameras/VR/index.ts ***!
  15986. \*****************************/
  15987. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15989. "use strict";
  15990. __webpack_require__.r(__webpack_exports__);
  15991. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15993. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15995. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15997. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15999. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  16000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  16001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  16002. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  16004. /***/ }),
  16005. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  16006. /*!***************************************!*\
  16007. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  16008. \***************************************/
  16009. /*! exports provided: VRCameraMetrics */
  16010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16011. "use strict";
  16012. __webpack_require__.r(__webpack_exports__);
  16013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  16014. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  16015. /**
  16016. * This represents all the required metrics to create a VR camera.
  16017. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  16018. */
  16019. var VRCameraMetrics = /** @class */ (function () {
  16020. function VRCameraMetrics() {
  16021. /**
  16022. * Define if the current vr camera should compensate the distortion of the lense or not.
  16023. */
  16024. this.compensateDistortion = true;
  16025. /**
  16026. * Defines if multiview should be enabled when rendering (Default: false)
  16027. */
  16028. this.multiviewEnabled = false;
  16029. }
  16030. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  16031. /**
  16032. * Gets the rendering aspect ratio based on the provided resolutions.
  16033. */
  16034. get: function () {
  16035. return this.hResolution / (2 * this.vResolution);
  16036. },
  16037. enumerable: true,
  16038. configurable: true
  16039. });
  16040. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  16041. /**
  16042. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  16043. */
  16044. get: function () {
  16045. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  16046. },
  16047. enumerable: true,
  16048. configurable: true
  16049. });
  16050. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  16051. /**
  16052. * @hidden
  16053. */
  16054. get: function () {
  16055. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  16056. var h = (4 * meters) / this.hScreenSize;
  16057. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  16058. },
  16059. enumerable: true,
  16060. configurable: true
  16061. });
  16062. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  16063. /**
  16064. * @hidden
  16065. */
  16066. get: function () {
  16067. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  16068. var h = (4 * meters) / this.hScreenSize;
  16069. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  16070. },
  16071. enumerable: true,
  16072. configurable: true
  16073. });
  16074. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  16075. /**
  16076. * @hidden
  16077. */
  16078. get: function () {
  16079. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  16080. },
  16081. enumerable: true,
  16082. configurable: true
  16083. });
  16084. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  16085. /**
  16086. * @hidden
  16087. */
  16088. get: function () {
  16089. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  16090. },
  16091. enumerable: true,
  16092. configurable: true
  16093. });
  16094. /**
  16095. * Get the default VRMetrics based on the most generic setup.
  16096. * @returns the default vr metrics
  16097. */
  16098. VRCameraMetrics.GetDefault = function () {
  16099. var result = new VRCameraMetrics();
  16100. result.hResolution = 1280;
  16101. result.vResolution = 800;
  16102. result.hScreenSize = 0.149759993;
  16103. result.vScreenSize = 0.0935999975;
  16104. result.vScreenCenter = 0.0467999987;
  16105. result.eyeToScreenDistance = 0.0410000011;
  16106. result.lensSeparationDistance = 0.0635000020;
  16107. result.interpupillaryDistance = 0.0640000030;
  16108. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  16109. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  16110. result.postProcessScaleFactor = 1.714605507808412;
  16111. result.lensCenterOffset = 0.151976421;
  16112. return result;
  16113. };
  16114. return VRCameraMetrics;
  16115. }());
  16116. /***/ }),
  16117. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  16118. /*!**********************************************************!*\
  16119. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  16120. \**********************************************************/
  16121. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  16122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16123. "use strict";
  16124. __webpack_require__.r(__webpack_exports__);
  16125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  16126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16127. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  16128. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  16129. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16130. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  16131. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16132. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  16133. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  16134. // Side effect import to define the stereoscopic mode.
  16135. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  16136. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16137. });
  16138. /**
  16139. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  16140. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16141. */
  16142. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  16143. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  16144. /**
  16145. * Creates a new VRDeviceOrientationArcRotateCamera
  16146. * @param name defines camera name
  16147. * @param alpha defines the camera rotation along the logitudinal axis
  16148. * @param beta defines the camera rotation along the latitudinal axis
  16149. * @param radius defines the camera distance from its target
  16150. * @param target defines the camera target
  16151. * @param scene defines the scene the camera belongs to
  16152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16154. */
  16155. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  16156. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16157. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16158. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  16159. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16160. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16161. _this.inputs.addVRDeviceOrientation();
  16162. return _this;
  16163. }
  16164. /**
  16165. * Gets camera class name
  16166. * @returns VRDeviceOrientationArcRotateCamera
  16167. */
  16168. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  16169. return "VRDeviceOrientationArcRotateCamera";
  16170. };
  16171. return VRDeviceOrientationArcRotateCamera;
  16172. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  16173. /***/ }),
  16174. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  16175. /*!*****************************************************!*\
  16176. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  16177. \*****************************************************/
  16178. /*! exports provided: VRDeviceOrientationFreeCamera */
  16179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16180. "use strict";
  16181. __webpack_require__.r(__webpack_exports__);
  16182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  16183. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16184. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  16185. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16186. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16187. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  16188. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16189. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  16190. // Side effect import to define the stereoscopic mode.
  16191. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  16192. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16193. });
  16194. /**
  16195. * Camera used to simulate VR rendering (based on FreeCamera)
  16196. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16197. */
  16198. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  16199. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  16200. /**
  16201. * Creates a new VRDeviceOrientationFreeCamera
  16202. * @param name defines camera name
  16203. * @param position defines the start position of the camera
  16204. * @param scene defines the scene the camera belongs to
  16205. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16206. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16207. */
  16208. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16209. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16210. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16211. var _this = _super.call(this, name, position, scene) || this;
  16212. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16213. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16214. return _this;
  16215. }
  16216. /**
  16217. * Gets camera class name
  16218. * @returns VRDeviceOrientationFreeCamera
  16219. */
  16220. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  16221. return "VRDeviceOrientationFreeCamera";
  16222. };
  16223. return VRDeviceOrientationFreeCamera;
  16224. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  16225. /***/ }),
  16226. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  16227. /*!********************************************************!*\
  16228. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  16229. \********************************************************/
  16230. /*! exports provided: VRDeviceOrientationGamepadCamera */
  16231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16232. "use strict";
  16233. __webpack_require__.r(__webpack_exports__);
  16234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  16235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16236. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16237. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16238. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  16239. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16240. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16241. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  16242. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  16243. });
  16244. /**
  16245. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  16246. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16247. */
  16248. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  16249. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  16250. /**
  16251. * Creates a new VRDeviceOrientationGamepadCamera
  16252. * @param name defines camera name
  16253. * @param position defines the start position of the camera
  16254. * @param scene defines the scene the camera belongs to
  16255. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16256. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16257. */
  16258. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16259. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16260. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  16261. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  16262. _this.inputs.addGamepad();
  16263. return _this;
  16264. }
  16265. /**
  16266. * Gets camera class name
  16267. * @returns VRDeviceOrientationGamepadCamera
  16268. */
  16269. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  16270. return "VRDeviceOrientationGamepadCamera";
  16271. };
  16272. return VRDeviceOrientationGamepadCamera;
  16273. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  16274. /***/ }),
  16275. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  16276. /*!******************************************!*\
  16277. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  16278. \******************************************/
  16279. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16281. "use strict";
  16282. __webpack_require__.r(__webpack_exports__);
  16283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16286. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16287. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16288. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16289. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16290. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16291. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16292. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16293. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16294. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  16295. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  16296. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16297. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16298. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16299. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16300. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16301. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16302. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16303. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16304. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16305. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16306. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16307. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16308. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16309. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16310. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16311. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16312. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16313. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16314. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../../Maths/math.axis */ "./Maths/math.axis.ts");
  16315. var VRExperienceHelperGazer = /** @class */ (function () {
  16316. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16317. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16318. this.scene = scene;
  16319. /** @hidden */
  16320. this._pointerDownOnMeshAsked = false;
  16321. /** @hidden */
  16322. this._isActionableMesh = false;
  16323. /** @hidden */
  16324. this._teleportationRequestInitiated = false;
  16325. /** @hidden */
  16326. this._teleportationBackRequestInitiated = false;
  16327. /** @hidden */
  16328. this._rotationRightAsked = false;
  16329. /** @hidden */
  16330. this._rotationLeftAsked = false;
  16331. /** @hidden */
  16332. this._dpadPressed = true;
  16333. /** @hidden */
  16334. this._activePointer = false;
  16335. this._id = VRExperienceHelperGazer._idCounter++;
  16336. // Gaze tracker
  16337. if (!gazeTrackerToClone) {
  16338. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16339. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16340. this._gazeTracker.isPickable = false;
  16341. this._gazeTracker.isVisible = false;
  16342. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_18__["StandardMaterial"]("targetMat", scene);
  16343. targetMat.specularColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"].Black();
  16344. targetMat.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7);
  16345. targetMat.backFaceCulling = false;
  16346. this._gazeTracker.material = targetMat;
  16347. }
  16348. else {
  16349. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16350. }
  16351. }
  16352. /** @hidden */
  16353. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16354. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_16__["Ray"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero(), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, length));
  16355. };
  16356. /** @hidden */
  16357. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16358. this._pointerDownOnMeshAsked = true;
  16359. if (this._currentHit) {
  16360. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16361. }
  16362. };
  16363. /** @hidden */
  16364. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16365. if (this._currentHit) {
  16366. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16367. }
  16368. this._pointerDownOnMeshAsked = false;
  16369. };
  16370. /** @hidden */
  16371. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16372. this._activePointer = true;
  16373. };
  16374. /** @hidden */
  16375. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16376. this._activePointer = false;
  16377. };
  16378. /** @hidden */
  16379. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16380. if (distance === void 0) { distance = 100; }
  16381. };
  16382. VRExperienceHelperGazer.prototype.dispose = function () {
  16383. this._interactionsEnabled = false;
  16384. this._teleportationEnabled = false;
  16385. if (this._gazeTracker) {
  16386. this._gazeTracker.dispose();
  16387. }
  16388. };
  16389. VRExperienceHelperGazer._idCounter = 0;
  16390. return VRExperienceHelperGazer;
  16391. }());
  16392. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16393. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16394. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16395. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16396. _this.webVRController = webVRController;
  16397. // Laser pointer
  16398. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16399. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_18__["StandardMaterial"]("laserPointerMat", scene);
  16400. laserPointerMaterial.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7);
  16401. laserPointerMaterial.alpha = 0.6;
  16402. _this._laserPointer.material = laserPointerMaterial;
  16403. _this._laserPointer.rotation.x = Math.PI / 2;
  16404. _this._laserPointer.position.z = -0.5;
  16405. _this._laserPointer.isVisible = false;
  16406. _this._laserPointer.isPickable = false;
  16407. if (!webVRController.mesh) {
  16408. // Create an empty mesh that is used prior to loading the high quality model
  16409. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__["Mesh"]("preloadControllerMesh", scene);
  16410. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_12__["PoseEnabledController"].POINTING_POSE, scene);
  16411. preloadPointerPose.rotation.x = -0.7;
  16412. preloadMesh.addChild(preloadPointerPose);
  16413. webVRController.attachToMesh(preloadMesh);
  16414. }
  16415. _this._setLaserPointerParent(webVRController.mesh);
  16416. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16417. _this._setLaserPointerParent(mesh);
  16418. });
  16419. return _this;
  16420. }
  16421. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16422. return this.webVRController.getForwardRay(length);
  16423. };
  16424. /** @hidden */
  16425. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16426. _super.prototype._activatePointer.call(this);
  16427. this._laserPointer.isVisible = true;
  16428. };
  16429. /** @hidden */
  16430. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16431. _super.prototype._deactivatePointer.call(this);
  16432. this._laserPointer.isVisible = false;
  16433. };
  16434. /** @hidden */
  16435. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16436. this._laserPointer.material.emissiveColor = color;
  16437. };
  16438. /** @hidden */
  16439. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16440. var makeNotPick = function (root) {
  16441. root.isPickable = false;
  16442. root.getChildMeshes().forEach(function (c) {
  16443. makeNotPick(c);
  16444. });
  16445. };
  16446. makeNotPick(mesh);
  16447. var meshChildren = mesh.getChildren(undefined, false);
  16448. var laserParent = mesh;
  16449. this.webVRController._pointingPoseNode = null;
  16450. for (var i = 0; i < meshChildren.length; i++) {
  16451. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_12__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16452. laserParent = meshChildren[i];
  16453. this.webVRController._pointingPoseNode = laserParent;
  16454. break;
  16455. }
  16456. }
  16457. this._laserPointer.parent = laserParent;
  16458. };
  16459. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16460. if (distance === void 0) { distance = 100; }
  16461. this._laserPointer.scaling.y = distance;
  16462. this._laserPointer.position.z = -distance / 2;
  16463. };
  16464. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16465. _super.prototype.dispose.call(this);
  16466. this._laserPointer.dispose();
  16467. if (this._meshAttachedObserver) {
  16468. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16469. }
  16470. };
  16471. return VRExperienceHelperControllerGazer;
  16472. }(VRExperienceHelperGazer));
  16473. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16475. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16476. var _this = _super.call(this, scene) || this;
  16477. _this.getCamera = getCamera;
  16478. return _this;
  16479. }
  16480. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16481. var camera = this.getCamera();
  16482. if (camera) {
  16483. return camera.getForwardRay(length);
  16484. }
  16485. else {
  16486. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_16__["Ray"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Forward());
  16487. }
  16488. };
  16489. return VRExperienceHelperCameraGazer;
  16490. }(VRExperienceHelperGazer));
  16491. /**
  16492. * Event containing information after VR has been entered
  16493. */
  16494. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16495. function OnAfterEnteringVRObservableEvent() {
  16496. }
  16497. return OnAfterEnteringVRObservableEvent;
  16498. }());
  16499. /**
  16500. * Helps to quickly add VR support to an existing scene.
  16501. * See http://doc.babylonjs.com/how_to/webvr_helper
  16502. */
  16503. var VRExperienceHelper = /** @class */ (function () {
  16504. /**
  16505. * Instantiates a VRExperienceHelper.
  16506. * Helps to quickly add VR support to an existing scene.
  16507. * @param scene The scene the VRExperienceHelper belongs to.
  16508. * @param webVROptions Options to modify the vr experience helper's behavior.
  16509. */
  16510. function VRExperienceHelper(scene,
  16511. /** Options to modify the vr experience helper's behavior. */
  16512. webVROptions) {
  16513. var _this = this;
  16514. if (webVROptions === void 0) { webVROptions = {}; }
  16515. this.webVROptions = webVROptions;
  16516. // Can the system support WebVR, even if a headset isn't plugged in?
  16517. this._webVRsupported = false;
  16518. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16519. this._webVRready = false;
  16520. // Are we waiting for the requestPresent callback to complete?
  16521. this._webVRrequesting = false;
  16522. // Are we presenting to the headset right now? (this is the vrDevice state)
  16523. this._webVRpresenting = false;
  16524. // Are we presenting in the fullscreen fallback?
  16525. this._fullscreenVRpresenting = false;
  16526. /**
  16527. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  16528. */
  16529. this.enableGazeEvenWhenNoPointerLock = false;
  16530. /**
  16531. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  16532. */
  16533. this.exitVROnDoubleTap = true;
  16534. /**
  16535. * Observable raised right before entering VR.
  16536. */
  16537. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16538. /**
  16539. * Observable raised when entering VR has completed.
  16540. */
  16541. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16542. /**
  16543. * Observable raised when exiting VR.
  16544. */
  16545. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16546. /**
  16547. * Observable raised when controller mesh is loaded.
  16548. */
  16549. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16550. this._useCustomVRButton = false;
  16551. this._teleportationRequested = false;
  16552. this._teleportActive = false;
  16553. this._floorMeshesCollection = [];
  16554. this._rotationAllowed = true;
  16555. this._teleportBackwardsVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16556. this._isDefaultTeleportationTarget = true;
  16557. this._teleportationFillColor = "#444444";
  16558. this._teleportationBorderColor = "#FFFFFF";
  16559. this._rotationAngle = 0;
  16560. this._haloCenter = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16561. this._padSensibilityUp = 0.65;
  16562. this._padSensibilityDown = 0.35;
  16563. this._leftController = null;
  16564. this._rightController = null;
  16565. /**
  16566. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16567. */
  16568. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16569. /**
  16570. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16571. */
  16572. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16573. /**
  16574. * Observable raised before camera teleportation
  16575. */
  16576. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16577. /**
  16578. * Observable raised after camera teleportation
  16579. */
  16580. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16581. /**
  16582. * Observable raised when current selected mesh gets unselected
  16583. */
  16584. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16585. /**
  16586. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16587. */
  16588. this.teleportationEnabled = true;
  16589. this._teleportationInitialized = false;
  16590. this._interactionsEnabled = false;
  16591. this._interactionsRequested = false;
  16592. this._displayGaze = true;
  16593. this._displayLaserPointer = true;
  16594. /**
  16595. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16596. */
  16597. this.updateGazeTrackerScale = true;
  16598. /**
  16599. * If the gaze trackers color should be updated when selecting meshes
  16600. */
  16601. this.updateGazeTrackerColor = true;
  16602. /**
  16603. * Defines wether or not Pointer lock should be requested when switching to
  16604. * full screen.
  16605. */
  16606. this.requestPointerLockOnFullScreen = true;
  16607. this._onResize = function () {
  16608. _this.moveButtonToBottomRight();
  16609. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16610. _this.exitVR();
  16611. }
  16612. };
  16613. this._onFullscreenChange = function () {
  16614. var anyDoc = document;
  16615. if (anyDoc.fullscreen !== undefined) {
  16616. _this._fullscreenVRpresenting = document.fullscreen;
  16617. }
  16618. else if (anyDoc.mozFullScreen !== undefined) {
  16619. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16620. }
  16621. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16622. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16623. }
  16624. else if (anyDoc.msIsFullScreen !== undefined) {
  16625. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16626. }
  16627. else if (document.msFullscreenElement !== undefined) {
  16628. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16629. }
  16630. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16631. _this.exitVR();
  16632. if (!_this._useCustomVRButton && _this._btnVR) {
  16633. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16634. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16635. }
  16636. }
  16637. };
  16638. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16639. this.beforeRender = function () {
  16640. if (_this._leftController && _this._leftController._activePointer) {
  16641. _this._castRayAndSelectObject(_this._leftController);
  16642. }
  16643. if (_this._rightController && _this._rightController._activePointer) {
  16644. _this._castRayAndSelectObject(_this._rightController);
  16645. }
  16646. if (_this._noControllerIsActive && (_this._scene.getEngine().isPointerLock || _this.enableGazeEvenWhenNoPointerLock)) {
  16647. _this._castRayAndSelectObject(_this._cameraGazer);
  16648. }
  16649. else {
  16650. _this._cameraGazer._gazeTracker.isVisible = false;
  16651. }
  16652. };
  16653. this._onNewGamepadConnected = function (gamepad) {
  16654. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_11__["Gamepad"].POSE_ENABLED) {
  16655. if (gamepad.leftStick) {
  16656. gamepad.onleftstickchanged(function (stickValues) {
  16657. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16658. // Listening to classic/xbox gamepad only if no VR controller is active
  16659. if ((!_this._leftController && !_this._rightController) ||
  16660. ((_this._leftController && !_this._leftController._activePointer) &&
  16661. (_this._rightController && !_this._rightController._activePointer))) {
  16662. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16663. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16664. }
  16665. }
  16666. });
  16667. }
  16668. if (gamepad.rightStick) {
  16669. gamepad.onrightstickchanged(function (stickValues) {
  16670. if (_this._teleportationInitialized) {
  16671. _this._checkRotate(stickValues, _this._cameraGazer);
  16672. }
  16673. });
  16674. }
  16675. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_11__["Gamepad"].XBOX) {
  16676. gamepad.onbuttondown(function (buttonPressed) {
  16677. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_14__["Xbox360Button"].A) {
  16678. _this._cameraGazer._selectionPointerDown();
  16679. }
  16680. });
  16681. gamepad.onbuttonup(function (buttonPressed) {
  16682. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_14__["Xbox360Button"].A) {
  16683. _this._cameraGazer._selectionPointerUp();
  16684. }
  16685. });
  16686. }
  16687. }
  16688. else {
  16689. var webVRController = gamepad;
  16690. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16691. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16692. _this._rightController = controller;
  16693. }
  16694. else {
  16695. _this._leftController = controller;
  16696. }
  16697. _this._tryEnableInteractionOnController(controller);
  16698. }
  16699. };
  16700. // 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
  16701. this._tryEnableInteractionOnController = function (controller) {
  16702. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16703. _this._enableInteractionOnController(controller);
  16704. }
  16705. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16706. _this._enableTeleportationOnController(controller);
  16707. }
  16708. };
  16709. this._onNewGamepadDisconnected = function (gamepad) {
  16710. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]) {
  16711. if (gamepad.hand === "left" && _this._leftController != null) {
  16712. _this._leftController.dispose();
  16713. _this._leftController = null;
  16714. }
  16715. if (gamepad.hand === "right" && _this._rightController != null) {
  16716. _this._rightController.dispose();
  16717. _this._rightController = null;
  16718. }
  16719. }
  16720. };
  16721. this._workingVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16722. this._workingQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16723. this._workingMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16724. this._scene = scene;
  16725. this._canvas = scene.getEngine().getRenderingCanvas();
  16726. // Parse options
  16727. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16728. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16729. }
  16730. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16731. webVROptions.createDeviceOrientationCamera = true;
  16732. }
  16733. if (webVROptions.laserToggle === undefined) {
  16734. webVROptions.laserToggle = true;
  16735. }
  16736. if (webVROptions.defaultHeight === undefined) {
  16737. webVROptions.defaultHeight = 1.7;
  16738. }
  16739. if (webVROptions.useCustomVRButton) {
  16740. this._useCustomVRButton = true;
  16741. if (webVROptions.customVRButton) {
  16742. this._btnVR = webVROptions.customVRButton;
  16743. }
  16744. }
  16745. if (webVROptions.rayLength) {
  16746. this._rayLength = webVROptions.rayLength;
  16747. }
  16748. this._defaultHeight = webVROptions.defaultHeight;
  16749. if (webVROptions.positionScale) {
  16750. this._rayLength *= webVROptions.positionScale;
  16751. this._defaultHeight *= webVROptions.positionScale;
  16752. }
  16753. this._hasEnteredVR = false;
  16754. // Set position
  16755. if (this._scene.activeCamera) {
  16756. this._position = this._scene.activeCamera.position.clone();
  16757. }
  16758. else {
  16759. this._position = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16760. }
  16761. // Set non-vr camera
  16762. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16763. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16764. // Copy data from existing camera
  16765. if (this._scene.activeCamera) {
  16766. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16767. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16768. // Set rotation from previous camera
  16769. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16770. var targetCamera = this._scene.activeCamera;
  16771. if (targetCamera.rotationQuaternion) {
  16772. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16773. }
  16774. else {
  16775. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16776. }
  16777. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16778. }
  16779. }
  16780. this._scene.activeCamera = this._deviceOrientationCamera;
  16781. if (this._canvas) {
  16782. this._scene.activeCamera.attachControl(this._canvas);
  16783. }
  16784. }
  16785. else {
  16786. this._existingCamera = this._scene.activeCamera;
  16787. }
  16788. // Create VR cameras
  16789. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16790. if (webVROptions.useMultiview) {
  16791. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16792. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_23__["VRCameraMetrics"].GetDefault();
  16793. }
  16794. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16795. }
  16796. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16797. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16798. }
  16799. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16800. this._webVRCamera.useStandingMatrix();
  16801. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16802. // Create default button
  16803. if (!this._useCustomVRButton) {
  16804. this._btnVR = document.createElement("BUTTON");
  16805. this._btnVR.className = "babylonVRicon";
  16806. this._btnVR.id = "babylonVRiconbtn";
  16807. this._btnVR.title = "Click to switch to VR";
  16808. 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) }";
  16809. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16810. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16811. // css += ".babylonVRicon.vrdisplaysupported { }";
  16812. // css += ".babylonVRicon.vrdisplayready { }";
  16813. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16814. var style = document.createElement('style');
  16815. style.appendChild(document.createTextNode(css));
  16816. document.getElementsByTagName('head')[0].appendChild(style);
  16817. this.moveButtonToBottomRight();
  16818. }
  16819. // VR button click event
  16820. if (this._btnVR) {
  16821. this._btnVR.addEventListener("click", function () {
  16822. if (!_this.isInVRMode) {
  16823. _this.enterVR();
  16824. }
  16825. else {
  16826. _this.exitVR();
  16827. }
  16828. });
  16829. }
  16830. // Window events
  16831. window.addEventListener("resize", this._onResize);
  16832. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16833. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16834. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16835. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16836. document.onmsfullscreenchange = this._onFullscreenChange;
  16837. // Display vr button when headset is connected
  16838. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16839. this.displayVRButton();
  16840. }
  16841. else {
  16842. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16843. if (e.vrDisplay) {
  16844. _this.displayVRButton();
  16845. }
  16846. });
  16847. }
  16848. // Exiting VR mode using 'ESC' key on desktop
  16849. this._onKeyDown = function (event) {
  16850. if (event.keyCode === 27 && _this.isInVRMode) {
  16851. _this.exitVR();
  16852. }
  16853. };
  16854. document.addEventListener("keydown", this._onKeyDown);
  16855. // Exiting VR mode double tapping the touch screen
  16856. this._scene.onPrePointerObservable.add(function () {
  16857. if (_this.isInVRMode && _this.exitVROnDoubleTap) {
  16858. _this.exitVR();
  16859. if (_this._fullscreenVRpresenting) {
  16860. _this._scene.getEngine().exitFullscreen();
  16861. }
  16862. }
  16863. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16864. // Listen for WebVR display changes
  16865. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16866. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16867. this._onVRRequestPresentStart = function () {
  16868. _this._webVRrequesting = true;
  16869. _this.updateButtonVisibility();
  16870. };
  16871. this._onVRRequestPresentComplete = function () {
  16872. _this._webVRrequesting = false;
  16873. _this.updateButtonVisibility();
  16874. };
  16875. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16876. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16877. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16878. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16879. scene.onDisposeObservable.add(function () {
  16880. _this.dispose();
  16881. });
  16882. // Gamepad connection events
  16883. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16884. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16885. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16886. this.updateButtonVisibility();
  16887. //create easing functions
  16888. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_21__["CircleEase"]();
  16889. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_21__["EasingFunction"].EASINGMODE_EASEINOUT);
  16890. // Allow clicking in the vrDeviceOrientationCamera
  16891. scene.onPointerObservable.add(function (e) {
  16892. if (_this._interactionsEnabled) {
  16893. if (scene.activeCamera === _this.vrDeviceOrientationCamera && e.event.pointerType === "mouse") {
  16894. if (e.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOWN) {
  16895. _this._cameraGazer._selectionPointerDown();
  16896. }
  16897. else if (e.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERUP) {
  16898. _this._cameraGazer._selectionPointerUp();
  16899. }
  16900. }
  16901. }
  16902. });
  16903. if (this.webVROptions.floorMeshes) {
  16904. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16905. }
  16906. }
  16907. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16908. /** Return this.onEnteringVRObservable
  16909. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16910. */
  16911. get: function () {
  16912. return this.onEnteringVRObservable;
  16913. },
  16914. enumerable: true,
  16915. configurable: true
  16916. });
  16917. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16918. /** Return this.onExitingVRObservable
  16919. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16920. */
  16921. get: function () {
  16922. return this.onExitingVRObservable;
  16923. },
  16924. enumerable: true,
  16925. configurable: true
  16926. });
  16927. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16928. /** Return this.onControllerMeshLoadedObservable
  16929. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16930. */
  16931. get: function () {
  16932. return this.onControllerMeshLoadedObservable;
  16933. },
  16934. enumerable: true,
  16935. configurable: true
  16936. });
  16937. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16938. /**
  16939. * The mesh used to display where the user is going to teleport.
  16940. */
  16941. get: function () {
  16942. return this._teleportationTarget;
  16943. },
  16944. /**
  16945. * Sets the mesh to be used to display where the user is going to teleport.
  16946. */
  16947. set: function (value) {
  16948. if (value) {
  16949. value.name = "teleportationTarget";
  16950. this._isDefaultTeleportationTarget = false;
  16951. this._teleportationTarget = value;
  16952. }
  16953. },
  16954. enumerable: true,
  16955. configurable: true
  16956. });
  16957. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16958. /**
  16959. * 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
  16960. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16961. * See http://doc.babylonjs.com/resources/baking_transformations
  16962. */
  16963. get: function () {
  16964. return this._cameraGazer._gazeTracker;
  16965. },
  16966. set: function (value) {
  16967. if (value) {
  16968. // Dispose of existing meshes
  16969. if (this._cameraGazer._gazeTracker) {
  16970. this._cameraGazer._gazeTracker.dispose();
  16971. }
  16972. if (this._leftController && this._leftController._gazeTracker) {
  16973. this._leftController._gazeTracker.dispose();
  16974. }
  16975. if (this._rightController && this._rightController._gazeTracker) {
  16976. this._rightController._gazeTracker.dispose();
  16977. }
  16978. // Set and create gaze trackers on head and controllers
  16979. this._cameraGazer._gazeTracker = value;
  16980. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16981. this._cameraGazer._gazeTracker.isPickable = false;
  16982. this._cameraGazer._gazeTracker.isVisible = false;
  16983. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16984. if (this._leftController) {
  16985. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16986. }
  16987. if (this._rightController) {
  16988. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16989. }
  16990. }
  16991. },
  16992. enumerable: true,
  16993. configurable: true
  16994. });
  16995. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16996. /**
  16997. * The gaze tracking mesh corresponding to the left controller
  16998. */
  16999. get: function () {
  17000. if (this._leftController) {
  17001. return this._leftController._gazeTracker;
  17002. }
  17003. return null;
  17004. },
  17005. enumerable: true,
  17006. configurable: true
  17007. });
  17008. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  17009. /**
  17010. * The gaze tracking mesh corresponding to the right controller
  17011. */
  17012. get: function () {
  17013. if (this._rightController) {
  17014. return this._rightController._gazeTracker;
  17015. }
  17016. return null;
  17017. },
  17018. enumerable: true,
  17019. configurable: true
  17020. });
  17021. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  17022. /**
  17023. * If the ray of the gaze should be displayed.
  17024. */
  17025. get: function () {
  17026. return this._displayGaze;
  17027. },
  17028. /**
  17029. * Sets if the ray of the gaze should be displayed.
  17030. */
  17031. set: function (value) {
  17032. this._displayGaze = value;
  17033. if (!value) {
  17034. this._cameraGazer._gazeTracker.isVisible = false;
  17035. if (this._leftController) {
  17036. this._leftController._gazeTracker.isVisible = false;
  17037. }
  17038. if (this._rightController) {
  17039. this._rightController._gazeTracker.isVisible = false;
  17040. }
  17041. }
  17042. },
  17043. enumerable: true,
  17044. configurable: true
  17045. });
  17046. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  17047. /**
  17048. * If the ray of the LaserPointer should be displayed.
  17049. */
  17050. get: function () {
  17051. return this._displayLaserPointer;
  17052. },
  17053. /**
  17054. * Sets if the ray of the LaserPointer should be displayed.
  17055. */
  17056. set: function (value) {
  17057. this._displayLaserPointer = value;
  17058. if (!value) {
  17059. if (this._rightController) {
  17060. this._rightController._deactivatePointer();
  17061. this._rightController._gazeTracker.isVisible = false;
  17062. }
  17063. if (this._leftController) {
  17064. this._leftController._deactivatePointer();
  17065. this._leftController._gazeTracker.isVisible = false;
  17066. }
  17067. }
  17068. else {
  17069. if (this._rightController) {
  17070. this._rightController._activatePointer();
  17071. }
  17072. if (this._leftController) {
  17073. this._leftController._activatePointer();
  17074. }
  17075. }
  17076. },
  17077. enumerable: true,
  17078. configurable: true
  17079. });
  17080. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  17081. /**
  17082. * The deviceOrientationCamera used as the camera when not in VR.
  17083. */
  17084. get: function () {
  17085. return this._deviceOrientationCamera;
  17086. },
  17087. enumerable: true,
  17088. configurable: true
  17089. });
  17090. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  17091. /**
  17092. * Based on the current WebVR support, returns the current VR camera used.
  17093. */
  17094. get: function () {
  17095. if (this._webVRready) {
  17096. return this._webVRCamera;
  17097. }
  17098. else {
  17099. return this._scene.activeCamera;
  17100. }
  17101. },
  17102. enumerable: true,
  17103. configurable: true
  17104. });
  17105. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  17106. /**
  17107. * The webVRCamera which is used when in VR.
  17108. */
  17109. get: function () {
  17110. return this._webVRCamera;
  17111. },
  17112. enumerable: true,
  17113. configurable: true
  17114. });
  17115. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  17116. /**
  17117. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  17118. */
  17119. get: function () {
  17120. return this._vrDeviceOrientationCamera;
  17121. },
  17122. enumerable: true,
  17123. configurable: true
  17124. });
  17125. Object.defineProperty(VRExperienceHelper.prototype, "vrButton", {
  17126. /**
  17127. * The html button that is used to trigger entering into VR.
  17128. */
  17129. get: function () {
  17130. return this._btnVR;
  17131. },
  17132. enumerable: true,
  17133. configurable: true
  17134. });
  17135. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  17136. get: function () {
  17137. var result = this._cameraGazer._teleportationRequestInitiated
  17138. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  17139. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  17140. return result;
  17141. },
  17142. enumerable: true,
  17143. configurable: true
  17144. });
  17145. // Raised when one of the controller has loaded successfully its associated default mesh
  17146. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  17147. if (this._leftController && this._leftController.webVRController == webVRController) {
  17148. if (webVRController.mesh) {
  17149. this._leftController._setLaserPointerParent(webVRController.mesh);
  17150. }
  17151. }
  17152. if (this._rightController && this._rightController.webVRController == webVRController) {
  17153. if (webVRController.mesh) {
  17154. this._rightController._setLaserPointerParent(webVRController.mesh);
  17155. }
  17156. }
  17157. try {
  17158. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  17159. }
  17160. catch (err) {
  17161. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  17162. }
  17163. };
  17164. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  17165. /**
  17166. * Gets a value indicating if we are currently in VR mode.
  17167. */
  17168. get: function () {
  17169. return this._webVRpresenting || this._fullscreenVRpresenting;
  17170. },
  17171. enumerable: true,
  17172. configurable: true
  17173. });
  17174. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  17175. var vrDisplay = this._scene.getEngine().getVRDevice();
  17176. if (vrDisplay) {
  17177. var wasPresenting = this._webVRpresenting;
  17178. this._webVRpresenting = vrDisplay.isPresenting;
  17179. if (wasPresenting && !this._webVRpresenting) {
  17180. this.exitVR();
  17181. }
  17182. }
  17183. else {
  17184. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  17185. }
  17186. this.updateButtonVisibility();
  17187. };
  17188. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  17189. this._webVRsupported = eventArgs.vrSupported;
  17190. this._webVRready = !!eventArgs.vrDisplay;
  17191. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  17192. this.updateButtonVisibility();
  17193. };
  17194. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  17195. if (this._canvas && !this._useCustomVRButton && this._btnVR) {
  17196. var rect = this._canvas.getBoundingClientRect();
  17197. this._btnVR.style.top = rect.top + rect.height - 70 + "px";
  17198. this._btnVR.style.left = rect.left + rect.width - 100 + "px";
  17199. }
  17200. };
  17201. VRExperienceHelper.prototype.displayVRButton = function () {
  17202. if (!this._useCustomVRButton && !this._btnVRDisplayed && this._btnVR) {
  17203. document.body.appendChild(this._btnVR);
  17204. this._btnVRDisplayed = true;
  17205. }
  17206. };
  17207. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  17208. if (!this._btnVR || this._useCustomVRButton) {
  17209. return;
  17210. }
  17211. this._btnVR.className = "babylonVRicon";
  17212. if (this.isInVRMode) {
  17213. this._btnVR.className += " vrdisplaypresenting";
  17214. }
  17215. else {
  17216. if (this._webVRready) {
  17217. this._btnVR.className += " vrdisplayready";
  17218. }
  17219. if (this._webVRsupported) {
  17220. this._btnVR.className += " vrdisplaysupported";
  17221. }
  17222. if (this._webVRrequesting) {
  17223. this._btnVR.className += " vrdisplayrequesting";
  17224. }
  17225. }
  17226. };
  17227. /**
  17228. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  17229. * Otherwise, will use the fullscreen API.
  17230. */
  17231. VRExperienceHelper.prototype.enterVR = function () {
  17232. var _this = this;
  17233. if (this.onEnteringVRObservable) {
  17234. try {
  17235. this.onEnteringVRObservable.notifyObservers(this);
  17236. }
  17237. catch (err) {
  17238. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  17239. }
  17240. }
  17241. if (this._scene.activeCamera) {
  17242. this._position = this._scene.activeCamera.position.clone();
  17243. if (this.vrDeviceOrientationCamera) {
  17244. this.vrDeviceOrientationCamera.rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  17245. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  17246. }
  17247. if (this.webVRCamera) {
  17248. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  17249. var desiredYRotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  17250. var delta = desiredYRotation - currentYRotation;
  17251. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  17252. this.webVRCamera.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  17253. }
  17254. // make sure that we return to the last active camera
  17255. this._existingCamera = this._scene.activeCamera;
  17256. // Remove and cache angular sensability to avoid camera rotation when in VR
  17257. if (this._existingCamera.angularSensibilityX) {
  17258. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  17259. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  17260. }
  17261. if (this._existingCamera.angularSensibilityY) {
  17262. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  17263. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  17264. }
  17265. if (this._existingCamera.angularSensibility) {
  17266. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  17267. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  17268. }
  17269. }
  17270. if (this._webVRrequesting) {
  17271. return;
  17272. }
  17273. // If WebVR is supported and a headset is connected
  17274. if (this._webVRready) {
  17275. if (!this._webVRpresenting) {
  17276. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  17277. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  17278. });
  17279. this._webVRCamera.position = this._position;
  17280. this._scene.activeCamera = this._webVRCamera;
  17281. }
  17282. }
  17283. else if (this._vrDeviceOrientationCamera) {
  17284. this._vrDeviceOrientationCamera.position = this._position;
  17285. if (this._scene.activeCamera) {
  17286. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  17287. }
  17288. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  17289. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  17290. this.updateButtonVisibility();
  17291. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  17292. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  17293. });
  17294. }
  17295. if (this._scene.activeCamera && this._canvas) {
  17296. this._scene.activeCamera.attachControl(this._canvas);
  17297. }
  17298. if (this._interactionsEnabled) {
  17299. this._scene.registerBeforeRender(this.beforeRender);
  17300. }
  17301. if (this._displayLaserPointer) {
  17302. [this._leftController, this._rightController].forEach(function (controller) {
  17303. if (controller) {
  17304. controller._activatePointer();
  17305. }
  17306. });
  17307. }
  17308. this._hasEnteredVR = true;
  17309. };
  17310. /**
  17311. * Attempt to exit VR, or fullscreen.
  17312. */
  17313. VRExperienceHelper.prototype.exitVR = function () {
  17314. if (this._hasEnteredVR) {
  17315. if (this.onExitingVRObservable) {
  17316. try {
  17317. this.onExitingVRObservable.notifyObservers(this);
  17318. }
  17319. catch (err) {
  17320. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17321. }
  17322. }
  17323. if (this._webVRpresenting) {
  17324. this._scene.getEngine().disableVR();
  17325. }
  17326. if (this._scene.activeCamera) {
  17327. this._position = this._scene.activeCamera.position.clone();
  17328. }
  17329. if (this.vrDeviceOrientationCamera) {
  17330. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17331. }
  17332. if (this._deviceOrientationCamera) {
  17333. this._deviceOrientationCamera.position = this._position;
  17334. this._scene.activeCamera = this._deviceOrientationCamera;
  17335. if (this._canvas) {
  17336. this._scene.activeCamera.attachControl(this._canvas);
  17337. }
  17338. // Restore angular sensibility
  17339. if (this._cachedAngularSensibility.angularSensibilityX) {
  17340. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17341. this._cachedAngularSensibility.angularSensibilityX = null;
  17342. }
  17343. if (this._cachedAngularSensibility.angularSensibilityY) {
  17344. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17345. this._cachedAngularSensibility.angularSensibilityY = null;
  17346. }
  17347. if (this._cachedAngularSensibility.angularSensibility) {
  17348. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17349. this._cachedAngularSensibility.angularSensibility = null;
  17350. }
  17351. }
  17352. else if (this._existingCamera) {
  17353. this._existingCamera.position = this._position;
  17354. this._scene.activeCamera = this._existingCamera;
  17355. // Restore angular sensibility
  17356. if (this._cachedAngularSensibility.angularSensibilityX) {
  17357. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17358. this._cachedAngularSensibility.angularSensibilityX = null;
  17359. }
  17360. if (this._cachedAngularSensibility.angularSensibilityY) {
  17361. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17362. this._cachedAngularSensibility.angularSensibilityY = null;
  17363. }
  17364. if (this._cachedAngularSensibility.angularSensibility) {
  17365. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17366. this._cachedAngularSensibility.angularSensibility = null;
  17367. }
  17368. }
  17369. this.updateButtonVisibility();
  17370. if (this._interactionsEnabled) {
  17371. this._scene.unregisterBeforeRender(this.beforeRender);
  17372. this._cameraGazer._gazeTracker.isVisible = false;
  17373. if (this._leftController) {
  17374. this._leftController._gazeTracker.isVisible = false;
  17375. }
  17376. if (this._rightController) {
  17377. this._rightController._gazeTracker.isVisible = false;
  17378. }
  17379. }
  17380. // resize to update width and height when exiting vr exits fullscreen
  17381. this._scene.getEngine().resize();
  17382. [this._leftController, this._rightController].forEach(function (controller) {
  17383. if (controller) {
  17384. controller._deactivatePointer();
  17385. }
  17386. });
  17387. this._hasEnteredVR = false;
  17388. // Update engine state to re enable non-vr camera input
  17389. var engine = this._scene.getEngine();
  17390. if (engine._onVrDisplayPresentChange) {
  17391. engine._onVrDisplayPresentChange();
  17392. }
  17393. }
  17394. };
  17395. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17396. /**
  17397. * The position of the vr experience helper.
  17398. */
  17399. get: function () {
  17400. return this._position;
  17401. },
  17402. /**
  17403. * Sets the position of the vr experience helper.
  17404. */
  17405. set: function (value) {
  17406. this._position = value;
  17407. if (this._scene.activeCamera) {
  17408. this._scene.activeCamera.position = value;
  17409. }
  17410. },
  17411. enumerable: true,
  17412. configurable: true
  17413. });
  17414. /**
  17415. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17416. */
  17417. VRExperienceHelper.prototype.enableInteractions = function () {
  17418. var _this = this;
  17419. if (!this._interactionsEnabled) {
  17420. this._interactionsRequested = true;
  17421. if (this._leftController) {
  17422. this._enableInteractionOnController(this._leftController);
  17423. }
  17424. if (this._rightController) {
  17425. this._enableInteractionOnController(this._rightController);
  17426. }
  17427. this.raySelectionPredicate = function (mesh) {
  17428. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17429. };
  17430. this.meshSelectionPredicate = function () {
  17431. return true;
  17432. };
  17433. this._raySelectionPredicate = function (mesh) {
  17434. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17435. && mesh.name.indexOf("teleportationTarget") === -1
  17436. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17437. return _this.raySelectionPredicate(mesh);
  17438. }
  17439. return false;
  17440. };
  17441. this._interactionsEnabled = true;
  17442. }
  17443. };
  17444. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17445. get: function () {
  17446. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17447. },
  17448. enumerable: true,
  17449. configurable: true
  17450. });
  17451. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17452. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17453. if (this._floorMeshesCollection[i].id === mesh.id) {
  17454. return true;
  17455. }
  17456. }
  17457. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17458. return true;
  17459. }
  17460. return false;
  17461. };
  17462. /**
  17463. * Adds a floor mesh to be used for teleportation.
  17464. * @param floorMesh the mesh to be used for teleportation.
  17465. */
  17466. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17467. if (!this._floorMeshesCollection) {
  17468. return;
  17469. }
  17470. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17471. return;
  17472. }
  17473. this._floorMeshesCollection.push(floorMesh);
  17474. };
  17475. /**
  17476. * Removes a floor mesh from being used for teleportation.
  17477. * @param floorMesh the mesh to be removed.
  17478. */
  17479. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17480. if (!this._floorMeshesCollection) {
  17481. return;
  17482. }
  17483. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17484. if (meshIndex !== -1) {
  17485. this._floorMeshesCollection.splice(meshIndex, 1);
  17486. }
  17487. };
  17488. /**
  17489. * Enables interactions and teleportation using the VR controllers and gaze.
  17490. * @param vrTeleportationOptions options to modify teleportation behavior.
  17491. */
  17492. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17493. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17494. if (!this._teleportationInitialized) {
  17495. this._teleportationRequested = true;
  17496. this.enableInteractions();
  17497. if (vrTeleportationOptions.floorMeshName) {
  17498. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17499. }
  17500. if (vrTeleportationOptions.floorMeshes) {
  17501. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17502. }
  17503. if (this._leftController != null) {
  17504. this._enableTeleportationOnController(this._leftController);
  17505. }
  17506. if (this._rightController != null) {
  17507. this._enableTeleportationOnController(this._rightController);
  17508. }
  17509. // Creates an image processing post process for the vignette not relying
  17510. // on the main scene configuration for image processing to reduce setup and spaces
  17511. // (gamma/linear) conflicts.
  17512. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_17__["ImageProcessingConfiguration"]();
  17513. imageProcessingConfiguration.vignetteColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color4"](0, 0, 0, 0);
  17514. imageProcessingConfiguration.vignetteEnabled = true;
  17515. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_20__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17516. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17517. this._teleportationInitialized = true;
  17518. if (this._isDefaultTeleportationTarget) {
  17519. this._createTeleportationCircles();
  17520. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17521. }
  17522. }
  17523. };
  17524. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17525. var _this = this;
  17526. var controllerMesh = controller.webVRController.mesh;
  17527. if (controllerMesh) {
  17528. controller._interactionsEnabled = true;
  17529. if (this.isInVRMode && this._displayLaserPointer) {
  17530. controller._activatePointer();
  17531. }
  17532. if (this.webVROptions.laserToggle) {
  17533. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17534. // Enabling / disabling laserPointer
  17535. if (_this._displayLaserPointer && stateObject.value === 1) {
  17536. if (controller._activePointer) {
  17537. controller._deactivatePointer();
  17538. }
  17539. else {
  17540. controller._activatePointer();
  17541. }
  17542. if (_this.displayGaze) {
  17543. controller._gazeTracker.isVisible = controller._activePointer;
  17544. }
  17545. }
  17546. });
  17547. }
  17548. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17549. var gazer = controller;
  17550. if (_this._noControllerIsActive) {
  17551. gazer = _this._cameraGazer;
  17552. }
  17553. if (!gazer._pointerDownOnMeshAsked) {
  17554. if (stateObject.value > _this._padSensibilityUp) {
  17555. gazer._selectionPointerDown();
  17556. }
  17557. }
  17558. else if (stateObject.value < _this._padSensibilityDown) {
  17559. gazer._selectionPointerUp();
  17560. }
  17561. });
  17562. }
  17563. };
  17564. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17565. // Dont teleport if another gaze already requested teleportation
  17566. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17567. return;
  17568. }
  17569. if (!gazer._teleportationRequestInitiated) {
  17570. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17571. gazer._activatePointer();
  17572. gazer._teleportationRequestInitiated = true;
  17573. }
  17574. }
  17575. else {
  17576. // Listening to the proper controller values changes to confirm teleportation
  17577. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17578. if (this._teleportActive) {
  17579. this.teleportCamera(this._haloCenter);
  17580. }
  17581. gazer._teleportationRequestInitiated = false;
  17582. }
  17583. }
  17584. };
  17585. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17586. // Only rotate when user is not currently selecting a teleportation location
  17587. if (gazer._teleportationRequestInitiated) {
  17588. return;
  17589. }
  17590. if (!gazer._rotationLeftAsked) {
  17591. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17592. gazer._rotationLeftAsked = true;
  17593. if (this._rotationAllowed) {
  17594. this._rotateCamera(false);
  17595. }
  17596. }
  17597. }
  17598. else {
  17599. if (stateObject.x > -this._padSensibilityDown) {
  17600. gazer._rotationLeftAsked = false;
  17601. }
  17602. }
  17603. if (!gazer._rotationRightAsked) {
  17604. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17605. gazer._rotationRightAsked = true;
  17606. if (this._rotationAllowed) {
  17607. this._rotateCamera(true);
  17608. }
  17609. }
  17610. }
  17611. else {
  17612. if (stateObject.x < this._padSensibilityDown) {
  17613. gazer._rotationRightAsked = false;
  17614. }
  17615. }
  17616. };
  17617. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17618. // Only teleport backwards when user is not currently selecting a teleportation location
  17619. if (gazer._teleportationRequestInitiated) {
  17620. return;
  17621. }
  17622. // Teleport backwards
  17623. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17624. if (!gazer._teleportationBackRequestInitiated) {
  17625. if (!this.currentVRCamera) {
  17626. return;
  17627. }
  17628. // Get rotation and position of the current camera
  17629. var rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17630. var position = this.currentVRCamera.position;
  17631. // If the camera has device position, use that instead
  17632. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17633. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17634. position = this.currentVRCamera.devicePosition;
  17635. }
  17636. // Get matrix with only the y rotation of the device rotation
  17637. rotation.toEulerAnglesToRef(this._workingVector);
  17638. this._workingVector.z = 0;
  17639. this._workingVector.x = 0;
  17640. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17641. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17642. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17643. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17644. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17645. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_16__["Ray"](position, this._workingVector);
  17646. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17647. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17648. this.teleportCamera(hit.pickedPoint);
  17649. }
  17650. gazer._teleportationBackRequestInitiated = true;
  17651. }
  17652. }
  17653. else {
  17654. gazer._teleportationBackRequestInitiated = false;
  17655. }
  17656. };
  17657. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17658. var _this = this;
  17659. var controllerMesh = controller.webVRController.mesh;
  17660. if (controllerMesh) {
  17661. if (!controller._interactionsEnabled) {
  17662. this._enableInteractionOnController(controller);
  17663. }
  17664. controller._interactionsEnabled = true;
  17665. controller._teleportationEnabled = true;
  17666. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_12__["PoseEnabledControllerType"].VIVE) {
  17667. controller._dpadPressed = false;
  17668. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17669. controller._dpadPressed = stateObject.pressed;
  17670. if (!controller._dpadPressed) {
  17671. controller._rotationLeftAsked = false;
  17672. controller._rotationRightAsked = false;
  17673. controller._teleportationBackRequestInitiated = false;
  17674. }
  17675. });
  17676. }
  17677. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17678. if (_this.teleportationEnabled) {
  17679. _this._checkTeleportBackwards(stateObject, controller);
  17680. _this._checkTeleportWithRay(stateObject, controller);
  17681. }
  17682. _this._checkRotate(stateObject, controller);
  17683. });
  17684. }
  17685. };
  17686. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17687. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17688. this._teleportationTarget.isPickable = false;
  17689. var length = 512;
  17690. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_19__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17691. dynamicTexture.hasAlpha = true;
  17692. var context = dynamicTexture.getContext();
  17693. var centerX = length / 2;
  17694. var centerY = length / 2;
  17695. var radius = 200;
  17696. context.beginPath();
  17697. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17698. context.fillStyle = this._teleportationFillColor;
  17699. context.fill();
  17700. context.lineWidth = 10;
  17701. context.strokeStyle = this._teleportationBorderColor;
  17702. context.stroke();
  17703. context.closePath();
  17704. dynamicTexture.update();
  17705. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_18__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17706. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17707. this._teleportationTarget.material = teleportationCircleMaterial;
  17708. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_15__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17709. torus.isPickable = false;
  17710. torus.parent = this._teleportationTarget;
  17711. var animationInnerCircle = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationInnerCircle", "position.y", 30, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  17712. var keys = [];
  17713. keys.push({
  17714. frame: 0,
  17715. value: 0
  17716. });
  17717. keys.push({
  17718. frame: 30,
  17719. value: 0.4
  17720. });
  17721. keys.push({
  17722. frame: 60,
  17723. value: 0
  17724. });
  17725. animationInnerCircle.setKeys(keys);
  17726. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_21__["SineEase"]();
  17727. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_21__["EasingFunction"].EASINGMODE_EASEINOUT);
  17728. animationInnerCircle.setEasingFunction(easingFunction);
  17729. torus.animations = [];
  17730. torus.animations.push(animationInnerCircle);
  17731. this._scene.beginAnimation(torus, 0, 60, true);
  17732. this._hideTeleportationTarget();
  17733. };
  17734. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17735. this._teleportActive = true;
  17736. if (this._teleportationInitialized) {
  17737. this._teleportationTarget.isVisible = true;
  17738. if (this._isDefaultTeleportationTarget) {
  17739. this._teleportationTarget.getChildren()[0].isVisible = true;
  17740. }
  17741. }
  17742. };
  17743. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17744. this._teleportActive = false;
  17745. if (this._teleportationInitialized) {
  17746. this._teleportationTarget.isVisible = false;
  17747. if (this._isDefaultTeleportationTarget) {
  17748. this._teleportationTarget.getChildren()[0].isVisible = false;
  17749. }
  17750. }
  17751. };
  17752. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17753. var _this = this;
  17754. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17755. return;
  17756. }
  17757. if (right) {
  17758. this._rotationAngle++;
  17759. }
  17760. else {
  17761. this._rotationAngle--;
  17762. }
  17763. this.currentVRCamera.animations = [];
  17764. var target = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17765. var animationRotation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationRotation", "rotationQuaternion", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_QUATERNION, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17766. var animationRotationKeys = [];
  17767. animationRotationKeys.push({
  17768. frame: 0,
  17769. value: this.currentVRCamera.rotationQuaternion
  17770. });
  17771. animationRotationKeys.push({
  17772. frame: 6,
  17773. value: target
  17774. });
  17775. animationRotation.setKeys(animationRotationKeys);
  17776. animationRotation.setEasingFunction(this._circleEase);
  17777. this.currentVRCamera.animations.push(animationRotation);
  17778. this._postProcessMove.animations = [];
  17779. var animationPP = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationPP", "vignetteWeight", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17780. var vignetteWeightKeys = [];
  17781. vignetteWeightKeys.push({
  17782. frame: 0,
  17783. value: 0
  17784. });
  17785. vignetteWeightKeys.push({
  17786. frame: 3,
  17787. value: 4
  17788. });
  17789. vignetteWeightKeys.push({
  17790. frame: 6,
  17791. value: 0
  17792. });
  17793. animationPP.setKeys(vignetteWeightKeys);
  17794. animationPP.setEasingFunction(this._circleEase);
  17795. this._postProcessMove.animations.push(animationPP);
  17796. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17797. var vignetteStretchKeys = [];
  17798. vignetteStretchKeys.push({
  17799. frame: 0,
  17800. value: 0
  17801. });
  17802. vignetteStretchKeys.push({
  17803. frame: 3,
  17804. value: 10
  17805. });
  17806. vignetteStretchKeys.push({
  17807. frame: 6,
  17808. value: 0
  17809. });
  17810. animationPP2.setKeys(vignetteStretchKeys);
  17811. animationPP2.setEasingFunction(this._circleEase);
  17812. this._postProcessMove.animations.push(animationPP2);
  17813. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17814. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17815. this._postProcessMove.samples = 4;
  17816. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17817. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17818. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17819. });
  17820. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17821. };
  17822. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17823. if (hit.pickedPoint) {
  17824. if (gazer._teleportationRequestInitiated) {
  17825. this._displayTeleportationTarget();
  17826. this._haloCenter.copyFrom(hit.pickedPoint);
  17827. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17828. }
  17829. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17830. if (pickNormal) {
  17831. var axis1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_29__["Axis"].Y, pickNormal);
  17832. var axis2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17833. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17834. }
  17835. this._teleportationTarget.position.y += 0.1;
  17836. }
  17837. };
  17838. /**
  17839. * Teleports the users feet to the desired location
  17840. * @param location The location where the user's feet should be placed
  17841. */
  17842. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17843. var _this = this;
  17844. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17845. return;
  17846. }
  17847. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17848. // offset of the headset from the anchor.
  17849. if (this.webVRCamera.leftCamera) {
  17850. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17851. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17852. location.subtractToRef(this._workingVector, this._workingVector);
  17853. }
  17854. else {
  17855. this._workingVector.copyFrom(location);
  17856. }
  17857. // Add height to account for user's height offset
  17858. if (this.isInVRMode) {
  17859. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17860. }
  17861. else {
  17862. this._workingVector.y += this._defaultHeight;
  17863. }
  17864. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17865. // Create animation from the camera's position to the new location
  17866. this.currentVRCamera.animations = [];
  17867. var animationCameraTeleportation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationCameraTeleportation", "position", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_VECTOR3, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17868. var animationCameraTeleportationKeys = [{
  17869. frame: 0,
  17870. value: this.currentVRCamera.position
  17871. },
  17872. {
  17873. frame: 11,
  17874. value: this._workingVector
  17875. }
  17876. ];
  17877. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17878. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17879. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17880. this._postProcessMove.animations = [];
  17881. var animationPP = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationPP", "vignetteWeight", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17882. var vignetteWeightKeys = [];
  17883. vignetteWeightKeys.push({
  17884. frame: 0,
  17885. value: 0
  17886. });
  17887. vignetteWeightKeys.push({
  17888. frame: 5,
  17889. value: 8
  17890. });
  17891. vignetteWeightKeys.push({
  17892. frame: 11,
  17893. value: 0
  17894. });
  17895. animationPP.setKeys(vignetteWeightKeys);
  17896. this._postProcessMove.animations.push(animationPP);
  17897. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_22__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17898. var vignetteStretchKeys = [];
  17899. vignetteStretchKeys.push({
  17900. frame: 0,
  17901. value: 0
  17902. });
  17903. vignetteStretchKeys.push({
  17904. frame: 5,
  17905. value: 10
  17906. });
  17907. vignetteStretchKeys.push({
  17908. frame: 11,
  17909. value: 0
  17910. });
  17911. animationPP2.setKeys(vignetteStretchKeys);
  17912. this._postProcessMove.animations.push(animationPP2);
  17913. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17914. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17915. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17916. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17917. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17918. });
  17919. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17920. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17921. });
  17922. this._hideTeleportationTarget();
  17923. };
  17924. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17925. if (normal) {
  17926. var angle = Math.acos(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17927. if (angle < Math.PI / 2) {
  17928. normal.scaleInPlace(-1);
  17929. }
  17930. }
  17931. return normal;
  17932. };
  17933. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17934. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17935. return;
  17936. }
  17937. var ray = gazer._getForwardRay(this._rayLength);
  17938. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17939. if (hit) {
  17940. // Populate the controllers mesh that can be used for drag/drop
  17941. if (gazer._laserPointer) {
  17942. hit.originMesh = gazer._laserPointer.parent;
  17943. }
  17944. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17945. }
  17946. gazer._currentHit = hit;
  17947. // Moving the gazeTracker on the mesh face targetted
  17948. if (hit && hit.pickedPoint) {
  17949. if (this._displayGaze) {
  17950. var multiplier = 1;
  17951. gazer._gazeTracker.isVisible = true;
  17952. if (gazer._isActionableMesh) {
  17953. multiplier = 3;
  17954. }
  17955. if (this.updateGazeTrackerScale) {
  17956. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17957. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17958. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17959. }
  17960. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17961. // To avoid z-fighting
  17962. var deltaFighting = 0.002;
  17963. if (pickNormal) {
  17964. var axis1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_29__["Axis"].Y, pickNormal);
  17965. var axis2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17966. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17967. }
  17968. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17969. if (gazer._gazeTracker.position.x < 0) {
  17970. gazer._gazeTracker.position.x += deltaFighting;
  17971. }
  17972. else {
  17973. gazer._gazeTracker.position.x -= deltaFighting;
  17974. }
  17975. if (gazer._gazeTracker.position.y < 0) {
  17976. gazer._gazeTracker.position.y += deltaFighting;
  17977. }
  17978. else {
  17979. gazer._gazeTracker.position.y -= deltaFighting;
  17980. }
  17981. if (gazer._gazeTracker.position.z < 0) {
  17982. gazer._gazeTracker.position.z += deltaFighting;
  17983. }
  17984. else {
  17985. gazer._gazeTracker.position.z -= deltaFighting;
  17986. }
  17987. }
  17988. // Changing the size of the laser pointer based on the distance from the targetted point
  17989. gazer._updatePointerDistance(hit.distance);
  17990. }
  17991. else {
  17992. gazer._updatePointerDistance();
  17993. gazer._gazeTracker.isVisible = false;
  17994. }
  17995. if (hit && hit.pickedMesh) {
  17996. // The object selected is the floor, we're in a teleportation scenario
  17997. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17998. // Moving the teleportation area to this targetted point
  17999. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  18000. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  18001. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  18002. }
  18003. gazer._currentMeshSelected = null;
  18004. if (gazer._teleportationRequestInitiated) {
  18005. this._moveTeleportationSelectorTo(hit, gazer, ray);
  18006. }
  18007. return;
  18008. }
  18009. // If not, we're in a selection scenario
  18010. //this._teleportationAllowed = false;
  18011. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  18012. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  18013. this.onNewMeshPicked.notifyObservers(hit);
  18014. gazer._currentMeshSelected = hit.pickedMesh;
  18015. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  18016. this.changeGazeColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0, 0, 1));
  18017. this.changeLaserColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.2, 0.2, 1));
  18018. gazer._isActionableMesh = true;
  18019. }
  18020. else {
  18021. this.changeGazeColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7));
  18022. this.changeLaserColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7));
  18023. gazer._isActionableMesh = false;
  18024. }
  18025. try {
  18026. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  18027. }
  18028. catch (err) {
  18029. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  18030. }
  18031. }
  18032. else {
  18033. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  18034. gazer._currentMeshSelected = null;
  18035. this.changeGazeColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7));
  18036. this.changeLaserColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7));
  18037. }
  18038. }
  18039. }
  18040. else {
  18041. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  18042. gazer._currentMeshSelected = null;
  18043. //this._teleportationAllowed = false;
  18044. this.changeGazeColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7));
  18045. this.changeLaserColor(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.7, 0.7, 0.7));
  18046. }
  18047. };
  18048. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  18049. if (mesh) {
  18050. this.onSelectedMeshUnselected.notifyObservers(mesh);
  18051. }
  18052. };
  18053. /**
  18054. * Sets the color of the laser ray from the vr controllers.
  18055. * @param color new color for the ray.
  18056. */
  18057. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  18058. if (this._leftController) {
  18059. this._leftController._setLaserPointerColor(color);
  18060. }
  18061. if (this._rightController) {
  18062. this._rightController._setLaserPointerColor(color);
  18063. }
  18064. };
  18065. /**
  18066. * Sets the color of the ray from the vr headsets gaze.
  18067. * @param color new color for the ray.
  18068. */
  18069. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  18070. if (!this.updateGazeTrackerColor) {
  18071. return;
  18072. }
  18073. if (!this._cameraGazer._gazeTracker.material) {
  18074. return;
  18075. }
  18076. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  18077. if (this._leftController) {
  18078. this._leftController._gazeTracker.material.emissiveColor = color;
  18079. }
  18080. if (this._rightController) {
  18081. this._rightController._gazeTracker.material.emissiveColor = color;
  18082. }
  18083. };
  18084. /**
  18085. * Exits VR and disposes of the vr experience helper
  18086. */
  18087. VRExperienceHelper.prototype.dispose = function () {
  18088. if (this.isInVRMode) {
  18089. this.exitVR();
  18090. }
  18091. if (this._postProcessMove) {
  18092. this._postProcessMove.dispose();
  18093. }
  18094. if (this._webVRCamera) {
  18095. this._webVRCamera.dispose();
  18096. }
  18097. if (this._vrDeviceOrientationCamera) {
  18098. this._vrDeviceOrientationCamera.dispose();
  18099. }
  18100. if (!this._useCustomVRButton && this._btnVR && this._btnVR.parentNode) {
  18101. document.body.removeChild(this._btnVR);
  18102. }
  18103. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  18104. this._deviceOrientationCamera.dispose();
  18105. }
  18106. if (this._cameraGazer) {
  18107. this._cameraGazer.dispose();
  18108. }
  18109. if (this._leftController) {
  18110. this._leftController.dispose();
  18111. }
  18112. if (this._rightController) {
  18113. this._rightController.dispose();
  18114. }
  18115. if (this._teleportationTarget) {
  18116. this._teleportationTarget.dispose();
  18117. }
  18118. this._floorMeshesCollection = [];
  18119. document.removeEventListener("keydown", this._onKeyDown);
  18120. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  18121. window.removeEventListener("resize", this._onResize);
  18122. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  18123. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  18124. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  18125. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  18126. document.onmsfullscreenchange = null;
  18127. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  18128. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  18129. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  18130. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  18131. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  18132. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  18133. this._scene.unregisterBeforeRender(this.beforeRender);
  18134. };
  18135. /**
  18136. * Gets the name of the VRExperienceHelper class
  18137. * @returns "VRExperienceHelper"
  18138. */
  18139. VRExperienceHelper.prototype.getClassName = function () {
  18140. return "VRExperienceHelper";
  18141. };
  18142. return VRExperienceHelper;
  18143. }());
  18144. /***/ }),
  18145. /***/ "./Cameras/VR/webVRCamera.ts":
  18146. /*!***********************************!*\
  18147. !*** ./Cameras/VR/webVRCamera.ts ***!
  18148. \***********************************/
  18149. /*! exports provided: WebVRFreeCamera */
  18150. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18151. "use strict";
  18152. __webpack_require__.r(__webpack_exports__);
  18153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  18154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18155. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18156. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18157. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18158. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  18159. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  18160. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  18161. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  18162. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  18163. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18164. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  18165. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  18166. /* harmony import */ var _Engines_Extensions_engine_webVR__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/Extensions/engine.webVR */ "./Engines/Extensions/engine.webVR.ts");
  18167. // Side effect import to define the stereoscopic mode.
  18168. // Side effect import to add webvr support to engine
  18169. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  18170. return function () { return new WebVRFreeCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  18171. });
  18172. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  18173. return function () { return new WebVRFreeCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  18174. });
  18175. /**
  18176. * This represents a WebVR camera.
  18177. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18178. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18179. */
  18180. var WebVRFreeCamera = /** @class */ (function (_super) {
  18181. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  18182. /**
  18183. * Instantiates a WebVRFreeCamera.
  18184. * @param name The name of the WebVRFreeCamera
  18185. * @param position The starting anchor position for the camera
  18186. * @param scene The scene the camera belongs to
  18187. * @param webVROptions a set of customizable options for the webVRCamera
  18188. */
  18189. function WebVRFreeCamera(name, position, scene, webVROptions) {
  18190. if (webVROptions === void 0) { webVROptions = {}; }
  18191. var _this = _super.call(this, name, position, scene) || this;
  18192. _this.webVROptions = webVROptions;
  18193. /**
  18194. * @hidden
  18195. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18196. */
  18197. _this._vrDevice = null;
  18198. /**
  18199. * The rawPose of the vrDevice.
  18200. */
  18201. _this.rawPose = null;
  18202. _this._specsVersion = "1.1";
  18203. _this._attached = false;
  18204. _this._descendants = [];
  18205. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  18206. _this._deviceRoomPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18207. /** @hidden */
  18208. _this._deviceRoomRotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  18209. _this._standingMatrix = null;
  18210. /**
  18211. * Represents device position in babylon space.
  18212. */
  18213. _this.devicePosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18214. /**
  18215. * Represents device rotation in babylon space.
  18216. */
  18217. _this.deviceRotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  18218. /**
  18219. * The scale of the device to be used when translating from device space to babylon space.
  18220. */
  18221. _this.deviceScaleFactor = 1;
  18222. _this._deviceToWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18223. _this._worldToDevice = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18224. /**
  18225. * References to the webVR controllers for the vrDevice.
  18226. */
  18227. _this.controllers = [];
  18228. /**
  18229. * Emits an event when a controller is attached.
  18230. */
  18231. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18232. /**
  18233. * Emits an event when a controller's mesh has been loaded;
  18234. */
  18235. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18236. /**
  18237. * Emits an event when the HMD's pose has been updated.
  18238. */
  18239. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18240. _this._poseSet = false;
  18241. /**
  18242. * If the rig cameras be used as parent instead of this camera.
  18243. */
  18244. _this.rigParenting = true;
  18245. _this._defaultHeight = undefined;
  18246. _this._htmlElementAttached = null;
  18247. _this._detachIfAttached = function () {
  18248. var vrDisplay = _this.getEngine().getVRDevice();
  18249. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  18250. _this.detachControl(_this._htmlElementAttached);
  18251. }
  18252. };
  18253. _this._workingVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18254. _this._oneVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  18255. _this._workingMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18256. _this._tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18257. _this._cache.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18258. if (webVROptions.defaultHeight) {
  18259. _this._defaultHeight = webVROptions.defaultHeight;
  18260. _this.position.y = _this._defaultHeight;
  18261. }
  18262. _this.minZ = 0.1;
  18263. //legacy support - the compensation boolean was removed.
  18264. if (arguments.length === 5) {
  18265. _this.webVROptions = arguments[4];
  18266. }
  18267. // default webVR options
  18268. if (_this.webVROptions.trackPosition == undefined) {
  18269. _this.webVROptions.trackPosition = true;
  18270. }
  18271. if (_this.webVROptions.controllerMeshes == undefined) {
  18272. _this.webVROptions.controllerMeshes = true;
  18273. }
  18274. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  18275. _this.webVROptions.defaultLightingOnControllers = true;
  18276. }
  18277. _this.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  18278. if (_this.webVROptions && _this.webVROptions.positionScale) {
  18279. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  18280. }
  18281. //enable VR
  18282. var engine = _this.getEngine();
  18283. _this._onVREnabled = function (success) { if (success) {
  18284. _this.initControllers();
  18285. } };
  18286. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  18287. engine.initWebVR().add(function (event) {
  18288. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  18289. return;
  18290. }
  18291. _this._vrDevice = event.vrDisplay;
  18292. //reset the rig parameters.
  18293. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  18294. if (_this._attached) {
  18295. _this.getEngine().enableVR();
  18296. }
  18297. });
  18298. if (typeof (VRFrameData) !== "undefined") {
  18299. _this._frameData = new VRFrameData();
  18300. }
  18301. if (webVROptions.useMultiview) {
  18302. if (!_this.getScene().getEngine().getCaps().multiview) {
  18303. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  18304. _this._useMultiviewToSingleView = false;
  18305. }
  18306. else {
  18307. _this._useMultiviewToSingleView = true;
  18308. _this._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", _this, 1.0);
  18309. }
  18310. }
  18311. /**
  18312. * The idea behind the following lines:
  18313. * objects that have the camera as parent should actually have the rig cameras as a parent.
  18314. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  18315. * the second will not show it correctly.
  18316. *
  18317. * To solve this - each object that has the camera as parent will be added to a protected array.
  18318. * When the rig camera renders, it will take this array and set all of those to be its children.
  18319. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18320. * Amazing!
  18321. */
  18322. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18323. if (camera.parent === _this && _this.rigParenting) {
  18324. _this._descendants = _this.getDescendants(true, function (n) {
  18325. // don't take the cameras or the controllers!
  18326. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18327. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18328. return !isController && !isRigCamera;
  18329. });
  18330. _this._descendants.forEach(function (node) {
  18331. node.parent = camera;
  18332. });
  18333. }
  18334. });
  18335. scene.onAfterCameraRenderObservable.add(function (camera) {
  18336. if (camera.parent === _this && _this.rigParenting) {
  18337. _this._descendants.forEach(function (node) {
  18338. node.parent = _this;
  18339. });
  18340. }
  18341. });
  18342. return _this;
  18343. }
  18344. /**
  18345. * Gets the device distance from the ground in meters.
  18346. * @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.
  18347. */
  18348. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18349. if (this._standingMatrix) {
  18350. // Add standing matrix offset to get real offset from ground in room
  18351. this._standingMatrix.getTranslationToRef(this._workingVector);
  18352. return this._deviceRoomPosition.y + this._workingVector.y;
  18353. }
  18354. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18355. return this._defaultHeight || 0;
  18356. };
  18357. /**
  18358. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18359. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18360. */
  18361. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18362. var _this = this;
  18363. if (callback === void 0) { callback = function (bool) { }; }
  18364. // Use standing matrix if available
  18365. this.getEngine().initWebVRAsync().then(function (result) {
  18366. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18367. callback(false);
  18368. }
  18369. else {
  18370. _this._standingMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18371. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18372. if (!_this.getScene().useRightHandedSystem) {
  18373. if (_this._standingMatrix) {
  18374. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18375. }
  18376. }
  18377. callback(true);
  18378. }
  18379. });
  18380. };
  18381. /**
  18382. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18383. * @returns A promise with a boolean set to if the standing matrix is supported.
  18384. */
  18385. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18386. var _this = this;
  18387. return new Promise(function (res) {
  18388. _this.useStandingMatrix(function (supported) {
  18389. res(supported);
  18390. });
  18391. });
  18392. };
  18393. /**
  18394. * Disposes the camera
  18395. */
  18396. WebVRFreeCamera.prototype.dispose = function () {
  18397. this._detachIfAttached();
  18398. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18399. if (this._updateCacheWhenTrackingDisabledObserver) {
  18400. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18401. }
  18402. _super.prototype.dispose.call(this);
  18403. };
  18404. /**
  18405. * Gets a vrController by name.
  18406. * @param name The name of the controller to retreive
  18407. * @returns the controller matching the name specified or null if not found
  18408. */
  18409. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18410. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18411. var gp = _a[_i];
  18412. if (gp.hand === name) {
  18413. return gp;
  18414. }
  18415. }
  18416. return null;
  18417. };
  18418. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18419. /**
  18420. * The controller corresponding to the users left hand.
  18421. */
  18422. get: function () {
  18423. if (!this._leftController) {
  18424. this._leftController = this.getControllerByName("left");
  18425. }
  18426. return this._leftController;
  18427. },
  18428. enumerable: true,
  18429. configurable: true
  18430. });
  18431. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18432. /**
  18433. * The controller corresponding to the users right hand.
  18434. */
  18435. get: function () {
  18436. if (!this._rightController) {
  18437. this._rightController = this.getControllerByName("right");
  18438. }
  18439. return this._rightController;
  18440. },
  18441. enumerable: true,
  18442. configurable: true
  18443. });
  18444. /**
  18445. * Casts a ray forward from the vrCamera's gaze.
  18446. * @param length Length of the ray (default: 100)
  18447. * @returns the ray corresponding to the gaze
  18448. */
  18449. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18450. if (length === void 0) { length = 100; }
  18451. if (this.leftCamera) {
  18452. // Use left eye to avoid computation to compute center on every call
  18453. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18454. }
  18455. else {
  18456. return _super.prototype.getForwardRay.call(this, length);
  18457. }
  18458. };
  18459. /**
  18460. * @hidden
  18461. * Updates the camera based on device's frame data
  18462. */
  18463. WebVRFreeCamera.prototype._checkInputs = function () {
  18464. if (this._vrDevice && this._vrDevice.isPresenting) {
  18465. this._vrDevice.getFrameData(this._frameData);
  18466. this.updateFromDevice(this._frameData.pose);
  18467. }
  18468. _super.prototype._checkInputs.call(this);
  18469. };
  18470. /**
  18471. * Updates the poseControlled values based on the input device pose.
  18472. * @param poseData Pose coming from the device
  18473. */
  18474. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18475. if (poseData && poseData.orientation) {
  18476. this.rawPose = poseData;
  18477. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18478. if (this.getScene().useRightHandedSystem) {
  18479. this._deviceRoomRotationQuaternion.z *= -1;
  18480. this._deviceRoomRotationQuaternion.w *= -1;
  18481. }
  18482. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18483. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18484. if (this.getScene().useRightHandedSystem) {
  18485. this._deviceRoomPosition.z *= -1;
  18486. }
  18487. }
  18488. this._poseSet = true;
  18489. }
  18490. };
  18491. /**
  18492. * WebVR's attach control will start broadcasting frames to the device.
  18493. * Note that in certain browsers (chrome for example) this function must be called
  18494. * within a user-interaction callback. Example:
  18495. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18496. *
  18497. * @param element html element to attach the vrDevice to
  18498. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18499. */
  18500. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18501. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18502. this._attached = true;
  18503. this._htmlElementAttached = element;
  18504. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18505. if (this._vrDevice) {
  18506. this.getEngine().enableVR();
  18507. }
  18508. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18509. };
  18510. /**
  18511. * Detaches the camera from the html element and disables VR
  18512. *
  18513. * @param element html element to detach from
  18514. */
  18515. WebVRFreeCamera.prototype.detachControl = function (element) {
  18516. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18517. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18518. _super.prototype.detachControl.call(this, element);
  18519. this._attached = false;
  18520. this.getEngine().disableVR();
  18521. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18522. };
  18523. /**
  18524. * @returns the name of this class
  18525. */
  18526. WebVRFreeCamera.prototype.getClassName = function () {
  18527. return "WebVRFreeCamera";
  18528. };
  18529. /**
  18530. * Calls resetPose on the vrDisplay
  18531. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18532. */
  18533. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18534. //uses the vrDisplay's "resetPose()".
  18535. //pitch and roll won't be affected.
  18536. this._vrDevice.resetPose();
  18537. };
  18538. /**
  18539. * @hidden
  18540. * Updates the rig cameras (left and right eye)
  18541. */
  18542. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18543. var camLeft = this._rigCameras[0];
  18544. var camRight = this._rigCameras[1];
  18545. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18546. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18547. camLeft.position.copyFrom(this._deviceRoomPosition);
  18548. camRight.position.copyFrom(this._deviceRoomPosition);
  18549. };
  18550. // Remove translation from 6dof headset if trackposition is set to false
  18551. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18552. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18553. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18554. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18555. if (!isViewMatrix) {
  18556. this._tmpMatrix.invert();
  18557. }
  18558. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18559. }
  18560. };
  18561. /**
  18562. * @hidden
  18563. * Updates the cached values of the camera
  18564. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18565. */
  18566. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18567. var _this = this;
  18568. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18569. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18570. if (!this.updateCacheCalled) {
  18571. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18572. this.updateCacheCalled = true;
  18573. this.update();
  18574. }
  18575. // Set working vector to the device position in room space rotated by the new rotation
  18576. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18577. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18578. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18579. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18580. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18581. // Add translation from anchor position
  18582. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18583. this._workingVector.addInPlace(this.position);
  18584. this._workingVector.subtractInPlace(this._cache.position);
  18585. this._deviceToWorld.setTranslation(this._workingVector);
  18586. // Set an inverted matrix to be used when updating the camera
  18587. this._deviceToWorld.invertToRef(this._worldToDevice);
  18588. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18589. this.controllers.forEach(function (controller) {
  18590. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18591. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18592. controller.update();
  18593. });
  18594. }
  18595. if (!ignoreParentClass) {
  18596. _super.prototype._updateCache.call(this);
  18597. }
  18598. this.updateCacheCalled = false;
  18599. };
  18600. /**
  18601. * @hidden
  18602. * Get current device position in babylon world
  18603. */
  18604. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18605. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18606. };
  18607. /**
  18608. * Updates the current device position and rotation in the babylon world
  18609. */
  18610. WebVRFreeCamera.prototype.update = function () {
  18611. this._computeDevicePosition();
  18612. // Get current device rotation in babylon world
  18613. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18614. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18615. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18616. if (this._poseSet) {
  18617. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18618. }
  18619. _super.prototype.update.call(this);
  18620. };
  18621. /**
  18622. * @hidden
  18623. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18624. * @returns an identity matrix
  18625. */
  18626. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18627. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18628. };
  18629. /**
  18630. * This function is called by the two RIG cameras.
  18631. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18632. * @hidden
  18633. */
  18634. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18635. // Update the parent camera prior to using a child camera to avoid desynchronization
  18636. var parentCamera = this._cameraRigParams["parentCamera"];
  18637. parentCamera._updateCache();
  18638. //WebVR 1.1
  18639. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18640. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18641. if (!this.getScene().useRightHandedSystem) {
  18642. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18643. }
  18644. // update the camera rotation matrix
  18645. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18646. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18647. // Computing target and final matrix
  18648. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18649. // should the view matrix be updated with scale and position offset?
  18650. if (parentCamera.deviceScaleFactor !== 1) {
  18651. this._webvrViewMatrix.invert();
  18652. // scale the position, if set
  18653. if (parentCamera.deviceScaleFactor) {
  18654. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18655. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18656. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18657. }
  18658. this._webvrViewMatrix.invert();
  18659. }
  18660. // Remove translation from 6dof headset if trackposition is set to false
  18661. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18662. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18663. // Compute global position
  18664. this._workingMatrix = this._workingMatrix || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18665. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18666. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18667. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18668. this._markSyncedWithParent();
  18669. return this._webvrViewMatrix;
  18670. };
  18671. /** @hidden */
  18672. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18673. var parentCamera = this.parent;
  18674. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18675. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18676. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18677. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18678. //babylon compatible matrix
  18679. if (!this.getScene().useRightHandedSystem) {
  18680. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18681. }
  18682. return this._projectionMatrix;
  18683. };
  18684. /**
  18685. * Initializes the controllers and their meshes
  18686. */
  18687. WebVRFreeCamera.prototype.initControllers = function () {
  18688. var _this = this;
  18689. this.controllers = [];
  18690. var manager = this.getScene().gamepadManager;
  18691. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18692. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18693. var webVrController = gamepad;
  18694. if (webVrController.defaultModel) {
  18695. webVrController.defaultModel.setEnabled(false);
  18696. }
  18697. if (webVrController.hand === "right") {
  18698. _this._rightController = null;
  18699. }
  18700. if (webVrController.hand === "left") {
  18701. _this._leftController = null;
  18702. }
  18703. var controllerIndex = _this.controllers.indexOf(webVrController);
  18704. if (controllerIndex !== -1) {
  18705. _this.controllers.splice(controllerIndex, 1);
  18706. }
  18707. }
  18708. });
  18709. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18710. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18711. var webVrController_1 = gamepad;
  18712. if (!_this.webVROptions.trackPosition) {
  18713. webVrController_1._disableTrackPosition(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18714. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18715. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18716. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18717. _this._updateCache();
  18718. });
  18719. }
  18720. }
  18721. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18722. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18723. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18724. if (_this.webVROptions.controllerMeshes) {
  18725. if (webVrController_1.defaultModel) {
  18726. webVrController_1.defaultModel.setEnabled(true);
  18727. }
  18728. else {
  18729. // Load the meshes
  18730. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18731. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18732. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18733. if (_this.webVROptions.defaultLightingOnControllers) {
  18734. if (!_this._lightOnControllers) {
  18735. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18736. }
  18737. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18738. var children = mesh.getChildren();
  18739. if (children && children.length !== 0) {
  18740. children.forEach(function (mesh) {
  18741. light.includedOnlyMeshes.push(mesh);
  18742. activateLightOnSubMeshes_1(mesh, light);
  18743. });
  18744. }
  18745. };
  18746. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18747. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18748. }
  18749. });
  18750. }
  18751. }
  18752. webVrController_1.attachToPoseControlledCamera(_this);
  18753. // since this is async - sanity check. Is the controller already stored?
  18754. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18755. //add to the controllers array
  18756. _this.controllers.push(webVrController_1);
  18757. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18758. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18759. // So we're overriding setting left & right manually to be sure
  18760. var firstViveWandDetected = false;
  18761. for (var i = 0; i < _this.controllers.length; i++) {
  18762. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18763. if (!firstViveWandDetected) {
  18764. firstViveWandDetected = true;
  18765. _this.controllers[i].hand = "left";
  18766. }
  18767. else {
  18768. _this.controllers[i].hand = "right";
  18769. }
  18770. }
  18771. }
  18772. //did we find enough controllers? Great! let the developer know.
  18773. if (_this.controllers.length >= 2) {
  18774. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18775. }
  18776. }
  18777. }
  18778. });
  18779. };
  18780. return WebVRFreeCamera;
  18781. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18782. /***/ }),
  18783. /***/ "./Cameras/XR/index.ts":
  18784. /*!*****************************!*\
  18785. !*** ./Cameras/XR/index.ts ***!
  18786. \*****************************/
  18787. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRInput, WebXRControllerTeleportation, WebXRControllerPointerSelection, WebXRControllerModelLoader, WebXRController, WebXRManagedOutputCanvas, WebXRSessionManager */
  18788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18789. "use strict";
  18790. __webpack_require__.r(__webpack_exports__);
  18791. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18793. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18797. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18800. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18802. /* harmony import */ var _webXRControllerTeleportation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRControllerTeleportation */ "./Cameras/XR/webXRControllerTeleportation.ts");
  18803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerTeleportation", function() { return _webXRControllerTeleportation__WEBPACK_IMPORTED_MODULE_4__["WebXRControllerTeleportation"]; });
  18804. /* harmony import */ var _webXRControllerPointerSelection__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRControllerPointerSelection */ "./Cameras/XR/webXRControllerPointerSelection.ts");
  18805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerPointerSelection", function() { return _webXRControllerPointerSelection__WEBPACK_IMPORTED_MODULE_5__["WebXRControllerPointerSelection"]; });
  18806. /* harmony import */ var _webXRControllerModelLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webXRControllerModelLoader */ "./Cameras/XR/webXRControllerModelLoader.ts");
  18807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerModelLoader", function() { return _webXRControllerModelLoader__WEBPACK_IMPORTED_MODULE_6__["WebXRControllerModelLoader"]; });
  18808. /* harmony import */ var _webXRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webXRController */ "./Cameras/XR/webXRController.ts");
  18809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRController__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  18810. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_8__["WebXRManagedOutputCanvas"]; });
  18812. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_9__["WebXRSessionManager"]; });
  18814. /***/ }),
  18815. /***/ "./Cameras/XR/webXRCamera.ts":
  18816. /*!***********************************!*\
  18817. !*** ./Cameras/XR/webXRCamera.ts ***!
  18818. \***********************************/
  18819. /*! exports provided: WebXRCamera */
  18820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18821. "use strict";
  18822. __webpack_require__.r(__webpack_exports__);
  18823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18824. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18825. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  18826. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18827. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18828. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18829. /* harmony import */ var _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math.viewport */ "./Maths/math.viewport.ts");
  18830. /**
  18831. * WebXR Camera which holds the views for the xrSession
  18832. * @see https://doc.babylonjs.com/how_to/webxr
  18833. */
  18834. var WebXRCamera = /** @class */ (function (_super) {
  18835. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18836. /**
  18837. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18838. * @param name the name of the camera
  18839. * @param scene the scene to add the camera to
  18840. */
  18841. function WebXRCamera(name, scene) {
  18842. var _this = _super.call(this, name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18843. // Initial camera configuration
  18844. _this.minZ = 0.1;
  18845. _this.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18846. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18847. _this.updateUpVectorFromRotation = true;
  18848. _this._updateNumberOfRigCameras(1);
  18849. return _this;
  18850. }
  18851. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18852. if (viewCount === void 0) { viewCount = 1; }
  18853. while (this.rigCameras.length < viewCount) {
  18854. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18855. newCamera.minZ = 0.1;
  18856. newCamera.parent = this;
  18857. newCamera.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18858. newCamera.updateUpVectorFromRotation = true;
  18859. this.rigCameras.push(newCamera);
  18860. }
  18861. while (this.rigCameras.length > viewCount) {
  18862. var removedCamera = this.rigCameras.pop();
  18863. if (removedCamera) {
  18864. removedCamera.dispose();
  18865. }
  18866. }
  18867. };
  18868. /** @hidden */
  18869. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18870. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18871. // Create initial camera rigs
  18872. this._updateNumberOfRigCameras(2);
  18873. this.rigCameras[0].viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 0.5, 1.0);
  18874. this.rigCameras[0].position.x = -pupilDistance / 2;
  18875. this.rigCameras[0].outputRenderTarget = null;
  18876. this.rigCameras[1].viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0.5, 0, 0.5, 1.0);
  18877. this.rigCameras[1].position.x = pupilDistance / 2;
  18878. this.rigCameras[1].outputRenderTarget = null;
  18879. };
  18880. /**
  18881. * Updates the cameras position from the current pose information of the XR session
  18882. * @param xrSessionManager the session containing pose information
  18883. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18884. */
  18885. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18886. var _this = this;
  18887. // Ensure all frame data is available
  18888. if (!xrSessionManager.currentFrame || !xrSessionManager.currentFrame.getViewerPose) {
  18889. return false;
  18890. }
  18891. var pose = xrSessionManager.currentFrame.getViewerPose(xrSessionManager.referenceSpace);
  18892. if (!pose || !pose.transform || !pose.transform.matrix) {
  18893. return false;
  18894. }
  18895. // Update the parent cameras matrix
  18896. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.transform.matrix, 0, 1, WebXRCamera._TmpMatrix);
  18897. if (!this._scene.useRightHandedSystem) {
  18898. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18899. }
  18900. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18901. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18902. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18903. this.computeWorldMatrix();
  18904. // Update camera rigs
  18905. this._updateNumberOfRigCameras(pose.views.length);
  18906. pose.views.forEach(function (view, i) {
  18907. // Update view/projection matrix
  18908. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.transform.matrix, 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18909. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18910. if (!_this._scene.useRightHandedSystem) {
  18911. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18912. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18913. }
  18914. // Update viewport
  18915. if (xrSessionManager.session.renderState.baseLayer) {
  18916. var viewport = xrSessionManager.session.renderState.baseLayer.getViewport(view);
  18917. var width = xrSessionManager.session.renderState.baseLayer.framebufferWidth;
  18918. var height = xrSessionManager.session.renderState.baseLayer.framebufferHeight;
  18919. _this.rigCameras[i].viewport.width = viewport.width / width;
  18920. _this.rigCameras[i].viewport.height = viewport.height / height;
  18921. _this.rigCameras[i].viewport.x = viewport.x / width;
  18922. _this.rigCameras[i].viewport.y = viewport.y / height;
  18923. }
  18924. // Set cameras to render to the session's render target
  18925. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18926. });
  18927. return true;
  18928. };
  18929. WebXRCamera._TmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18930. return WebXRCamera;
  18931. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18932. /***/ }),
  18933. /***/ "./Cameras/XR/webXRController.ts":
  18934. /*!***************************************!*\
  18935. !*** ./Cameras/XR/webXRController.ts ***!
  18936. \***************************************/
  18937. /*! exports provided: WebXRController */
  18938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18939. "use strict";
  18940. __webpack_require__.r(__webpack_exports__);
  18941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18942. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18943. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18944. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  18945. /**
  18946. * Represents an XR input
  18947. */
  18948. var WebXRController = /** @class */ (function () {
  18949. /**
  18950. * Creates the controller
  18951. * @see https://doc.babylonjs.com/how_to/webxr
  18952. * @param scene the scene which the controller should be associated to
  18953. * @param inputSource the underlying input source for the controller
  18954. * @param parentContainer parent that the controller meshes should be children of
  18955. */
  18956. function WebXRController(scene,
  18957. /** The underlying input source for the controller */
  18958. inputSource, parentContainer) {
  18959. if (parentContainer === void 0) { parentContainer = null; }
  18960. this.scene = scene;
  18961. this.inputSource = inputSource;
  18962. this.parentContainer = parentContainer;
  18963. /**
  18964. * Event that fires when the controller is removed/disposed
  18965. */
  18966. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18967. this._tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18968. this._tmpQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  18969. this._tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  18970. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18971. if (parentContainer) {
  18972. parentContainer.addChild(this.pointer);
  18973. }
  18974. if (this.inputSource.gripSpace) {
  18975. this.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", this.scene);
  18976. if (this.parentContainer) {
  18977. this.parentContainer.addChild(this.grip);
  18978. }
  18979. }
  18980. }
  18981. /**
  18982. * Updates the controller pose based on the given XRFrame
  18983. * @param xrFrame xr frame to update the pose with
  18984. * @param referenceSpace reference space to use
  18985. */
  18986. WebXRController.prototype.updateFromXRFrame = function (xrFrame, referenceSpace) {
  18987. var pose = xrFrame.getPose(this.inputSource.targetRaySpace, referenceSpace);
  18988. // Update the pointer mesh
  18989. if (pose) {
  18990. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(pose.transform.matrix, 0, 1, this._tmpMatrix);
  18991. if (!this.pointer.getScene().useRightHandedSystem) {
  18992. this._tmpMatrix.toggleModelMatrixHandInPlace();
  18993. }
  18994. if (!this.pointer.rotationQuaternion) {
  18995. this.pointer.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  18996. }
  18997. this._tmpMatrix.decompose(this.pointer.scaling, this.pointer.rotationQuaternion, this.pointer.position);
  18998. }
  18999. // Update the grip mesh if it exists
  19000. if (this.inputSource.gripSpace && this.grip) {
  19001. var pose_1 = xrFrame.getPose(this.inputSource.gripSpace, referenceSpace);
  19002. if (pose_1) {
  19003. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(pose_1.transform.matrix, 0, 1, this._tmpMatrix);
  19004. if (!this.grip.getScene().useRightHandedSystem) {
  19005. this._tmpMatrix.toggleModelMatrixHandInPlace();
  19006. }
  19007. if (!this.grip.rotationQuaternion) {
  19008. this.grip.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  19009. }
  19010. this._tmpMatrix.decompose(this.grip.scaling, this.grip.rotationQuaternion, this.grip.position);
  19011. }
  19012. }
  19013. };
  19014. /**
  19015. * Gets a world space ray coming from the controller
  19016. * @param result the resulting ray
  19017. */
  19018. WebXRController.prototype.getWorldPointerRayToRef = function (result) {
  19019. // Force update to ensure picked point is synced with ray
  19020. var worldMatrix = this.pointer.computeWorldMatrix(true);
  19021. worldMatrix.decompose(undefined, this._tmpQuaternion, undefined);
  19022. this._tmpVector.set(0, 0, 1);
  19023. this._tmpVector.rotateByQuaternionToRef(this._tmpQuaternion, this._tmpVector);
  19024. result.origin = this.pointer.absolutePosition;
  19025. result.direction.copyFrom(this._tmpVector);
  19026. result.length = 1000;
  19027. };
  19028. /**
  19029. * Disposes of the object
  19030. */
  19031. WebXRController.prototype.dispose = function () {
  19032. if (this.grip) {
  19033. this.grip.dispose();
  19034. }
  19035. this.pointer.dispose();
  19036. this.onDisposeObservable.notifyObservers({});
  19037. };
  19038. return WebXRController;
  19039. }());
  19040. /***/ }),
  19041. /***/ "./Cameras/XR/webXRControllerModelLoader.ts":
  19042. /*!**************************************************!*\
  19043. !*** ./Cameras/XR/webXRControllerModelLoader.ts ***!
  19044. \**************************************************/
  19045. /*! exports provided: WebXRControllerModelLoader */
  19046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19047. "use strict";
  19048. __webpack_require__.r(__webpack_exports__);
  19049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerModelLoader", function() { return WebXRControllerModelLoader; });
  19050. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  19051. /* harmony import */ var _Gamepads_Controllers_windowsMotionController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Gamepads/Controllers/windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  19052. /* harmony import */ var _Gamepads_Controllers_oculusTouchController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Gamepads/Controllers/oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  19053. /* harmony import */ var _Gamepads_Controllers_viveController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/Controllers/viveController */ "./Gamepads/Controllers/viveController.ts");
  19054. /**
  19055. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  19056. */
  19057. var WebXRControllerModelLoader = /** @class */ (function () {
  19058. /**
  19059. * Creates the WebXRControllerModelLoader
  19060. * @param input xr input that creates the controllers
  19061. */
  19062. function WebXRControllerModelLoader(input) {
  19063. input.onControllerAddedObservable.add(function (c) {
  19064. if (c.inputSource.gamepad && c.inputSource.gamepad.id === "htc-vive") {
  19065. var controllerModel_1 = new _Gamepads_Controllers_viveController__WEBPACK_IMPORTED_MODULE_3__["ViveController"](c.inputSource.gamepad);
  19066. controllerModel_1.hand = c.inputSource.handedness;
  19067. controllerModel_1.isXR = true;
  19068. controllerModel_1.initControllerMesh(c.grip.getScene(), function (m) {
  19069. m.isPickable = false;
  19070. m.getChildMeshes(false).forEach(function (m) {
  19071. m.isPickable = false;
  19072. });
  19073. controllerModel_1.mesh.parent = c.grip;
  19074. controllerModel_1.mesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromEulerAngles(0, Math.PI, 0);
  19075. });
  19076. }
  19077. else if (c.inputSource.gamepad && c.inputSource.gamepad.id === "oculus-touch") {
  19078. var controllerModel_2 = new _Gamepads_Controllers_oculusTouchController__WEBPACK_IMPORTED_MODULE_2__["OculusTouchController"](c.inputSource.gamepad);
  19079. controllerModel_2.hand = c.inputSource.handedness;
  19080. controllerModel_2.isXR = true;
  19081. controllerModel_2.initControllerMesh(c.grip.getScene(), function (m) {
  19082. controllerModel_2.mesh.parent = c.grip;
  19083. controllerModel_2.mesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromEulerAngles(0, Math.PI, 0);
  19084. controllerModel_2.mesh.position.y = 0.034;
  19085. controllerModel_2.mesh.position.z = 0.052;
  19086. });
  19087. }
  19088. else if (c.inputSource.gamepad && c.inputSource.gamepad.id === "oculus-quest") {
  19089. _Gamepads_Controllers_oculusTouchController__WEBPACK_IMPORTED_MODULE_2__["OculusTouchController"]._IsQuest = true;
  19090. var controllerModel_3 = new _Gamepads_Controllers_oculusTouchController__WEBPACK_IMPORTED_MODULE_2__["OculusTouchController"](c.inputSource.gamepad);
  19091. controllerModel_3.hand = c.inputSource.handedness;
  19092. controllerModel_3.isXR = true;
  19093. controllerModel_3.initControllerMesh(c.grip.getScene(), function (m) {
  19094. controllerModel_3.mesh.parent = c.grip;
  19095. controllerModel_3.mesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromEulerAngles(Math.PI / -4, Math.PI, 0);
  19096. });
  19097. }
  19098. else {
  19099. var controllerModel_4 = new _Gamepads_Controllers_windowsMotionController__WEBPACK_IMPORTED_MODULE_1__["WindowsMotionController"](c.inputSource.gamepad);
  19100. controllerModel_4.hand = c.inputSource.handedness;
  19101. controllerModel_4.isXR = true;
  19102. controllerModel_4.initControllerMesh(c.grip.getScene(), function (m) {
  19103. controllerModel_4.mesh.parent = c.grip;
  19104. controllerModel_4.mesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromEulerAngles(0, Math.PI, 0);
  19105. });
  19106. }
  19107. });
  19108. }
  19109. return WebXRControllerModelLoader;
  19110. }());
  19111. /***/ }),
  19112. /***/ "./Cameras/XR/webXRControllerPointerSelection.ts":
  19113. /*!*******************************************************!*\
  19114. !*** ./Cameras/XR/webXRControllerPointerSelection.ts ***!
  19115. \*******************************************************/
  19116. /*! exports provided: WebXRControllerPointerSelection */
  19117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19118. "use strict";
  19119. __webpack_require__.r(__webpack_exports__);
  19120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerPointerSelection", function() { return WebXRControllerPointerSelection; });
  19121. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  19122. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  19123. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  19124. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  19125. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  19126. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math.axis */ "./Maths/math.axis.ts");
  19127. /**
  19128. * Handles pointer input automatically for the pointer of XR controllers
  19129. */
  19130. var WebXRControllerPointerSelection = /** @class */ (function () {
  19131. /**
  19132. * Creates a WebXRControllerPointerSelection
  19133. * @param input input manager to setup pointer selection
  19134. */
  19135. function WebXRControllerPointerSelection(input) {
  19136. var _this = this;
  19137. this._tmpRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]());
  19138. input.onControllerAddedObservable.add(function (controller) {
  19139. var scene = controller.pointer.getScene();
  19140. var laserPointer;
  19141. var cursorMesh;
  19142. var triggerDown = false;
  19143. var id;
  19144. id = WebXRControllerPointerSelection._idCounter++;
  19145. // Create a laser pointer for the XR controller
  19146. laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder("laserPointer", 1, 0.0002, 0.004, 20, 1, scene, false);
  19147. laserPointer.parent = controller.pointer;
  19148. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__["StandardMaterial"]("laserPointerMat", scene);
  19149. laserPointerMaterial.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.7, 0.7, 0.7);
  19150. laserPointerMaterial.alpha = 0.6;
  19151. laserPointer.material = laserPointerMaterial;
  19152. laserPointer.rotation.x = Math.PI / 2;
  19153. _this._updatePointerDistance(laserPointer, 1);
  19154. laserPointer.isPickable = false;
  19155. // Create a gaze tracker for the XR controlelr
  19156. cursorMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus("gazeTracker", 0.0035 * 3, 0.0025 * 3, 20, scene, false);
  19157. cursorMesh.bakeCurrentTransformIntoVertices();
  19158. cursorMesh.isPickable = false;
  19159. cursorMesh.isVisible = false;
  19160. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__["StandardMaterial"]("targetMat", scene);
  19161. targetMat.specularColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  19162. targetMat.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.7, 0.7, 0.7);
  19163. targetMat.backFaceCulling = false;
  19164. cursorMesh.material = targetMat;
  19165. var renderObserver = scene.onBeforeRenderObservable.add(function () {
  19166. // Every frame check collisions/input
  19167. controller.getWorldPointerRayToRef(_this._tmpRay);
  19168. var pick = scene.pickWithRay(_this._tmpRay);
  19169. if (pick) {
  19170. if (controller.inputSource.gamepad && controller.inputSource.gamepad.buttons[0] && controller.inputSource.gamepad.buttons[0].value > 0.7) {
  19171. if (!triggerDown) {
  19172. scene.simulatePointerDown(pick, { pointerId: id });
  19173. }
  19174. triggerDown = true;
  19175. }
  19176. else {
  19177. if (triggerDown) {
  19178. scene.simulatePointerUp(pick, { pointerId: id });
  19179. }
  19180. triggerDown = false;
  19181. }
  19182. scene.simulatePointerMove(pick, { pointerId: id });
  19183. }
  19184. if (pick && pick.pickedPoint && pick.hit) {
  19185. // Update laser state
  19186. _this._updatePointerDistance(laserPointer, pick.distance);
  19187. // Update cursor state
  19188. cursorMesh.position.copyFrom(pick.pickedPoint);
  19189. cursorMesh.scaling.x = Math.sqrt(pick.distance);
  19190. cursorMesh.scaling.y = Math.sqrt(pick.distance);
  19191. cursorMesh.scaling.z = Math.sqrt(pick.distance);
  19192. // To avoid z-fighting
  19193. var pickNormal = _this._convertNormalToDirectionOfRay(pick.getNormal(), _this._tmpRay);
  19194. var deltaFighting = 0.002;
  19195. cursorMesh.position.copyFrom(pick.pickedPoint);
  19196. if (pickNormal) {
  19197. var axis1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Y, pickNormal);
  19198. var axis2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(pickNormal, axis1);
  19199. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, cursorMesh.rotation);
  19200. cursorMesh.position.addInPlace(pickNormal.scale(deltaFighting));
  19201. }
  19202. cursorMesh.isVisible = true;
  19203. }
  19204. else {
  19205. cursorMesh.isVisible = false;
  19206. }
  19207. });
  19208. controller.onDisposeObservable.addOnce(function () {
  19209. laserPointer.dispose();
  19210. cursorMesh.dispose();
  19211. scene.onBeforeRenderObservable.remove(renderObserver);
  19212. });
  19213. });
  19214. }
  19215. WebXRControllerPointerSelection.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  19216. if (normal) {
  19217. var angle = Math.acos(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, ray.direction));
  19218. if (angle < Math.PI / 2) {
  19219. normal.scaleInPlace(-1);
  19220. }
  19221. }
  19222. return normal;
  19223. };
  19224. WebXRControllerPointerSelection.prototype._updatePointerDistance = function (_laserPointer, distance) {
  19225. if (distance === void 0) { distance = 100; }
  19226. _laserPointer.scaling.y = distance;
  19227. _laserPointer.position.z = distance / 2;
  19228. };
  19229. WebXRControllerPointerSelection._idCounter = 0;
  19230. return WebXRControllerPointerSelection;
  19231. }());
  19232. /***/ }),
  19233. /***/ "./Cameras/XR/webXRControllerTeleportation.ts":
  19234. /*!****************************************************!*\
  19235. !*** ./Cameras/XR/webXRControllerTeleportation.ts ***!
  19236. \****************************************************/
  19237. /*! exports provided: WebXRControllerTeleportation */
  19238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19239. "use strict";
  19240. __webpack_require__.r(__webpack_exports__);
  19241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerTeleportation", function() { return WebXRControllerTeleportation; });
  19242. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  19243. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  19244. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  19245. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  19246. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  19247. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  19248. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  19249. /**
  19250. * Enables teleportation
  19251. */
  19252. var WebXRControllerTeleportation = /** @class */ (function () {
  19253. /**
  19254. * Creates a WebXRControllerTeleportation
  19255. * @param input input manager to add teleportation to
  19256. * @param floorMeshes floormeshes which can be teleported to
  19257. */
  19258. function WebXRControllerTeleportation(input, floorMeshes) {
  19259. var _this = this;
  19260. if (floorMeshes === void 0) { floorMeshes = []; }
  19261. this._teleportationFillColor = "#444444";
  19262. this._teleportationBorderColor = "#FFFFFF";
  19263. this._tmpRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]());
  19264. this._tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  19265. input.onControllerAddedObservable.add(function (c) {
  19266. var scene = c.pointer.getScene();
  19267. var forwardReadyToTeleport = false;
  19268. var backwardReadyToTeleport = false;
  19269. var leftReadyToTeleport = false;
  19270. var rightReadyToTeleport = false;
  19271. // Teleport target abd it's animation
  19272. var teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, scene);
  19273. teleportationTarget.isPickable = false;
  19274. var length = 512;
  19275. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_4__["DynamicTexture"]("DynamicTexture", length, scene, true);
  19276. dynamicTexture.hasAlpha = true;
  19277. var context = dynamicTexture.getContext();
  19278. var centerX = length / 2;
  19279. var centerY = length / 2;
  19280. var radius = 200;
  19281. context.beginPath();
  19282. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  19283. context.fillStyle = _this._teleportationFillColor;
  19284. context.fill();
  19285. context.lineWidth = 10;
  19286. context.strokeStyle = _this._teleportationBorderColor;
  19287. context.stroke();
  19288. context.closePath();
  19289. dynamicTexture.update();
  19290. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__["StandardMaterial"]("TextPlaneMaterial", scene);
  19291. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  19292. teleportationTarget.material = teleportationCircleMaterial;
  19293. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, scene, false);
  19294. torus.isPickable = false;
  19295. torus.parent = teleportationTarget;
  19296. var animationInnerCircle = new _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"]("animationInnerCircle", "position.y", 30, _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  19297. var keys = [];
  19298. keys.push({
  19299. frame: 0,
  19300. value: 0
  19301. });
  19302. keys.push({
  19303. frame: 30,
  19304. value: 0.4
  19305. });
  19306. keys.push({
  19307. frame: 60,
  19308. value: 0
  19309. });
  19310. animationInnerCircle.setKeys(keys);
  19311. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_5__["SineEase"]();
  19312. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_5__["EasingFunction"].EASINGMODE_EASEINOUT);
  19313. animationInnerCircle.setEasingFunction(easingFunction);
  19314. torus.animations = [];
  19315. torus.animations.push(animationInnerCircle);
  19316. scene.beginAnimation(torus, 0, 60, true);
  19317. // Handle user input on every frame
  19318. var renderObserver = scene.onBeforeRenderObservable.add(function () {
  19319. // Move the teleportationTarget to where the user is targetting to teleport to
  19320. if (forwardReadyToTeleport) {
  19321. c.getWorldPointerRayToRef(_this._tmpRay);
  19322. var pick = scene.pickWithRay(_this._tmpRay, function (o) {
  19323. return floorMeshes.indexOf(o) !== -1;
  19324. });
  19325. if (pick && pick.pickedPoint) {
  19326. // To avoid z-fighting
  19327. teleportationTarget.position.copyFrom(pick.pickedPoint);
  19328. teleportationTarget.position.y += 0.002;
  19329. }
  19330. teleportationTarget.isVisible = true;
  19331. teleportationTarget.getChildren()[0].isVisible = true;
  19332. }
  19333. else {
  19334. teleportationTarget.isVisible = false;
  19335. teleportationTarget.getChildren()[0].isVisible = false;
  19336. }
  19337. if (c.inputSource.gamepad) {
  19338. if (c.inputSource.gamepad.axes[1] !== undefined) {
  19339. // Forward teleportation
  19340. if (c.inputSource.gamepad.axes[1] < -0.7) {
  19341. forwardReadyToTeleport = true;
  19342. }
  19343. else {
  19344. if (forwardReadyToTeleport) {
  19345. // Teleport the users feet to where they targetted
  19346. _this._tmpVector.copyFrom(teleportationTarget.position);
  19347. _this._tmpVector.y += input.baseExperience.camera.position.y;
  19348. input.baseExperience.setPositionOfCameraUsingContainer(_this._tmpVector);
  19349. }
  19350. forwardReadyToTeleport = false;
  19351. }
  19352. // Backward teleportation
  19353. if (c.inputSource.gamepad.axes[1] > 0.7) {
  19354. backwardReadyToTeleport = true;
  19355. }
  19356. else {
  19357. if (backwardReadyToTeleport) {
  19358. // Cast a ray down from behind the user
  19359. var camMat = input.baseExperience.camera.computeWorldMatrix();
  19360. var q = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19361. camMat.decompose(undefined, q, _this._tmpRay.origin);
  19362. _this._tmpVector.set(0, 0, -1);
  19363. _this._tmpVector.rotateByQuaternionToRef(q, _this._tmpVector);
  19364. _this._tmpVector.y = 0;
  19365. _this._tmpVector.normalize();
  19366. _this._tmpVector.y = -1.5;
  19367. _this._tmpVector.normalize();
  19368. _this._tmpRay.direction.copyFrom(_this._tmpVector);
  19369. var pick = scene.pickWithRay(_this._tmpRay, function (o) {
  19370. return floorMeshes.indexOf(o) !== -1;
  19371. });
  19372. if (pick && pick.pickedPoint) {
  19373. // Teleport the users feet to where they targetted
  19374. _this._tmpVector.copyFrom(pick.pickedPoint);
  19375. _this._tmpVector.y += input.baseExperience.camera.position.y;
  19376. input.baseExperience.setPositionOfCameraUsingContainer(_this._tmpVector);
  19377. }
  19378. }
  19379. backwardReadyToTeleport = false;
  19380. }
  19381. }
  19382. if (c.inputSource.gamepad.axes[0] !== undefined) {
  19383. if (c.inputSource.gamepad.axes[0] < -0.7) {
  19384. leftReadyToTeleport = true;
  19385. }
  19386. else {
  19387. if (leftReadyToTeleport) {
  19388. input.baseExperience.rotateCameraByQuaternionUsingContainer(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromEulerAngles(0, -Math.PI / 4, 0));
  19389. }
  19390. leftReadyToTeleport = false;
  19391. }
  19392. if (c.inputSource.gamepad.axes[0] > 0.7) {
  19393. rightReadyToTeleport = true;
  19394. }
  19395. else {
  19396. if (rightReadyToTeleport) {
  19397. input.baseExperience.rotateCameraByQuaternionUsingContainer(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromEulerAngles(0, Math.PI / 4, 0));
  19398. }
  19399. rightReadyToTeleport = false;
  19400. }
  19401. }
  19402. }
  19403. });
  19404. c.onDisposeObservable.addOnce(function () {
  19405. teleportationTarget.dispose();
  19406. dynamicTexture.dispose();
  19407. teleportationCircleMaterial.dispose();
  19408. torus.dispose();
  19409. scene.onBeforeRenderObservable.remove(renderObserver);
  19410. });
  19411. });
  19412. }
  19413. return WebXRControllerTeleportation;
  19414. }());
  19415. /***/ }),
  19416. /***/ "./Cameras/XR/webXRDefaultExperience.ts":
  19417. /*!**********************************************!*\
  19418. !*** ./Cameras/XR/webXRDefaultExperience.ts ***!
  19419. \**********************************************/
  19420. /*! exports provided: WebXRDefaultExperienceOptions, WebXRDefaultExperience */
  19421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19422. "use strict";
  19423. __webpack_require__.r(__webpack_exports__);
  19424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRDefaultExperienceOptions", function() { return WebXRDefaultExperienceOptions; });
  19425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRDefaultExperience", function() { return WebXRDefaultExperience; });
  19426. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19427. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  19428. /* harmony import */ var _webXRControllerModelLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRControllerModelLoader */ "./Cameras/XR/webXRControllerModelLoader.ts");
  19429. /* harmony import */ var _webXRControllerPointerSelection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRControllerPointerSelection */ "./Cameras/XR/webXRControllerPointerSelection.ts");
  19430. /* harmony import */ var _webXRControllerTeleportation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRControllerTeleportation */ "./Cameras/XR/webXRControllerTeleportation.ts");
  19431. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  19432. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  19433. /**
  19434. * Options for the default xr helper
  19435. */
  19436. var WebXRDefaultExperienceOptions = /** @class */ (function () {
  19437. function WebXRDefaultExperienceOptions() {
  19438. }
  19439. return WebXRDefaultExperienceOptions;
  19440. }());
  19441. /**
  19442. * Default experience which provides a similar setup to the previous webVRExperience
  19443. */
  19444. var WebXRDefaultExperience = /** @class */ (function () {
  19445. function WebXRDefaultExperience() {
  19446. }
  19447. /**
  19448. * Creates the default xr experience
  19449. * @param scene scene
  19450. * @param options options for basic configuration
  19451. * @returns resulting WebXRDefaultExperience
  19452. */
  19453. WebXRDefaultExperience.CreateAsync = function (scene, options) {
  19454. var result = new WebXRDefaultExperience();
  19455. // Create base experience
  19456. return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"].CreateAsync(scene).then(function (xrHelper) {
  19457. result.baseExperience = xrHelper;
  19458. // Add controller support
  19459. result.input = new _webXRInput__WEBPACK_IMPORTED_MODULE_1__["WebXRInput"](xrHelper);
  19460. result.controllerModelLoader = new _webXRControllerModelLoader__WEBPACK_IMPORTED_MODULE_2__["WebXRControllerModelLoader"](result.input);
  19461. result.pointerSelection = new _webXRControllerPointerSelection__WEBPACK_IMPORTED_MODULE_3__["WebXRControllerPointerSelection"](result.input);
  19462. result.teleportation = new _webXRControllerTeleportation__WEBPACK_IMPORTED_MODULE_4__["WebXRControllerTeleportation"](result.input, options.floorMeshes);
  19463. // Create output canvas manager (this controls where the xr frames will be rendered)
  19464. result.outputCanvas = new _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_5__["WebXRManagedOutputCanvas"](xrHelper, scene.getEngine().getRenderingCanvas());
  19465. // Create ui for entering/exiting xr
  19466. return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_6__["WebXREnterExitUI"].CreateAsync(scene, result.baseExperience, { webXRManagedOutputCanvas: result.outputCanvas });
  19467. }).then(function (ui) {
  19468. result.enterExitUI = ui;
  19469. return result;
  19470. });
  19471. };
  19472. /**
  19473. * DIsposes of the experience helper
  19474. */
  19475. WebXRDefaultExperience.prototype.dispose = function () {
  19476. if (this.baseExperience) {
  19477. this.baseExperience.dispose();
  19478. }
  19479. if (this.input) {
  19480. this.input.dispose();
  19481. }
  19482. if (this.enterExitUI) {
  19483. this.enterExitUI.dispose();
  19484. }
  19485. if (this.outputCanvas) {
  19486. this.outputCanvas.dispose();
  19487. }
  19488. };
  19489. return WebXRDefaultExperience;
  19490. }());
  19491. /***/ }),
  19492. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  19493. /*!****************************************!*\
  19494. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  19495. \****************************************/
  19496. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  19497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19498. "use strict";
  19499. __webpack_require__.r(__webpack_exports__);
  19500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  19501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  19502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  19503. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19504. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19505. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19506. /**
  19507. * Button which can be used to enter a different mode of XR
  19508. */
  19509. var WebXREnterExitUIButton = /** @class */ (function () {
  19510. /**
  19511. * Creates a WebXREnterExitUIButton
  19512. * @param element button element
  19513. * @param sessionMode XR initialization session mode
  19514. * @param referenceSpaceType the type of reference space to be used
  19515. */
  19516. function WebXREnterExitUIButton(
  19517. /** button element */
  19518. element,
  19519. /** XR initialization options for the button */
  19520. sessionMode,
  19521. /** Reference space type */
  19522. referenceSpaceType) {
  19523. this.element = element;
  19524. this.sessionMode = sessionMode;
  19525. this.referenceSpaceType = referenceSpaceType;
  19526. }
  19527. /**
  19528. * Overwritable function which can be used to update the button's visuals when the state changes
  19529. * @param activeButton the current active button in the UI
  19530. */
  19531. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  19532. };
  19533. return WebXREnterExitUIButton;
  19534. }());
  19535. /**
  19536. * Options to create the webXR UI
  19537. */
  19538. var WebXREnterExitUIOptions = /** @class */ (function () {
  19539. function WebXREnterExitUIOptions() {
  19540. }
  19541. return WebXREnterExitUIOptions;
  19542. }());
  19543. /**
  19544. * UI to allow the user to enter/exit XR mode
  19545. */
  19546. var WebXREnterExitUI = /** @class */ (function () {
  19547. function WebXREnterExitUI(scene, options) {
  19548. var _this = this;
  19549. this.scene = scene;
  19550. this._buttons = [];
  19551. this._activeButton = null;
  19552. /**
  19553. * Fired every time the active button is changed.
  19554. *
  19555. * When xr is entered via a button that launches xr that button will be the callback parameter
  19556. *
  19557. * When exiting xr the callback parameter will be null)
  19558. */
  19559. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19560. this._overlay = document.createElement("div");
  19561. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  19562. if (options.customButtons) {
  19563. this._buttons = options.customButtons;
  19564. }
  19565. else {
  19566. var hmdBtn = document.createElement("button");
  19567. 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;";
  19568. hmdBtn.innerText = "HMD";
  19569. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, "immersive-vr", "local-floor"));
  19570. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  19571. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  19572. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  19573. };
  19574. this._updateButtons(null);
  19575. }
  19576. var renderCanvas = scene.getEngine().getRenderingCanvas();
  19577. if (renderCanvas && renderCanvas.parentNode) {
  19578. renderCanvas.parentNode.appendChild(this._overlay);
  19579. scene.onDisposeObservable.addOnce(function () {
  19580. _this.dispose();
  19581. });
  19582. }
  19583. }
  19584. /**
  19585. * Creates UI to allow the user to enter/exit XR mode
  19586. * @param scene the scene to add the ui to
  19587. * @param helper the xr experience helper to enter/exit xr with
  19588. * @param options options to configure the UI
  19589. * @returns the created ui
  19590. */
  19591. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  19592. var _this = this;
  19593. var ui = new WebXREnterExitUI(scene, options);
  19594. var supportedPromises = ui._buttons.map(function (btn) {
  19595. return helper.sessionManager.supportsSessionAsync(btn.sessionMode);
  19596. });
  19597. helper.onStateChangedObservable.add(function (state) {
  19598. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  19599. ui._updateButtons(null);
  19600. }
  19601. });
  19602. return Promise.all(supportedPromises).then(function (results) {
  19603. results.forEach(function (supported, i) {
  19604. if (supported) {
  19605. ui._overlay.appendChild(ui._buttons[i].element);
  19606. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  19607. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  19608. switch (_a.label) {
  19609. case 0:
  19610. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  19611. ui._updateButtons(null);
  19612. return [4 /*yield*/, helper.exitXRAsync()];
  19613. case 1:
  19614. _a.sent();
  19615. return [2 /*return*/];
  19616. case 2:
  19617. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  19618. ui._updateButtons(ui._buttons[i]);
  19619. if (!options.webXRManagedOutputCanvas) return [3 /*break*/, 4];
  19620. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].sessionMode, ui._buttons[i].referenceSpaceType, options.webXRManagedOutputCanvas)];
  19621. case 3:
  19622. _a.sent();
  19623. _a.label = 4;
  19624. case 4: return [2 /*return*/];
  19625. }
  19626. });
  19627. }); };
  19628. }
  19629. });
  19630. return ui;
  19631. });
  19632. };
  19633. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  19634. var _this = this;
  19635. this._activeButton = activeButton;
  19636. this._buttons.forEach(function (b) {
  19637. b.update(_this._activeButton);
  19638. });
  19639. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  19640. };
  19641. /**
  19642. * Disposes of the object
  19643. */
  19644. WebXREnterExitUI.prototype.dispose = function () {
  19645. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  19646. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  19647. renderCanvas.parentNode.removeChild(this._overlay);
  19648. }
  19649. this.activeButtonChangedObservable.clear();
  19650. };
  19651. return WebXREnterExitUI;
  19652. }());
  19653. /***/ }),
  19654. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  19655. /*!*********************************************!*\
  19656. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  19657. \*********************************************/
  19658. /*! exports provided: WebXRState, WebXRExperienceHelper */
  19659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19660. "use strict";
  19661. __webpack_require__.r(__webpack_exports__);
  19662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  19663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  19664. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19665. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  19666. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  19667. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  19668. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  19669. /**
  19670. * States of the webXR experience
  19671. */
  19672. var WebXRState;
  19673. (function (WebXRState) {
  19674. /**
  19675. * Transitioning to being in XR mode
  19676. */
  19677. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  19678. /**
  19679. * Transitioning to non XR mode
  19680. */
  19681. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  19682. /**
  19683. * In XR mode and presenting
  19684. */
  19685. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  19686. /**
  19687. * Not entered XR mode
  19688. */
  19689. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  19690. })(WebXRState || (WebXRState = {}));
  19691. /**
  19692. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  19693. * @see https://doc.babylonjs.com/how_to/webxr
  19694. */
  19695. var WebXRExperienceHelper = /** @class */ (function () {
  19696. /**
  19697. * Creates a WebXRExperienceHelper
  19698. * @param scene The scene the helper should be created in
  19699. */
  19700. function WebXRExperienceHelper(scene) {
  19701. var _this = this;
  19702. this.scene = scene;
  19703. /**
  19704. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  19705. */
  19706. this.state = WebXRState.NOT_IN_XR;
  19707. /**
  19708. * Fires when the state of the experience helper has changed
  19709. */
  19710. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  19711. this._nonVRCamera = null;
  19712. this._originalSceneAutoClear = true;
  19713. this._supported = false;
  19714. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  19715. this.sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  19716. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("WebXR Container", scene);
  19717. this.camera.parent = this.container;
  19718. scene.onDisposeObservable.add(function () {
  19719. _this.exitXRAsync();
  19720. });
  19721. }
  19722. WebXRExperienceHelper.prototype._setState = function (val) {
  19723. this.state = val;
  19724. this.onStateChangedObservable.notifyObservers(this.state);
  19725. };
  19726. /**
  19727. * Creates the experience helper
  19728. * @param scene the scene to attach the experience helper to
  19729. * @returns a promise for the experience helper
  19730. */
  19731. WebXRExperienceHelper.CreateAsync = function (scene) {
  19732. var helper = new WebXRExperienceHelper(scene);
  19733. return helper.sessionManager.initializeAsync().then(function () {
  19734. helper._supported = true;
  19735. return helper;
  19736. }).catch(function () {
  19737. return helper;
  19738. });
  19739. };
  19740. /**
  19741. * Exits XR mode and returns the scene to its original state
  19742. * @returns promise that resolves after xr mode has exited
  19743. */
  19744. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  19745. this._setState(WebXRState.EXITING_XR);
  19746. return this.sessionManager.exitXRAsync();
  19747. };
  19748. /**
  19749. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  19750. * @param sessionCreationOptions options for the XR session
  19751. * @param referenceSpaceType frame of reference of the XR session
  19752. * @param outputCanvas the output canvas that will be used to enter XR mode
  19753. * @returns promise that resolves after xr mode has entered
  19754. */
  19755. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, referenceSpaceType, outputCanvas) {
  19756. var _this = this;
  19757. if (!this._supported) {
  19758. throw "XR session not supported by this browser";
  19759. }
  19760. this._setState(WebXRState.ENTERING_XR);
  19761. return this.sessionManager.initializeSessionAsync(sessionCreationOptions).then(function () {
  19762. return _this.sessionManager.setReferenceSpaceAsync(referenceSpaceType);
  19763. }).then(function () {
  19764. return outputCanvas.initializeXRLayerAsync(_this.sessionManager.session);
  19765. }).then(function () {
  19766. return _this.sessionManager.updateRenderStateAsync({ depthFar: _this.camera.maxZ, depthNear: _this.camera.minZ, baseLayer: outputCanvas.xrLayer });
  19767. }).then(function () {
  19768. return _this.sessionManager.startRenderingToXRAsync();
  19769. }).then(function () {
  19770. // Cache pre xr scene settings
  19771. _this._originalSceneAutoClear = _this.scene.autoClear;
  19772. _this._nonVRCamera = _this.scene.activeCamera;
  19773. // Overwrite current scene settings
  19774. _this.scene.autoClear = false;
  19775. _this.scene.activeCamera = _this.camera;
  19776. _this.sessionManager.onXRFrameObservable.add(function () {
  19777. _this.camera.updateFromXRSessionManager(_this.sessionManager);
  19778. });
  19779. _this.sessionManager.onXRSessionEnded.addOnce(function () {
  19780. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  19781. _this.camera.rigCameras.forEach(function (c) {
  19782. c.outputRenderTarget = null;
  19783. });
  19784. // Restore scene settings
  19785. _this.scene.autoClear = _this._originalSceneAutoClear;
  19786. _this.scene.activeCamera = _this._nonVRCamera;
  19787. _this._setState(WebXRState.NOT_IN_XR);
  19788. });
  19789. // Wait until the first frame arrives before setting state to in xr
  19790. _this.sessionManager.onXRFrameObservable.addOnce(function () {
  19791. _this._setState(WebXRState.IN_XR);
  19792. });
  19793. }).catch(function (e) {
  19794. console.log(e);
  19795. console.log(e.message);
  19796. });
  19797. };
  19798. /**
  19799. * Updates the global position of the camera by moving the camera's container
  19800. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  19801. * @param position The desired global position of the camera
  19802. */
  19803. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  19804. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  19805. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  19806. };
  19807. /**
  19808. * Rotates the xr camera by rotating the camera's container around the camera's position
  19809. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  19810. * @param rotation the desired quaternion rotation to apply to the camera
  19811. */
  19812. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  19813. if (!this.container.rotationQuaternion) {
  19814. this.container.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  19815. }
  19816. this.container.rotationQuaternion.multiplyInPlace(rotation);
  19817. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  19818. };
  19819. /**
  19820. * Disposes of the experience helper
  19821. */
  19822. WebXRExperienceHelper.prototype.dispose = function () {
  19823. this.camera.dispose();
  19824. this.container.dispose();
  19825. this.onStateChangedObservable.clear();
  19826. this.sessionManager.dispose();
  19827. };
  19828. WebXRExperienceHelper._TmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  19829. return WebXRExperienceHelper;
  19830. }());
  19831. /***/ }),
  19832. /***/ "./Cameras/XR/webXRInput.ts":
  19833. /*!**********************************!*\
  19834. !*** ./Cameras/XR/webXRInput.ts ***!
  19835. \**********************************/
  19836. /*! exports provided: WebXRInput */
  19837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19838. "use strict";
  19839. __webpack_require__.r(__webpack_exports__);
  19840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  19841. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19842. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19843. /* harmony import */ var _webXRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRController */ "./Cameras/XR/webXRController.ts");
  19844. /**
  19845. * XR input used to track XR inputs such as controllers/rays
  19846. */
  19847. var WebXRInput = /** @class */ (function () {
  19848. /**
  19849. * Initializes the WebXRInput
  19850. * @param baseExperience experience helper which the input should be created for
  19851. */
  19852. function WebXRInput(
  19853. /**
  19854. * Base experience the input listens to
  19855. */
  19856. baseExperience) {
  19857. var _this = this;
  19858. this.baseExperience = baseExperience;
  19859. /**
  19860. * XR controllers being tracked
  19861. */
  19862. this.controllers = [];
  19863. /**
  19864. * Event when a controller has been connected/added
  19865. */
  19866. this.onControllerAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  19867. /**
  19868. * Event when a controller has been removed/disconnected
  19869. */
  19870. this.onControllerRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  19871. this._onInputSourcesChange = function (event) {
  19872. _this._addAndRemoveControllers(event.added, event.removed);
  19873. };
  19874. // Remove controllers when exiting XR
  19875. this._stateObserver = baseExperience.onStateChangedObservable.add(function (s) {
  19876. if (s === _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_1__["WebXRState"].NOT_IN_XR) {
  19877. _this._addAndRemoveControllers([], _this.controllers.map(function (c) { return c.inputSource; }));
  19878. }
  19879. });
  19880. this._frameObserver = baseExperience.sessionManager.onXRFrameObservable.add(function () {
  19881. if (!baseExperience.sessionManager.currentFrame) {
  19882. return;
  19883. }
  19884. // Start listing to input add/remove event
  19885. if (_this.controllers.length == 0 && baseExperience.sessionManager.session.inputSources) {
  19886. _this._addAndRemoveControllers(baseExperience.sessionManager.session.inputSources, []);
  19887. baseExperience.sessionManager.session.addEventListener("inputsourceschange", _this._onInputSourcesChange);
  19888. }
  19889. // Update controller pose info
  19890. _this.controllers.forEach(function (controller) {
  19891. controller.updateFromXRFrame(baseExperience.sessionManager.currentFrame, baseExperience.sessionManager.referenceSpace);
  19892. });
  19893. });
  19894. }
  19895. WebXRInput.prototype._addAndRemoveControllers = function (addInputs, removeInputs) {
  19896. var _this = this;
  19897. // Add controllers if they don't already exist
  19898. var sources = this.controllers.map(function (c) { return c.inputSource; });
  19899. for (var _i = 0, addInputs_1 = addInputs; _i < addInputs_1.length; _i++) {
  19900. var input = addInputs_1[_i];
  19901. if (sources.indexOf(input) === -1) {
  19902. var controller = new _webXRController__WEBPACK_IMPORTED_MODULE_2__["WebXRController"](this.baseExperience.camera._scene, input, this.baseExperience.container);
  19903. this.controllers.push(controller);
  19904. this.onControllerAddedObservable.notifyObservers(controller);
  19905. }
  19906. }
  19907. // Remove and dispose of controllers to be disposed
  19908. var keepControllers = [];
  19909. var removedControllers = [];
  19910. this.controllers.forEach(function (c) {
  19911. if (removeInputs.indexOf(c.inputSource) === -1) {
  19912. keepControllers.push(c);
  19913. }
  19914. else {
  19915. removedControllers.push(c);
  19916. }
  19917. });
  19918. this.controllers = keepControllers;
  19919. removedControllers.forEach(function (c) {
  19920. _this.onControllerRemovedObservable.notifyObservers(c);
  19921. c.dispose();
  19922. });
  19923. };
  19924. /**
  19925. * Disposes of the object
  19926. */
  19927. WebXRInput.prototype.dispose = function () {
  19928. this.controllers.forEach(function (c) {
  19929. c.dispose();
  19930. });
  19931. this.baseExperience.sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19932. this.baseExperience.onStateChangedObservable.remove(this._stateObserver);
  19933. };
  19934. return WebXRInput;
  19935. }());
  19936. /***/ }),
  19937. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19938. /*!************************************************!*\
  19939. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19940. \************************************************/
  19941. /*! exports provided: WebXRManagedOutputCanvas */
  19942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19943. "use strict";
  19944. __webpack_require__.r(__webpack_exports__);
  19945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19946. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19947. /**
  19948. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19949. */
  19950. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19951. /**
  19952. * Initializes the canvas to be added/removed upon entering/exiting xr
  19953. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19954. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19955. */
  19956. function WebXRManagedOutputCanvas(helper, canvas) {
  19957. var _this = this;
  19958. this.helper = helper;
  19959. this._canvas = null;
  19960. /**
  19961. * xr layer for the canvas
  19962. */
  19963. this.xrLayer = null;
  19964. if (!canvas) {
  19965. canvas = document.createElement('canvas');
  19966. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;";
  19967. }
  19968. this._setManagedOutputCanvas(canvas);
  19969. helper.onStateChangedObservable.add(function (stateInfo) {
  19970. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19971. // 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
  19972. _this._addCanvas();
  19973. }
  19974. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19975. _this._removeCanvas();
  19976. }
  19977. });
  19978. }
  19979. /**
  19980. * Initializes the xr layer for the session
  19981. * @param xrSession xr session
  19982. * @returns a promise that will resolve once the XR Layer has been created
  19983. */
  19984. WebXRManagedOutputCanvas.prototype.initializeXRLayerAsync = function (xrSession) {
  19985. var _this = this;
  19986. return this.canvasContext.makeXRCompatible().then(function () {
  19987. _this.xrLayer = new XRWebGLLayer(xrSession, _this.canvasContext);
  19988. });
  19989. };
  19990. /**
  19991. * Disposes of the object
  19992. */
  19993. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19994. this._removeCanvas();
  19995. this._setManagedOutputCanvas(null);
  19996. };
  19997. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19998. this._removeCanvas();
  19999. if (!canvas) {
  20000. this._canvas = null;
  20001. this.canvasContext = null;
  20002. }
  20003. else {
  20004. this._canvas = canvas;
  20005. this.canvasContext = this._canvas.getContext('webgl');
  20006. if (!this.canvasContext) {
  20007. this.canvasContext = this._canvas.getContext('webgl2');
  20008. }
  20009. }
  20010. };
  20011. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  20012. if (this._canvas && this._canvas !== this.helper.container.getScene().getEngine().getRenderingCanvas()) {
  20013. document.body.appendChild(this._canvas);
  20014. }
  20015. };
  20016. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  20017. if (this._canvas && document.body.contains(this._canvas) && this._canvas !== this.helper.container.getScene().getEngine().getRenderingCanvas()) {
  20018. document.body.removeChild(this._canvas);
  20019. }
  20020. };
  20021. return WebXRManagedOutputCanvas;
  20022. }());
  20023. /***/ }),
  20024. /***/ "./Cameras/XR/webXRSessionManager.ts":
  20025. /*!*******************************************!*\
  20026. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  20027. \*******************************************/
  20028. /*! exports provided: WebXRSessionManager */
  20029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20030. "use strict";
  20031. __webpack_require__.r(__webpack_exports__);
  20032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  20033. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  20034. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  20035. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  20036. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  20037. /**
  20038. * Manages an XRSession to work with Babylon's engine
  20039. * @see https://doc.babylonjs.com/how_to/webxr
  20040. */
  20041. var WebXRSessionManager = /** @class */ (function () {
  20042. /**
  20043. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  20044. * @param scene The scene which the session should be created for
  20045. */
  20046. function WebXRSessionManager(scene) {
  20047. this.scene = scene;
  20048. /**
  20049. * Fires every time a new xrFrame arrives which can be used to update the camera
  20050. */
  20051. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  20052. /**
  20053. * Fires when the xr session is ended either by the device or manually done
  20054. */
  20055. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  20056. /** @hidden */
  20057. this._sessionRenderTargetTexture = null;
  20058. this.baseLayer = null;
  20059. }
  20060. /**
  20061. * Initializes the manager
  20062. * After initialization enterXR can be called to start an XR session
  20063. * @returns Promise which resolves after it is initialized
  20064. */
  20065. WebXRSessionManager.prototype.initializeAsync = function () {
  20066. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  20067. // Check if the browser supports webXR
  20068. this._xrNavigator = navigator;
  20069. if (!this._xrNavigator.xr) {
  20070. return Promise.reject("webXR not supported by this browser");
  20071. }
  20072. return Promise.resolve();
  20073. };
  20074. /**
  20075. * Initializes an xr session
  20076. * @param xrSessionMode mode to initialize
  20077. * @returns a promise which will resolve once the session has been initialized
  20078. */
  20079. WebXRSessionManager.prototype.initializeSessionAsync = function (xrSessionMode) {
  20080. var _this = this;
  20081. return this._xrNavigator.xr.requestSession(xrSessionMode).then(function (session) {
  20082. _this.session = session;
  20083. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  20084. _this.session.addEventListener("end", function () {
  20085. // Remove render target texture and notify frame obervers
  20086. _this._sessionRenderTargetTexture = null;
  20087. // Restore frame buffer to avoid clear on xr framebuffer after session end
  20088. _this.scene.getEngine().restoreDefaultFramebuffer();
  20089. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  20090. _this.scene.getEngine().customAnimationFrameRequester = null;
  20091. _this.onXRSessionEnded.notifyObservers(null);
  20092. _this.scene.getEngine()._renderLoop();
  20093. }, { once: true });
  20094. });
  20095. };
  20096. /**
  20097. * Sets the reference space on the xr session
  20098. * @param referenceSpace space to set
  20099. * @returns a promise that will resolve once the reference space has been set
  20100. */
  20101. WebXRSessionManager.prototype.setReferenceSpaceAsync = function (referenceSpace) {
  20102. var _this = this;
  20103. return this.session.requestReferenceSpace(referenceSpace).then(function (referenceSpace) {
  20104. _this.referenceSpace = referenceSpace;
  20105. });
  20106. };
  20107. /**
  20108. * Updates the render state of the session
  20109. * @param state state to set
  20110. * @returns a promise that resolves once the render state has been updated
  20111. */
  20112. WebXRSessionManager.prototype.updateRenderStateAsync = function (state) {
  20113. if (state.baseLayer) {
  20114. this.baseLayer = state.baseLayer;
  20115. }
  20116. return this.session.updateRenderState(state);
  20117. };
  20118. /**
  20119. * Starts rendering to the xr layer
  20120. * @returns a promise that will resolve once rendering has started
  20121. */
  20122. WebXRSessionManager.prototype.startRenderingToXRAsync = function () {
  20123. var _this = this;
  20124. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  20125. this.scene.getEngine().customAnimationFrameRequester = {
  20126. requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),
  20127. renderFunction: function (timestamp, xrFrame) {
  20128. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  20129. _this.currentFrame = xrFrame;
  20130. _this.onXRFrameObservable.notifyObservers(null);
  20131. _this.scene.getEngine()._renderLoop();
  20132. }
  20133. };
  20134. // Create render target texture from xr's webgl render target
  20135. this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(this.session, this.scene, this.baseLayer);
  20136. // Stop window's animation frame and trigger sessions animation frame
  20137. window.cancelAnimationFrame(this.scene.getEngine()._frameHandler);
  20138. this.scene.getEngine()._renderLoop();
  20139. return Promise.resolve();
  20140. };
  20141. /**
  20142. * Stops the xrSession and restores the renderloop
  20143. * @returns Promise which resolves after it exits XR
  20144. */
  20145. WebXRSessionManager.prototype.exitXRAsync = function () {
  20146. if (this.session) {
  20147. this.session.end();
  20148. }
  20149. return new Promise(function () { });
  20150. };
  20151. /**
  20152. * Checks if a session would be supported for the creation options specified
  20153. * @param sessionMode session mode to check if supported eg. immersive-vr
  20154. * @returns true if supported
  20155. */
  20156. WebXRSessionManager.prototype.supportsSessionAsync = function (sessionMode) {
  20157. if (!navigator.xr || !navigator.xr.supportsSession) {
  20158. return Promise.resolve(false);
  20159. }
  20160. else {
  20161. return navigator.xr.supportsSession(sessionMode).then(function () {
  20162. return Promise.resolve(true);
  20163. }).catch(function (e) {
  20164. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn(e);
  20165. return Promise.resolve(false);
  20166. });
  20167. }
  20168. };
  20169. /**
  20170. * @hidden
  20171. * Converts the render layer of xrSession to a render target
  20172. * @param session session to create render target for
  20173. * @param scene scene the new render target should be created for
  20174. */
  20175. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene, baseLayer) {
  20176. if (!baseLayer) {
  20177. throw "no layer";
  20178. }
  20179. // Create internal texture
  20180. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  20181. internalTexture.width = baseLayer.framebufferWidth;
  20182. internalTexture.height = baseLayer.framebufferHeight;
  20183. internalTexture._framebuffer = baseLayer.framebuffer;
  20184. // Create render target texture from the internal texture
  20185. var renderTargetTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("XR renderTargetTexture", { width: internalTexture.width, height: internalTexture.height }, scene, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);
  20186. renderTargetTexture._texture = internalTexture;
  20187. return renderTargetTexture;
  20188. };
  20189. /**
  20190. * Disposes of the session manager
  20191. */
  20192. WebXRSessionManager.prototype.dispose = function () {
  20193. this.onXRFrameObservable.clear();
  20194. this.onXRSessionEnded.clear();
  20195. };
  20196. return WebXRSessionManager;
  20197. }());
  20198. /***/ }),
  20199. /***/ "./Cameras/arcRotateCamera.ts":
  20200. /*!************************************!*\
  20201. !*** ./Cameras/arcRotateCamera.ts ***!
  20202. \************************************/
  20203. /*! exports provided: ArcRotateCamera */
  20204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20205. "use strict";
  20206. __webpack_require__.r(__webpack_exports__);
  20207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  20208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20209. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20210. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20211. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  20212. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  20213. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  20214. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  20215. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  20216. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  20217. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  20218. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  20219. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  20220. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  20221. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  20222. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  20223. });
  20224. /**
  20225. * This represents an orbital type of camera.
  20226. *
  20227. * 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.
  20228. * 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.
  20229. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  20230. */
  20231. var ArcRotateCamera = /** @class */ (function (_super) {
  20232. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  20233. /**
  20234. * Instantiates a new ArcRotateCamera in a given scene
  20235. * @param name Defines the name of the camera
  20236. * @param alpha Defines the camera rotation along the logitudinal axis
  20237. * @param beta Defines the camera rotation along the latitudinal axis
  20238. * @param radius Defines the camera distance from its target
  20239. * @param target Defines the camera target
  20240. * @param scene Defines the scene the camera belongs to
  20241. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  20242. */
  20243. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  20244. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20245. var _this = _super.call(this, name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  20246. _this._upVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  20247. /**
  20248. * Current inertia value on the longitudinal axis.
  20249. * The bigger this number the longer it will take for the camera to stop.
  20250. */
  20251. _this.inertialAlphaOffset = 0;
  20252. /**
  20253. * Current inertia value on the latitudinal axis.
  20254. * The bigger this number the longer it will take for the camera to stop.
  20255. */
  20256. _this.inertialBetaOffset = 0;
  20257. /**
  20258. * Current inertia value on the radius axis.
  20259. * The bigger this number the longer it will take for the camera to stop.
  20260. */
  20261. _this.inertialRadiusOffset = 0;
  20262. /**
  20263. * Minimum allowed angle on the longitudinal axis.
  20264. * This can help limiting how the Camera is able to move in the scene.
  20265. */
  20266. _this.lowerAlphaLimit = null;
  20267. /**
  20268. * Maximum allowed angle on the longitudinal axis.
  20269. * This can help limiting how the Camera is able to move in the scene.
  20270. */
  20271. _this.upperAlphaLimit = null;
  20272. /**
  20273. * Minimum allowed angle on the latitudinal axis.
  20274. * This can help limiting how the Camera is able to move in the scene.
  20275. */
  20276. _this.lowerBetaLimit = 0.01;
  20277. /**
  20278. * Maximum allowed angle on the latitudinal axis.
  20279. * This can help limiting how the Camera is able to move in the scene.
  20280. */
  20281. _this.upperBetaLimit = Math.PI - 0.01;
  20282. /**
  20283. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  20284. * This can help limiting how the Camera is able to move in the scene.
  20285. */
  20286. _this.lowerRadiusLimit = null;
  20287. /**
  20288. * Maximum allowed distance of the camera to the target (The camera can not get further).
  20289. * This can help limiting how the Camera is able to move in the scene.
  20290. */
  20291. _this.upperRadiusLimit = null;
  20292. /**
  20293. * Defines the current inertia value used during panning of the camera along the X axis.
  20294. */
  20295. _this.inertialPanningX = 0;
  20296. /**
  20297. * Defines the current inertia value used during panning of the camera along the Y axis.
  20298. */
  20299. _this.inertialPanningY = 0;
  20300. /**
  20301. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  20302. * Basically if your fingers moves away from more than this distance you will be considered
  20303. * in pinch mode.
  20304. */
  20305. _this.pinchToPanMaxDistance = 20;
  20306. /**
  20307. * Defines the maximum distance the camera can pan.
  20308. * This could help keeping the cammera always in your scene.
  20309. */
  20310. _this.panningDistanceLimit = null;
  20311. /**
  20312. * Defines the target of the camera before paning.
  20313. */
  20314. _this.panningOriginTarget = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20315. /**
  20316. * Defines the value of the inertia used during panning.
  20317. * 0 would mean stop inertia and one would mean no decelleration at all.
  20318. */
  20319. _this.panningInertia = 0.9;
  20320. //-- end properties for backward compatibility for inputs
  20321. /**
  20322. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  20323. */
  20324. _this.zoomOnFactor = 1;
  20325. /**
  20326. * Defines a screen offset for the camera position.
  20327. */
  20328. _this.targetScreenOffset = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  20329. /**
  20330. * Allows the camera to be completely reversed.
  20331. * If false the camera can not arrive upside down.
  20332. */
  20333. _this.allowUpsideDown = true;
  20334. /**
  20335. * Define if double tap/click is used to restore the previously saved state of the camera.
  20336. */
  20337. _this.useInputToRestoreState = true;
  20338. /** @hidden */
  20339. _this._viewMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20340. /**
  20341. * Defines the allowed panning axis.
  20342. */
  20343. _this.panningAxis = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  20344. /**
  20345. * Observable triggered when the mesh target has been changed on the camera.
  20346. */
  20347. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  20348. /**
  20349. * Defines whether the camera should check collision with the objects oh the scene.
  20350. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  20351. */
  20352. _this.checkCollisions = false;
  20353. /**
  20354. * Defines the collision radius of the camera.
  20355. * This simulates a sphere around the camera.
  20356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  20357. */
  20358. _this.collisionRadius = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  20359. _this._previousPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20360. _this._collisionVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20361. _this._newPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20362. _this._computationVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20363. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  20364. if (collidedMesh === void 0) { collidedMesh = null; }
  20365. if (!collidedMesh) {
  20366. _this._previousPosition.copyFrom(_this._position);
  20367. }
  20368. else {
  20369. _this.setPosition(newPosition);
  20370. if (_this.onCollide) {
  20371. _this.onCollide(collidedMesh);
  20372. }
  20373. }
  20374. // Recompute because of constraints
  20375. var cosa = Math.cos(_this.alpha);
  20376. var sina = Math.sin(_this.alpha);
  20377. var cosb = Math.cos(_this.beta);
  20378. var sinb = Math.sin(_this.beta);
  20379. if (sinb === 0) {
  20380. sinb = 0.0001;
  20381. }
  20382. var target = _this._getTargetPosition();
  20383. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  20384. target.addToRef(_this._computationVector, _this._newPosition);
  20385. _this._position.copyFrom(_this._newPosition);
  20386. var up = _this.upVector;
  20387. if (_this.allowUpsideDown && _this.beta < 0) {
  20388. up = up.clone();
  20389. up = up.negate();
  20390. }
  20391. _this._computeViewMatrix(_this._position, target, up);
  20392. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  20393. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  20394. _this._collisionTriggered = false;
  20395. };
  20396. _this._target = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20397. if (target) {
  20398. _this.setTarget(target);
  20399. }
  20400. _this.alpha = alpha;
  20401. _this.beta = beta;
  20402. _this.radius = radius;
  20403. _this.getViewMatrix();
  20404. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  20405. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  20406. return _this;
  20407. }
  20408. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  20409. /**
  20410. * Defines the target point of the camera.
  20411. * The camera looks towards it form the radius distance.
  20412. */
  20413. get: function () {
  20414. return this._target;
  20415. },
  20416. set: function (value) {
  20417. this.setTarget(value);
  20418. },
  20419. enumerable: true,
  20420. configurable: true
  20421. });
  20422. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  20423. /**
  20424. * Define the current local position of the camera in the scene
  20425. */
  20426. get: function () {
  20427. return this._position;
  20428. },
  20429. set: function (newPosition) {
  20430. this.setPosition(newPosition);
  20431. },
  20432. enumerable: true,
  20433. configurable: true
  20434. });
  20435. Object.defineProperty(ArcRotateCamera.prototype, "upVector", {
  20436. get: function () {
  20437. return this._upVector;
  20438. },
  20439. /**
  20440. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  20441. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  20442. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  20443. */
  20444. set: function (vec) {
  20445. if (!this._upToYMatrix) {
  20446. this._YToUpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20447. this._upToYMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20448. this._upVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20449. }
  20450. vec.normalize();
  20451. this._upVector.copyFrom(vec);
  20452. this.setMatUp();
  20453. },
  20454. enumerable: true,
  20455. configurable: true
  20456. });
  20457. /**
  20458. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  20459. */
  20460. ArcRotateCamera.prototype.setMatUp = function () {
  20461. // from y-up to custom-up (used in _getViewMatrix)
  20462. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upVector, this._YToUpMatrix);
  20463. // from custom-up to y-up (used in rebuildAnglesAndRadius)
  20464. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(this._upVector, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upToYMatrix);
  20465. };
  20466. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  20467. //-- begin properties for backward compatibility for inputs
  20468. /**
  20469. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  20470. */
  20471. get: function () {
  20472. var pointers = this.inputs.attached["pointers"];
  20473. if (pointers) {
  20474. return pointers.angularSensibilityX;
  20475. }
  20476. return 0;
  20477. },
  20478. set: function (value) {
  20479. var pointers = this.inputs.attached["pointers"];
  20480. if (pointers) {
  20481. pointers.angularSensibilityX = value;
  20482. }
  20483. },
  20484. enumerable: true,
  20485. configurable: true
  20486. });
  20487. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  20488. /**
  20489. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  20490. */
  20491. get: function () {
  20492. var pointers = this.inputs.attached["pointers"];
  20493. if (pointers) {
  20494. return pointers.angularSensibilityY;
  20495. }
  20496. return 0;
  20497. },
  20498. set: function (value) {
  20499. var pointers = this.inputs.attached["pointers"];
  20500. if (pointers) {
  20501. pointers.angularSensibilityY = value;
  20502. }
  20503. },
  20504. enumerable: true,
  20505. configurable: true
  20506. });
  20507. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  20508. /**
  20509. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  20510. */
  20511. get: function () {
  20512. var pointers = this.inputs.attached["pointers"];
  20513. if (pointers) {
  20514. return pointers.pinchPrecision;
  20515. }
  20516. return 0;
  20517. },
  20518. set: function (value) {
  20519. var pointers = this.inputs.attached["pointers"];
  20520. if (pointers) {
  20521. pointers.pinchPrecision = value;
  20522. }
  20523. },
  20524. enumerable: true,
  20525. configurable: true
  20526. });
  20527. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  20528. /**
  20529. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  20530. * It will be used instead of pinchDeltaPrecision if different from 0.
  20531. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  20532. */
  20533. get: function () {
  20534. var pointers = this.inputs.attached["pointers"];
  20535. if (pointers) {
  20536. return pointers.pinchDeltaPercentage;
  20537. }
  20538. return 0;
  20539. },
  20540. set: function (value) {
  20541. var pointers = this.inputs.attached["pointers"];
  20542. if (pointers) {
  20543. pointers.pinchDeltaPercentage = value;
  20544. }
  20545. },
  20546. enumerable: true,
  20547. configurable: true
  20548. });
  20549. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  20550. /**
  20551. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  20552. */
  20553. get: function () {
  20554. var pointers = this.inputs.attached["pointers"];
  20555. if (pointers) {
  20556. return pointers.panningSensibility;
  20557. }
  20558. return 0;
  20559. },
  20560. set: function (value) {
  20561. var pointers = this.inputs.attached["pointers"];
  20562. if (pointers) {
  20563. pointers.panningSensibility = value;
  20564. }
  20565. },
  20566. enumerable: true,
  20567. configurable: true
  20568. });
  20569. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  20570. /**
  20571. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  20572. */
  20573. get: function () {
  20574. var keyboard = this.inputs.attached["keyboard"];
  20575. if (keyboard) {
  20576. return keyboard.keysUp;
  20577. }
  20578. return [];
  20579. },
  20580. set: function (value) {
  20581. var keyboard = this.inputs.attached["keyboard"];
  20582. if (keyboard) {
  20583. keyboard.keysUp = value;
  20584. }
  20585. },
  20586. enumerable: true,
  20587. configurable: true
  20588. });
  20589. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  20590. /**
  20591. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  20592. */
  20593. get: function () {
  20594. var keyboard = this.inputs.attached["keyboard"];
  20595. if (keyboard) {
  20596. return keyboard.keysDown;
  20597. }
  20598. return [];
  20599. },
  20600. set: function (value) {
  20601. var keyboard = this.inputs.attached["keyboard"];
  20602. if (keyboard) {
  20603. keyboard.keysDown = value;
  20604. }
  20605. },
  20606. enumerable: true,
  20607. configurable: true
  20608. });
  20609. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  20610. /**
  20611. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  20612. */
  20613. get: function () {
  20614. var keyboard = this.inputs.attached["keyboard"];
  20615. if (keyboard) {
  20616. return keyboard.keysLeft;
  20617. }
  20618. return [];
  20619. },
  20620. set: function (value) {
  20621. var keyboard = this.inputs.attached["keyboard"];
  20622. if (keyboard) {
  20623. keyboard.keysLeft = value;
  20624. }
  20625. },
  20626. enumerable: true,
  20627. configurable: true
  20628. });
  20629. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  20630. /**
  20631. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  20632. */
  20633. get: function () {
  20634. var keyboard = this.inputs.attached["keyboard"];
  20635. if (keyboard) {
  20636. return keyboard.keysRight;
  20637. }
  20638. return [];
  20639. },
  20640. set: function (value) {
  20641. var keyboard = this.inputs.attached["keyboard"];
  20642. if (keyboard) {
  20643. keyboard.keysRight = value;
  20644. }
  20645. },
  20646. enumerable: true,
  20647. configurable: true
  20648. });
  20649. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  20650. /**
  20651. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  20652. */
  20653. get: function () {
  20654. var mousewheel = this.inputs.attached["mousewheel"];
  20655. if (mousewheel) {
  20656. return mousewheel.wheelPrecision;
  20657. }
  20658. return 0;
  20659. },
  20660. set: function (value) {
  20661. var mousewheel = this.inputs.attached["mousewheel"];
  20662. if (mousewheel) {
  20663. mousewheel.wheelPrecision = value;
  20664. }
  20665. },
  20666. enumerable: true,
  20667. configurable: true
  20668. });
  20669. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  20670. /**
  20671. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  20672. * It will be used instead of pinchDeltaPrecision if different from 0.
  20673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  20674. */
  20675. get: function () {
  20676. var mousewheel = this.inputs.attached["mousewheel"];
  20677. if (mousewheel) {
  20678. return mousewheel.wheelDeltaPercentage;
  20679. }
  20680. return 0;
  20681. },
  20682. set: function (value) {
  20683. var mousewheel = this.inputs.attached["mousewheel"];
  20684. if (mousewheel) {
  20685. mousewheel.wheelDeltaPercentage = value;
  20686. }
  20687. },
  20688. enumerable: true,
  20689. configurable: true
  20690. });
  20691. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  20692. /**
  20693. * Gets the bouncing behavior of the camera if it has been enabled.
  20694. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  20695. */
  20696. get: function () {
  20697. return this._bouncingBehavior;
  20698. },
  20699. enumerable: true,
  20700. configurable: true
  20701. });
  20702. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  20703. /**
  20704. * Defines if the bouncing behavior of the camera is enabled on the camera.
  20705. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  20706. */
  20707. get: function () {
  20708. return this._bouncingBehavior != null;
  20709. },
  20710. set: function (value) {
  20711. if (value === this.useBouncingBehavior) {
  20712. return;
  20713. }
  20714. if (value) {
  20715. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  20716. this.addBehavior(this._bouncingBehavior);
  20717. }
  20718. else if (this._bouncingBehavior) {
  20719. this.removeBehavior(this._bouncingBehavior);
  20720. this._bouncingBehavior = null;
  20721. }
  20722. },
  20723. enumerable: true,
  20724. configurable: true
  20725. });
  20726. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  20727. /**
  20728. * Gets the framing behavior of the camera if it has been enabled.
  20729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  20730. */
  20731. get: function () {
  20732. return this._framingBehavior;
  20733. },
  20734. enumerable: true,
  20735. configurable: true
  20736. });
  20737. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  20738. /**
  20739. * Defines if the framing behavior of the camera is enabled on the camera.
  20740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  20741. */
  20742. get: function () {
  20743. return this._framingBehavior != null;
  20744. },
  20745. set: function (value) {
  20746. if (value === this.useFramingBehavior) {
  20747. return;
  20748. }
  20749. if (value) {
  20750. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  20751. this.addBehavior(this._framingBehavior);
  20752. }
  20753. else if (this._framingBehavior) {
  20754. this.removeBehavior(this._framingBehavior);
  20755. this._framingBehavior = null;
  20756. }
  20757. },
  20758. enumerable: true,
  20759. configurable: true
  20760. });
  20761. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  20762. /**
  20763. * Gets the auto rotation behavior of the camera if it has been enabled.
  20764. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  20765. */
  20766. get: function () {
  20767. return this._autoRotationBehavior;
  20768. },
  20769. enumerable: true,
  20770. configurable: true
  20771. });
  20772. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  20773. /**
  20774. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  20775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  20776. */
  20777. get: function () {
  20778. return this._autoRotationBehavior != null;
  20779. },
  20780. set: function (value) {
  20781. if (value === this.useAutoRotationBehavior) {
  20782. return;
  20783. }
  20784. if (value) {
  20785. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  20786. this.addBehavior(this._autoRotationBehavior);
  20787. }
  20788. else if (this._autoRotationBehavior) {
  20789. this.removeBehavior(this._autoRotationBehavior);
  20790. this._autoRotationBehavior = null;
  20791. }
  20792. },
  20793. enumerable: true,
  20794. configurable: true
  20795. });
  20796. // Cache
  20797. /** @hidden */
  20798. ArcRotateCamera.prototype._initCache = function () {
  20799. _super.prototype._initCache.call(this);
  20800. this._cache._target = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20801. this._cache.alpha = undefined;
  20802. this._cache.beta = undefined;
  20803. this._cache.radius = undefined;
  20804. this._cache.targetScreenOffset = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  20805. };
  20806. /** @hidden */
  20807. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  20808. if (!ignoreParentClass) {
  20809. _super.prototype._updateCache.call(this);
  20810. }
  20811. this._cache._target.copyFrom(this._getTargetPosition());
  20812. this._cache.alpha = this.alpha;
  20813. this._cache.beta = this.beta;
  20814. this._cache.radius = this.radius;
  20815. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  20816. };
  20817. ArcRotateCamera.prototype._getTargetPosition = function () {
  20818. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  20819. var pos = this._targetHost.absolutePosition;
  20820. if (this._targetBoundingCenter) {
  20821. pos.addToRef(this._targetBoundingCenter, this._target);
  20822. }
  20823. else {
  20824. this._target.copyFrom(pos);
  20825. }
  20826. }
  20827. var lockedTargetPosition = this._getLockedTargetPosition();
  20828. if (lockedTargetPosition) {
  20829. return lockedTargetPosition;
  20830. }
  20831. return this._target;
  20832. };
  20833. /**
  20834. * Stores the current state of the camera (alpha, beta, radius and target)
  20835. * @returns the camera itself
  20836. */
  20837. ArcRotateCamera.prototype.storeState = function () {
  20838. this._storedAlpha = this.alpha;
  20839. this._storedBeta = this.beta;
  20840. this._storedRadius = this.radius;
  20841. this._storedTarget = this._getTargetPosition().clone();
  20842. return _super.prototype.storeState.call(this);
  20843. };
  20844. /**
  20845. * @hidden
  20846. * Restored camera state. You must call storeState() first
  20847. */
  20848. ArcRotateCamera.prototype._restoreStateValues = function () {
  20849. if (!_super.prototype._restoreStateValues.call(this)) {
  20850. return false;
  20851. }
  20852. this.alpha = this._storedAlpha;
  20853. this.beta = this._storedBeta;
  20854. this.radius = this._storedRadius;
  20855. this.setTarget(this._storedTarget.clone());
  20856. this.inertialAlphaOffset = 0;
  20857. this.inertialBetaOffset = 0;
  20858. this.inertialRadiusOffset = 0;
  20859. this.inertialPanningX = 0;
  20860. this.inertialPanningY = 0;
  20861. return true;
  20862. };
  20863. // Synchronized
  20864. /** @hidden */
  20865. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  20866. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  20867. return false;
  20868. }
  20869. return this._cache._target.equals(this._getTargetPosition())
  20870. && this._cache.alpha === this.alpha
  20871. && this._cache.beta === this.beta
  20872. && this._cache.radius === this.radius
  20873. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  20874. };
  20875. /**
  20876. * Attached controls to the current camera.
  20877. * @param element Defines the element the controls should be listened from
  20878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20879. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  20880. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  20881. */
  20882. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  20883. var _this = this;
  20884. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  20885. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  20886. this._useCtrlForPanning = useCtrlForPanning;
  20887. this._panningMouseButton = panningMouseButton;
  20888. this.inputs.attachElement(element, noPreventDefault);
  20889. this._reset = function () {
  20890. _this.inertialAlphaOffset = 0;
  20891. _this.inertialBetaOffset = 0;
  20892. _this.inertialRadiusOffset = 0;
  20893. _this.inertialPanningX = 0;
  20894. _this.inertialPanningY = 0;
  20895. };
  20896. };
  20897. /**
  20898. * Detach the current controls from the camera.
  20899. * The camera will stop reacting to inputs.
  20900. * @param element Defines the element to stop listening the inputs from
  20901. */
  20902. ArcRotateCamera.prototype.detachControl = function (element) {
  20903. this.inputs.detachElement(element);
  20904. if (this._reset) {
  20905. this._reset();
  20906. }
  20907. };
  20908. /** @hidden */
  20909. ArcRotateCamera.prototype._checkInputs = function () {
  20910. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  20911. if (this._collisionTriggered) {
  20912. return;
  20913. }
  20914. this.inputs.checkInputs();
  20915. // Inertia
  20916. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  20917. var inertialAlphaOffset = this.inertialAlphaOffset;
  20918. if (this.beta <= 0) {
  20919. inertialAlphaOffset *= -1;
  20920. }
  20921. if (this.getScene().useRightHandedSystem) {
  20922. inertialAlphaOffset *= -1;
  20923. }
  20924. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  20925. inertialAlphaOffset *= -1;
  20926. }
  20927. this.alpha += inertialAlphaOffset;
  20928. this.beta += this.inertialBetaOffset;
  20929. this.radius -= this.inertialRadiusOffset;
  20930. this.inertialAlphaOffset *= this.inertia;
  20931. this.inertialBetaOffset *= this.inertia;
  20932. this.inertialRadiusOffset *= this.inertia;
  20933. if (Math.abs(this.inertialAlphaOffset) < _Maths_math_constants__WEBPACK_IMPORTED_MODULE_12__["Epsilon"]) {
  20934. this.inertialAlphaOffset = 0;
  20935. }
  20936. if (Math.abs(this.inertialBetaOffset) < _Maths_math_constants__WEBPACK_IMPORTED_MODULE_12__["Epsilon"]) {
  20937. this.inertialBetaOffset = 0;
  20938. }
  20939. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_12__["Epsilon"]) {
  20940. this.inertialRadiusOffset = 0;
  20941. }
  20942. }
  20943. // Panning inertia
  20944. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20945. if (!this._localDirection) {
  20946. this._localDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20947. this._transformedDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20948. }
  20949. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20950. this._localDirection.multiplyInPlace(this.panningAxis);
  20951. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20952. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20953. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20954. if (!this.panningAxis.y) {
  20955. this._transformedDirection.y = 0;
  20956. }
  20957. if (!this._targetHost) {
  20958. if (this.panningDistanceLimit) {
  20959. this._transformedDirection.addInPlace(this._target);
  20960. var distanceSquared = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20961. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20962. this._target.copyFrom(this._transformedDirection);
  20963. }
  20964. }
  20965. else {
  20966. this._target.addInPlace(this._transformedDirection);
  20967. }
  20968. }
  20969. this.inertialPanningX *= this.panningInertia;
  20970. this.inertialPanningY *= this.panningInertia;
  20971. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_12__["Epsilon"]) {
  20972. this.inertialPanningX = 0;
  20973. }
  20974. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_12__["Epsilon"]) {
  20975. this.inertialPanningY = 0;
  20976. }
  20977. }
  20978. // Limits
  20979. this._checkLimits();
  20980. _super.prototype._checkInputs.call(this);
  20981. };
  20982. ArcRotateCamera.prototype._checkLimits = function () {
  20983. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20984. if (this.allowUpsideDown && this.beta > Math.PI) {
  20985. this.beta = this.beta - (2 * Math.PI);
  20986. }
  20987. }
  20988. else {
  20989. if (this.beta < this.lowerBetaLimit) {
  20990. this.beta = this.lowerBetaLimit;
  20991. }
  20992. }
  20993. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20994. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20995. this.beta = this.beta + (2 * Math.PI);
  20996. }
  20997. }
  20998. else {
  20999. if (this.beta > this.upperBetaLimit) {
  21000. this.beta = this.upperBetaLimit;
  21001. }
  21002. }
  21003. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  21004. this.alpha = this.lowerAlphaLimit;
  21005. }
  21006. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  21007. this.alpha = this.upperAlphaLimit;
  21008. }
  21009. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21010. this.radius = this.lowerRadiusLimit;
  21011. this.inertialRadiusOffset = 0;
  21012. }
  21013. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21014. this.radius = this.upperRadiusLimit;
  21015. this.inertialRadiusOffset = 0;
  21016. }
  21017. };
  21018. /**
  21019. * Rebuilds angles (alpha, beta) and radius from the give position and target
  21020. */
  21021. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  21022. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  21023. // need to rotate to Y up equivalent if up vector not Axis.Y
  21024. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  21025. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector);
  21026. }
  21027. this.radius = this._computationVector.length();
  21028. if (this.radius === 0) {
  21029. this.radius = 0.0001; // Just to avoid division by zero
  21030. }
  21031. // Alpha
  21032. if (this._computationVector.x === 0 && this._computationVector.z === 0) {
  21033. this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
  21034. }
  21035. else {
  21036. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  21037. }
  21038. if (this._computationVector.z < 0) {
  21039. this.alpha = 2 * Math.PI - this.alpha;
  21040. }
  21041. // Beta
  21042. this.beta = Math.acos(this._computationVector.y / this.radius);
  21043. this._checkLimits();
  21044. };
  21045. /**
  21046. * Use a position to define the current camera related information like aplha, beta and radius
  21047. * @param position Defines the position to set the camera at
  21048. */
  21049. ArcRotateCamera.prototype.setPosition = function (position) {
  21050. if (this._position.equals(position)) {
  21051. return;
  21052. }
  21053. this._position.copyFrom(position);
  21054. this.rebuildAnglesAndRadius();
  21055. };
  21056. /**
  21057. * Defines the target the camera should look at.
  21058. * This will automatically adapt alpha beta and radius to fit within the new target.
  21059. * @param target Defines the new target as a Vector or a mesh
  21060. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  21061. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  21062. */
  21063. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  21064. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  21065. if (allowSamePosition === void 0) { allowSamePosition = false; }
  21066. if (target.getBoundingInfo) {
  21067. if (toBoundingCenter) {
  21068. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  21069. }
  21070. else {
  21071. this._targetBoundingCenter = null;
  21072. }
  21073. target.computeWorldMatrix();
  21074. this._targetHost = target;
  21075. this._target = this._getTargetPosition();
  21076. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  21077. }
  21078. else {
  21079. var newTarget = target;
  21080. var currentTarget = this._getTargetPosition();
  21081. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  21082. return;
  21083. }
  21084. this._targetHost = null;
  21085. this._target = newTarget;
  21086. this._targetBoundingCenter = null;
  21087. this.onMeshTargetChangedObservable.notifyObservers(null);
  21088. }
  21089. this.rebuildAnglesAndRadius();
  21090. };
  21091. /** @hidden */
  21092. ArcRotateCamera.prototype._getViewMatrix = function () {
  21093. // Compute
  21094. var cosa = Math.cos(this.alpha);
  21095. var sina = Math.sin(this.alpha);
  21096. var cosb = Math.cos(this.beta);
  21097. var sinb = Math.sin(this.beta);
  21098. if (sinb === 0) {
  21099. sinb = 0.0001;
  21100. }
  21101. var target = this._getTargetPosition();
  21102. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  21103. // Rotate according to up vector
  21104. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  21105. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector);
  21106. }
  21107. target.addToRef(this._computationVector, this._newPosition);
  21108. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  21109. var coordinator = this.getScene().collisionCoordinator;
  21110. if (!this._collider) {
  21111. this._collider = coordinator.createCollider();
  21112. }
  21113. this._collider._radius = this.collisionRadius;
  21114. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  21115. this._collisionTriggered = true;
  21116. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21117. }
  21118. else {
  21119. this._position.copyFrom(this._newPosition);
  21120. var up = this.upVector;
  21121. if (this.allowUpsideDown && sinb < 0) {
  21122. up = up.clone();
  21123. up = up.negate();
  21124. }
  21125. this._computeViewMatrix(this._position, target, up);
  21126. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  21127. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  21128. }
  21129. this._currentTarget = target;
  21130. return this._viewMatrix;
  21131. };
  21132. /**
  21133. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  21134. * @param meshes Defines the mesh to zoom on
  21135. * @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)
  21136. */
  21137. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  21138. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  21139. meshes = meshes || this.getScene().meshes;
  21140. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  21141. var distance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  21142. this.radius = distance * this.zoomOnFactor;
  21143. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  21144. };
  21145. /**
  21146. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  21147. * The target will be changed but the radius
  21148. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  21149. * @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)
  21150. */
  21151. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  21152. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  21153. var meshesOrMinMaxVector;
  21154. var distance;
  21155. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  21156. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  21157. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  21158. distance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  21159. }
  21160. else { //minMaxVector and distance
  21161. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  21162. meshesOrMinMaxVector = minMaxVectorAndDistance;
  21163. distance = minMaxVectorAndDistance.distance;
  21164. }
  21165. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  21166. if (!doNotUpdateMaxZ) {
  21167. this.maxZ = distance * 2;
  21168. }
  21169. };
  21170. /**
  21171. * @override
  21172. * Override Camera.createRigCamera
  21173. */
  21174. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  21175. var alphaShift = 0;
  21176. switch (this.cameraRigMode) {
  21177. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21178. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21179. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21180. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  21181. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  21182. break;
  21183. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21184. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  21185. break;
  21186. }
  21187. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  21188. rigCam._cameraRigParams = {};
  21189. return rigCam;
  21190. };
  21191. /**
  21192. * @hidden
  21193. * @override
  21194. * Override Camera._updateRigCameras
  21195. */
  21196. ArcRotateCamera.prototype._updateRigCameras = function () {
  21197. var camLeft = this._rigCameras[0];
  21198. var camRight = this._rigCameras[1];
  21199. camLeft.beta = camRight.beta = this.beta;
  21200. switch (this.cameraRigMode) {
  21201. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21202. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21203. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21204. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  21205. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  21206. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  21207. break;
  21208. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21209. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  21210. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  21211. break;
  21212. }
  21213. _super.prototype._updateRigCameras.call(this);
  21214. };
  21215. /**
  21216. * Destroy the camera and release the current resources hold by it.
  21217. */
  21218. ArcRotateCamera.prototype.dispose = function () {
  21219. this.inputs.clear();
  21220. _super.prototype.dispose.call(this);
  21221. };
  21222. /**
  21223. * Gets the current object class name.
  21224. * @return the class name
  21225. */
  21226. ArcRotateCamera.prototype.getClassName = function () {
  21227. return "ArcRotateCamera";
  21228. };
  21229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21231. ], ArcRotateCamera.prototype, "alpha", void 0);
  21232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21234. ], ArcRotateCamera.prototype, "beta", void 0);
  21235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21237. ], ArcRotateCamera.prototype, "radius", void 0);
  21238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  21240. ], ArcRotateCamera.prototype, "_target", void 0);
  21241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("upVector")
  21243. ], ArcRotateCamera.prototype, "_upVector", void 0);
  21244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21246. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  21247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21249. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  21250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21252. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  21253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21255. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  21256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21258. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  21259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21261. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  21262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21264. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  21265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21267. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  21268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21270. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  21271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21273. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  21274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21276. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  21277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21279. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  21280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21282. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  21283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21285. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  21286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21288. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  21289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21291. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  21292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21294. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  21295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21297. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  21298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21300. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  21301. return ArcRotateCamera;
  21302. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  21303. /***/ }),
  21304. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  21305. /*!*************************************************!*\
  21306. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  21307. \*************************************************/
  21308. /*! exports provided: ArcRotateCameraInputsManager */
  21309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21310. "use strict";
  21311. __webpack_require__.r(__webpack_exports__);
  21312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  21313. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21314. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  21315. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  21316. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  21317. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21318. /**
  21319. * Default Inputs manager for the ArcRotateCamera.
  21320. * It groups all the default supported inputs for ease of use.
  21321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21322. */
  21323. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  21324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  21325. /**
  21326. * Instantiates a new ArcRotateCameraInputsManager.
  21327. * @param camera Defines the camera the inputs belong to
  21328. */
  21329. function ArcRotateCameraInputsManager(camera) {
  21330. return _super.call(this, camera) || this;
  21331. }
  21332. /**
  21333. * Add mouse wheel input support to the input manager.
  21334. * @returns the current input manager
  21335. */
  21336. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  21337. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  21338. return this;
  21339. };
  21340. /**
  21341. * Add pointers input support to the input manager.
  21342. * @returns the current input manager
  21343. */
  21344. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  21345. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  21346. return this;
  21347. };
  21348. /**
  21349. * Add keyboard input support to the input manager.
  21350. * @returns the current input manager
  21351. */
  21352. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  21353. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  21354. return this;
  21355. };
  21356. return ArcRotateCameraInputsManager;
  21357. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  21358. /***/ }),
  21359. /***/ "./Cameras/camera.ts":
  21360. /*!***************************!*\
  21361. !*** ./Cameras/camera.ts ***!
  21362. \***************************/
  21363. /*! exports provided: Camera */
  21364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21365. "use strict";
  21366. __webpack_require__.r(__webpack_exports__);
  21367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  21368. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21369. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21370. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  21371. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21372. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  21373. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  21374. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  21375. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21376. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  21377. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  21378. /* harmony import */ var _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Maths/math.viewport */ "./Maths/math.viewport.ts");
  21379. /* harmony import */ var _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Maths/math.frustum */ "./Maths/math.frustum.ts");
  21380. /**
  21381. * This is the base class of all the camera used in the application.
  21382. * @see http://doc.babylonjs.com/features/cameras
  21383. */
  21384. var Camera = /** @class */ (function (_super) {
  21385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  21386. /**
  21387. * Instantiates a new camera object.
  21388. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  21389. * @see http://doc.babylonjs.com/features/cameras
  21390. * @param name Defines the name of the camera in the scene
  21391. * @param position Defines the position of the camera
  21392. * @param scene Defines the scene the camera belongs too
  21393. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  21394. */
  21395. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21396. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21397. var _this = _super.call(this, name, scene) || this;
  21398. /** @hidden */
  21399. _this._position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21400. /**
  21401. * The vector the camera should consider as up.
  21402. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  21403. */
  21404. _this.upVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  21405. /**
  21406. * Define the current limit on the left side for an orthographic camera
  21407. * In scene unit
  21408. */
  21409. _this.orthoLeft = null;
  21410. /**
  21411. * Define the current limit on the right side for an orthographic camera
  21412. * In scene unit
  21413. */
  21414. _this.orthoRight = null;
  21415. /**
  21416. * Define the current limit on the bottom side for an orthographic camera
  21417. * In scene unit
  21418. */
  21419. _this.orthoBottom = null;
  21420. /**
  21421. * Define the current limit on the top side for an orthographic camera
  21422. * In scene unit
  21423. */
  21424. _this.orthoTop = null;
  21425. /**
  21426. * Field Of View is set in Radians. (default is 0.8)
  21427. */
  21428. _this.fov = 0.8;
  21429. /**
  21430. * Define the minimum distance the camera can see from.
  21431. * This is important to note that the depth buffer are not infinite and the closer it starts
  21432. * the more your scene might encounter depth fighting issue.
  21433. */
  21434. _this.minZ = 1;
  21435. /**
  21436. * Define the maximum distance the camera can see to.
  21437. * This is important to note that the depth buffer are not infinite and the further it end
  21438. * the more your scene might encounter depth fighting issue.
  21439. */
  21440. _this.maxZ = 10000.0;
  21441. /**
  21442. * Define the default inertia of the camera.
  21443. * This helps giving a smooth feeling to the camera movement.
  21444. */
  21445. _this.inertia = 0.9;
  21446. /**
  21447. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  21448. */
  21449. _this.mode = Camera.PERSPECTIVE_CAMERA;
  21450. /**
  21451. * Define wether the camera is intermediate.
  21452. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  21453. */
  21454. _this.isIntermediate = false;
  21455. /**
  21456. * Define the viewport of the camera.
  21457. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  21458. */
  21459. _this.viewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_10__["Viewport"](0, 0, 1.0, 1.0);
  21460. /**
  21461. * Restricts the camera to viewing objects with the same layerMask.
  21462. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  21463. */
  21464. _this.layerMask = 0x0FFFFFFF;
  21465. /**
  21466. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  21467. */
  21468. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  21469. /**
  21470. * Rig mode of the camera.
  21471. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  21472. * This is normally controlled byt the camera themselves as internal use.
  21473. */
  21474. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  21475. /**
  21476. * 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
  21477. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  21478. * else in the scene. (Eg. security camera)
  21479. *
  21480. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  21481. */
  21482. _this.customRenderTargets = new Array();
  21483. /**
  21484. * When set, the camera will render to this render target instead of the default canvas
  21485. *
  21486. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  21487. */
  21488. _this.outputRenderTarget = null;
  21489. /**
  21490. * Observable triggered when the camera view matrix has changed.
  21491. */
  21492. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  21493. /**
  21494. * Observable triggered when the camera Projection matrix has changed.
  21495. */
  21496. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  21497. /**
  21498. * Observable triggered when the inputs have been processed.
  21499. */
  21500. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  21501. /**
  21502. * Observable triggered when reset has been called and applied to the camera.
  21503. */
  21504. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  21505. /** @hidden */
  21506. _this._rigCameras = new Array();
  21507. _this._webvrViewMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21508. /** @hidden */
  21509. _this._skipRendering = false;
  21510. /** @hidden */
  21511. _this._projectionMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  21512. /** @hidden */
  21513. _this._postProcesses = new Array();
  21514. /** @hidden */
  21515. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  21516. _this._globalPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21517. /** @hidden */
  21518. _this._computedViewMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21519. _this._doNotComputeProjectionMatrix = false;
  21520. _this._transformMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  21521. _this._refreshFrustumPlanes = true;
  21522. /** @hidden */
  21523. _this._isCamera = true;
  21524. /** @hidden */
  21525. _this._isLeftCamera = false;
  21526. /** @hidden */
  21527. _this._isRightCamera = false;
  21528. _this.getScene().addCamera(_this);
  21529. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  21530. _this.getScene().activeCamera = _this;
  21531. }
  21532. _this.position = position;
  21533. return _this;
  21534. }
  21535. Object.defineProperty(Camera.prototype, "position", {
  21536. /**
  21537. * Define the current local position of the camera in the scene
  21538. */
  21539. get: function () {
  21540. return this._position;
  21541. },
  21542. set: function (newPosition) {
  21543. this._position = newPosition;
  21544. },
  21545. enumerable: true,
  21546. configurable: true
  21547. });
  21548. /**
  21549. * Store current camera state (fov, position, etc..)
  21550. * @returns the camera
  21551. */
  21552. Camera.prototype.storeState = function () {
  21553. this._stateStored = true;
  21554. this._storedFov = this.fov;
  21555. return this;
  21556. };
  21557. /**
  21558. * Restores the camera state values if it has been stored. You must call storeState() first
  21559. */
  21560. Camera.prototype._restoreStateValues = function () {
  21561. if (!this._stateStored) {
  21562. return false;
  21563. }
  21564. this.fov = this._storedFov;
  21565. return true;
  21566. };
  21567. /**
  21568. * Restored camera state. You must call storeState() first.
  21569. * @returns true if restored and false otherwise
  21570. */
  21571. Camera.prototype.restoreState = function () {
  21572. if (this._restoreStateValues()) {
  21573. this.onRestoreStateObservable.notifyObservers(this);
  21574. return true;
  21575. }
  21576. return false;
  21577. };
  21578. /**
  21579. * Gets the class name of the camera.
  21580. * @returns the class name
  21581. */
  21582. Camera.prototype.getClassName = function () {
  21583. return "Camera";
  21584. };
  21585. /**
  21586. * Gets a string representation of the camera useful for debug purpose.
  21587. * @param fullDetails Defines that a more verboe level of logging is required
  21588. * @returns the string representation
  21589. */
  21590. Camera.prototype.toString = function (fullDetails) {
  21591. var ret = "Name: " + this.name;
  21592. ret += ", type: " + this.getClassName();
  21593. if (this.animations) {
  21594. for (var i = 0; i < this.animations.length; i++) {
  21595. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  21596. }
  21597. }
  21598. if (fullDetails) {
  21599. }
  21600. return ret;
  21601. };
  21602. Object.defineProperty(Camera.prototype, "globalPosition", {
  21603. /**
  21604. * Gets the current world space position of the camera.
  21605. */
  21606. get: function () {
  21607. return this._globalPosition;
  21608. },
  21609. enumerable: true,
  21610. configurable: true
  21611. });
  21612. /**
  21613. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  21614. * @returns the active meshe list
  21615. */
  21616. Camera.prototype.getActiveMeshes = function () {
  21617. return this._activeMeshes;
  21618. };
  21619. /**
  21620. * Check wether a mesh is part of the current active mesh list of the camera
  21621. * @param mesh Defines the mesh to check
  21622. * @returns true if active, false otherwise
  21623. */
  21624. Camera.prototype.isActiveMesh = function (mesh) {
  21625. return (this._activeMeshes.indexOf(mesh) !== -1);
  21626. };
  21627. /**
  21628. * Is this camera ready to be used/rendered
  21629. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  21630. * @return true if the camera is ready
  21631. */
  21632. Camera.prototype.isReady = function (completeCheck) {
  21633. if (completeCheck === void 0) { completeCheck = false; }
  21634. if (completeCheck) {
  21635. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  21636. var pp = _a[_i];
  21637. if (pp && !pp.isReady()) {
  21638. return false;
  21639. }
  21640. }
  21641. }
  21642. return _super.prototype.isReady.call(this, completeCheck);
  21643. };
  21644. /** @hidden */
  21645. Camera.prototype._initCache = function () {
  21646. _super.prototype._initCache.call(this);
  21647. this._cache.position = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  21648. this._cache.upVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  21649. this._cache.mode = undefined;
  21650. this._cache.minZ = undefined;
  21651. this._cache.maxZ = undefined;
  21652. this._cache.fov = undefined;
  21653. this._cache.fovMode = undefined;
  21654. this._cache.aspectRatio = undefined;
  21655. this._cache.orthoLeft = undefined;
  21656. this._cache.orthoRight = undefined;
  21657. this._cache.orthoBottom = undefined;
  21658. this._cache.orthoTop = undefined;
  21659. this._cache.renderWidth = undefined;
  21660. this._cache.renderHeight = undefined;
  21661. };
  21662. /** @hidden */
  21663. Camera.prototype._updateCache = function (ignoreParentClass) {
  21664. if (!ignoreParentClass) {
  21665. _super.prototype._updateCache.call(this);
  21666. }
  21667. this._cache.position.copyFrom(this.position);
  21668. this._cache.upVector.copyFrom(this.upVector);
  21669. };
  21670. /** @hidden */
  21671. Camera.prototype._isSynchronized = function () {
  21672. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  21673. };
  21674. /** @hidden */
  21675. Camera.prototype._isSynchronizedViewMatrix = function () {
  21676. if (!_super.prototype._isSynchronized.call(this)) {
  21677. return false;
  21678. }
  21679. return this._cache.position.equals(this.position)
  21680. && this._cache.upVector.equals(this.upVector)
  21681. && this.isSynchronizedWithParent();
  21682. };
  21683. /** @hidden */
  21684. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  21685. var check = this._cache.mode === this.mode
  21686. && this._cache.minZ === this.minZ
  21687. && this._cache.maxZ === this.maxZ;
  21688. if (!check) {
  21689. return false;
  21690. }
  21691. var engine = this.getEngine();
  21692. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  21693. check = this._cache.fov === this.fov
  21694. && this._cache.fovMode === this.fovMode
  21695. && this._cache.aspectRatio === engine.getAspectRatio(this);
  21696. }
  21697. else {
  21698. check = this._cache.orthoLeft === this.orthoLeft
  21699. && this._cache.orthoRight === this.orthoRight
  21700. && this._cache.orthoBottom === this.orthoBottom
  21701. && this._cache.orthoTop === this.orthoTop
  21702. && this._cache.renderWidth === engine.getRenderWidth()
  21703. && this._cache.renderHeight === engine.getRenderHeight();
  21704. }
  21705. return check;
  21706. };
  21707. /**
  21708. * Attach the input controls to a specific dom element to get the input from.
  21709. * @param element Defines the element the controls should be listened from
  21710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21711. */
  21712. Camera.prototype.attachControl = function (element, noPreventDefault) {
  21713. };
  21714. /**
  21715. * Detach the current controls from the specified dom element.
  21716. * @param element Defines the element to stop listening the inputs from
  21717. */
  21718. Camera.prototype.detachControl = function (element) {
  21719. };
  21720. /**
  21721. * Update the camera state according to the different inputs gathered during the frame.
  21722. */
  21723. Camera.prototype.update = function () {
  21724. this._checkInputs();
  21725. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21726. this._updateRigCameras();
  21727. }
  21728. };
  21729. /** @hidden */
  21730. Camera.prototype._checkInputs = function () {
  21731. this.onAfterCheckInputsObservable.notifyObservers(this);
  21732. };
  21733. Object.defineProperty(Camera.prototype, "rigCameras", {
  21734. /** @hidden */
  21735. get: function () {
  21736. return this._rigCameras;
  21737. },
  21738. enumerable: true,
  21739. configurable: true
  21740. });
  21741. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  21742. /**
  21743. * Gets the post process used by the rig cameras
  21744. */
  21745. get: function () {
  21746. return this._rigPostProcess;
  21747. },
  21748. enumerable: true,
  21749. configurable: true
  21750. });
  21751. /**
  21752. * Internal, gets the first post proces.
  21753. * @returns the first post process to be run on this camera.
  21754. */
  21755. Camera.prototype._getFirstPostProcess = function () {
  21756. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  21757. if (this._postProcesses[ppIndex] !== null) {
  21758. return this._postProcesses[ppIndex];
  21759. }
  21760. }
  21761. return null;
  21762. };
  21763. Camera.prototype._cascadePostProcessesToRigCams = function () {
  21764. // invalidate framebuffer
  21765. var firstPostProcess = this._getFirstPostProcess();
  21766. if (firstPostProcess) {
  21767. firstPostProcess.markTextureDirty();
  21768. }
  21769. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  21770. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  21771. var cam = this._rigCameras[i];
  21772. var rigPostProcess = cam._rigPostProcess;
  21773. // for VR rig, there does not have to be a post process
  21774. if (rigPostProcess) {
  21775. var isPass = rigPostProcess.getEffectName() === "pass";
  21776. if (isPass) {
  21777. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  21778. cam.isIntermediate = this._postProcesses.length === 0;
  21779. }
  21780. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  21781. rigPostProcess.markTextureDirty();
  21782. }
  21783. else {
  21784. cam._postProcesses = this._postProcesses.slice(0);
  21785. }
  21786. }
  21787. };
  21788. /**
  21789. * Attach a post process to the camera.
  21790. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  21791. * @param postProcess The post process to attach to the camera
  21792. * @param insertAt The position of the post process in case several of them are in use in the scene
  21793. * @returns the position the post process has been inserted at
  21794. */
  21795. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  21796. if (insertAt === void 0) { insertAt = null; }
  21797. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  21798. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  21799. return 0;
  21800. }
  21801. if (insertAt == null || insertAt < 0) {
  21802. this._postProcesses.push(postProcess);
  21803. }
  21804. else if (this._postProcesses[insertAt] === null) {
  21805. this._postProcesses[insertAt] = postProcess;
  21806. }
  21807. else {
  21808. this._postProcesses.splice(insertAt, 0, postProcess);
  21809. }
  21810. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  21811. return this._postProcesses.indexOf(postProcess);
  21812. };
  21813. /**
  21814. * Detach a post process to the camera.
  21815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  21816. * @param postProcess The post process to detach from the camera
  21817. */
  21818. Camera.prototype.detachPostProcess = function (postProcess) {
  21819. var idx = this._postProcesses.indexOf(postProcess);
  21820. if (idx !== -1) {
  21821. this._postProcesses[idx] = null;
  21822. }
  21823. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  21824. };
  21825. /**
  21826. * Gets the current world matrix of the camera
  21827. */
  21828. Camera.prototype.getWorldMatrix = function () {
  21829. if (this._isSynchronizedViewMatrix()) {
  21830. return this._worldMatrix;
  21831. }
  21832. // Getting the the view matrix will also compute the world matrix.
  21833. this.getViewMatrix();
  21834. return this._worldMatrix;
  21835. };
  21836. /** @hidden */
  21837. Camera.prototype._getViewMatrix = function () {
  21838. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21839. };
  21840. /**
  21841. * Gets the current view matrix of the camera.
  21842. * @param force forces the camera to recompute the matrix without looking at the cached state
  21843. * @returns the view matrix
  21844. */
  21845. Camera.prototype.getViewMatrix = function (force) {
  21846. if (!force && this._isSynchronizedViewMatrix()) {
  21847. return this._computedViewMatrix;
  21848. }
  21849. this.updateCache();
  21850. this._computedViewMatrix = this._getViewMatrix();
  21851. this._currentRenderId = this.getScene().getRenderId();
  21852. this._childUpdateId++;
  21853. this._refreshFrustumPlanes = true;
  21854. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  21855. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  21856. }
  21857. // Notify parent camera if rig camera is changed
  21858. if (this.parent && this.parent.onViewMatrixChangedObservable) {
  21859. this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent);
  21860. }
  21861. this.onViewMatrixChangedObservable.notifyObservers(this);
  21862. this._computedViewMatrix.invertToRef(this._worldMatrix);
  21863. return this._computedViewMatrix;
  21864. };
  21865. /**
  21866. * Freeze the projection matrix.
  21867. * It will prevent the cache check of the camera projection compute and can speed up perf
  21868. * if no parameter of the camera are meant to change
  21869. * @param projection Defines manually a projection if necessary
  21870. */
  21871. Camera.prototype.freezeProjectionMatrix = function (projection) {
  21872. this._doNotComputeProjectionMatrix = true;
  21873. if (projection !== undefined) {
  21874. this._projectionMatrix = projection;
  21875. }
  21876. };
  21877. /**
  21878. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  21879. */
  21880. Camera.prototype.unfreezeProjectionMatrix = function () {
  21881. this._doNotComputeProjectionMatrix = false;
  21882. };
  21883. /**
  21884. * Gets the current projection matrix of the camera.
  21885. * @param force forces the camera to recompute the matrix without looking at the cached state
  21886. * @returns the projection matrix
  21887. */
  21888. Camera.prototype.getProjectionMatrix = function (force) {
  21889. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  21890. return this._projectionMatrix;
  21891. }
  21892. // Cache
  21893. this._cache.mode = this.mode;
  21894. this._cache.minZ = this.minZ;
  21895. this._cache.maxZ = this.maxZ;
  21896. // Matrix
  21897. this._refreshFrustumPlanes = true;
  21898. var engine = this.getEngine();
  21899. var scene = this.getScene();
  21900. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  21901. this._cache.fov = this.fov;
  21902. this._cache.fovMode = this.fovMode;
  21903. this._cache.aspectRatio = engine.getAspectRatio(this);
  21904. if (this.minZ <= 0) {
  21905. this.minZ = 0.1;
  21906. }
  21907. if (scene.useRightHandedSystem) {
  21908. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovRHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  21909. }
  21910. else {
  21911. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  21912. }
  21913. }
  21914. else {
  21915. var halfWidth = engine.getRenderWidth() / 2.0;
  21916. var halfHeight = engine.getRenderHeight() / 2.0;
  21917. if (scene.useRightHandedSystem) {
  21918. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterRHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  21919. }
  21920. else {
  21921. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  21922. }
  21923. this._cache.orthoLeft = this.orthoLeft;
  21924. this._cache.orthoRight = this.orthoRight;
  21925. this._cache.orthoBottom = this.orthoBottom;
  21926. this._cache.orthoTop = this.orthoTop;
  21927. this._cache.renderWidth = engine.getRenderWidth();
  21928. this._cache.renderHeight = engine.getRenderHeight();
  21929. }
  21930. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21931. return this._projectionMatrix;
  21932. };
  21933. /**
  21934. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21935. * @returns a Matrix
  21936. */
  21937. Camera.prototype.getTransformationMatrix = function () {
  21938. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21939. return this._transformMatrix;
  21940. };
  21941. Camera.prototype._updateFrustumPlanes = function () {
  21942. if (!this._refreshFrustumPlanes) {
  21943. return;
  21944. }
  21945. this.getTransformationMatrix();
  21946. if (!this._frustumPlanes) {
  21947. this._frustumPlanes = _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_11__["Frustum"].GetPlanes(this._transformMatrix);
  21948. }
  21949. else {
  21950. _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_11__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21951. }
  21952. this._refreshFrustumPlanes = false;
  21953. };
  21954. /**
  21955. * Checks if a cullable object (mesh...) is in the camera frustum
  21956. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21957. * @param target The object to check
  21958. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  21959. * @returns true if the object is in frustum otherwise false
  21960. */
  21961. Camera.prototype.isInFrustum = function (target, checkRigCameras) {
  21962. if (checkRigCameras === void 0) { checkRigCameras = false; }
  21963. this._updateFrustumPlanes();
  21964. if (checkRigCameras && this.rigCameras.length > 0) {
  21965. var result = false;
  21966. this.rigCameras.forEach(function (cam) {
  21967. cam._updateFrustumPlanes();
  21968. result = result || target.isInFrustum(cam._frustumPlanes);
  21969. });
  21970. return result;
  21971. }
  21972. else {
  21973. return target.isInFrustum(this._frustumPlanes);
  21974. }
  21975. };
  21976. /**
  21977. * Checks if a cullable object (mesh...) is in the camera frustum
  21978. * Unlike isInFrustum this cheks the full bounding box
  21979. * @param target The object to check
  21980. * @returns true if the object is in frustum otherwise false
  21981. */
  21982. Camera.prototype.isCompletelyInFrustum = function (target) {
  21983. this._updateFrustumPlanes();
  21984. return target.isCompletelyInFrustum(this._frustumPlanes);
  21985. };
  21986. /**
  21987. * Gets a ray in the forward direction from the camera.
  21988. * @param length Defines the length of the ray to create
  21989. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21990. * @param origin Defines the start point of the ray which defaults to the camera position
  21991. * @returns the forward ray
  21992. */
  21993. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21994. if (length === void 0) { length = 100; }
  21995. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21996. };
  21997. /**
  21998. * Releases resources associated with this node.
  21999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22001. */
  22002. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  22003. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  22004. // Observables
  22005. this.onViewMatrixChangedObservable.clear();
  22006. this.onProjectionMatrixChangedObservable.clear();
  22007. this.onAfterCheckInputsObservable.clear();
  22008. this.onRestoreStateObservable.clear();
  22009. // Inputs
  22010. if (this.inputs) {
  22011. this.inputs.clear();
  22012. }
  22013. // Animations
  22014. this.getScene().stopAnimation(this);
  22015. // Remove from scene
  22016. this.getScene().removeCamera(this);
  22017. while (this._rigCameras.length > 0) {
  22018. var camera = this._rigCameras.pop();
  22019. if (camera) {
  22020. camera.dispose();
  22021. }
  22022. }
  22023. // Postprocesses
  22024. if (this._rigPostProcess) {
  22025. this._rigPostProcess.dispose(this);
  22026. this._rigPostProcess = null;
  22027. this._postProcesses = [];
  22028. }
  22029. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  22030. this._rigPostProcess = null;
  22031. this._postProcesses = [];
  22032. }
  22033. else {
  22034. var i = this._postProcesses.length;
  22035. while (--i >= 0) {
  22036. var postProcess = this._postProcesses[i];
  22037. if (postProcess) {
  22038. postProcess.dispose(this);
  22039. }
  22040. }
  22041. }
  22042. // Render targets
  22043. var i = this.customRenderTargets.length;
  22044. while (--i >= 0) {
  22045. this.customRenderTargets[i].dispose();
  22046. }
  22047. this.customRenderTargets = [];
  22048. // Active Meshes
  22049. this._activeMeshes.dispose();
  22050. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  22051. };
  22052. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  22053. /**
  22054. * Gets the left camera of a rig setup in case of Rigged Camera
  22055. */
  22056. get: function () {
  22057. return this._isLeftCamera;
  22058. },
  22059. enumerable: true,
  22060. configurable: true
  22061. });
  22062. Object.defineProperty(Camera.prototype, "isRightCamera", {
  22063. /**
  22064. * Gets the right camera of a rig setup in case of Rigged Camera
  22065. */
  22066. get: function () {
  22067. return this._isRightCamera;
  22068. },
  22069. enumerable: true,
  22070. configurable: true
  22071. });
  22072. Object.defineProperty(Camera.prototype, "leftCamera", {
  22073. /**
  22074. * Gets the left camera of a rig setup in case of Rigged Camera
  22075. */
  22076. get: function () {
  22077. if (this._rigCameras.length < 1) {
  22078. return null;
  22079. }
  22080. return this._rigCameras[0];
  22081. },
  22082. enumerable: true,
  22083. configurable: true
  22084. });
  22085. Object.defineProperty(Camera.prototype, "rightCamera", {
  22086. /**
  22087. * Gets the right camera of a rig setup in case of Rigged Camera
  22088. */
  22089. get: function () {
  22090. if (this._rigCameras.length < 2) {
  22091. return null;
  22092. }
  22093. return this._rigCameras[1];
  22094. },
  22095. enumerable: true,
  22096. configurable: true
  22097. });
  22098. /**
  22099. * Gets the left camera target of a rig setup in case of Rigged Camera
  22100. * @returns the target position
  22101. */
  22102. Camera.prototype.getLeftTarget = function () {
  22103. if (this._rigCameras.length < 1) {
  22104. return null;
  22105. }
  22106. return this._rigCameras[0].getTarget();
  22107. };
  22108. /**
  22109. * Gets the right camera target of a rig setup in case of Rigged Camera
  22110. * @returns the target position
  22111. */
  22112. Camera.prototype.getRightTarget = function () {
  22113. if (this._rigCameras.length < 2) {
  22114. return null;
  22115. }
  22116. return this._rigCameras[1].getTarget();
  22117. };
  22118. /**
  22119. * @hidden
  22120. */
  22121. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  22122. if (this.cameraRigMode === mode) {
  22123. return;
  22124. }
  22125. while (this._rigCameras.length > 0) {
  22126. var camera = this._rigCameras.pop();
  22127. if (camera) {
  22128. camera.dispose();
  22129. }
  22130. }
  22131. this.cameraRigMode = mode;
  22132. this._cameraRigParams = {};
  22133. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  22134. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  22135. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  22136. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  22137. // create the rig cameras, unless none
  22138. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  22139. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  22140. if (leftCamera) {
  22141. leftCamera._isLeftCamera = true;
  22142. }
  22143. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  22144. if (rightCamera) {
  22145. rightCamera._isRightCamera = true;
  22146. }
  22147. if (leftCamera && rightCamera) {
  22148. this._rigCameras.push(leftCamera);
  22149. this._rigCameras.push(rightCamera);
  22150. }
  22151. }
  22152. switch (this.cameraRigMode) {
  22153. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22154. Camera._setStereoscopicAnaglyphRigMode(this);
  22155. break;
  22156. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22157. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22158. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22159. Camera._setStereoscopicRigMode(this);
  22160. break;
  22161. case Camera.RIG_MODE_VR:
  22162. Camera._setVRRigMode(this, rigParams);
  22163. break;
  22164. case Camera.RIG_MODE_WEBVR:
  22165. Camera._setWebVRRigMode(this, rigParams);
  22166. break;
  22167. }
  22168. this._cascadePostProcessesToRigCams();
  22169. this.update();
  22170. };
  22171. /** @hidden */
  22172. Camera._setStereoscopicRigMode = function (camera) {
  22173. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  22174. };
  22175. /** @hidden */
  22176. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  22177. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  22178. };
  22179. /** @hidden */
  22180. Camera._setVRRigMode = function (camera, rigParams) {
  22181. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  22182. };
  22183. /** @hidden */
  22184. Camera._setWebVRRigMode = function (camera, rigParams) {
  22185. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  22186. };
  22187. /** @hidden */
  22188. Camera.prototype._getVRProjectionMatrix = function () {
  22189. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  22190. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  22191. return this._projectionMatrix;
  22192. };
  22193. Camera.prototype._updateCameraRotationMatrix = function () {
  22194. //Here for WebVR
  22195. };
  22196. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  22197. //Here for WebVR
  22198. };
  22199. /**
  22200. * This function MUST be overwritten by the different WebVR cameras available.
  22201. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  22202. * @hidden
  22203. */
  22204. Camera.prototype._getWebVRProjectionMatrix = function () {
  22205. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  22206. };
  22207. /**
  22208. * This function MUST be overwritten by the different WebVR cameras available.
  22209. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  22210. * @hidden
  22211. */
  22212. Camera.prototype._getWebVRViewMatrix = function () {
  22213. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  22214. };
  22215. /** @hidden */
  22216. Camera.prototype.setCameraRigParameter = function (name, value) {
  22217. if (!this._cameraRigParams) {
  22218. this._cameraRigParams = {};
  22219. }
  22220. this._cameraRigParams[name] = value;
  22221. //provisionnally:
  22222. if (name === "interaxialDistance") {
  22223. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  22224. }
  22225. };
  22226. /**
  22227. * needs to be overridden by children so sub has required properties to be copied
  22228. * @hidden
  22229. */
  22230. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  22231. return null;
  22232. };
  22233. /**
  22234. * May need to be overridden by children
  22235. * @hidden
  22236. */
  22237. Camera.prototype._updateRigCameras = function () {
  22238. for (var i = 0; i < this._rigCameras.length; i++) {
  22239. this._rigCameras[i].minZ = this.minZ;
  22240. this._rigCameras[i].maxZ = this.maxZ;
  22241. this._rigCameras[i].fov = this.fov;
  22242. this._rigCameras[i].upVector.copyFrom(this.upVector);
  22243. }
  22244. // only update viewport when ANAGLYPH
  22245. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  22246. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  22247. }
  22248. };
  22249. /** @hidden */
  22250. Camera.prototype._setupInputs = function () {
  22251. };
  22252. /**
  22253. * Serialiaze the camera setup to a json represention
  22254. * @returns the JSON representation
  22255. */
  22256. Camera.prototype.serialize = function () {
  22257. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  22258. // Type
  22259. serializationObject.type = this.getClassName();
  22260. // Parent
  22261. if (this.parent) {
  22262. serializationObject.parentId = this.parent.id;
  22263. }
  22264. if (this.inputs) {
  22265. this.inputs.serialize(serializationObject);
  22266. }
  22267. // Animations
  22268. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  22269. serializationObject.ranges = this.serializeAnimationRanges();
  22270. return serializationObject;
  22271. };
  22272. /**
  22273. * Clones the current camera.
  22274. * @param name The cloned camera name
  22275. * @returns the cloned camera
  22276. */
  22277. Camera.prototype.clone = function (name) {
  22278. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  22279. };
  22280. /**
  22281. * Gets the direction of the camera relative to a given local axis.
  22282. * @param localAxis Defines the reference axis to provide a relative direction.
  22283. * @return the direction
  22284. */
  22285. Camera.prototype.getDirection = function (localAxis) {
  22286. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  22287. this.getDirectionToRef(localAxis, result);
  22288. return result;
  22289. };
  22290. /**
  22291. * Gets the direction of the camera relative to a given local axis into a passed vector.
  22292. * @param localAxis Defines the reference axis to provide a relative direction.
  22293. * @param result Defines the vector to store the result in
  22294. */
  22295. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  22296. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  22297. };
  22298. /**
  22299. * Gets a camera constructor for a given camera type
  22300. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  22301. * @param name The name of the camera the result will be able to instantiate
  22302. * @param scene The scene the result will construct the camera in
  22303. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  22304. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  22305. * @returns a factory method to construc the camera
  22306. */
  22307. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  22308. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  22309. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  22310. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  22311. interaxial_distance: interaxial_distance,
  22312. isStereoscopicSideBySide: isStereoscopicSideBySide
  22313. });
  22314. if (constructorFunc) {
  22315. return constructorFunc;
  22316. }
  22317. // Default to universal camera
  22318. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  22319. };
  22320. /**
  22321. * Compute the world matrix of the camera.
  22322. * @returns the camera workd matrix
  22323. */
  22324. Camera.prototype.computeWorldMatrix = function () {
  22325. return this.getWorldMatrix();
  22326. };
  22327. /**
  22328. * Parse a JSON and creates the camera from the parsed information
  22329. * @param parsedCamera The JSON to parse
  22330. * @param scene The scene to instantiate the camera in
  22331. * @returns the newly constructed camera
  22332. */
  22333. Camera.Parse = function (parsedCamera, scene) {
  22334. var type = parsedCamera.type;
  22335. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  22336. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  22337. // Parent
  22338. if (parsedCamera.parentId) {
  22339. camera._waitingParentId = parsedCamera.parentId;
  22340. }
  22341. //If camera has an input manager, let it parse inputs settings
  22342. if (camera.inputs) {
  22343. camera.inputs.parse(parsedCamera);
  22344. camera._setupInputs();
  22345. }
  22346. if (camera.setPosition) { // need to force position
  22347. camera.position.copyFromFloats(0, 0, 0);
  22348. camera.setPosition(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  22349. }
  22350. // Target
  22351. if (parsedCamera.target) {
  22352. if (camera.setTarget) {
  22353. camera.setTarget(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  22354. }
  22355. }
  22356. // Apply 3d rig, when found
  22357. if (parsedCamera.cameraRigMode) {
  22358. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  22359. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  22360. }
  22361. // Animations
  22362. if (parsedCamera.animations) {
  22363. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  22364. var parsedAnimation = parsedCamera.animations[animationIndex];
  22365. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  22366. if (internalClass) {
  22367. camera.animations.push(internalClass.Parse(parsedAnimation));
  22368. }
  22369. }
  22370. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  22371. }
  22372. if (parsedCamera.autoAnimate) {
  22373. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  22374. }
  22375. return camera;
  22376. };
  22377. /** @hidden */
  22378. Camera._createDefaultParsedCamera = function (name, scene) {
  22379. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  22380. };
  22381. /**
  22382. * This is the default projection mode used by the cameras.
  22383. * It helps recreating a feeling of perspective and better appreciate depth.
  22384. * This is the best way to simulate real life cameras.
  22385. */
  22386. Camera.PERSPECTIVE_CAMERA = 0;
  22387. /**
  22388. * This helps creating camera with an orthographic mode.
  22389. * 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.
  22390. */
  22391. Camera.ORTHOGRAPHIC_CAMERA = 1;
  22392. /**
  22393. * This is the default FOV mode for perspective cameras.
  22394. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  22395. */
  22396. Camera.FOVMODE_VERTICAL_FIXED = 0;
  22397. /**
  22398. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  22399. */
  22400. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  22401. /**
  22402. * This specifies ther is no need for a camera rig.
  22403. * Basically only one eye is rendered corresponding to the camera.
  22404. */
  22405. Camera.RIG_MODE_NONE = 0;
  22406. /**
  22407. * Simulates a camera Rig with one blue eye and one red eye.
  22408. * This can be use with 3d blue and red glasses.
  22409. */
  22410. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  22411. /**
  22412. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  22413. */
  22414. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  22415. /**
  22416. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  22417. */
  22418. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  22419. /**
  22420. * Defines that both eyes of the camera will be rendered over under each other.
  22421. */
  22422. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  22423. /**
  22424. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  22425. */
  22426. Camera.RIG_MODE_VR = 20;
  22427. /**
  22428. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  22429. */
  22430. Camera.RIG_MODE_WEBVR = 21;
  22431. /**
  22432. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  22433. */
  22434. Camera.RIG_MODE_CUSTOM = 22;
  22435. /**
  22436. * Defines if by default attaching controls should prevent the default javascript event to continue.
  22437. */
  22438. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  22439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  22441. ], Camera.prototype, "_position", void 0);
  22442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22444. ], Camera.prototype, "upVector", void 0);
  22445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22447. ], Camera.prototype, "orthoLeft", void 0);
  22448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22450. ], Camera.prototype, "orthoRight", void 0);
  22451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22453. ], Camera.prototype, "orthoBottom", void 0);
  22454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22456. ], Camera.prototype, "orthoTop", void 0);
  22457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22459. ], Camera.prototype, "fov", void 0);
  22460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22462. ], Camera.prototype, "minZ", void 0);
  22463. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22465. ], Camera.prototype, "maxZ", void 0);
  22466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22468. ], Camera.prototype, "inertia", void 0);
  22469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22471. ], Camera.prototype, "mode", void 0);
  22472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22474. ], Camera.prototype, "layerMask", void 0);
  22475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22477. ], Camera.prototype, "fovMode", void 0);
  22478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22480. ], Camera.prototype, "cameraRigMode", void 0);
  22481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22483. ], Camera.prototype, "interaxialDistance", void 0);
  22484. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22485. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22486. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  22487. return Camera;
  22488. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  22489. /***/ }),
  22490. /***/ "./Cameras/cameraInputsManager.ts":
  22491. /*!****************************************!*\
  22492. !*** ./Cameras/cameraInputsManager.ts ***!
  22493. \****************************************/
  22494. /*! exports provided: CameraInputTypes, CameraInputsManager */
  22495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22496. "use strict";
  22497. __webpack_require__.r(__webpack_exports__);
  22498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  22499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  22500. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  22501. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22502. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22503. /**
  22504. * @ignore
  22505. * This is a list of all the different input types that are available in the application.
  22506. * Fo instance: ArcRotateCameraGamepadInput...
  22507. */
  22508. var CameraInputTypes = {};
  22509. /**
  22510. * This represents the input manager used within a camera.
  22511. * It helps dealing with all the different kind of input attached to a camera.
  22512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22513. */
  22514. var CameraInputsManager = /** @class */ (function () {
  22515. /**
  22516. * Instantiate a new Camera Input Manager.
  22517. * @param camera Defines the camera the input manager blongs to
  22518. */
  22519. function CameraInputsManager(camera) {
  22520. this.attached = {};
  22521. this.camera = camera;
  22522. this.checkInputs = function () { };
  22523. }
  22524. /**
  22525. * Add an input method to a camera
  22526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22527. * @param input camera input method
  22528. */
  22529. CameraInputsManager.prototype.add = function (input) {
  22530. var type = input.getSimpleName();
  22531. if (this.attached[type]) {
  22532. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  22533. return;
  22534. }
  22535. this.attached[type] = input;
  22536. input.camera = this.camera;
  22537. //for checkInputs, we are dynamically creating a function
  22538. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  22539. if (input.checkInputs) {
  22540. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  22541. }
  22542. if (this.attachedElement) {
  22543. input.attachControl(this.attachedElement);
  22544. }
  22545. };
  22546. /**
  22547. * Remove a specific input method from a camera
  22548. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  22549. * @param inputToRemove camera input method
  22550. */
  22551. CameraInputsManager.prototype.remove = function (inputToRemove) {
  22552. for (var cam in this.attached) {
  22553. var input = this.attached[cam];
  22554. if (input === inputToRemove) {
  22555. input.detachControl(this.attachedElement);
  22556. input.camera = null;
  22557. delete this.attached[cam];
  22558. this.rebuildInputCheck();
  22559. }
  22560. }
  22561. };
  22562. /**
  22563. * Remove a specific input type from a camera
  22564. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  22565. * @param inputType the type of the input to remove
  22566. */
  22567. CameraInputsManager.prototype.removeByType = function (inputType) {
  22568. for (var cam in this.attached) {
  22569. var input = this.attached[cam];
  22570. if (input.getClassName() === inputType) {
  22571. input.detachControl(this.attachedElement);
  22572. input.camera = null;
  22573. delete this.attached[cam];
  22574. this.rebuildInputCheck();
  22575. }
  22576. }
  22577. };
  22578. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  22579. var current = this.checkInputs;
  22580. return function () {
  22581. current();
  22582. fn();
  22583. };
  22584. };
  22585. /**
  22586. * Attach the input controls to the currently attached dom element to listen the events from.
  22587. * @param input Defines the input to attach
  22588. */
  22589. CameraInputsManager.prototype.attachInput = function (input) {
  22590. if (this.attachedElement) {
  22591. input.attachControl(this.attachedElement, this.noPreventDefault);
  22592. }
  22593. };
  22594. /**
  22595. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  22596. * @param element Defines the dom element to collect the events from
  22597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22598. */
  22599. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  22600. if (noPreventDefault === void 0) { noPreventDefault = false; }
  22601. if (this.attachedElement) {
  22602. return;
  22603. }
  22604. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  22605. this.attachedElement = element;
  22606. this.noPreventDefault = noPreventDefault;
  22607. for (var cam in this.attached) {
  22608. this.attached[cam].attachControl(element, noPreventDefault);
  22609. }
  22610. };
  22611. /**
  22612. * Detach the current manager inputs controls from a specific dom element.
  22613. * @param element Defines the dom element to collect the events from
  22614. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  22615. */
  22616. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  22617. if (disconnect === void 0) { disconnect = false; }
  22618. if (this.attachedElement !== element) {
  22619. return;
  22620. }
  22621. for (var cam in this.attached) {
  22622. this.attached[cam].detachControl(element);
  22623. if (disconnect) {
  22624. this.attached[cam].camera = null;
  22625. }
  22626. }
  22627. this.attachedElement = null;
  22628. };
  22629. /**
  22630. * Rebuild the dynamic inputCheck function from the current list of
  22631. * defined inputs in the manager.
  22632. */
  22633. CameraInputsManager.prototype.rebuildInputCheck = function () {
  22634. this.checkInputs = function () { };
  22635. for (var cam in this.attached) {
  22636. var input = this.attached[cam];
  22637. if (input.checkInputs) {
  22638. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  22639. }
  22640. }
  22641. };
  22642. /**
  22643. * Remove all attached input methods from a camera
  22644. */
  22645. CameraInputsManager.prototype.clear = function () {
  22646. if (this.attachedElement) {
  22647. this.detachElement(this.attachedElement, true);
  22648. }
  22649. this.attached = {};
  22650. this.attachedElement = null;
  22651. this.checkInputs = function () { };
  22652. };
  22653. /**
  22654. * Serialize the current input manager attached to a camera.
  22655. * This ensures than once parsed,
  22656. * the input associated to the camera will be identical to the current ones
  22657. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  22658. */
  22659. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  22660. var inputs = {};
  22661. for (var cam in this.attached) {
  22662. var input = this.attached[cam];
  22663. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  22664. inputs[input.getClassName()] = res;
  22665. }
  22666. serializedCamera.inputsmgr = inputs;
  22667. };
  22668. /**
  22669. * Parses an input manager serialized JSON to restore the previous list of inputs
  22670. * and states associated to a camera.
  22671. * @param parsedCamera Defines the JSON to parse
  22672. */
  22673. CameraInputsManager.prototype.parse = function (parsedCamera) {
  22674. var parsedInputs = parsedCamera.inputsmgr;
  22675. if (parsedInputs) {
  22676. this.clear();
  22677. for (var n in parsedInputs) {
  22678. var construct = CameraInputTypes[n];
  22679. if (construct) {
  22680. var parsedinput = parsedInputs[n];
  22681. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  22682. this.add(input);
  22683. }
  22684. }
  22685. }
  22686. else {
  22687. //2016-03-08 this part is for managing backward compatibility
  22688. for (var n in this.attached) {
  22689. var construct = CameraInputTypes[this.attached[n].getClassName()];
  22690. if (construct) {
  22691. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  22692. this.remove(this.attached[n]);
  22693. this.add(input);
  22694. }
  22695. }
  22696. }
  22697. };
  22698. return CameraInputsManager;
  22699. }());
  22700. /***/ }),
  22701. /***/ "./Cameras/deviceOrientationCamera.ts":
  22702. /*!********************************************!*\
  22703. !*** ./Cameras/deviceOrientationCamera.ts ***!
  22704. \********************************************/
  22705. /*! exports provided: DeviceOrientationCamera */
  22706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22707. "use strict";
  22708. __webpack_require__.r(__webpack_exports__);
  22709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  22710. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22711. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22712. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  22713. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22714. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  22715. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  22716. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  22717. return function () { return new DeviceOrientationCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22718. });
  22719. // We're mainly based on the logic defined into the FreeCamera code
  22720. /**
  22721. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  22722. * being tilted forward or back and left or right.
  22723. */
  22724. var DeviceOrientationCamera = /** @class */ (function (_super) {
  22725. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  22726. /**
  22727. * Creates a new device orientation camera
  22728. * @param name The name of the camera
  22729. * @param position The start position camera
  22730. * @param scene The scene the camera belongs to
  22731. */
  22732. function DeviceOrientationCamera(name, position, scene) {
  22733. var _this = _super.call(this, name, position, scene) || this;
  22734. _this._tmpDragQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  22735. /**
  22736. * @hidden
  22737. * Disabled pointer input on first orientation sensor update (Default: true)
  22738. */
  22739. _this._disablePointerInputWhenUsingDeviceOrientation = true;
  22740. _this._dragFactor = 0;
  22741. _this._quaternionCache = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  22742. _this.inputs.addDeviceOrientation();
  22743. // When the orientation sensor fires it's first event, disable mouse input
  22744. if (_this.inputs._deviceOrientationInput) {
  22745. _this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function () {
  22746. if (_this._disablePointerInputWhenUsingDeviceOrientation) {
  22747. if (_this.inputs._mouseInput) {
  22748. _this.inputs._mouseInput._allowCameraRotation = false;
  22749. _this.inputs._mouseInput.onPointerMovedObservable.add(function (e) {
  22750. if (_this._dragFactor != 0) {
  22751. if (!_this._initialQuaternion) {
  22752. _this._initialQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  22753. }
  22754. // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
  22755. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromEulerAnglesToRef(0, e.offsetX * _this._dragFactor, 0, _this._tmpDragQuaternion);
  22756. _this._initialQuaternion.multiplyToRef(_this._tmpDragQuaternion, _this._initialQuaternion);
  22757. }
  22758. });
  22759. }
  22760. }
  22761. });
  22762. }
  22763. return _this;
  22764. }
  22765. /**
  22766. * Enabled turning on the y axis when the orientation sensor is active
  22767. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  22768. */
  22769. DeviceOrientationCamera.prototype.enableHorizontalDragging = function (dragFactor) {
  22770. if (dragFactor === void 0) { dragFactor = 1 / 300; }
  22771. this._dragFactor = dragFactor;
  22772. };
  22773. /**
  22774. * Gets the current instance class name ("DeviceOrientationCamera").
  22775. * This helps avoiding instanceof at run time.
  22776. * @returns the class name
  22777. */
  22778. DeviceOrientationCamera.prototype.getClassName = function () {
  22779. return "DeviceOrientationCamera";
  22780. };
  22781. /**
  22782. * @hidden
  22783. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  22784. */
  22785. DeviceOrientationCamera.prototype._checkInputs = function () {
  22786. _super.prototype._checkInputs.call(this);
  22787. this._quaternionCache.copyFrom(this.rotationQuaternion);
  22788. if (this._initialQuaternion) {
  22789. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  22790. }
  22791. };
  22792. /**
  22793. * Reset the camera to its default orientation on the specified axis only.
  22794. * @param axis The axis to reset
  22795. */
  22796. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  22797. var _this = this;
  22798. if (axis === void 0) { axis = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Y; }
  22799. //can only work if this camera has a rotation quaternion already.
  22800. if (!this.rotationQuaternion) {
  22801. return;
  22802. }
  22803. if (!this._initialQuaternion) {
  22804. this._initialQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  22805. }
  22806. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  22807. ['x', 'y', 'z'].forEach(function (axisName) {
  22808. if (!axis[axisName]) {
  22809. _this._initialQuaternion[axisName] = 0;
  22810. }
  22811. else {
  22812. _this._initialQuaternion[axisName] *= -1;
  22813. }
  22814. });
  22815. this._initialQuaternion.normalize();
  22816. //force rotation update
  22817. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  22818. };
  22819. return DeviceOrientationCamera;
  22820. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22821. /***/ }),
  22822. /***/ "./Cameras/flyCamera.ts":
  22823. /*!******************************!*\
  22824. !*** ./Cameras/flyCamera.ts ***!
  22825. \******************************/
  22826. /*! exports provided: FlyCamera */
  22827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22828. "use strict";
  22829. __webpack_require__.r(__webpack_exports__);
  22830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  22831. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22832. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22833. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  22834. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22835. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22836. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22837. /**
  22838. * This is a flying camera, designed for 3D movement and rotation in all directions,
  22839. * such as in a 3D Space Shooter or a Flight Simulator.
  22840. */
  22841. var FlyCamera = /** @class */ (function (_super) {
  22842. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  22843. /**
  22844. * Instantiates a FlyCamera.
  22845. * This is a flying camera, designed for 3D movement and rotation in all directions,
  22846. * such as in a 3D Space Shooter or a Flight Simulator.
  22847. * @param name Define the name of the camera in the scene.
  22848. * @param position Define the starting position of the camera in the scene.
  22849. * @param scene Define the scene the camera belongs to.
  22850. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  22851. */
  22852. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22853. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22854. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22855. /**
  22856. * Define the collision ellipsoid of the camera.
  22857. * This is helpful for simulating a camera body, like a player's body.
  22858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22859. */
  22860. _this.ellipsoid = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  22861. /**
  22862. * Define an offset for the position of the ellipsoid around the camera.
  22863. * This can be helpful if the camera is attached away from the player's body center,
  22864. * such as at its head.
  22865. */
  22866. _this.ellipsoidOffset = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22867. /**
  22868. * Enable or disable collisions of the camera with the rest of the scene objects.
  22869. */
  22870. _this.checkCollisions = false;
  22871. /**
  22872. * Enable or disable gravity on the camera.
  22873. */
  22874. _this.applyGravity = false;
  22875. /**
  22876. * Define the current direction the camera is moving to.
  22877. */
  22878. _this.cameraDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22879. /**
  22880. * Track Roll to maintain the wanted Rolling when looking around.
  22881. */
  22882. _this._trackRoll = 0;
  22883. /**
  22884. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  22885. */
  22886. _this.rollCorrect = 100;
  22887. /**
  22888. * Mimic a banked turn, Rolling the camera when Yawing.
  22889. * It's recommended to use rollCorrect = 10 for faster banking correction.
  22890. */
  22891. _this.bankedTurn = false;
  22892. /**
  22893. * Limit in radians for how much Roll banking will add. (Default: 90°)
  22894. */
  22895. _this.bankedTurnLimit = Math.PI / 2;
  22896. /**
  22897. * Value of 0 disables the banked Roll.
  22898. * Value of 1 is equal to the Yaw angle in radians.
  22899. */
  22900. _this.bankedTurnMultiplier = 1;
  22901. _this._needMoveForGravity = false;
  22902. _this._oldPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22903. _this._diffPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22904. _this._newPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22905. // Collisions.
  22906. _this._collisionMask = -1;
  22907. /** @hidden */
  22908. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22909. if (collidedMesh === void 0) { collidedMesh = null; }
  22910. var updatePosition = function (newPos) {
  22911. _this._newPosition.copyFrom(newPos);
  22912. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22913. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22914. _this.position.addInPlace(_this._diffPosition);
  22915. if (_this.onCollide && collidedMesh) {
  22916. _this.onCollide(collidedMesh);
  22917. }
  22918. }
  22919. };
  22920. updatePosition(newPosition);
  22921. };
  22922. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  22923. _this.inputs.addKeyboard().addMouse();
  22924. return _this;
  22925. }
  22926. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  22927. /**
  22928. * Gets the input sensibility for mouse input.
  22929. * Higher values reduce sensitivity.
  22930. */
  22931. get: function () {
  22932. var mouse = this.inputs.attached["mouse"];
  22933. if (mouse) {
  22934. return mouse.angularSensibility;
  22935. }
  22936. return 0;
  22937. },
  22938. /**
  22939. * Sets the input sensibility for a mouse input.
  22940. * Higher values reduce sensitivity.
  22941. */
  22942. set: function (value) {
  22943. var mouse = this.inputs.attached["mouse"];
  22944. if (mouse) {
  22945. mouse.angularSensibility = value;
  22946. }
  22947. },
  22948. enumerable: true,
  22949. configurable: true
  22950. });
  22951. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  22952. /**
  22953. * Get the keys for camera movement forward.
  22954. */
  22955. get: function () {
  22956. var keyboard = this.inputs.attached["keyboard"];
  22957. if (keyboard) {
  22958. return keyboard.keysForward;
  22959. }
  22960. return [];
  22961. },
  22962. /**
  22963. * Set the keys for camera movement forward.
  22964. */
  22965. set: function (value) {
  22966. var keyboard = this.inputs.attached["keyboard"];
  22967. if (keyboard) {
  22968. keyboard.keysForward = value;
  22969. }
  22970. },
  22971. enumerable: true,
  22972. configurable: true
  22973. });
  22974. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22975. /**
  22976. * Get the keys for camera movement backward.
  22977. */
  22978. get: function () {
  22979. var keyboard = this.inputs.attached["keyboard"];
  22980. if (keyboard) {
  22981. return keyboard.keysBackward;
  22982. }
  22983. return [];
  22984. },
  22985. set: function (value) {
  22986. var keyboard = this.inputs.attached["keyboard"];
  22987. if (keyboard) {
  22988. keyboard.keysBackward = value;
  22989. }
  22990. },
  22991. enumerable: true,
  22992. configurable: true
  22993. });
  22994. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22995. /**
  22996. * Get the keys for camera movement up.
  22997. */
  22998. get: function () {
  22999. var keyboard = this.inputs.attached["keyboard"];
  23000. if (keyboard) {
  23001. return keyboard.keysUp;
  23002. }
  23003. return [];
  23004. },
  23005. /**
  23006. * Set the keys for camera movement up.
  23007. */
  23008. set: function (value) {
  23009. var keyboard = this.inputs.attached["keyboard"];
  23010. if (keyboard) {
  23011. keyboard.keysUp = value;
  23012. }
  23013. },
  23014. enumerable: true,
  23015. configurable: true
  23016. });
  23017. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  23018. /**
  23019. * Get the keys for camera movement down.
  23020. */
  23021. get: function () {
  23022. var keyboard = this.inputs.attached["keyboard"];
  23023. if (keyboard) {
  23024. return keyboard.keysDown;
  23025. }
  23026. return [];
  23027. },
  23028. /**
  23029. * Set the keys for camera movement down.
  23030. */
  23031. set: function (value) {
  23032. var keyboard = this.inputs.attached["keyboard"];
  23033. if (keyboard) {
  23034. keyboard.keysDown = value;
  23035. }
  23036. },
  23037. enumerable: true,
  23038. configurable: true
  23039. });
  23040. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  23041. /**
  23042. * Get the keys for camera movement left.
  23043. */
  23044. get: function () {
  23045. var keyboard = this.inputs.attached["keyboard"];
  23046. if (keyboard) {
  23047. return keyboard.keysLeft;
  23048. }
  23049. return [];
  23050. },
  23051. /**
  23052. * Set the keys for camera movement left.
  23053. */
  23054. set: function (value) {
  23055. var keyboard = this.inputs.attached["keyboard"];
  23056. if (keyboard) {
  23057. keyboard.keysLeft = value;
  23058. }
  23059. },
  23060. enumerable: true,
  23061. configurable: true
  23062. });
  23063. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  23064. /**
  23065. * Set the keys for camera movement right.
  23066. */
  23067. get: function () {
  23068. var keyboard = this.inputs.attached["keyboard"];
  23069. if (keyboard) {
  23070. return keyboard.keysRight;
  23071. }
  23072. return [];
  23073. },
  23074. /**
  23075. * Set the keys for camera movement right.
  23076. */
  23077. set: function (value) {
  23078. var keyboard = this.inputs.attached["keyboard"];
  23079. if (keyboard) {
  23080. keyboard.keysRight = value;
  23081. }
  23082. },
  23083. enumerable: true,
  23084. configurable: true
  23085. });
  23086. /**
  23087. * Attach a control to the HTML DOM element.
  23088. * @param element Defines the element that listens to the input events.
  23089. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  23090. */
  23091. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  23092. this.inputs.attachElement(element, noPreventDefault);
  23093. };
  23094. /**
  23095. * Detach a control from the HTML DOM element.
  23096. * The camera will stop reacting to that input.
  23097. * @param element Defines the element that listens to the input events.
  23098. */
  23099. FlyCamera.prototype.detachControl = function (element) {
  23100. this.inputs.detachElement(element);
  23101. this.cameraDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  23102. };
  23103. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  23104. /**
  23105. * Get the mask that the camera ignores in collision events.
  23106. */
  23107. get: function () {
  23108. return this._collisionMask;
  23109. },
  23110. /**
  23111. * Set the mask that the camera ignores in collision events.
  23112. */
  23113. set: function (mask) {
  23114. this._collisionMask = !isNaN(mask) ? mask : -1;
  23115. },
  23116. enumerable: true,
  23117. configurable: true
  23118. });
  23119. /** @hidden */
  23120. FlyCamera.prototype._collideWithWorld = function (displacement) {
  23121. var globalPosition;
  23122. if (this.parent) {
  23123. globalPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  23124. }
  23125. else {
  23126. globalPosition = this.position;
  23127. }
  23128. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  23129. this._oldPosition.addInPlace(this.ellipsoidOffset);
  23130. var coordinator = this.getScene().collisionCoordinator;
  23131. if (!this._collider) {
  23132. this._collider = coordinator.createCollider();
  23133. }
  23134. this._collider._radius = this.ellipsoid;
  23135. this._collider.collisionMask = this._collisionMask;
  23136. // No need for clone, as long as gravity is not on.
  23137. var actualDisplacement = displacement;
  23138. // Add gravity to direction to prevent dual-collision checking.
  23139. if (this.applyGravity) {
  23140. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  23141. actualDisplacement = displacement.add(this.getScene().gravity);
  23142. }
  23143. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  23144. };
  23145. /** @hidden */
  23146. FlyCamera.prototype._checkInputs = function () {
  23147. if (!this._localDirection) {
  23148. this._localDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23149. this._transformedDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23150. }
  23151. this.inputs.checkInputs();
  23152. _super.prototype._checkInputs.call(this);
  23153. };
  23154. /** @hidden */
  23155. FlyCamera.prototype._decideIfNeedsToMove = function () {
  23156. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23157. };
  23158. /** @hidden */
  23159. FlyCamera.prototype._updatePosition = function () {
  23160. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  23161. this._collideWithWorld(this.cameraDirection);
  23162. }
  23163. else {
  23164. _super.prototype._updatePosition.call(this);
  23165. }
  23166. };
  23167. /**
  23168. * Restore the Roll to its target value at the rate specified.
  23169. * @param rate - Higher means slower restoring.
  23170. * @hidden
  23171. */
  23172. FlyCamera.prototype.restoreRoll = function (rate) {
  23173. var limit = this._trackRoll; // Target Roll.
  23174. var z = this.rotation.z; // Current Roll.
  23175. var delta = limit - z; // Difference in Roll.
  23176. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  23177. // If the difference is noticable, restore the Roll.
  23178. if (Math.abs(delta) >= minRad) {
  23179. // Change Z rotation towards the target Roll.
  23180. this.rotation.z += delta / rate;
  23181. // Match when near enough.
  23182. if (Math.abs(limit - this.rotation.z) <= minRad) {
  23183. this.rotation.z = limit;
  23184. }
  23185. }
  23186. };
  23187. /**
  23188. * Destroy the camera and release the current resources held by it.
  23189. */
  23190. FlyCamera.prototype.dispose = function () {
  23191. this.inputs.clear();
  23192. _super.prototype.dispose.call(this);
  23193. };
  23194. /**
  23195. * Get the current object class name.
  23196. * @returns the class name.
  23197. */
  23198. FlyCamera.prototype.getClassName = function () {
  23199. return "FlyCamera";
  23200. };
  23201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23203. ], FlyCamera.prototype, "ellipsoid", void 0);
  23204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23206. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  23207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23209. ], FlyCamera.prototype, "checkCollisions", void 0);
  23210. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23211. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23212. ], FlyCamera.prototype, "applyGravity", void 0);
  23213. return FlyCamera;
  23214. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  23215. /***/ }),
  23216. /***/ "./Cameras/flyCameraInputsManager.ts":
  23217. /*!*******************************************!*\
  23218. !*** ./Cameras/flyCameraInputsManager.ts ***!
  23219. \*******************************************/
  23220. /*! exports provided: FlyCameraInputsManager */
  23221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23222. "use strict";
  23223. __webpack_require__.r(__webpack_exports__);
  23224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  23225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23226. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23227. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  23228. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  23229. /**
  23230. * Default Inputs manager for the FlyCamera.
  23231. * It groups all the default supported inputs for ease of use.
  23232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23233. */
  23234. var FlyCameraInputsManager = /** @class */ (function (_super) {
  23235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  23236. /**
  23237. * Instantiates a new FlyCameraInputsManager.
  23238. * @param camera Defines the camera the inputs belong to.
  23239. */
  23240. function FlyCameraInputsManager(camera) {
  23241. return _super.call(this, camera) || this;
  23242. }
  23243. /**
  23244. * Add keyboard input support to the input manager.
  23245. * @returns the new FlyCameraKeyboardMoveInput().
  23246. */
  23247. FlyCameraInputsManager.prototype.addKeyboard = function () {
  23248. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  23249. return this;
  23250. };
  23251. /**
  23252. * Add mouse input support to the input manager.
  23253. * @param touchEnabled Enable touch screen support.
  23254. * @returns the new FlyCameraMouseInput().
  23255. */
  23256. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23257. if (touchEnabled === void 0) { touchEnabled = true; }
  23258. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  23259. return this;
  23260. };
  23261. return FlyCameraInputsManager;
  23262. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23263. /***/ }),
  23264. /***/ "./Cameras/followCamera.ts":
  23265. /*!*********************************!*\
  23266. !*** ./Cameras/followCamera.ts ***!
  23267. \*********************************/
  23268. /*! exports provided: FollowCamera, ArcFollowCamera */
  23269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23270. "use strict";
  23271. __webpack_require__.r(__webpack_exports__);
  23272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  23273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  23274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23275. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23276. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  23277. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23278. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  23279. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  23280. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  23281. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  23282. return function () { return new FollowCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  23283. });
  23284. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  23285. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  23286. });
  23287. /**
  23288. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  23289. * an arc rotate version arcFollowCamera are available.
  23290. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  23291. */
  23292. var FollowCamera = /** @class */ (function (_super) {
  23293. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  23294. /**
  23295. * Instantiates the follow camera.
  23296. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  23297. * @param name Define the name of the camera in the scene
  23298. * @param position Define the position of the camera
  23299. * @param scene Define the scene the camera belong to
  23300. * @param lockedTarget Define the target of the camera
  23301. */
  23302. function FollowCamera(name, position, scene, lockedTarget) {
  23303. if (lockedTarget === void 0) { lockedTarget = null; }
  23304. var _this = _super.call(this, name, position, scene) || this;
  23305. /**
  23306. * Distance the follow camera should follow an object at
  23307. */
  23308. _this.radius = 12;
  23309. /**
  23310. * Minimum allowed distance of the camera to the axis of rotation
  23311. * (The camera can not get closer).
  23312. * This can help limiting how the Camera is able to move in the scene.
  23313. */
  23314. _this.lowerRadiusLimit = null;
  23315. /**
  23316. * Maximum allowed distance of the camera to the axis of rotation
  23317. * (The camera can not get further).
  23318. * This can help limiting how the Camera is able to move in the scene.
  23319. */
  23320. _this.upperRadiusLimit = null;
  23321. /**
  23322. * Define a rotation offset between the camera and the object it follows
  23323. */
  23324. _this.rotationOffset = 0;
  23325. /**
  23326. * Minimum allowed angle to camera position relative to target object.
  23327. * This can help limiting how the Camera is able to move in the scene.
  23328. */
  23329. _this.lowerRotationOffsetLimit = null;
  23330. /**
  23331. * Maximum allowed angle to camera position relative to target object.
  23332. * This can help limiting how the Camera is able to move in the scene.
  23333. */
  23334. _this.upperRotationOffsetLimit = null;
  23335. /**
  23336. * Define a height offset between the camera and the object it follows.
  23337. * It can help following an object from the top (like a car chaing a plane)
  23338. */
  23339. _this.heightOffset = 4;
  23340. /**
  23341. * Minimum allowed height of camera position relative to target object.
  23342. * This can help limiting how the Camera is able to move in the scene.
  23343. */
  23344. _this.lowerHeightOffsetLimit = null;
  23345. /**
  23346. * Maximum allowed height of camera position relative to target object.
  23347. * This can help limiting how the Camera is able to move in the scene.
  23348. */
  23349. _this.upperHeightOffsetLimit = null;
  23350. /**
  23351. * Define how fast the camera can accelerate to follow it s target.
  23352. */
  23353. _this.cameraAcceleration = 0.05;
  23354. /**
  23355. * Define the speed limit of the camera following an object.
  23356. */
  23357. _this.maxCameraSpeed = 20;
  23358. _this.lockedTarget = lockedTarget;
  23359. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  23360. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  23361. return _this;
  23362. // Uncomment the following line when the relevant handlers have been implemented.
  23363. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  23364. }
  23365. FollowCamera.prototype._follow = function (cameraTarget) {
  23366. if (!cameraTarget) {
  23367. return;
  23368. }
  23369. var yRotation;
  23370. if (cameraTarget.rotationQuaternion) {
  23371. var rotMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  23372. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  23373. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  23374. }
  23375. else {
  23376. yRotation = cameraTarget.rotation.y;
  23377. }
  23378. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  23379. var targetPosition = cameraTarget.getAbsolutePosition();
  23380. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  23381. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  23382. var dx = targetX - this.position.x;
  23383. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  23384. var dz = (targetZ) - this.position.z;
  23385. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  23386. var vy = dy * this.cameraAcceleration;
  23387. var vz = dz * this.cameraAcceleration * 2;
  23388. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  23389. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  23390. }
  23391. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  23392. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  23393. }
  23394. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  23395. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  23396. }
  23397. this.position = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  23398. this.setTarget(targetPosition);
  23399. };
  23400. /**
  23401. * Attached controls to the current camera.
  23402. * @param element Defines the element the controls should be listened from
  23403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23404. */
  23405. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  23406. this.inputs.attachElement(element, noPreventDefault);
  23407. this._reset = function () {
  23408. };
  23409. };
  23410. /**
  23411. * Detach the current controls from the camera.
  23412. * The camera will stop reacting to inputs.
  23413. * @param element Defines the element to stop listening the inputs from
  23414. */
  23415. FollowCamera.prototype.detachControl = function (element) {
  23416. this.inputs.detachElement(element);
  23417. if (this._reset) {
  23418. this._reset();
  23419. }
  23420. };
  23421. /** @hidden */
  23422. FollowCamera.prototype._checkInputs = function () {
  23423. this.inputs.checkInputs();
  23424. this._checkLimits();
  23425. _super.prototype._checkInputs.call(this);
  23426. if (this.lockedTarget) {
  23427. this._follow(this.lockedTarget);
  23428. }
  23429. };
  23430. FollowCamera.prototype._checkLimits = function () {
  23431. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  23432. this.radius = this.lowerRadiusLimit;
  23433. }
  23434. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  23435. this.radius = this.upperRadiusLimit;
  23436. }
  23437. if (this.lowerHeightOffsetLimit !== null &&
  23438. this.heightOffset < this.lowerHeightOffsetLimit) {
  23439. this.heightOffset = this.lowerHeightOffsetLimit;
  23440. }
  23441. if (this.upperHeightOffsetLimit !== null &&
  23442. this.heightOffset > this.upperHeightOffsetLimit) {
  23443. this.heightOffset = this.upperHeightOffsetLimit;
  23444. }
  23445. if (this.lowerRotationOffsetLimit !== null &&
  23446. this.rotationOffset < this.lowerRotationOffsetLimit) {
  23447. this.rotationOffset = this.lowerRotationOffsetLimit;
  23448. }
  23449. if (this.upperRotationOffsetLimit !== null &&
  23450. this.rotationOffset > this.upperRotationOffsetLimit) {
  23451. this.rotationOffset = this.upperRotationOffsetLimit;
  23452. }
  23453. };
  23454. /**
  23455. * Gets the camera class name.
  23456. * @returns the class name
  23457. */
  23458. FollowCamera.prototype.getClassName = function () {
  23459. return "FollowCamera";
  23460. };
  23461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23463. ], FollowCamera.prototype, "radius", void 0);
  23464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23466. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  23467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23469. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  23470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23472. ], FollowCamera.prototype, "rotationOffset", void 0);
  23473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23475. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  23476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23478. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  23479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23481. ], FollowCamera.prototype, "heightOffset", void 0);
  23482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23484. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  23485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23487. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  23488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23490. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  23491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23493. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  23494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23496. ], FollowCamera.prototype, "lockedTarget", void 0);
  23497. return FollowCamera;
  23498. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  23499. /**
  23500. * Arc Rotate version of the follow camera.
  23501. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  23502. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  23503. */
  23504. var ArcFollowCamera = /** @class */ (function (_super) {
  23505. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  23506. /**
  23507. * Instantiates a new ArcFollowCamera
  23508. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  23509. * @param name Define the name of the camera
  23510. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  23511. * @param beta Define the rotation angle of the camera around the elevation axis
  23512. * @param radius Define the radius of the camera from its target point
  23513. * @param target Define the target of the camera
  23514. * @param scene Define the scene the camera belongs to
  23515. */
  23516. function ArcFollowCamera(name,
  23517. /** The longitudinal angle of the camera */
  23518. alpha,
  23519. /** The latitudinal angle of the camera */
  23520. beta,
  23521. /** The radius of the camera from its target */
  23522. radius,
  23523. /** Define the camera target (the messh it should follow) */
  23524. target, scene) {
  23525. var _this = _super.call(this, name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  23526. _this.alpha = alpha;
  23527. _this.beta = beta;
  23528. _this.radius = radius;
  23529. _this.target = target;
  23530. _this._cartesianCoordinates = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  23531. _this._follow();
  23532. return _this;
  23533. }
  23534. ArcFollowCamera.prototype._follow = function () {
  23535. if (!this.target) {
  23536. return;
  23537. }
  23538. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  23539. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  23540. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  23541. var targetPosition = this.target.getAbsolutePosition();
  23542. this.position = targetPosition.add(this._cartesianCoordinates);
  23543. this.setTarget(targetPosition);
  23544. };
  23545. /** @hidden */
  23546. ArcFollowCamera.prototype._checkInputs = function () {
  23547. _super.prototype._checkInputs.call(this);
  23548. this._follow();
  23549. };
  23550. /**
  23551. * Returns the class name of the object.
  23552. * It is mostly used internally for serialization purposes.
  23553. */
  23554. ArcFollowCamera.prototype.getClassName = function () {
  23555. return "ArcFollowCamera";
  23556. };
  23557. return ArcFollowCamera;
  23558. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  23559. /***/ }),
  23560. /***/ "./Cameras/followCameraInputsManager.ts":
  23561. /*!**********************************************!*\
  23562. !*** ./Cameras/followCameraInputsManager.ts ***!
  23563. \**********************************************/
  23564. /*! exports provided: FollowCameraInputsManager */
  23565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23566. "use strict";
  23567. __webpack_require__.r(__webpack_exports__);
  23568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  23569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23570. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23571. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  23572. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  23573. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  23574. /**
  23575. * Default Inputs manager for the FollowCamera.
  23576. * It groups all the default supported inputs for ease of use.
  23577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23578. */
  23579. var FollowCameraInputsManager = /** @class */ (function (_super) {
  23580. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  23581. /**
  23582. * Instantiates a new FollowCameraInputsManager.
  23583. * @param camera Defines the camera the inputs belong to
  23584. */
  23585. function FollowCameraInputsManager(camera) {
  23586. return _super.call(this, camera) || this;
  23587. }
  23588. /**
  23589. * Add keyboard input support to the input manager.
  23590. * @returns the current input manager
  23591. */
  23592. FollowCameraInputsManager.prototype.addKeyboard = function () {
  23593. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  23594. return this;
  23595. };
  23596. /**
  23597. * Add mouse wheel input support to the input manager.
  23598. * @returns the current input manager
  23599. */
  23600. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  23601. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  23602. return this;
  23603. };
  23604. /**
  23605. * Add pointers input support to the input manager.
  23606. * @returns the current input manager
  23607. */
  23608. FollowCameraInputsManager.prototype.addPointers = function () {
  23609. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  23610. return this;
  23611. };
  23612. /**
  23613. * Add orientation input support to the input manager.
  23614. * @returns the current input manager
  23615. */
  23616. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  23617. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  23618. return this;
  23619. };
  23620. return FollowCameraInputsManager;
  23621. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23622. /***/ }),
  23623. /***/ "./Cameras/freeCamera.ts":
  23624. /*!*******************************!*\
  23625. !*** ./Cameras/freeCamera.ts ***!
  23626. \*******************************/
  23627. /*! exports provided: FreeCamera */
  23628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23629. "use strict";
  23630. __webpack_require__.r(__webpack_exports__);
  23631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  23632. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23633. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23634. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  23635. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23636. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23637. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23638. /**
  23639. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23640. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  23641. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23642. */
  23643. var FreeCamera = /** @class */ (function (_super) {
  23644. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  23645. /**
  23646. * Instantiates a Free Camera.
  23647. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23648. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  23649. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23650. * @param name Define the name of the camera in the scene
  23651. * @param position Define the start position of the camera in the scene
  23652. * @param scene Define the scene the camera belongs to
  23653. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23654. */
  23655. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23656. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23657. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23658. /**
  23659. * Define the collision ellipsoid of the camera.
  23660. * This is helpful to simulate a camera body like the player body around the camera
  23661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  23662. */
  23663. _this.ellipsoid = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  23664. /**
  23665. * Define an offset for the position of the ellipsoid around the camera.
  23666. * This can be helpful to determine the center of the body near the gravity center of the body
  23667. * instead of its head.
  23668. */
  23669. _this.ellipsoidOffset = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  23670. /**
  23671. * Enable or disable collisions of the camera with the rest of the scene objects.
  23672. */
  23673. _this.checkCollisions = false;
  23674. /**
  23675. * Enable or disable gravity on the camera.
  23676. */
  23677. _this.applyGravity = false;
  23678. _this._needMoveForGravity = false;
  23679. _this._oldPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23680. _this._diffPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23681. _this._newPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23682. // Collisions
  23683. _this._collisionMask = -1;
  23684. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  23685. if (collidedMesh === void 0) { collidedMesh = null; }
  23686. var updatePosition = function (newPos) {
  23687. _this._newPosition.copyFrom(newPos);
  23688. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  23689. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  23690. _this.position.addInPlace(_this._diffPosition);
  23691. if (_this.onCollide && collidedMesh) {
  23692. _this.onCollide(collidedMesh);
  23693. }
  23694. }
  23695. };
  23696. updatePosition(newPosition);
  23697. };
  23698. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  23699. _this.inputs.addKeyboard().addMouse();
  23700. return _this;
  23701. }
  23702. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  23703. /**
  23704. * Gets the input sensibility for a mouse input. (default is 2000.0)
  23705. * Higher values reduce sensitivity.
  23706. */
  23707. get: function () {
  23708. var mouse = this.inputs.attached["mouse"];
  23709. if (mouse) {
  23710. return mouse.angularSensibility;
  23711. }
  23712. return 0;
  23713. },
  23714. /**
  23715. * Sets the input sensibility for a mouse input. (default is 2000.0)
  23716. * Higher values reduce sensitivity.
  23717. */
  23718. set: function (value) {
  23719. var mouse = this.inputs.attached["mouse"];
  23720. if (mouse) {
  23721. mouse.angularSensibility = value;
  23722. }
  23723. },
  23724. enumerable: true,
  23725. configurable: true
  23726. });
  23727. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  23728. /**
  23729. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  23730. */
  23731. get: function () {
  23732. var keyboard = this.inputs.attached["keyboard"];
  23733. if (keyboard) {
  23734. return keyboard.keysUp;
  23735. }
  23736. return [];
  23737. },
  23738. set: function (value) {
  23739. var keyboard = this.inputs.attached["keyboard"];
  23740. if (keyboard) {
  23741. keyboard.keysUp = value;
  23742. }
  23743. },
  23744. enumerable: true,
  23745. configurable: true
  23746. });
  23747. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  23748. /**
  23749. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  23750. */
  23751. get: function () {
  23752. var keyboard = this.inputs.attached["keyboard"];
  23753. if (keyboard) {
  23754. return keyboard.keysDown;
  23755. }
  23756. return [];
  23757. },
  23758. set: function (value) {
  23759. var keyboard = this.inputs.attached["keyboard"];
  23760. if (keyboard) {
  23761. keyboard.keysDown = value;
  23762. }
  23763. },
  23764. enumerable: true,
  23765. configurable: true
  23766. });
  23767. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  23768. /**
  23769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  23770. */
  23771. get: function () {
  23772. var keyboard = this.inputs.attached["keyboard"];
  23773. if (keyboard) {
  23774. return keyboard.keysLeft;
  23775. }
  23776. return [];
  23777. },
  23778. set: function (value) {
  23779. var keyboard = this.inputs.attached["keyboard"];
  23780. if (keyboard) {
  23781. keyboard.keysLeft = value;
  23782. }
  23783. },
  23784. enumerable: true,
  23785. configurable: true
  23786. });
  23787. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  23788. /**
  23789. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  23790. */
  23791. get: function () {
  23792. var keyboard = this.inputs.attached["keyboard"];
  23793. if (keyboard) {
  23794. return keyboard.keysRight;
  23795. }
  23796. return [];
  23797. },
  23798. set: function (value) {
  23799. var keyboard = this.inputs.attached["keyboard"];
  23800. if (keyboard) {
  23801. keyboard.keysRight = value;
  23802. }
  23803. },
  23804. enumerable: true,
  23805. configurable: true
  23806. });
  23807. /**
  23808. * Attached controls to the current camera.
  23809. * @param element Defines the element the controls should be listened from
  23810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23811. */
  23812. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  23813. this.inputs.attachElement(element, noPreventDefault);
  23814. };
  23815. /**
  23816. * Detach the current controls from the camera.
  23817. * The camera will stop reacting to inputs.
  23818. * @param element Defines the element to stop listening the inputs from
  23819. */
  23820. FreeCamera.prototype.detachControl = function (element) {
  23821. this.inputs.detachElement(element);
  23822. this.cameraDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  23823. this.cameraRotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  23824. };
  23825. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  23826. /**
  23827. * Define a collision mask to limit the list of object the camera can collide with
  23828. */
  23829. get: function () {
  23830. return this._collisionMask;
  23831. },
  23832. set: function (mask) {
  23833. this._collisionMask = !isNaN(mask) ? mask : -1;
  23834. },
  23835. enumerable: true,
  23836. configurable: true
  23837. });
  23838. /** @hidden */
  23839. FreeCamera.prototype._collideWithWorld = function (displacement) {
  23840. var globalPosition;
  23841. if (this.parent) {
  23842. globalPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  23843. }
  23844. else {
  23845. globalPosition = this.position;
  23846. }
  23847. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  23848. this._oldPosition.addInPlace(this.ellipsoidOffset);
  23849. var coordinator = this.getScene().collisionCoordinator;
  23850. if (!this._collider) {
  23851. this._collider = coordinator.createCollider();
  23852. }
  23853. this._collider._radius = this.ellipsoid;
  23854. this._collider.collisionMask = this._collisionMask;
  23855. //no need for clone, as long as gravity is not on.
  23856. var actualDisplacement = displacement;
  23857. //add gravity to the direction to prevent the dual-collision checking
  23858. if (this.applyGravity) {
  23859. //this prevents mending with cameraDirection, a global variable of the free camera class.
  23860. actualDisplacement = displacement.add(this.getScene().gravity);
  23861. }
  23862. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  23863. };
  23864. /** @hidden */
  23865. FreeCamera.prototype._checkInputs = function () {
  23866. if (!this._localDirection) {
  23867. this._localDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23868. this._transformedDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23869. }
  23870. this.inputs.checkInputs();
  23871. _super.prototype._checkInputs.call(this);
  23872. };
  23873. /** @hidden */
  23874. FreeCamera.prototype._decideIfNeedsToMove = function () {
  23875. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23876. };
  23877. /** @hidden */
  23878. FreeCamera.prototype._updatePosition = function () {
  23879. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  23880. this._collideWithWorld(this.cameraDirection);
  23881. }
  23882. else {
  23883. _super.prototype._updatePosition.call(this);
  23884. }
  23885. };
  23886. /**
  23887. * Destroy the camera and release the current resources hold by it.
  23888. */
  23889. FreeCamera.prototype.dispose = function () {
  23890. this.inputs.clear();
  23891. _super.prototype.dispose.call(this);
  23892. };
  23893. /**
  23894. * Gets the current object class name.
  23895. * @return the class name
  23896. */
  23897. FreeCamera.prototype.getClassName = function () {
  23898. return "FreeCamera";
  23899. };
  23900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23902. ], FreeCamera.prototype, "ellipsoid", void 0);
  23903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23905. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  23906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23908. ], FreeCamera.prototype, "checkCollisions", void 0);
  23909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23911. ], FreeCamera.prototype, "applyGravity", void 0);
  23912. return FreeCamera;
  23913. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  23914. /***/ }),
  23915. /***/ "./Cameras/freeCameraInputsManager.ts":
  23916. /*!********************************************!*\
  23917. !*** ./Cameras/freeCameraInputsManager.ts ***!
  23918. \********************************************/
  23919. /*! exports provided: FreeCameraInputsManager */
  23920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23921. "use strict";
  23922. __webpack_require__.r(__webpack_exports__);
  23923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  23924. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23925. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23926. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  23927. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  23928. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  23929. /**
  23930. * Default Inputs manager for the FreeCamera.
  23931. * It groups all the default supported inputs for ease of use.
  23932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23933. */
  23934. var FreeCameraInputsManager = /** @class */ (function (_super) {
  23935. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  23936. /**
  23937. * Instantiates a new FreeCameraInputsManager.
  23938. * @param camera Defines the camera the inputs belong to
  23939. */
  23940. function FreeCameraInputsManager(camera) {
  23941. var _this = _super.call(this, camera) || this;
  23942. /**
  23943. * @hidden
  23944. */
  23945. _this._mouseInput = null;
  23946. return _this;
  23947. }
  23948. /**
  23949. * Add keyboard input support to the input manager.
  23950. * @returns the current input manager
  23951. */
  23952. FreeCameraInputsManager.prototype.addKeyboard = function () {
  23953. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  23954. return this;
  23955. };
  23956. /**
  23957. * Add mouse input support to the input manager.
  23958. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  23959. * @returns the current input manager
  23960. */
  23961. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23962. if (touchEnabled === void 0) { touchEnabled = true; }
  23963. if (!this._mouseInput) {
  23964. this._mouseInput = new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled);
  23965. this.add(this._mouseInput);
  23966. }
  23967. return this;
  23968. };
  23969. /**
  23970. * Removes the mouse input support from the manager
  23971. * @returns the current input manager
  23972. */
  23973. FreeCameraInputsManager.prototype.removeMouse = function () {
  23974. if (this._mouseInput) {
  23975. this.remove(this._mouseInput);
  23976. }
  23977. return this;
  23978. };
  23979. /**
  23980. * Add touch input support to the input manager.
  23981. * @returns the current input manager
  23982. */
  23983. FreeCameraInputsManager.prototype.addTouch = function () {
  23984. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23985. return this;
  23986. };
  23987. /**
  23988. * Remove all attached input methods from a camera
  23989. */
  23990. FreeCameraInputsManager.prototype.clear = function () {
  23991. _super.prototype.clear.call(this);
  23992. this._mouseInput = null;
  23993. };
  23994. return FreeCameraInputsManager;
  23995. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23996. /***/ }),
  23997. /***/ "./Cameras/gamepadCamera.ts":
  23998. /*!**********************************!*\
  23999. !*** ./Cameras/gamepadCamera.ts ***!
  24000. \**********************************/
  24001. /*! exports provided: GamepadCamera */
  24002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24003. "use strict";
  24004. __webpack_require__.r(__webpack_exports__);
  24005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  24006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  24007. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  24008. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  24009. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  24010. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  24011. return function () { return new GamepadCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  24012. });
  24013. /**
  24014. * This represents a FPS type of camera. This is only here for back compat purpose.
  24015. * Please use the UniversalCamera instead as both are identical.
  24016. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  24017. */
  24018. var GamepadCamera = /** @class */ (function (_super) {
  24019. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  24020. /**
  24021. * Instantiates a new Gamepad Camera
  24022. * This represents a FPS type of camera. This is only here for back compat purpose.
  24023. * Please use the UniversalCamera instead as both are identical.
  24024. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  24025. * @param name Define the name of the camera in the scene
  24026. * @param position Define the start position of the camera in the scene
  24027. * @param scene Define the scene the camera belongs to
  24028. */
  24029. function GamepadCamera(name, position, scene) {
  24030. return _super.call(this, name, position, scene) || this;
  24031. }
  24032. /**
  24033. * Gets the current object class name.
  24034. * @return the class name
  24035. */
  24036. GamepadCamera.prototype.getClassName = function () {
  24037. return "GamepadCamera";
  24038. };
  24039. return GamepadCamera;
  24040. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  24041. /***/ }),
  24042. /***/ "./Cameras/index.ts":
  24043. /*!**************************!*\
  24044. !*** ./Cameras/index.ts ***!
  24045. \**************************/
  24046. /*! 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, WebXRInput, WebXRControllerTeleportation, WebXRControllerPointerSelection, WebXRControllerModelLoader, WebXRController, WebXRManagedOutputCanvas, WebXRSessionManager */
  24047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24048. "use strict";
  24049. __webpack_require__.r(__webpack_exports__);
  24050. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  24051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  24052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  24053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  24054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  24055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  24056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  24057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  24058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  24059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  24060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  24061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  24062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  24063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  24064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  24065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  24066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  24067. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  24068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  24069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  24070. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  24071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  24072. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  24073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  24074. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  24075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  24076. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  24077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  24078. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  24079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  24080. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  24081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  24082. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  24083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  24084. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  24085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  24086. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  24087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  24088. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  24089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  24090. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  24091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  24092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  24093. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  24094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  24095. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  24096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  24097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  24098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  24099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  24100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  24101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  24102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  24103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  24104. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  24105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  24106. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  24107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  24108. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  24109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  24110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  24111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  24112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  24113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  24114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  24115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  24116. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  24117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  24118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  24119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  24120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  24121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  24122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  24123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  24124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerTeleportation", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRControllerTeleportation"]; });
  24125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerPointerSelection", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRControllerPointerSelection"]; });
  24126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerModelLoader", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRControllerModelLoader"]; });
  24127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  24128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  24129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  24130. /***/ }),
  24131. /***/ "./Cameras/targetCamera.ts":
  24132. /*!*********************************!*\
  24133. !*** ./Cameras/targetCamera.ts ***!
  24134. \*********************************/
  24135. /*! exports provided: TargetCamera */
  24136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24137. "use strict";
  24138. __webpack_require__.r(__webpack_exports__);
  24139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  24140. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  24141. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  24142. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  24143. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  24144. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  24145. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  24146. /**
  24147. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  24148. * This is the base of the follow, arc rotate cameras and Free camera
  24149. * @see http://doc.babylonjs.com/features/cameras
  24150. */
  24151. var TargetCamera = /** @class */ (function (_super) {
  24152. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  24153. /**
  24154. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  24155. * This is the base of the follow, arc rotate cameras and Free camera
  24156. * @see http://doc.babylonjs.com/features/cameras
  24157. * @param name Defines the name of the camera in the scene
  24158. * @param position Defines the start position of the camera in the scene
  24159. * @param scene Defines the scene the camera belongs to
  24160. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24161. */
  24162. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  24163. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  24164. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  24165. /**
  24166. * Define the current direction the camera is moving to
  24167. */
  24168. _this.cameraDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  24169. /**
  24170. * Define the current rotation the camera is rotating to
  24171. */
  24172. _this.cameraRotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  24173. /**
  24174. * When set, the up vector of the camera will be updated by the rotation of the camera
  24175. */
  24176. _this.updateUpVectorFromRotation = false;
  24177. _this._tmpQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  24178. /**
  24179. * Define the current rotation of the camera
  24180. */
  24181. _this.rotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  24182. /**
  24183. * Define the current speed of the camera
  24184. */
  24185. _this.speed = 2.0;
  24186. /**
  24187. * Add cconstraint to the camera to prevent it to move freely in all directions and
  24188. * around all axis.
  24189. */
  24190. _this.noRotationConstraint = false;
  24191. /**
  24192. * Define the current target of the camera as an object or a position.
  24193. */
  24194. _this.lockedTarget = null;
  24195. /** @hidden */
  24196. _this._currentTarget = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  24197. /** @hidden */
  24198. _this._initialFocalDistance = 1;
  24199. /** @hidden */
  24200. _this._viewMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  24201. /** @hidden */
  24202. _this._camMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  24203. /** @hidden */
  24204. _this._cameraTransformMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  24205. /** @hidden */
  24206. _this._cameraRotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  24207. /** @hidden */
  24208. _this._referencePoint = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  24209. /** @hidden */
  24210. _this._transformedReferencePoint = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  24211. _this._globalCurrentTarget = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  24212. _this._globalCurrentUpVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  24213. _this._defaultUp = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  24214. _this._cachedRotationZ = 0;
  24215. _this._cachedQuaternionRotationZ = 0;
  24216. return _this;
  24217. }
  24218. /**
  24219. * Gets the position in front of the camera at a given distance.
  24220. * @param distance The distance from the camera we want the position to be
  24221. * @returns the position
  24222. */
  24223. TargetCamera.prototype.getFrontPosition = function (distance) {
  24224. this.getWorldMatrix();
  24225. var direction = this.getTarget().subtract(this.position);
  24226. direction.normalize();
  24227. direction.scaleInPlace(distance);
  24228. return this.globalPosition.add(direction);
  24229. };
  24230. /** @hidden */
  24231. TargetCamera.prototype._getLockedTargetPosition = function () {
  24232. if (!this.lockedTarget) {
  24233. return null;
  24234. }
  24235. if (this.lockedTarget.absolutePosition) {
  24236. this.lockedTarget.computeWorldMatrix();
  24237. }
  24238. return this.lockedTarget.absolutePosition || this.lockedTarget;
  24239. };
  24240. /**
  24241. * Store current camera state of the camera (fov, position, rotation, etc..)
  24242. * @returns the camera
  24243. */
  24244. TargetCamera.prototype.storeState = function () {
  24245. this._storedPosition = this.position.clone();
  24246. this._storedRotation = this.rotation.clone();
  24247. if (this.rotationQuaternion) {
  24248. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  24249. }
  24250. return _super.prototype.storeState.call(this);
  24251. };
  24252. /**
  24253. * Restored camera state. You must call storeState() first
  24254. * @returns whether it was successful or not
  24255. * @hidden
  24256. */
  24257. TargetCamera.prototype._restoreStateValues = function () {
  24258. if (!_super.prototype._restoreStateValues.call(this)) {
  24259. return false;
  24260. }
  24261. this.position = this._storedPosition.clone();
  24262. this.rotation = this._storedRotation.clone();
  24263. if (this.rotationQuaternion) {
  24264. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  24265. }
  24266. this.cameraDirection.copyFromFloats(0, 0, 0);
  24267. this.cameraRotation.copyFromFloats(0, 0);
  24268. return true;
  24269. };
  24270. /** @hidden */
  24271. TargetCamera.prototype._initCache = function () {
  24272. _super.prototype._initCache.call(this);
  24273. this._cache.lockedTarget = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  24274. this._cache.rotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  24275. this._cache.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  24276. };
  24277. /** @hidden */
  24278. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  24279. if (!ignoreParentClass) {
  24280. _super.prototype._updateCache.call(this);
  24281. }
  24282. var lockedTargetPosition = this._getLockedTargetPosition();
  24283. if (!lockedTargetPosition) {
  24284. this._cache.lockedTarget = null;
  24285. }
  24286. else {
  24287. if (!this._cache.lockedTarget) {
  24288. this._cache.lockedTarget = lockedTargetPosition.clone();
  24289. }
  24290. else {
  24291. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  24292. }
  24293. }
  24294. this._cache.rotation.copyFrom(this.rotation);
  24295. if (this.rotationQuaternion) {
  24296. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  24297. }
  24298. };
  24299. // Synchronized
  24300. /** @hidden */
  24301. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  24302. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  24303. return false;
  24304. }
  24305. var lockedTargetPosition = this._getLockedTargetPosition();
  24306. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  24307. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  24308. };
  24309. // Methods
  24310. /** @hidden */
  24311. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  24312. var engine = this.getEngine();
  24313. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  24314. };
  24315. // Target
  24316. /**
  24317. * Defines the target the camera should look at.
  24318. * @param target Defines the new target as a Vector or a mesh
  24319. */
  24320. TargetCamera.prototype.setTarget = function (target) {
  24321. this.upVector.normalize();
  24322. this._initialFocalDistance = target.subtract(this.position).length();
  24323. if (this.position.z === target.z) {
  24324. this.position.z += _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["Epsilon"];
  24325. }
  24326. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  24327. this._camMatrix.invert();
  24328. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  24329. var vDir = target.subtract(this.position);
  24330. if (vDir.x >= 0.0) {
  24331. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  24332. }
  24333. else {
  24334. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  24335. }
  24336. this.rotation.z = 0;
  24337. if (isNaN(this.rotation.x)) {
  24338. this.rotation.x = 0;
  24339. }
  24340. if (isNaN(this.rotation.y)) {
  24341. this.rotation.y = 0;
  24342. }
  24343. if (isNaN(this.rotation.z)) {
  24344. this.rotation.z = 0;
  24345. }
  24346. if (this.rotationQuaternion) {
  24347. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  24348. }
  24349. };
  24350. /**
  24351. * Return the current target position of the camera. This value is expressed in local space.
  24352. * @returns the target position
  24353. */
  24354. TargetCamera.prototype.getTarget = function () {
  24355. return this._currentTarget;
  24356. };
  24357. /** @hidden */
  24358. TargetCamera.prototype._decideIfNeedsToMove = function () {
  24359. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  24360. };
  24361. /** @hidden */
  24362. TargetCamera.prototype._updatePosition = function () {
  24363. if (this.parent) {
  24364. this.parent.getWorldMatrix().invertToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0]);
  24365. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this.cameraDirection, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0], _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0]);
  24366. this.position.addInPlace(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0]);
  24367. return;
  24368. }
  24369. this.position.addInPlace(this.cameraDirection);
  24370. };
  24371. /** @hidden */
  24372. TargetCamera.prototype._checkInputs = function () {
  24373. var needToMove = this._decideIfNeedsToMove();
  24374. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  24375. // Move
  24376. if (needToMove) {
  24377. this._updatePosition();
  24378. }
  24379. // Rotate
  24380. if (needToRotate) {
  24381. this.rotation.x += this.cameraRotation.x;
  24382. this.rotation.y += this.cameraRotation.y;
  24383. //rotate, if quaternion is set and rotation was used
  24384. if (this.rotationQuaternion) {
  24385. var len = this.rotation.lengthSquared();
  24386. if (len) {
  24387. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  24388. }
  24389. }
  24390. if (!this.noRotationConstraint) {
  24391. var limit = 1.570796;
  24392. if (this.rotation.x > limit) {
  24393. this.rotation.x = limit;
  24394. }
  24395. if (this.rotation.x < -limit) {
  24396. this.rotation.x = -limit;
  24397. }
  24398. }
  24399. }
  24400. // Inertia
  24401. if (needToMove) {
  24402. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["Epsilon"]) {
  24403. this.cameraDirection.x = 0;
  24404. }
  24405. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["Epsilon"]) {
  24406. this.cameraDirection.y = 0;
  24407. }
  24408. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["Epsilon"]) {
  24409. this.cameraDirection.z = 0;
  24410. }
  24411. this.cameraDirection.scaleInPlace(this.inertia);
  24412. }
  24413. if (needToRotate) {
  24414. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["Epsilon"]) {
  24415. this.cameraRotation.x = 0;
  24416. }
  24417. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["Epsilon"]) {
  24418. this.cameraRotation.y = 0;
  24419. }
  24420. this.cameraRotation.scaleInPlace(this.inertia);
  24421. }
  24422. _super.prototype._checkInputs.call(this);
  24423. };
  24424. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  24425. if (this.rotationQuaternion) {
  24426. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  24427. }
  24428. else {
  24429. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  24430. }
  24431. };
  24432. /**
  24433. * 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)
  24434. * @returns the current camera
  24435. */
  24436. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  24437. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  24438. return this;
  24439. };
  24440. /** @hidden */
  24441. TargetCamera.prototype._getViewMatrix = function () {
  24442. if (this.lockedTarget) {
  24443. this.setTarget(this._getLockedTargetPosition());
  24444. }
  24445. // Compute
  24446. this._updateCameraRotationMatrix();
  24447. // Apply the changed rotation to the upVector
  24448. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  24449. this._rotateUpVectorWithCameraRotationMatrix();
  24450. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  24451. }
  24452. else if (this._cachedRotationZ != this.rotation.z) {
  24453. this._rotateUpVectorWithCameraRotationMatrix();
  24454. this._cachedRotationZ = this.rotation.z;
  24455. }
  24456. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  24457. // Computing target and final matrix
  24458. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  24459. if (this.updateUpVectorFromRotation) {
  24460. if (this.rotationQuaternion) {
  24461. _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  24462. }
  24463. else {
  24464. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  24465. _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  24466. }
  24467. }
  24468. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  24469. return this._viewMatrix;
  24470. };
  24471. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  24472. if (this.parent) {
  24473. var parentWorldMatrix = this.parent.getWorldMatrix();
  24474. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  24475. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  24476. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  24477. this._markSyncedWithParent();
  24478. }
  24479. else {
  24480. this._globalPosition.copyFrom(position);
  24481. this._globalCurrentTarget.copyFrom(target);
  24482. this._globalCurrentUpVector.copyFrom(up);
  24483. }
  24484. if (this.getScene().useRightHandedSystem) {
  24485. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  24486. }
  24487. else {
  24488. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  24489. }
  24490. };
  24491. /**
  24492. * @hidden
  24493. */
  24494. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  24495. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  24496. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  24497. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  24498. if (!this.rotationQuaternion) {
  24499. this.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  24500. }
  24501. rigCamera._cameraRigParams = {};
  24502. rigCamera.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  24503. }
  24504. return rigCamera;
  24505. }
  24506. return null;
  24507. };
  24508. /**
  24509. * @hidden
  24510. */
  24511. TargetCamera.prototype._updateRigCameras = function () {
  24512. var camLeft = this._rigCameras[0];
  24513. var camRight = this._rigCameras[1];
  24514. this.computeWorldMatrix();
  24515. switch (this.cameraRigMode) {
  24516. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  24517. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  24518. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  24519. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  24520. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  24521. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  24522. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  24523. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  24524. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  24525. break;
  24526. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  24527. if (camLeft.rotationQuaternion) {
  24528. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  24529. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  24530. }
  24531. else {
  24532. camLeft.rotation.copyFrom(this.rotation);
  24533. camRight.rotation.copyFrom(this.rotation);
  24534. }
  24535. camLeft.position.copyFrom(this.position);
  24536. camRight.position.copyFrom(this.position);
  24537. break;
  24538. }
  24539. _super.prototype._updateRigCameras.call(this);
  24540. };
  24541. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  24542. var target = this.getTarget();
  24543. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  24544. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  24545. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  24546. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  24547. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  24548. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  24549. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  24550. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  24551. rigCamera.setTarget(newFocalTarget);
  24552. };
  24553. /**
  24554. * Gets the current object class name.
  24555. * @return the class name
  24556. */
  24557. TargetCamera.prototype.getClassName = function () {
  24558. return "TargetCamera";
  24559. };
  24560. TargetCamera._RigCamTransformMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  24561. TargetCamera._TargetTransformMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  24562. TargetCamera._TargetFocalPoint = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  24563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  24564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  24565. ], TargetCamera.prototype, "rotation", void 0);
  24566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  24567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  24568. ], TargetCamera.prototype, "speed", void 0);
  24569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  24570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  24571. ], TargetCamera.prototype, "lockedTarget", void 0);
  24572. return TargetCamera;
  24573. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  24574. /***/ }),
  24575. /***/ "./Cameras/touchCamera.ts":
  24576. /*!********************************!*\
  24577. !*** ./Cameras/touchCamera.ts ***!
  24578. \********************************/
  24579. /*! exports provided: TouchCamera */
  24580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24581. "use strict";
  24582. __webpack_require__.r(__webpack_exports__);
  24583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  24584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  24585. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  24586. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  24587. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  24588. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  24589. return function () { return new TouchCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  24590. });
  24591. /**
  24592. * This represents a FPS type of camera controlled by touch.
  24593. * This is like a universal camera minus the Gamepad controls.
  24594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  24595. */
  24596. var TouchCamera = /** @class */ (function (_super) {
  24597. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  24598. /**
  24599. * Instantiates a new touch camera.
  24600. * This represents a FPS type of camera controlled by touch.
  24601. * This is like a universal camera minus the Gamepad controls.
  24602. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  24603. * @param name Define the name of the camera in the scene
  24604. * @param position Define the start position of the camera in the scene
  24605. * @param scene Define the scene the camera belongs to
  24606. */
  24607. function TouchCamera(name, position, scene) {
  24608. var _this = _super.call(this, name, position, scene) || this;
  24609. _this.inputs.addTouch();
  24610. _this._setupInputs();
  24611. return _this;
  24612. }
  24613. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  24614. /**
  24615. * Defines the touch sensibility for rotation.
  24616. * The higher the faster.
  24617. */
  24618. get: function () {
  24619. var touch = this.inputs.attached["touch"];
  24620. if (touch) {
  24621. return touch.touchAngularSensibility;
  24622. }
  24623. return 0;
  24624. },
  24625. set: function (value) {
  24626. var touch = this.inputs.attached["touch"];
  24627. if (touch) {
  24628. touch.touchAngularSensibility = value;
  24629. }
  24630. },
  24631. enumerable: true,
  24632. configurable: true
  24633. });
  24634. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  24635. /**
  24636. * Defines the touch sensibility for move.
  24637. * The higher the faster.
  24638. */
  24639. get: function () {
  24640. var touch = this.inputs.attached["touch"];
  24641. if (touch) {
  24642. return touch.touchMoveSensibility;
  24643. }
  24644. return 0;
  24645. },
  24646. set: function (value) {
  24647. var touch = this.inputs.attached["touch"];
  24648. if (touch) {
  24649. touch.touchMoveSensibility = value;
  24650. }
  24651. },
  24652. enumerable: true,
  24653. configurable: true
  24654. });
  24655. /**
  24656. * Gets the current object class name.
  24657. * @return the class name
  24658. */
  24659. TouchCamera.prototype.getClassName = function () {
  24660. return "TouchCamera";
  24661. };
  24662. /** @hidden */
  24663. TouchCamera.prototype._setupInputs = function () {
  24664. var mouse = this.inputs.attached["mouse"];
  24665. if (mouse) {
  24666. mouse.touchEnabled = false;
  24667. }
  24668. };
  24669. return TouchCamera;
  24670. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  24671. /***/ }),
  24672. /***/ "./Cameras/universalCamera.ts":
  24673. /*!************************************!*\
  24674. !*** ./Cameras/universalCamera.ts ***!
  24675. \************************************/
  24676. /*! exports provided: UniversalCamera */
  24677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24678. "use strict";
  24679. __webpack_require__.r(__webpack_exports__);
  24680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  24681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  24682. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  24683. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  24684. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  24685. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  24686. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  24687. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  24688. // Forcing to use the Universal camera
  24689. return function () { return new UniversalCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  24690. });
  24691. /**
  24692. * 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,
  24693. * which still works and will still be found in many Playgrounds.
  24694. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  24695. */
  24696. var UniversalCamera = /** @class */ (function (_super) {
  24697. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  24698. /**
  24699. * 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,
  24700. * which still works and will still be found in many Playgrounds.
  24701. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  24702. * @param name Define the name of the camera in the scene
  24703. * @param position Define the start position of the camera in the scene
  24704. * @param scene Define the scene the camera belongs to
  24705. */
  24706. function UniversalCamera(name, position, scene) {
  24707. var _this = _super.call(this, name, position, scene) || this;
  24708. _this.inputs.addGamepad();
  24709. return _this;
  24710. }
  24711. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  24712. /**
  24713. * Defines the gamepad rotation sensiblity.
  24714. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  24715. */
  24716. get: function () {
  24717. var gamepad = this.inputs.attached["gamepad"];
  24718. if (gamepad) {
  24719. return gamepad.gamepadAngularSensibility;
  24720. }
  24721. return 0;
  24722. },
  24723. set: function (value) {
  24724. var gamepad = this.inputs.attached["gamepad"];
  24725. if (gamepad) {
  24726. gamepad.gamepadAngularSensibility = value;
  24727. }
  24728. },
  24729. enumerable: true,
  24730. configurable: true
  24731. });
  24732. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  24733. /**
  24734. * Defines the gamepad move sensiblity.
  24735. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  24736. */
  24737. get: function () {
  24738. var gamepad = this.inputs.attached["gamepad"];
  24739. if (gamepad) {
  24740. return gamepad.gamepadMoveSensibility;
  24741. }
  24742. return 0;
  24743. },
  24744. set: function (value) {
  24745. var gamepad = this.inputs.attached["gamepad"];
  24746. if (gamepad) {
  24747. gamepad.gamepadMoveSensibility = value;
  24748. }
  24749. },
  24750. enumerable: true,
  24751. configurable: true
  24752. });
  24753. /**
  24754. * Gets the current object class name.
  24755. * @return the class name
  24756. */
  24757. UniversalCamera.prototype.getClassName = function () {
  24758. return "UniversalCamera";
  24759. };
  24760. return UniversalCamera;
  24761. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  24762. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  24763. return new UniversalCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  24764. };
  24765. /***/ }),
  24766. /***/ "./Cameras/virtualJoysticksCamera.ts":
  24767. /*!*******************************************!*\
  24768. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  24769. \*******************************************/
  24770. /*! exports provided: VirtualJoysticksCamera */
  24771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24772. "use strict";
  24773. __webpack_require__.r(__webpack_exports__);
  24774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  24775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  24776. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  24777. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  24778. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  24779. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  24780. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  24781. return function () { return new VirtualJoysticksCamera(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  24782. });
  24783. /**
  24784. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24785. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  24786. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  24787. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  24788. */
  24789. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  24790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  24791. /**
  24792. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  24793. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  24794. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  24795. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  24796. * @param name Define the name of the camera in the scene
  24797. * @param position Define the start position of the camera in the scene
  24798. * @param scene Define the scene the camera belongs to
  24799. */
  24800. function VirtualJoysticksCamera(name, position, scene) {
  24801. var _this = _super.call(this, name, position, scene) || this;
  24802. _this.inputs.addVirtualJoystick();
  24803. return _this;
  24804. }
  24805. /**
  24806. * Gets the current object class name.
  24807. * @return the class name
  24808. */
  24809. VirtualJoysticksCamera.prototype.getClassName = function () {
  24810. return "VirtualJoysticksCamera";
  24811. };
  24812. return VirtualJoysticksCamera;
  24813. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  24814. /***/ }),
  24815. /***/ "./Collisions/collider.ts":
  24816. /*!********************************!*\
  24817. !*** ./Collisions/collider.ts ***!
  24818. \********************************/
  24819. /*! exports provided: Collider */
  24820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24821. "use strict";
  24822. __webpack_require__.r(__webpack_exports__);
  24823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  24824. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  24825. /* harmony import */ var _Maths_math_plane__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.plane */ "./Maths/math.plane.ts");
  24826. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  24827. if (boxMin.x > sphereCenter.x + sphereRadius) {
  24828. return false;
  24829. }
  24830. if (sphereCenter.x - sphereRadius > boxMax.x) {
  24831. return false;
  24832. }
  24833. if (boxMin.y > sphereCenter.y + sphereRadius) {
  24834. return false;
  24835. }
  24836. if (sphereCenter.y - sphereRadius > boxMax.y) {
  24837. return false;
  24838. }
  24839. if (boxMin.z > sphereCenter.z + sphereRadius) {
  24840. return false;
  24841. }
  24842. if (sphereCenter.z - sphereRadius > boxMax.z) {
  24843. return false;
  24844. }
  24845. return true;
  24846. };
  24847. var getLowestRoot = (function () {
  24848. var result = { root: 0, found: false };
  24849. return function (a, b, c, maxR) {
  24850. result.root = 0;
  24851. result.found = false;
  24852. var determinant = b * b - 4.0 * a * c;
  24853. if (determinant < 0) {
  24854. return result;
  24855. }
  24856. var sqrtD = Math.sqrt(determinant);
  24857. var r1 = (-b - sqrtD) / (2.0 * a);
  24858. var r2 = (-b + sqrtD) / (2.0 * a);
  24859. if (r1 > r2) {
  24860. var temp = r2;
  24861. r2 = r1;
  24862. r1 = temp;
  24863. }
  24864. if (r1 > 0 && r1 < maxR) {
  24865. result.root = r1;
  24866. result.found = true;
  24867. return result;
  24868. }
  24869. if (r2 > 0 && r2 < maxR) {
  24870. result.root = r2;
  24871. result.found = true;
  24872. return result;
  24873. }
  24874. return result;
  24875. };
  24876. })();
  24877. /** @hidden */
  24878. var Collider = /** @class */ (function () {
  24879. function Collider() {
  24880. this._collisionPoint = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24881. this._planeIntersectionPoint = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24882. this._tempVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24883. this._tempVector2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24884. this._tempVector3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24885. this._tempVector4 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24886. this._edge = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24887. this._baseToVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24888. this._destinationPoint = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24889. this._slidePlaneNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24890. this._displacementVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24891. /** @hidden */
  24892. this._radius = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  24893. /** @hidden */
  24894. this._retry = 0;
  24895. /** @hidden */
  24896. this._basePointWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24897. this._velocityWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24898. this._normalizedVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24899. this._collisionMask = -1;
  24900. }
  24901. Object.defineProperty(Collider.prototype, "collisionMask", {
  24902. get: function () {
  24903. return this._collisionMask;
  24904. },
  24905. set: function (mask) {
  24906. this._collisionMask = !isNaN(mask) ? mask : -1;
  24907. },
  24908. enumerable: true,
  24909. configurable: true
  24910. });
  24911. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  24912. /**
  24913. * Gets the plane normal used to compute the sliding response (in local space)
  24914. */
  24915. get: function () {
  24916. return this._slidePlaneNormal;
  24917. },
  24918. enumerable: true,
  24919. configurable: true
  24920. });
  24921. // Methods
  24922. /** @hidden */
  24923. Collider.prototype._initialize = function (source, dir, e) {
  24924. this._velocity = dir;
  24925. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  24926. this._basePoint = source;
  24927. source.multiplyToRef(this._radius, this._basePointWorld);
  24928. dir.multiplyToRef(this._radius, this._velocityWorld);
  24929. this._velocityWorldLength = this._velocityWorld.length();
  24930. this._epsilon = e;
  24931. this.collisionFound = false;
  24932. };
  24933. /** @hidden */
  24934. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  24935. pa.subtractToRef(point, this._tempVector);
  24936. pb.subtractToRef(point, this._tempVector2);
  24937. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  24938. var d = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24939. if (d < 0) {
  24940. return false;
  24941. }
  24942. pc.subtractToRef(point, this._tempVector3);
  24943. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  24944. d = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24945. if (d < 0) {
  24946. return false;
  24947. }
  24948. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  24949. d = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24950. return d >= 0;
  24951. };
  24952. /** @hidden */
  24953. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  24954. var distance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  24955. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  24956. if (distance > this._velocityWorldLength + max + sphereRadius) {
  24957. return false;
  24958. }
  24959. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  24960. return false;
  24961. }
  24962. return true;
  24963. };
  24964. /** @hidden */
  24965. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial, hostMesh) {
  24966. var t0;
  24967. var embeddedInPlane = false;
  24968. //defensive programming, actually not needed.
  24969. if (!trianglePlaneArray) {
  24970. trianglePlaneArray = [];
  24971. }
  24972. if (!trianglePlaneArray[faceIndex]) {
  24973. trianglePlaneArray[faceIndex] = new _Maths_math_plane__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 0, 0, 0);
  24974. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  24975. }
  24976. var trianglePlane = trianglePlaneArray[faceIndex];
  24977. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  24978. return;
  24979. }
  24980. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  24981. var normalDotVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  24982. if (normalDotVelocity == 0) {
  24983. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  24984. return;
  24985. }
  24986. embeddedInPlane = true;
  24987. t0 = 0;
  24988. }
  24989. else {
  24990. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24991. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24992. if (t0 > t1) {
  24993. var temp = t1;
  24994. t1 = t0;
  24995. t0 = temp;
  24996. }
  24997. if (t0 > 1.0 || t1 < 0.0) {
  24998. return;
  24999. }
  25000. if (t0 < 0) {
  25001. t0 = 0;
  25002. }
  25003. if (t0 > 1.0) {
  25004. t0 = 1.0;
  25005. }
  25006. }
  25007. this._collisionPoint.copyFromFloats(0, 0, 0);
  25008. var found = false;
  25009. var t = 1.0;
  25010. if (!embeddedInPlane) {
  25011. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  25012. this._velocity.scaleToRef(t0, this._tempVector);
  25013. this._planeIntersectionPoint.addInPlace(this._tempVector);
  25014. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  25015. found = true;
  25016. t = t0;
  25017. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  25018. }
  25019. }
  25020. if (!found) {
  25021. var velocitySquaredLength = this._velocity.lengthSquared();
  25022. var a = velocitySquaredLength;
  25023. this._basePoint.subtractToRef(p1, this._tempVector);
  25024. var b = 2.0 * (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  25025. var c = this._tempVector.lengthSquared() - 1.0;
  25026. var lowestRoot = getLowestRoot(a, b, c, t);
  25027. if (lowestRoot.found) {
  25028. t = lowestRoot.root;
  25029. found = true;
  25030. this._collisionPoint.copyFrom(p1);
  25031. }
  25032. this._basePoint.subtractToRef(p2, this._tempVector);
  25033. b = 2.0 * (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  25034. c = this._tempVector.lengthSquared() - 1.0;
  25035. lowestRoot = getLowestRoot(a, b, c, t);
  25036. if (lowestRoot.found) {
  25037. t = lowestRoot.root;
  25038. found = true;
  25039. this._collisionPoint.copyFrom(p2);
  25040. }
  25041. this._basePoint.subtractToRef(p3, this._tempVector);
  25042. b = 2.0 * (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  25043. c = this._tempVector.lengthSquared() - 1.0;
  25044. lowestRoot = getLowestRoot(a, b, c, t);
  25045. if (lowestRoot.found) {
  25046. t = lowestRoot.root;
  25047. found = true;
  25048. this._collisionPoint.copyFrom(p3);
  25049. }
  25050. p2.subtractToRef(p1, this._edge);
  25051. p1.subtractToRef(this._basePoint, this._baseToVertex);
  25052. var edgeSquaredLength = this._edge.lengthSquared();
  25053. var edgeDotVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  25054. var edgeDotBaseToVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  25055. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  25056. b = edgeSquaredLength * (2.0 * _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  25057. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  25058. lowestRoot = getLowestRoot(a, b, c, t);
  25059. if (lowestRoot.found) {
  25060. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  25061. if (f >= 0.0 && f <= 1.0) {
  25062. t = lowestRoot.root;
  25063. found = true;
  25064. this._edge.scaleInPlace(f);
  25065. p1.addToRef(this._edge, this._collisionPoint);
  25066. }
  25067. }
  25068. p3.subtractToRef(p2, this._edge);
  25069. p2.subtractToRef(this._basePoint, this._baseToVertex);
  25070. edgeSquaredLength = this._edge.lengthSquared();
  25071. edgeDotVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  25072. edgeDotBaseToVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  25073. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  25074. b = edgeSquaredLength * (2.0 * _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  25075. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  25076. lowestRoot = getLowestRoot(a, b, c, t);
  25077. if (lowestRoot.found) {
  25078. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  25079. if (f >= 0.0 && f <= 1.0) {
  25080. t = lowestRoot.root;
  25081. found = true;
  25082. this._edge.scaleInPlace(f);
  25083. p2.addToRef(this._edge, this._collisionPoint);
  25084. }
  25085. }
  25086. p1.subtractToRef(p3, this._edge);
  25087. p3.subtractToRef(this._basePoint, this._baseToVertex);
  25088. edgeSquaredLength = this._edge.lengthSquared();
  25089. edgeDotVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  25090. edgeDotBaseToVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  25091. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  25092. b = edgeSquaredLength * (2.0 * _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  25093. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  25094. lowestRoot = getLowestRoot(a, b, c, t);
  25095. if (lowestRoot.found) {
  25096. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  25097. if (f >= 0.0 && f <= 1.0) {
  25098. t = lowestRoot.root;
  25099. found = true;
  25100. this._edge.scaleInPlace(f);
  25101. p3.addToRef(this._edge, this._collisionPoint);
  25102. }
  25103. }
  25104. }
  25105. if (found) {
  25106. var distToCollision = t * this._velocity.length();
  25107. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  25108. if (!this.intersectionPoint) {
  25109. this.intersectionPoint = this._collisionPoint.clone();
  25110. }
  25111. else {
  25112. this.intersectionPoint.copyFrom(this._collisionPoint);
  25113. }
  25114. this._nearestDistance = distToCollision;
  25115. this.collisionFound = true;
  25116. this.collidedMesh = hostMesh;
  25117. }
  25118. }
  25119. };
  25120. /** @hidden */
  25121. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial, hostMesh) {
  25122. for (var i = indexStart; i < indexEnd; i += 3) {
  25123. var p1 = pts[indices[i] - decal];
  25124. var p2 = pts[indices[i + 1] - decal];
  25125. var p3 = pts[indices[i + 2] - decal];
  25126. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial, hostMesh);
  25127. }
  25128. };
  25129. /** @hidden */
  25130. Collider.prototype._getResponse = function (pos, vel) {
  25131. pos.addToRef(vel, this._destinationPoint);
  25132. vel.scaleInPlace((this._nearestDistance / vel.length()));
  25133. this._basePoint.addToRef(vel, pos);
  25134. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  25135. this._slidePlaneNormal.normalize();
  25136. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  25137. pos.addInPlace(this._displacementVector);
  25138. this.intersectionPoint.addInPlace(this._displacementVector);
  25139. this._slidePlaneNormal.scaleInPlace(_Maths_math_plane__WEBPACK_IMPORTED_MODULE_1__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  25140. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  25141. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  25142. };
  25143. return Collider;
  25144. }());
  25145. /***/ }),
  25146. /***/ "./Collisions/collisionCoordinator.ts":
  25147. /*!********************************************!*\
  25148. !*** ./Collisions/collisionCoordinator.ts ***!
  25149. \********************************************/
  25150. /*! exports provided: DefaultCollisionCoordinator */
  25151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25152. "use strict";
  25153. __webpack_require__.r(__webpack_exports__);
  25154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  25155. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25156. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  25157. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  25158. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  25159. /** @hidden */
  25160. var DefaultCollisionCoordinator = /** @class */ (function () {
  25161. function DefaultCollisionCoordinator() {
  25162. this._scaledPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25163. this._scaledVelocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25164. this._finalPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25165. }
  25166. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  25167. position.divideToRef(collider._radius, this._scaledPosition);
  25168. displacement.divideToRef(collider._radius, this._scaledVelocity);
  25169. collider.collidedMesh = null;
  25170. collider._retry = 0;
  25171. collider._initialVelocity = this._scaledVelocity;
  25172. collider._initialPosition = this._scaledPosition;
  25173. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  25174. this._finalPosition.multiplyInPlace(collider._radius);
  25175. //run the callback
  25176. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  25177. };
  25178. DefaultCollisionCoordinator.prototype.createCollider = function () {
  25179. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  25180. };
  25181. DefaultCollisionCoordinator.prototype.init = function (scene) {
  25182. this._scene = scene;
  25183. };
  25184. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  25185. if (excludedMesh === void 0) { excludedMesh = null; }
  25186. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  25187. if (collider._retry >= maximumRetry) {
  25188. finalPosition.copyFrom(position);
  25189. return;
  25190. }
  25191. // Check if this is a mesh else camera or -1
  25192. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  25193. collider._initialize(position, velocity, closeDistance);
  25194. // Check all meshes
  25195. for (var index = 0; index < this._scene.meshes.length; index++) {
  25196. var mesh = this._scene.meshes[index];
  25197. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  25198. mesh._checkCollision(collider);
  25199. }
  25200. }
  25201. if (!collider.collisionFound) {
  25202. position.addToRef(velocity, finalPosition);
  25203. return;
  25204. }
  25205. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  25206. collider._getResponse(position, velocity);
  25207. }
  25208. if (velocity.length() <= closeDistance) {
  25209. finalPosition.copyFrom(position);
  25210. return;
  25211. }
  25212. collider._retry++;
  25213. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  25214. };
  25215. return DefaultCollisionCoordinator;
  25216. }());
  25217. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  25218. return new DefaultCollisionCoordinator();
  25219. };
  25220. /***/ }),
  25221. /***/ "./Collisions/index.ts":
  25222. /*!*****************************!*\
  25223. !*** ./Collisions/index.ts ***!
  25224. \*****************************/
  25225. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, _MeshCollisionData */
  25226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25227. "use strict";
  25228. __webpack_require__.r(__webpack_exports__);
  25229. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  25230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  25231. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  25232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  25233. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  25234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  25235. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  25237. /* harmony import */ var _meshCollisionData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./meshCollisionData */ "./Collisions/meshCollisionData.ts");
  25238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _meshCollisionData__WEBPACK_IMPORTED_MODULE_4__["_MeshCollisionData"]; });
  25239. /***/ }),
  25240. /***/ "./Collisions/intersectionInfo.ts":
  25241. /*!****************************************!*\
  25242. !*** ./Collisions/intersectionInfo.ts ***!
  25243. \****************************************/
  25244. /*! exports provided: IntersectionInfo */
  25245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25246. "use strict";
  25247. __webpack_require__.r(__webpack_exports__);
  25248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  25249. /**
  25250. * @hidden
  25251. */
  25252. var IntersectionInfo = /** @class */ (function () {
  25253. function IntersectionInfo(bu, bv, distance) {
  25254. this.bu = bu;
  25255. this.bv = bv;
  25256. this.distance = distance;
  25257. this.faceId = 0;
  25258. this.subMeshId = 0;
  25259. }
  25260. return IntersectionInfo;
  25261. }());
  25262. /***/ }),
  25263. /***/ "./Collisions/meshCollisionData.ts":
  25264. /*!*****************************************!*\
  25265. !*** ./Collisions/meshCollisionData.ts ***!
  25266. \*****************************************/
  25267. /*! exports provided: _MeshCollisionData */
  25268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25269. "use strict";
  25270. __webpack_require__.r(__webpack_exports__);
  25271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _MeshCollisionData; });
  25272. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  25273. /**
  25274. * @hidden
  25275. */
  25276. var _MeshCollisionData = /** @class */ (function () {
  25277. function _MeshCollisionData() {
  25278. this._checkCollisions = false;
  25279. this._collisionMask = -1;
  25280. this._collisionGroup = -1;
  25281. this._collider = null;
  25282. this._oldPositionForCollisions = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  25283. this._diffPositionForCollisions = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  25284. }
  25285. return _MeshCollisionData;
  25286. }());
  25287. /***/ }),
  25288. /***/ "./Collisions/pickingInfo.ts":
  25289. /*!***********************************!*\
  25290. !*** ./Collisions/pickingInfo.ts ***!
  25291. \***********************************/
  25292. /*! exports provided: PickingInfo */
  25293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25294. "use strict";
  25295. __webpack_require__.r(__webpack_exports__);
  25296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  25297. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  25298. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  25299. /**
  25300. * Information about the result of picking within a scene
  25301. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  25302. */
  25303. var PickingInfo = /** @class */ (function () {
  25304. function PickingInfo() {
  25305. /** @hidden */
  25306. this._pickingUnavailable = false;
  25307. /**
  25308. * If the pick collided with an object
  25309. */
  25310. this.hit = false;
  25311. /**
  25312. * Distance away where the pick collided
  25313. */
  25314. this.distance = 0;
  25315. /**
  25316. * The location of pick collision
  25317. */
  25318. this.pickedPoint = null;
  25319. /**
  25320. * The mesh corresponding the the pick collision
  25321. */
  25322. this.pickedMesh = null;
  25323. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  25324. this.bu = 0;
  25325. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  25326. this.bv = 0;
  25327. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25328. this.faceId = -1;
  25329. /** Id of the the submesh that was picked */
  25330. this.subMeshId = 0;
  25331. /** If a sprite was picked, this will be the sprite the pick collided with */
  25332. this.pickedSprite = null;
  25333. /**
  25334. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  25335. */
  25336. this.originMesh = null;
  25337. /**
  25338. * The ray that was used to perform the picking.
  25339. */
  25340. this.ray = null;
  25341. }
  25342. /**
  25343. * Gets the normal correspodning to the face the pick collided with
  25344. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25345. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25346. * @returns The normal correspodning to the face the pick collided with
  25347. */
  25348. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  25349. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  25350. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  25351. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  25352. return null;
  25353. }
  25354. var indices = this.pickedMesh.getIndices();
  25355. if (!indices) {
  25356. return null;
  25357. }
  25358. var result;
  25359. if (useVerticesNormals) {
  25360. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  25361. var normal0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  25362. var normal1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  25363. var normal2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  25364. normal0 = normal0.scale(this.bu);
  25365. normal1 = normal1.scale(this.bv);
  25366. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  25367. result = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
  25368. }
  25369. else {
  25370. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  25371. var vertex1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  25372. var vertex2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  25373. var vertex3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  25374. var p1p2 = vertex1.subtract(vertex2);
  25375. var p3p2 = vertex3.subtract(vertex2);
  25376. result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  25377. }
  25378. if (useWorldCoordinates) {
  25379. var wm = this.pickedMesh.getWorldMatrix();
  25380. if (this.pickedMesh.nonUniformScaling) {
  25381. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0].copyFrom(wm);
  25382. wm = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  25383. wm.setTranslationFromFloats(0, 0, 0);
  25384. wm.invert();
  25385. wm.transposeToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[1]);
  25386. wm = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[1];
  25387. }
  25388. result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  25389. }
  25390. result.normalize();
  25391. return result;
  25392. };
  25393. /**
  25394. * Gets the texture coordinates of where the pick occured
  25395. * @returns the vector containing the coordnates of the texture
  25396. */
  25397. PickingInfo.prototype.getTextureCoordinates = function () {
  25398. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  25399. return null;
  25400. }
  25401. var indices = this.pickedMesh.getIndices();
  25402. if (!indices) {
  25403. return null;
  25404. }
  25405. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  25406. if (!uvs) {
  25407. return null;
  25408. }
  25409. var uv0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  25410. var uv1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  25411. var uv2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  25412. uv0 = uv0.scale(this.bu);
  25413. uv1 = uv1.scale(this.bv);
  25414. uv2 = uv2.scale(1.0 - this.bu - this.bv);
  25415. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  25416. };
  25417. return PickingInfo;
  25418. }());
  25419. /***/ }),
  25420. /***/ "./Culling/Octrees/index.ts":
  25421. /*!**********************************!*\
  25422. !*** ./Culling/Octrees/index.ts ***!
  25423. \**********************************/
  25424. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  25425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25426. "use strict";
  25427. __webpack_require__.r(__webpack_exports__);
  25428. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  25429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  25430. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  25431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  25432. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  25433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  25434. /***/ }),
  25435. /***/ "./Culling/Octrees/octree.ts":
  25436. /*!***********************************!*\
  25437. !*** ./Culling/Octrees/octree.ts ***!
  25438. \***********************************/
  25439. /*! exports provided: Octree */
  25440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25441. "use strict";
  25442. __webpack_require__.r(__webpack_exports__);
  25443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  25444. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  25445. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  25446. /**
  25447. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  25448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  25449. */
  25450. var Octree = /** @class */ (function () {
  25451. /**
  25452. * Creates a octree
  25453. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  25454. * @param creationFunc function to be used to instatiate the octree
  25455. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  25456. * @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.)
  25457. */
  25458. function Octree(creationFunc, maxBlockCapacity,
  25459. /** 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.) */
  25460. maxDepth) {
  25461. if (maxDepth === void 0) { maxDepth = 2; }
  25462. this.maxDepth = maxDepth;
  25463. /**
  25464. * Content stored in the octree
  25465. */
  25466. this.dynamicContent = new Array();
  25467. this._maxBlockCapacity = maxBlockCapacity || 64;
  25468. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  25469. this._creationFunc = creationFunc;
  25470. }
  25471. // Methods
  25472. /**
  25473. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  25474. * @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);
  25475. * @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);
  25476. * @param entries meshes to be added to the octree blocks
  25477. */
  25478. Octree.prototype.update = function (worldMin, worldMax, entries) {
  25479. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  25480. };
  25481. /**
  25482. * Adds a mesh to the octree
  25483. * @param entry Mesh to add to the octree
  25484. */
  25485. Octree.prototype.addMesh = function (entry) {
  25486. for (var index = 0; index < this.blocks.length; index++) {
  25487. var block = this.blocks[index];
  25488. block.addEntry(entry);
  25489. }
  25490. };
  25491. /**
  25492. * Remove an element from the octree
  25493. * @param entry defines the element to remove
  25494. */
  25495. Octree.prototype.removeMesh = function (entry) {
  25496. for (var index = 0; index < this.blocks.length; index++) {
  25497. var block = this.blocks[index];
  25498. block.removeEntry(entry);
  25499. }
  25500. };
  25501. /**
  25502. * Selects an array of meshes within the frustum
  25503. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  25504. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  25505. * @returns array of meshes within the frustum
  25506. */
  25507. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  25508. this._selectionContent.reset();
  25509. for (var index = 0; index < this.blocks.length; index++) {
  25510. var block = this.blocks[index];
  25511. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  25512. }
  25513. if (allowDuplicate) {
  25514. this._selectionContent.concat(this.dynamicContent);
  25515. }
  25516. else {
  25517. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  25518. }
  25519. return this._selectionContent;
  25520. };
  25521. /**
  25522. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  25523. * @param sphereCenter defines the bounding sphere center
  25524. * @param sphereRadius defines the bounding sphere radius
  25525. * @param allowDuplicate defines if the selection array can contains duplicated entries
  25526. * @returns an array of objects that intersect the sphere
  25527. */
  25528. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  25529. this._selectionContent.reset();
  25530. for (var index = 0; index < this.blocks.length; index++) {
  25531. var block = this.blocks[index];
  25532. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  25533. }
  25534. if (allowDuplicate) {
  25535. this._selectionContent.concat(this.dynamicContent);
  25536. }
  25537. else {
  25538. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  25539. }
  25540. return this._selectionContent;
  25541. };
  25542. /**
  25543. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  25544. * @param ray defines the ray to test with
  25545. * @returns array of intersected objects
  25546. */
  25547. Octree.prototype.intersectsRay = function (ray) {
  25548. this._selectionContent.reset();
  25549. for (var index = 0; index < this.blocks.length; index++) {
  25550. var block = this.blocks[index];
  25551. block.intersectsRay(ray, this._selectionContent);
  25552. }
  25553. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  25554. return this._selectionContent;
  25555. };
  25556. /**
  25557. * Adds a mesh into the octree block if it intersects the block
  25558. */
  25559. Octree.CreationFuncForMeshes = function (entry, block) {
  25560. var boundingInfo = entry.getBoundingInfo();
  25561. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  25562. block.entries.push(entry);
  25563. }
  25564. };
  25565. /**
  25566. * Adds a submesh into the octree block if it intersects the block
  25567. */
  25568. Octree.CreationFuncForSubMeshes = function (entry, block) {
  25569. var boundingInfo = entry.getBoundingInfo();
  25570. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  25571. block.entries.push(entry);
  25572. }
  25573. };
  25574. return Octree;
  25575. }());
  25576. /***/ }),
  25577. /***/ "./Culling/Octrees/octreeBlock.ts":
  25578. /*!****************************************!*\
  25579. !*** ./Culling/Octrees/octreeBlock.ts ***!
  25580. \****************************************/
  25581. /*! exports provided: OctreeBlock */
  25582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25583. "use strict";
  25584. __webpack_require__.r(__webpack_exports__);
  25585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  25586. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  25587. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  25588. /**
  25589. * Class used to store a cell in an octree
  25590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  25591. */
  25592. var OctreeBlock = /** @class */ (function () {
  25593. /**
  25594. * Creates a new block
  25595. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  25596. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  25597. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  25598. * @param depth defines the current depth of this block in the octree
  25599. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  25600. * @param creationFunc defines a callback to call when an element is added to the block
  25601. */
  25602. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  25603. /**
  25604. * Gets the content of the current block
  25605. */
  25606. this.entries = new Array();
  25607. this._boundingVectors = new Array();
  25608. this._capacity = capacity;
  25609. this._depth = depth;
  25610. this._maxDepth = maxDepth;
  25611. this._creationFunc = creationFunc;
  25612. this._minPoint = minPoint;
  25613. this._maxPoint = maxPoint;
  25614. this._boundingVectors.push(minPoint.clone());
  25615. this._boundingVectors.push(maxPoint.clone());
  25616. this._boundingVectors.push(minPoint.clone());
  25617. this._boundingVectors[2].x = maxPoint.x;
  25618. this._boundingVectors.push(minPoint.clone());
  25619. this._boundingVectors[3].y = maxPoint.y;
  25620. this._boundingVectors.push(minPoint.clone());
  25621. this._boundingVectors[4].z = maxPoint.z;
  25622. this._boundingVectors.push(maxPoint.clone());
  25623. this._boundingVectors[5].z = minPoint.z;
  25624. this._boundingVectors.push(maxPoint.clone());
  25625. this._boundingVectors[6].x = minPoint.x;
  25626. this._boundingVectors.push(maxPoint.clone());
  25627. this._boundingVectors[7].y = minPoint.y;
  25628. }
  25629. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  25630. // Property
  25631. /**
  25632. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  25633. */
  25634. get: function () {
  25635. return this._capacity;
  25636. },
  25637. enumerable: true,
  25638. configurable: true
  25639. });
  25640. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  25641. /**
  25642. * Gets the minimum vector (in world space) of the block's bounding box
  25643. */
  25644. get: function () {
  25645. return this._minPoint;
  25646. },
  25647. enumerable: true,
  25648. configurable: true
  25649. });
  25650. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  25651. /**
  25652. * Gets the maximum vector (in world space) of the block's bounding box
  25653. */
  25654. get: function () {
  25655. return this._maxPoint;
  25656. },
  25657. enumerable: true,
  25658. configurable: true
  25659. });
  25660. // Methods
  25661. /**
  25662. * Add a new element to this block
  25663. * @param entry defines the element to add
  25664. */
  25665. OctreeBlock.prototype.addEntry = function (entry) {
  25666. if (this.blocks) {
  25667. for (var index = 0; index < this.blocks.length; index++) {
  25668. var block = this.blocks[index];
  25669. block.addEntry(entry);
  25670. }
  25671. return;
  25672. }
  25673. this._creationFunc(entry, this);
  25674. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  25675. this.createInnerBlocks();
  25676. }
  25677. };
  25678. /**
  25679. * Remove an element from this block
  25680. * @param entry defines the element to remove
  25681. */
  25682. OctreeBlock.prototype.removeEntry = function (entry) {
  25683. if (this.blocks) {
  25684. for (var index = 0; index < this.blocks.length; index++) {
  25685. var block = this.blocks[index];
  25686. block.removeEntry(entry);
  25687. }
  25688. return;
  25689. }
  25690. var entryIndex = this.entries.indexOf(entry);
  25691. if (entryIndex > -1) {
  25692. this.entries.splice(entryIndex, 1);
  25693. }
  25694. };
  25695. /**
  25696. * Add an array of elements to this block
  25697. * @param entries defines the array of elements to add
  25698. */
  25699. OctreeBlock.prototype.addEntries = function (entries) {
  25700. for (var index = 0; index < entries.length; index++) {
  25701. var mesh = entries[index];
  25702. this.addEntry(mesh);
  25703. }
  25704. };
  25705. /**
  25706. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  25707. * @param frustumPlanes defines the frustum planes to test
  25708. * @param selection defines the array to store current content if selection is positive
  25709. * @param allowDuplicate defines if the selection array can contains duplicated entries
  25710. */
  25711. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  25712. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  25713. if (this.blocks) {
  25714. for (var index = 0; index < this.blocks.length; index++) {
  25715. var block = this.blocks[index];
  25716. block.select(frustumPlanes, selection, allowDuplicate);
  25717. }
  25718. return;
  25719. }
  25720. if (allowDuplicate) {
  25721. selection.concat(this.entries);
  25722. }
  25723. else {
  25724. selection.concatWithNoDuplicate(this.entries);
  25725. }
  25726. }
  25727. };
  25728. /**
  25729. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  25730. * @param sphereCenter defines the bounding sphere center
  25731. * @param sphereRadius defines the bounding sphere radius
  25732. * @param selection defines the array to store current content if selection is positive
  25733. * @param allowDuplicate defines if the selection array can contains duplicated entries
  25734. */
  25735. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  25736. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  25737. if (this.blocks) {
  25738. for (var index = 0; index < this.blocks.length; index++) {
  25739. var block = this.blocks[index];
  25740. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  25741. }
  25742. return;
  25743. }
  25744. if (allowDuplicate) {
  25745. selection.concat(this.entries);
  25746. }
  25747. else {
  25748. selection.concatWithNoDuplicate(this.entries);
  25749. }
  25750. }
  25751. };
  25752. /**
  25753. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  25754. * @param ray defines the ray to test with
  25755. * @param selection defines the array to store current content if selection is positive
  25756. */
  25757. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  25758. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  25759. if (this.blocks) {
  25760. for (var index = 0; index < this.blocks.length; index++) {
  25761. var block = this.blocks[index];
  25762. block.intersectsRay(ray, selection);
  25763. }
  25764. return;
  25765. }
  25766. selection.concatWithNoDuplicate(this.entries);
  25767. }
  25768. };
  25769. /**
  25770. * Subdivide the content into child blocks (this block will then be empty)
  25771. */
  25772. OctreeBlock.prototype.createInnerBlocks = function () {
  25773. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  25774. };
  25775. /**
  25776. * @hidden
  25777. */
  25778. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  25779. target.blocks = new Array();
  25780. var blockSize = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  25781. // Segmenting space
  25782. for (var x = 0; x < 2; x++) {
  25783. for (var y = 0; y < 2; y++) {
  25784. for (var z = 0; z < 2; z++) {
  25785. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  25786. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  25787. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  25788. block.addEntries(entries);
  25789. target.blocks.push(block);
  25790. }
  25791. }
  25792. }
  25793. };
  25794. return OctreeBlock;
  25795. }());
  25796. /***/ }),
  25797. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  25798. /*!*************************************************!*\
  25799. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  25800. \*************************************************/
  25801. /*! exports provided: OctreeSceneComponent */
  25802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25803. "use strict";
  25804. __webpack_require__.r(__webpack_exports__);
  25805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  25806. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  25807. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  25808. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  25809. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  25810. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  25811. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  25812. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  25813. if (maxCapacity === void 0) { maxCapacity = 64; }
  25814. if (maxDepth === void 0) { maxDepth = 2; }
  25815. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  25816. if (!component) {
  25817. component = new OctreeSceneComponent(this);
  25818. this._addComponent(component);
  25819. }
  25820. if (!this._selectionOctree) {
  25821. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  25822. }
  25823. var worldExtends = this.getWorldExtends();
  25824. // Update octree
  25825. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  25826. return this._selectionOctree;
  25827. };
  25828. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  25829. get: function () {
  25830. return this._selectionOctree;
  25831. },
  25832. enumerable: true,
  25833. configurable: true
  25834. });
  25835. /**
  25836. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  25837. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25838. * @param maxCapacity defines the maximum size of each block (64 by default)
  25839. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  25840. * @returns the new octree
  25841. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  25842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  25843. */
  25844. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  25845. if (maxCapacity === void 0) { maxCapacity = 64; }
  25846. if (maxDepth === void 0) { maxDepth = 2; }
  25847. var scene = this.getScene();
  25848. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  25849. if (!component) {
  25850. component = new OctreeSceneComponent(scene);
  25851. scene._addComponent(component);
  25852. }
  25853. if (!this._submeshesOctree) {
  25854. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  25855. }
  25856. this.computeWorldMatrix(true);
  25857. var boundingInfo = this.getBoundingInfo();
  25858. // Update octree
  25859. var bbox = boundingInfo.boundingBox;
  25860. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  25861. return this._submeshesOctree;
  25862. };
  25863. /**
  25864. * Defines the octree scene component responsible to manage any octrees
  25865. * in a given scene.
  25866. */
  25867. var OctreeSceneComponent = /** @class */ (function () {
  25868. /**
  25869. * Creates a new instance of the component for the given scene
  25870. * @param scene Defines the scene to register the component in
  25871. */
  25872. function OctreeSceneComponent(scene) {
  25873. /**
  25874. * The component name help to identify the component in the list of scene components.
  25875. */
  25876. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  25877. /**
  25878. * Indicates if the meshes have been checked to make sure they are isEnabled()
  25879. */
  25880. this.checksIsEnabled = true;
  25881. this._tempRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](1, 1, 1));
  25882. this.scene = scene;
  25883. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  25884. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  25885. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  25886. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  25887. }
  25888. /**
  25889. * Registers the component in a given scene
  25890. */
  25891. OctreeSceneComponent.prototype.register = function () {
  25892. var _this = this;
  25893. this.scene.onMeshRemovedObservable.add(function (mesh) {
  25894. var sceneOctree = _this.scene.selectionOctree;
  25895. if (sceneOctree !== undefined && sceneOctree !== null) {
  25896. var index = sceneOctree.dynamicContent.indexOf(mesh);
  25897. if (index !== -1) {
  25898. sceneOctree.dynamicContent.splice(index, 1);
  25899. }
  25900. }
  25901. });
  25902. this.scene.onMeshImportedObservable.add(function (mesh) {
  25903. var sceneOctree = _this.scene.selectionOctree;
  25904. if (sceneOctree !== undefined && sceneOctree !== null) {
  25905. sceneOctree.addMesh(mesh);
  25906. }
  25907. });
  25908. };
  25909. /**
  25910. * Return the list of active meshes
  25911. * @returns the list of active meshes
  25912. */
  25913. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  25914. if (this.scene._selectionOctree) {
  25915. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  25916. return selection;
  25917. }
  25918. return this.scene._getDefaultMeshCandidates();
  25919. };
  25920. /**
  25921. * Return the list of active sub meshes
  25922. * @param mesh The mesh to get the candidates sub meshes from
  25923. * @returns the list of active sub meshes
  25924. */
  25925. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  25926. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  25927. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  25928. return intersections;
  25929. }
  25930. return this.scene._getDefaultSubMeshCandidates(mesh);
  25931. };
  25932. /**
  25933. * Return the list of sub meshes intersecting with a given local ray
  25934. * @param mesh defines the mesh to find the submesh for
  25935. * @param localRay defines the ray in local space
  25936. * @returns the list of intersecting sub meshes
  25937. */
  25938. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  25939. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  25940. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  25941. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  25942. return intersections;
  25943. }
  25944. return this.scene._getDefaultSubMeshCandidates(mesh);
  25945. };
  25946. /**
  25947. * Return the list of sub meshes colliding with a collider
  25948. * @param mesh defines the mesh to find the submesh for
  25949. * @param collider defines the collider to evaluate the collision against
  25950. * @returns the list of colliding sub meshes
  25951. */
  25952. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  25953. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  25954. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  25955. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  25956. return intersections;
  25957. }
  25958. return this.scene._getDefaultSubMeshCandidates(mesh);
  25959. };
  25960. /**
  25961. * Rebuilds the elements related to this component in case of
  25962. * context lost for instance.
  25963. */
  25964. OctreeSceneComponent.prototype.rebuild = function () {
  25965. // Nothing to do here.
  25966. };
  25967. /**
  25968. * Disposes the component and the associated ressources.
  25969. */
  25970. OctreeSceneComponent.prototype.dispose = function () {
  25971. // Nothing to do here.
  25972. };
  25973. return OctreeSceneComponent;
  25974. }());
  25975. /***/ }),
  25976. /***/ "./Culling/boundingBox.ts":
  25977. /*!********************************!*\
  25978. !*** ./Culling/boundingBox.ts ***!
  25979. \********************************/
  25980. /*! exports provided: BoundingBox */
  25981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25982. "use strict";
  25983. __webpack_require__.r(__webpack_exports__);
  25984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  25985. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25986. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  25987. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  25988. /**
  25989. * Class used to store bounding box information
  25990. */
  25991. var BoundingBox = /** @class */ (function () {
  25992. /**
  25993. * Creates a new bounding box
  25994. * @param min defines the minimum vector (in local space)
  25995. * @param max defines the maximum vector (in local space)
  25996. * @param worldMatrix defines the new world matrix
  25997. */
  25998. function BoundingBox(min, max, worldMatrix) {
  25999. /**
  26000. * Gets the 8 vectors representing the bounding box in local space
  26001. */
  26002. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26003. /**
  26004. * Gets the center of the bounding box in local space
  26005. */
  26006. this.center = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26007. /**
  26008. * Gets the center of the bounding box in world space
  26009. */
  26010. this.centerWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26011. /**
  26012. * Gets the extend size in local space
  26013. */
  26014. this.extendSize = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26015. /**
  26016. * Gets the extend size in world space
  26017. */
  26018. this.extendSizeWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26019. /**
  26020. * Gets the OBB (object bounding box) directions
  26021. */
  26022. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26023. /**
  26024. * Gets the 8 vectors representing the bounding box in world space
  26025. */
  26026. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26027. /**
  26028. * Gets the minimum vector in world space
  26029. */
  26030. this.minimumWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26031. /**
  26032. * Gets the maximum vector in world space
  26033. */
  26034. this.maximumWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26035. /**
  26036. * Gets the minimum vector in local space
  26037. */
  26038. this.minimum = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26039. /**
  26040. * Gets the maximum vector in local space
  26041. */
  26042. this.maximum = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26043. this.reConstruct(min, max, worldMatrix);
  26044. }
  26045. // Methods
  26046. /**
  26047. * Recreates the entire bounding box from scratch as if we call the constructor in place
  26048. * @param min defines the new minimum vector (in local space)
  26049. * @param max defines the new maximum vector (in local space)
  26050. * @param worldMatrix defines the new world matrix
  26051. */
  26052. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  26053. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  26054. var vectors = this.vectors;
  26055. this.minimum.copyFromFloats(minX, minY, minZ);
  26056. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  26057. vectors[0].copyFromFloats(minX, minY, minZ);
  26058. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  26059. vectors[2].copyFromFloats(maxX, minY, minZ);
  26060. vectors[3].copyFromFloats(minX, maxY, minZ);
  26061. vectors[4].copyFromFloats(minX, minY, maxZ);
  26062. vectors[5].copyFromFloats(maxX, maxY, minZ);
  26063. vectors[6].copyFromFloats(minX, maxY, maxZ);
  26064. vectors[7].copyFromFloats(maxX, minY, maxZ);
  26065. // OBB
  26066. max.addToRef(min, this.center).scaleInPlace(0.5);
  26067. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  26068. this._worldMatrix = worldMatrix || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly;
  26069. this._update(this._worldMatrix);
  26070. };
  26071. /**
  26072. * Scale the current bounding box by applying a scale factor
  26073. * @param factor defines the scale factor to apply
  26074. * @returns the current bounding box
  26075. */
  26076. BoundingBox.prototype.scale = function (factor) {
  26077. var tmpVectors = BoundingBox.TmpVector3;
  26078. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  26079. var len = diff.length();
  26080. diff.normalizeFromLength(len);
  26081. var distance = len * factor;
  26082. var newRadius = diff.scaleInPlace(distance * 0.5);
  26083. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  26084. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  26085. this.reConstruct(min, max, this._worldMatrix);
  26086. return this;
  26087. };
  26088. /**
  26089. * Gets the world matrix of the bounding box
  26090. * @returns a matrix
  26091. */
  26092. BoundingBox.prototype.getWorldMatrix = function () {
  26093. return this._worldMatrix;
  26094. };
  26095. /** @hidden */
  26096. BoundingBox.prototype._update = function (world) {
  26097. var minWorld = this.minimumWorld;
  26098. var maxWorld = this.maximumWorld;
  26099. var directions = this.directions;
  26100. var vectorsWorld = this.vectorsWorld;
  26101. var vectors = this.vectors;
  26102. if (!world.isIdentity()) {
  26103. minWorld.setAll(Number.MAX_VALUE);
  26104. maxWorld.setAll(-Number.MAX_VALUE);
  26105. for (var index = 0; index < 8; ++index) {
  26106. var v = vectorsWorld[index];
  26107. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  26108. minWorld.minimizeInPlace(v);
  26109. maxWorld.maximizeInPlace(v);
  26110. }
  26111. // Extend
  26112. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  26113. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  26114. }
  26115. else {
  26116. minWorld.copyFrom(this.minimum);
  26117. maxWorld.copyFrom(this.maximum);
  26118. for (var index = 0; index < 8; ++index) {
  26119. vectorsWorld[index].copyFrom(vectors[index]);
  26120. }
  26121. // Extend
  26122. this.extendSizeWorld.copyFrom(this.extendSize);
  26123. this.centerWorld.copyFrom(this.center);
  26124. }
  26125. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  26126. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  26127. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  26128. this._worldMatrix = world;
  26129. };
  26130. /**
  26131. * Tests if the bounding box is intersecting the frustum planes
  26132. * @param frustumPlanes defines the frustum planes to test
  26133. * @returns true if there is an intersection
  26134. */
  26135. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  26136. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  26137. };
  26138. /**
  26139. * Tests if the bounding box is entirely inside the frustum planes
  26140. * @param frustumPlanes defines the frustum planes to test
  26141. * @returns true if there is an inclusion
  26142. */
  26143. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  26144. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  26145. };
  26146. /**
  26147. * Tests if a point is inside the bounding box
  26148. * @param point defines the point to test
  26149. * @returns true if the point is inside the bounding box
  26150. */
  26151. BoundingBox.prototype.intersectsPoint = function (point) {
  26152. var min = this.minimumWorld;
  26153. var max = this.maximumWorld;
  26154. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  26155. var pointX = point.x, pointY = point.y, pointZ = point.z;
  26156. var delta = -_Maths_math_constants__WEBPACK_IMPORTED_MODULE_2__["Epsilon"];
  26157. if (maxX - pointX < delta || delta > pointX - minX) {
  26158. return false;
  26159. }
  26160. if (maxY - pointY < delta || delta > pointY - minY) {
  26161. return false;
  26162. }
  26163. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  26164. return false;
  26165. }
  26166. return true;
  26167. };
  26168. /**
  26169. * Tests if the bounding box intersects with a bounding sphere
  26170. * @param sphere defines the sphere to test
  26171. * @returns true if there is an intersection
  26172. */
  26173. BoundingBox.prototype.intersectsSphere = function (sphere) {
  26174. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  26175. };
  26176. /**
  26177. * Tests if the bounding box intersects with a box defined by a min and max vectors
  26178. * @param min defines the min vector to use
  26179. * @param max defines the max vector to use
  26180. * @returns true if there is an intersection
  26181. */
  26182. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  26183. var myMin = this.minimumWorld;
  26184. var myMax = this.maximumWorld;
  26185. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  26186. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  26187. if (myMaxX < minX || myMinX > maxX) {
  26188. return false;
  26189. }
  26190. if (myMaxY < minY || myMinY > maxY) {
  26191. return false;
  26192. }
  26193. if (myMaxZ < minZ || myMinZ > maxZ) {
  26194. return false;
  26195. }
  26196. return true;
  26197. };
  26198. // Statics
  26199. /**
  26200. * Tests if two bounding boxes are intersections
  26201. * @param box0 defines the first box to test
  26202. * @param box1 defines the second box to test
  26203. * @returns true if there is an intersection
  26204. */
  26205. BoundingBox.Intersects = function (box0, box1) {
  26206. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  26207. };
  26208. /**
  26209. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  26210. * @param minPoint defines the minimum vector of the bounding box
  26211. * @param maxPoint defines the maximum vector of the bounding box
  26212. * @param sphereCenter defines the sphere center
  26213. * @param sphereRadius defines the sphere radius
  26214. * @returns true if there is an intersection
  26215. */
  26216. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  26217. var vector = BoundingBox.TmpVector3[0];
  26218. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  26219. var num = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  26220. return (num <= (sphereRadius * sphereRadius));
  26221. };
  26222. /**
  26223. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  26224. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  26225. * @param frustumPlanes defines the frustum planes to test
  26226. * @return true if there is an inclusion
  26227. */
  26228. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  26229. for (var p = 0; p < 6; ++p) {
  26230. var frustumPlane = frustumPlanes[p];
  26231. for (var i = 0; i < 8; ++i) {
  26232. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  26233. return false;
  26234. }
  26235. }
  26236. }
  26237. return true;
  26238. };
  26239. /**
  26240. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  26241. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  26242. * @param frustumPlanes defines the frustum planes to test
  26243. * @return true if there is an intersection
  26244. */
  26245. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  26246. for (var p = 0; p < 6; ++p) {
  26247. var canReturnFalse = true;
  26248. var frustumPlane = frustumPlanes[p];
  26249. for (var i = 0; i < 8; ++i) {
  26250. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  26251. canReturnFalse = false;
  26252. break;
  26253. }
  26254. }
  26255. if (canReturnFalse) {
  26256. return false;
  26257. }
  26258. }
  26259. return true;
  26260. };
  26261. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26262. return BoundingBox;
  26263. }());
  26264. /***/ }),
  26265. /***/ "./Culling/boundingInfo.ts":
  26266. /*!*********************************!*\
  26267. !*** ./Culling/boundingInfo.ts ***!
  26268. \*********************************/
  26269. /*! exports provided: BoundingInfo */
  26270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26271. "use strict";
  26272. __webpack_require__.r(__webpack_exports__);
  26273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  26274. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  26275. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  26276. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  26277. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  26278. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  26279. var _result0 = { min: 0, max: 0 };
  26280. var _result1 = { min: 0, max: 0 };
  26281. var computeBoxExtents = function (axis, box, result) {
  26282. var p = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  26283. var r0 = Math.abs(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  26284. var r1 = Math.abs(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  26285. var r2 = Math.abs(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  26286. var r = r0 + r1 + r2;
  26287. result.min = p - r;
  26288. result.max = p + r;
  26289. };
  26290. var axisOverlap = function (axis, box0, box1) {
  26291. computeBoxExtents(axis, box0, _result0);
  26292. computeBoxExtents(axis, box1, _result1);
  26293. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  26294. };
  26295. /**
  26296. * Info for a bounding data of a mesh
  26297. */
  26298. var BoundingInfo = /** @class */ (function () {
  26299. /**
  26300. * Constructs bounding info
  26301. * @param minimum min vector of the bounding box/sphere
  26302. * @param maximum max vector of the bounding box/sphere
  26303. * @param worldMatrix defines the new world matrix
  26304. */
  26305. function BoundingInfo(minimum, maximum, worldMatrix) {
  26306. this._isLocked = false;
  26307. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  26308. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  26309. }
  26310. /**
  26311. * Recreates the entire bounding info from scratch as if we call the constructor in place
  26312. * @param min defines the new minimum vector (in local space)
  26313. * @param max defines the new maximum vector (in local space)
  26314. * @param worldMatrix defines the new world matrix
  26315. */
  26316. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  26317. this.boundingBox.reConstruct(min, max, worldMatrix);
  26318. this.boundingSphere.reConstruct(min, max, worldMatrix);
  26319. };
  26320. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  26321. /**
  26322. * min vector of the bounding box/sphere
  26323. */
  26324. get: function () {
  26325. return this.boundingBox.minimum;
  26326. },
  26327. enumerable: true,
  26328. configurable: true
  26329. });
  26330. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  26331. /**
  26332. * max vector of the bounding box/sphere
  26333. */
  26334. get: function () {
  26335. return this.boundingBox.maximum;
  26336. },
  26337. enumerable: true,
  26338. configurable: true
  26339. });
  26340. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  26341. /**
  26342. * If the info is locked and won't be updated to avoid perf overhead
  26343. */
  26344. get: function () {
  26345. return this._isLocked;
  26346. },
  26347. set: function (value) {
  26348. this._isLocked = value;
  26349. },
  26350. enumerable: true,
  26351. configurable: true
  26352. });
  26353. // Methods
  26354. /**
  26355. * Updates the bounding sphere and box
  26356. * @param world world matrix to be used to update
  26357. */
  26358. BoundingInfo.prototype.update = function (world) {
  26359. if (this._isLocked) {
  26360. return;
  26361. }
  26362. this.boundingBox._update(world);
  26363. this.boundingSphere._update(world);
  26364. };
  26365. /**
  26366. * Recreate the bounding info to be centered around a specific point given a specific extend.
  26367. * @param center New center of the bounding info
  26368. * @param extend New extend of the bounding info
  26369. * @returns the current bounding info
  26370. */
  26371. BoundingInfo.prototype.centerOn = function (center, extend) {
  26372. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  26373. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  26374. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  26375. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  26376. return this;
  26377. };
  26378. /**
  26379. * Scale the current bounding info by applying a scale factor
  26380. * @param factor defines the scale factor to apply
  26381. * @returns the current bounding info
  26382. */
  26383. BoundingInfo.prototype.scale = function (factor) {
  26384. this.boundingBox.scale(factor);
  26385. this.boundingSphere.scale(factor);
  26386. return this;
  26387. };
  26388. /**
  26389. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  26390. * @param frustumPlanes defines the frustum to test
  26391. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  26392. * @returns true if the bounding info is in the frustum planes
  26393. */
  26394. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  26395. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  26396. 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);
  26397. if (inclusionTest) {
  26398. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  26399. return true;
  26400. }
  26401. }
  26402. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  26403. return false;
  26404. }
  26405. 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);
  26406. if (bSphereOnlyTest) {
  26407. return true;
  26408. }
  26409. return this.boundingBox.isInFrustum(frustumPlanes);
  26410. };
  26411. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  26412. /**
  26413. * Gets the world distance between the min and max points of the bounding box
  26414. */
  26415. get: function () {
  26416. var boundingBox = this.boundingBox;
  26417. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  26418. return diag.length();
  26419. },
  26420. enumerable: true,
  26421. configurable: true
  26422. });
  26423. /**
  26424. * Checks if a cullable object (mesh...) is in the camera frustum
  26425. * Unlike isInFrustum this cheks the full bounding box
  26426. * @param frustumPlanes Camera near/planes
  26427. * @returns true if the object is in frustum otherwise false
  26428. */
  26429. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  26430. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  26431. };
  26432. /** @hidden */
  26433. BoundingInfo.prototype._checkCollision = function (collider) {
  26434. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  26435. };
  26436. /**
  26437. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  26438. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26439. * @param point the point to check intersection with
  26440. * @returns if the point intersects
  26441. */
  26442. BoundingInfo.prototype.intersectsPoint = function (point) {
  26443. if (!this.boundingSphere.centerWorld) {
  26444. return false;
  26445. }
  26446. if (!this.boundingSphere.intersectsPoint(point)) {
  26447. return false;
  26448. }
  26449. if (!this.boundingBox.intersectsPoint(point)) {
  26450. return false;
  26451. }
  26452. return true;
  26453. };
  26454. /**
  26455. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  26456. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26457. * @param boundingInfo the bounding info to check intersection with
  26458. * @param precise if the intersection should be done using OBB
  26459. * @returns if the bounding info intersects
  26460. */
  26461. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  26462. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  26463. return false;
  26464. }
  26465. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  26466. return false;
  26467. }
  26468. if (!precise) {
  26469. return true;
  26470. }
  26471. var box0 = this.boundingBox;
  26472. var box1 = boundingInfo.boundingBox;
  26473. if (!axisOverlap(box0.directions[0], box0, box1)) {
  26474. return false;
  26475. }
  26476. if (!axisOverlap(box0.directions[1], box0, box1)) {
  26477. return false;
  26478. }
  26479. if (!axisOverlap(box0.directions[2], box0, box1)) {
  26480. return false;
  26481. }
  26482. if (!axisOverlap(box1.directions[0], box0, box1)) {
  26483. return false;
  26484. }
  26485. if (!axisOverlap(box1.directions[1], box0, box1)) {
  26486. return false;
  26487. }
  26488. if (!axisOverlap(box1.directions[2], box0, box1)) {
  26489. return false;
  26490. }
  26491. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  26492. return false;
  26493. }
  26494. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  26495. return false;
  26496. }
  26497. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  26498. return false;
  26499. }
  26500. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  26501. return false;
  26502. }
  26503. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  26504. return false;
  26505. }
  26506. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  26507. return false;
  26508. }
  26509. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  26510. return false;
  26511. }
  26512. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  26513. return false;
  26514. }
  26515. if (!axisOverlap(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  26516. return false;
  26517. }
  26518. return true;
  26519. };
  26520. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26521. return BoundingInfo;
  26522. }());
  26523. /***/ }),
  26524. /***/ "./Culling/boundingSphere.ts":
  26525. /*!***********************************!*\
  26526. !*** ./Culling/boundingSphere.ts ***!
  26527. \***********************************/
  26528. /*! exports provided: BoundingSphere */
  26529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26530. "use strict";
  26531. __webpack_require__.r(__webpack_exports__);
  26532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  26533. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  26534. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  26535. /**
  26536. * Class used to store bounding sphere information
  26537. */
  26538. var BoundingSphere = /** @class */ (function () {
  26539. /**
  26540. * Creates a new bounding sphere
  26541. * @param min defines the minimum vector (in local space)
  26542. * @param max defines the maximum vector (in local space)
  26543. * @param worldMatrix defines the new world matrix
  26544. */
  26545. function BoundingSphere(min, max, worldMatrix) {
  26546. /**
  26547. * Gets the center of the bounding sphere in local space
  26548. */
  26549. this.center = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26550. /**
  26551. * Gets the center of the bounding sphere in world space
  26552. */
  26553. this.centerWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26554. /**
  26555. * Gets the minimum vector in local space
  26556. */
  26557. this.minimum = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26558. /**
  26559. * Gets the maximum vector in local space
  26560. */
  26561. this.maximum = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  26562. this.reConstruct(min, max, worldMatrix);
  26563. }
  26564. /**
  26565. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  26566. * @param min defines the new minimum vector (in local space)
  26567. * @param max defines the new maximum vector (in local space)
  26568. * @param worldMatrix defines the new world matrix
  26569. */
  26570. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  26571. this.minimum.copyFrom(min);
  26572. this.maximum.copyFrom(max);
  26573. var distance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  26574. max.addToRef(min, this.center).scaleInPlace(0.5);
  26575. this.radius = distance * 0.5;
  26576. this._update(worldMatrix || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  26577. };
  26578. /**
  26579. * Scale the current bounding sphere by applying a scale factor
  26580. * @param factor defines the scale factor to apply
  26581. * @returns the current bounding box
  26582. */
  26583. BoundingSphere.prototype.scale = function (factor) {
  26584. var newRadius = this.radius * factor;
  26585. var tmpVectors = BoundingSphere.TmpVector3;
  26586. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  26587. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  26588. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  26589. this.reConstruct(min, max, this._worldMatrix);
  26590. return this;
  26591. };
  26592. /**
  26593. * Gets the world matrix of the bounding box
  26594. * @returns a matrix
  26595. */
  26596. BoundingSphere.prototype.getWorldMatrix = function () {
  26597. return this._worldMatrix;
  26598. };
  26599. // Methods
  26600. /** @hidden */
  26601. BoundingSphere.prototype._update = function (worldMatrix) {
  26602. if (!worldMatrix.isIdentity()) {
  26603. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  26604. var tempVector = BoundingSphere.TmpVector3[0];
  26605. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  26606. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  26607. }
  26608. else {
  26609. this.centerWorld.copyFrom(this.center);
  26610. this.radiusWorld = this.radius;
  26611. }
  26612. };
  26613. /**
  26614. * Tests if the bounding sphere is intersecting the frustum planes
  26615. * @param frustumPlanes defines the frustum planes to test
  26616. * @returns true if there is an intersection
  26617. */
  26618. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  26619. var center = this.centerWorld;
  26620. var radius = this.radiusWorld;
  26621. for (var i = 0; i < 6; i++) {
  26622. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  26623. return false;
  26624. }
  26625. }
  26626. return true;
  26627. };
  26628. /**
  26629. * Tests if the bounding sphere center is in between the frustum planes.
  26630. * Used for optimistic fast inclusion.
  26631. * @param frustumPlanes defines the frustum planes to test
  26632. * @returns true if the sphere center is in between the frustum planes
  26633. */
  26634. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  26635. var center = this.centerWorld;
  26636. for (var i = 0; i < 6; i++) {
  26637. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  26638. return false;
  26639. }
  26640. }
  26641. return true;
  26642. };
  26643. /**
  26644. * Tests if a point is inside the bounding sphere
  26645. * @param point defines the point to test
  26646. * @returns true if the point is inside the bounding sphere
  26647. */
  26648. BoundingSphere.prototype.intersectsPoint = function (point) {
  26649. var squareDistance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  26650. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  26651. return false;
  26652. }
  26653. return true;
  26654. };
  26655. // Statics
  26656. /**
  26657. * Checks if two sphere intersct
  26658. * @param sphere0 sphere 0
  26659. * @param sphere1 sphere 1
  26660. * @returns true if the speres intersect
  26661. */
  26662. BoundingSphere.Intersects = function (sphere0, sphere1) {
  26663. var squareDistance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  26664. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  26665. if (radiusSum * radiusSum < squareDistance) {
  26666. return false;
  26667. }
  26668. return true;
  26669. };
  26670. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26671. return BoundingSphere;
  26672. }());
  26673. /***/ }),
  26674. /***/ "./Culling/index.ts":
  26675. /*!**************************!*\
  26676. !*** ./Culling/index.ts ***!
  26677. \**************************/
  26678. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  26679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26680. "use strict";
  26681. __webpack_require__.r(__webpack_exports__);
  26682. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  26683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  26684. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  26685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  26686. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  26687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  26688. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  26689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  26690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  26691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  26692. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  26693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  26694. /***/ }),
  26695. /***/ "./Culling/ray.ts":
  26696. /*!************************!*\
  26697. !*** ./Culling/ray.ts ***!
  26698. \************************/
  26699. /*! exports provided: Ray */
  26700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26701. "use strict";
  26702. __webpack_require__.r(__webpack_exports__);
  26703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  26704. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  26705. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  26706. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  26707. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  26708. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26709. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  26710. /**
  26711. * Class representing a ray with position and direction
  26712. */
  26713. var Ray = /** @class */ (function () {
  26714. /**
  26715. * Creates a new ray
  26716. * @param origin origin point
  26717. * @param direction direction
  26718. * @param length length of the ray
  26719. */
  26720. function Ray(
  26721. /** origin point */
  26722. origin,
  26723. /** direction */
  26724. direction,
  26725. /** length of the ray */
  26726. length) {
  26727. if (length === void 0) { length = Number.MAX_VALUE; }
  26728. this.origin = origin;
  26729. this.direction = direction;
  26730. this.length = length;
  26731. }
  26732. // Methods
  26733. /**
  26734. * Checks if the ray intersects a box
  26735. * @param minimum bound of the box
  26736. * @param maximum bound of the box
  26737. * @param intersectionTreshold extra extend to be added to the box in all direction
  26738. * @returns if the box was hit
  26739. */
  26740. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  26741. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  26742. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  26743. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  26744. var d = 0.0;
  26745. var maxValue = Number.MAX_VALUE;
  26746. var inv;
  26747. var min;
  26748. var max;
  26749. var temp;
  26750. if (Math.abs(this.direction.x) < 0.0000001) {
  26751. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  26752. return false;
  26753. }
  26754. }
  26755. else {
  26756. inv = 1.0 / this.direction.x;
  26757. min = (newMinimum.x - this.origin.x) * inv;
  26758. max = (newMaximum.x - this.origin.x) * inv;
  26759. if (max === -Infinity) {
  26760. max = Infinity;
  26761. }
  26762. if (min > max) {
  26763. temp = min;
  26764. min = max;
  26765. max = temp;
  26766. }
  26767. d = Math.max(min, d);
  26768. maxValue = Math.min(max, maxValue);
  26769. if (d > maxValue) {
  26770. return false;
  26771. }
  26772. }
  26773. if (Math.abs(this.direction.y) < 0.0000001) {
  26774. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  26775. return false;
  26776. }
  26777. }
  26778. else {
  26779. inv = 1.0 / this.direction.y;
  26780. min = (newMinimum.y - this.origin.y) * inv;
  26781. max = (newMaximum.y - this.origin.y) * inv;
  26782. if (max === -Infinity) {
  26783. max = Infinity;
  26784. }
  26785. if (min > max) {
  26786. temp = min;
  26787. min = max;
  26788. max = temp;
  26789. }
  26790. d = Math.max(min, d);
  26791. maxValue = Math.min(max, maxValue);
  26792. if (d > maxValue) {
  26793. return false;
  26794. }
  26795. }
  26796. if (Math.abs(this.direction.z) < 0.0000001) {
  26797. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  26798. return false;
  26799. }
  26800. }
  26801. else {
  26802. inv = 1.0 / this.direction.z;
  26803. min = (newMinimum.z - this.origin.z) * inv;
  26804. max = (newMaximum.z - this.origin.z) * inv;
  26805. if (max === -Infinity) {
  26806. max = Infinity;
  26807. }
  26808. if (min > max) {
  26809. temp = min;
  26810. min = max;
  26811. max = temp;
  26812. }
  26813. d = Math.max(min, d);
  26814. maxValue = Math.min(max, maxValue);
  26815. if (d > maxValue) {
  26816. return false;
  26817. }
  26818. }
  26819. return true;
  26820. };
  26821. /**
  26822. * Checks if the ray intersects a box
  26823. * @param box the bounding box to check
  26824. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  26825. * @returns if the box was hit
  26826. */
  26827. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  26828. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  26829. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  26830. };
  26831. /**
  26832. * If the ray hits a sphere
  26833. * @param sphere the bounding sphere to check
  26834. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  26835. * @returns true if it hits the sphere
  26836. */
  26837. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  26838. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  26839. var x = sphere.center.x - this.origin.x;
  26840. var y = sphere.center.y - this.origin.y;
  26841. var z = sphere.center.z - this.origin.z;
  26842. var pyth = (x * x) + (y * y) + (z * z);
  26843. var radius = sphere.radius + intersectionTreshold;
  26844. var rr = radius * radius;
  26845. if (pyth <= rr) {
  26846. return true;
  26847. }
  26848. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  26849. if (dot < 0.0) {
  26850. return false;
  26851. }
  26852. var temp = pyth - (dot * dot);
  26853. return temp <= rr;
  26854. };
  26855. /**
  26856. * If the ray hits a triange
  26857. * @param vertex0 triangle vertex
  26858. * @param vertex1 triangle vertex
  26859. * @param vertex2 triangle vertex
  26860. * @returns intersection information if hit
  26861. */
  26862. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  26863. var edge1 = Ray.TmpVector3[0];
  26864. var edge2 = Ray.TmpVector3[1];
  26865. var pvec = Ray.TmpVector3[2];
  26866. var tvec = Ray.TmpVector3[3];
  26867. var qvec = Ray.TmpVector3[4];
  26868. vertex1.subtractToRef(vertex0, edge1);
  26869. vertex2.subtractToRef(vertex0, edge2);
  26870. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  26871. var det = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  26872. if (det === 0) {
  26873. return null;
  26874. }
  26875. var invdet = 1 / det;
  26876. this.origin.subtractToRef(vertex0, tvec);
  26877. var bv = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  26878. if (bv < 0 || bv > 1.0) {
  26879. return null;
  26880. }
  26881. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  26882. var bw = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  26883. if (bw < 0 || bv + bw > 1.0) {
  26884. return null;
  26885. }
  26886. //check if the distance is longer than the predefined length.
  26887. var distance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  26888. if (distance > this.length) {
  26889. return null;
  26890. }
  26891. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](1 - bv - bw, bv, distance);
  26892. };
  26893. /**
  26894. * Checks if ray intersects a plane
  26895. * @param plane the plane to check
  26896. * @returns the distance away it was hit
  26897. */
  26898. Ray.prototype.intersectsPlane = function (plane) {
  26899. var distance;
  26900. var result1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  26901. if (Math.abs(result1) < 9.99999997475243E-07) {
  26902. return null;
  26903. }
  26904. else {
  26905. var result2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  26906. distance = (-plane.d - result2) / result1;
  26907. if (distance < 0.0) {
  26908. if (distance < -9.99999997475243E-07) {
  26909. return null;
  26910. }
  26911. else {
  26912. return 0;
  26913. }
  26914. }
  26915. return distance;
  26916. }
  26917. };
  26918. /**
  26919. * Calculate the intercept of a ray on a given axis
  26920. * @param axis to check 'x' | 'y' | 'z'
  26921. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  26922. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  26923. */
  26924. Ray.prototype.intersectsAxis = function (axis, offset) {
  26925. if (offset === void 0) { offset = 0; }
  26926. switch (axis) {
  26927. case 'y':
  26928. var t = (this.origin.y - offset) / this.direction.y;
  26929. if (t > 0) {
  26930. return null;
  26931. }
  26932. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this.origin.x + (this.direction.x * -t), offset, this.origin.z + (this.direction.z * -t));
  26933. case 'x':
  26934. var t = (this.origin.x - offset) / this.direction.x;
  26935. if (t > 0) {
  26936. return null;
  26937. }
  26938. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](offset, this.origin.y + (this.direction.y * -t), this.origin.z + (this.direction.z * -t));
  26939. case 'z':
  26940. var t = (this.origin.z - offset) / this.direction.z;
  26941. if (t > 0) {
  26942. return null;
  26943. }
  26944. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this.origin.x + (this.direction.x * -t), this.origin.y + (this.direction.y * -t), offset);
  26945. default:
  26946. return null;
  26947. }
  26948. };
  26949. /**
  26950. * Checks if ray intersects a mesh
  26951. * @param mesh the mesh to check
  26952. * @param fastCheck if only the bounding box should checked
  26953. * @returns picking info of the intersecton
  26954. */
  26955. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  26956. var tm = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0];
  26957. mesh.getWorldMatrix().invertToRef(tm);
  26958. if (this._tmpRay) {
  26959. Ray.TransformToRef(this, tm, this._tmpRay);
  26960. }
  26961. else {
  26962. this._tmpRay = Ray.Transform(this, tm);
  26963. }
  26964. return mesh.intersects(this._tmpRay, fastCheck);
  26965. };
  26966. /**
  26967. * Checks if ray intersects a mesh
  26968. * @param meshes the meshes to check
  26969. * @param fastCheck if only the bounding box should checked
  26970. * @param results array to store result in
  26971. * @returns Array of picking infos
  26972. */
  26973. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  26974. if (results) {
  26975. results.length = 0;
  26976. }
  26977. else {
  26978. results = [];
  26979. }
  26980. for (var i = 0; i < meshes.length; i++) {
  26981. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  26982. if (pickInfo.hit) {
  26983. results.push(pickInfo);
  26984. }
  26985. }
  26986. results.sort(this._comparePickingInfo);
  26987. return results;
  26988. };
  26989. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  26990. if (pickingInfoA.distance < pickingInfoB.distance) {
  26991. return -1;
  26992. }
  26993. else if (pickingInfoA.distance > pickingInfoB.distance) {
  26994. return 1;
  26995. }
  26996. else {
  26997. return 0;
  26998. }
  26999. };
  27000. /**
  27001. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  27002. * @param sega the first point of the segment to test the intersection against
  27003. * @param segb the second point of the segment to test the intersection against
  27004. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  27005. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  27006. */
  27007. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  27008. var o = this.origin;
  27009. var u = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  27010. var rsegb = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  27011. var v = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[2];
  27012. var w = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[3];
  27013. segb.subtractToRef(sega, u);
  27014. this.direction.scaleToRef(Ray.rayl, v);
  27015. o.addToRef(v, rsegb);
  27016. sega.subtractToRef(o, w);
  27017. var a = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  27018. var b = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  27019. var c = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  27020. var d = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  27021. var e = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  27022. var D = a * c - b * b; // always >= 0
  27023. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  27024. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  27025. // compute the line parameters of the two closest points
  27026. if (D < Ray.smallnum) { // the lines are almost parallel
  27027. sN = 0.0; // force using point P0 on segment S1
  27028. sD = 1.0; // to prevent possible division by 0.0 later
  27029. tN = e;
  27030. tD = c;
  27031. }
  27032. else { // get the closest points on the infinite lines
  27033. sN = (b * e - c * d);
  27034. tN = (a * e - b * d);
  27035. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  27036. sN = 0.0;
  27037. tN = e;
  27038. tD = c;
  27039. }
  27040. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  27041. sN = sD;
  27042. tN = e + b;
  27043. tD = c;
  27044. }
  27045. }
  27046. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  27047. tN = 0.0;
  27048. // recompute sc for this edge
  27049. if (-d < 0.0) {
  27050. sN = 0.0;
  27051. }
  27052. else if (-d > a) {
  27053. sN = sD;
  27054. }
  27055. else {
  27056. sN = -d;
  27057. sD = a;
  27058. }
  27059. }
  27060. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  27061. tN = tD;
  27062. // recompute sc for this edge
  27063. if ((-d + b) < 0.0) {
  27064. sN = 0;
  27065. }
  27066. else if ((-d + b) > a) {
  27067. sN = sD;
  27068. }
  27069. else {
  27070. sN = (-d + b);
  27071. sD = a;
  27072. }
  27073. }
  27074. // finally do the division to get sc and tc
  27075. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  27076. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  27077. // get the difference of the two closest points
  27078. var qtc = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[4];
  27079. v.scaleToRef(tc, qtc);
  27080. var qsc = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[5];
  27081. u.scaleToRef(sc, qsc);
  27082. qsc.addInPlace(w);
  27083. var dP = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[6];
  27084. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  27085. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  27086. if (isIntersected) {
  27087. return qsc.length();
  27088. }
  27089. return -1;
  27090. };
  27091. /**
  27092. * Update the ray from viewport position
  27093. * @param x position
  27094. * @param y y position
  27095. * @param viewportWidth viewport width
  27096. * @param viewportHeight viewport height
  27097. * @param world world matrix
  27098. * @param view view matrix
  27099. * @param projection projection matrix
  27100. * @returns this ray updated
  27101. */
  27102. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  27103. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  27104. return this;
  27105. };
  27106. // Statics
  27107. /**
  27108. * Creates a ray with origin and direction of 0,0,0
  27109. * @returns the new ray
  27110. */
  27111. Ray.Zero = function () {
  27112. return new Ray(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  27113. };
  27114. /**
  27115. * Creates a new ray from screen space and viewport
  27116. * @param x position
  27117. * @param y y position
  27118. * @param viewportWidth viewport width
  27119. * @param viewportHeight viewport height
  27120. * @param world world matrix
  27121. * @param view view matrix
  27122. * @param projection projection matrix
  27123. * @returns new ray
  27124. */
  27125. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  27126. var result = Ray.Zero();
  27127. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  27128. };
  27129. /**
  27130. * 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
  27131. * transformed to the given world matrix.
  27132. * @param origin The origin point
  27133. * @param end The end point
  27134. * @param world a matrix to transform the ray to. Default is the identity matrix.
  27135. * @returns the new ray
  27136. */
  27137. Ray.CreateNewFromTo = function (origin, end, world) {
  27138. if (world === void 0) { world = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  27139. var direction = end.subtract(origin);
  27140. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  27141. direction.normalize();
  27142. return Ray.Transform(new Ray(origin, direction, length), world);
  27143. };
  27144. /**
  27145. * Transforms a ray by a matrix
  27146. * @param ray ray to transform
  27147. * @param matrix matrix to apply
  27148. * @returns the resulting new ray
  27149. */
  27150. Ray.Transform = function (ray, matrix) {
  27151. var result = new Ray(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0));
  27152. Ray.TransformToRef(ray, matrix, result);
  27153. return result;
  27154. };
  27155. /**
  27156. * Transforms a ray by a matrix
  27157. * @param ray ray to transform
  27158. * @param matrix matrix to apply
  27159. * @param result ray to store result in
  27160. */
  27161. Ray.TransformToRef = function (ray, matrix, result) {
  27162. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  27163. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  27164. result.length = ray.length;
  27165. var dir = result.direction;
  27166. var len = dir.length();
  27167. if (!(len === 0 || len === 1)) {
  27168. var num = 1.0 / len;
  27169. dir.x *= num;
  27170. dir.y *= num;
  27171. dir.z *= num;
  27172. result.length *= len;
  27173. }
  27174. };
  27175. /**
  27176. * Unproject a ray from screen space to object space
  27177. * @param sourceX defines the screen space x coordinate to use
  27178. * @param sourceY defines the screen space y coordinate to use
  27179. * @param viewportWidth defines the current width of the viewport
  27180. * @param viewportHeight defines the current height of the viewport
  27181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  27182. * @param view defines the view matrix to use
  27183. * @param projection defines the projection matrix to use
  27184. */
  27185. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  27186. var matrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0];
  27187. world.multiplyToRef(view, matrix);
  27188. matrix.multiplyToRef(projection, matrix);
  27189. matrix.invert();
  27190. var nearScreenSource = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  27191. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  27192. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  27193. nearScreenSource.z = -1.0;
  27194. var farScreenSource = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  27195. var nearVec3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[2];
  27196. var farVec3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[3];
  27197. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  27198. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  27199. this.origin.copyFrom(nearVec3);
  27200. farVec3.subtractToRef(nearVec3, this.direction);
  27201. this.direction.normalize();
  27202. };
  27203. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  27204. Ray.smallnum = 0.00000001;
  27205. Ray.rayl = 10e8;
  27206. return Ray;
  27207. }());
  27208. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  27209. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  27210. var result = Ray.Zero();
  27211. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  27212. return result;
  27213. };
  27214. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  27215. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  27216. var engine = this.getEngine();
  27217. if (!camera) {
  27218. if (!this.activeCamera) {
  27219. throw new Error("Active camera not set");
  27220. }
  27221. camera = this.activeCamera;
  27222. }
  27223. var cameraViewport = camera.viewport;
  27224. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  27225. // Moving coordinates to local viewport world
  27226. x = x / engine.getHardwareScalingLevel() - viewport.x;
  27227. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  27228. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  27229. return this;
  27230. };
  27231. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  27232. var result = Ray.Zero();
  27233. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  27234. return result;
  27235. };
  27236. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  27237. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  27238. return this;
  27239. }
  27240. var engine = this.getEngine();
  27241. if (!camera) {
  27242. if (!this.activeCamera) {
  27243. throw new Error("Active camera not set");
  27244. }
  27245. camera = this.activeCamera;
  27246. }
  27247. var cameraViewport = camera.viewport;
  27248. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  27249. var identity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  27250. // Moving coordinates to local viewport world
  27251. x = x / engine.getHardwareScalingLevel() - viewport.x;
  27252. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  27253. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  27254. return this;
  27255. };
  27256. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  27257. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  27258. return null;
  27259. }
  27260. var pickingInfo = null;
  27261. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  27262. var mesh = this.meshes[meshIndex];
  27263. if (predicate) {
  27264. if (!predicate(mesh)) {
  27265. continue;
  27266. }
  27267. }
  27268. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  27269. continue;
  27270. }
  27271. var world = mesh.getWorldMatrix();
  27272. var ray = rayFunction(world);
  27273. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  27274. if (!result || !result.hit) {
  27275. continue;
  27276. }
  27277. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  27278. continue;
  27279. }
  27280. pickingInfo = result;
  27281. if (fastCheck) {
  27282. break;
  27283. }
  27284. }
  27285. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  27286. };
  27287. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  27288. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  27289. return null;
  27290. }
  27291. var pickingInfos = new Array();
  27292. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  27293. var mesh = this.meshes[meshIndex];
  27294. if (predicate) {
  27295. if (!predicate(mesh)) {
  27296. continue;
  27297. }
  27298. }
  27299. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  27300. continue;
  27301. }
  27302. var world = mesh.getWorldMatrix();
  27303. var ray = rayFunction(world);
  27304. var result = mesh.intersects(ray, false, trianglePredicate);
  27305. if (!result || !result.hit) {
  27306. continue;
  27307. }
  27308. pickingInfos.push(result);
  27309. }
  27310. return pickingInfos;
  27311. };
  27312. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  27313. var _this = this;
  27314. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  27315. return null;
  27316. }
  27317. var result = this._internalPick(function (world) {
  27318. if (!_this._tempPickingRay) {
  27319. _this._tempPickingRay = Ray.Zero();
  27320. }
  27321. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  27322. return _this._tempPickingRay;
  27323. }, predicate, fastCheck, trianglePredicate);
  27324. if (result) {
  27325. result.ray = this.createPickingRay(x, y, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  27326. }
  27327. return result;
  27328. };
  27329. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  27330. var _this = this;
  27331. var result = this._internalPick(function (world) {
  27332. if (!_this._pickWithRayInverseMatrix) {
  27333. _this._pickWithRayInverseMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  27334. }
  27335. world.invertToRef(_this._pickWithRayInverseMatrix);
  27336. if (!_this._cachedRayForTransform) {
  27337. _this._cachedRayForTransform = Ray.Zero();
  27338. }
  27339. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  27340. return _this._cachedRayForTransform;
  27341. }, predicate, fastCheck, trianglePredicate);
  27342. if (result) {
  27343. result.ray = ray;
  27344. }
  27345. return result;
  27346. };
  27347. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  27348. var _this = this;
  27349. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  27350. };
  27351. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  27352. var _this = this;
  27353. return this._internalMultiPick(function (world) {
  27354. if (!_this._pickWithRayInverseMatrix) {
  27355. _this._pickWithRayInverseMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  27356. }
  27357. world.invertToRef(_this._pickWithRayInverseMatrix);
  27358. if (!_this._cachedRayForTransform) {
  27359. _this._cachedRayForTransform = Ray.Zero();
  27360. }
  27361. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  27362. return _this._cachedRayForTransform;
  27363. }, predicate, trianglePredicate);
  27364. };
  27365. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  27366. if (length === void 0) { length = 100; }
  27367. if (!transform) {
  27368. transform = this.getWorldMatrix();
  27369. }
  27370. if (!origin) {
  27371. origin = this.position;
  27372. }
  27373. var forward = this._scene.useRightHandedSystem ? new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  27374. var forwardWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  27375. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  27376. return new Ray(origin, direction, length);
  27377. };
  27378. /***/ }),
  27379. /***/ "./Debug/axesViewer.ts":
  27380. /*!*****************************!*\
  27381. !*** ./Debug/axesViewer.ts ***!
  27382. \*****************************/
  27383. /*! exports provided: AxesViewer */
  27384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27385. "use strict";
  27386. __webpack_require__.r(__webpack_exports__);
  27387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  27388. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  27389. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  27390. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  27391. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  27392. /**
  27393. * The Axes viewer will show 3 axes in a specific point in space
  27394. */
  27395. var AxesViewer = /** @class */ (function () {
  27396. /**
  27397. * Creates a new AxesViewer
  27398. * @param scene defines the hosting scene
  27399. * @param scaleLines defines a number used to scale line length (1 by default)
  27400. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  27401. * @param xAxis defines the node hierarchy used to render the x-axis
  27402. * @param yAxis defines the node hierarchy used to render the y-axis
  27403. * @param zAxis defines the node hierarchy used to render the z-axis
  27404. */
  27405. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  27406. if (scaleLines === void 0) { scaleLines = 1; }
  27407. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  27408. this._scaleLinesFactor = 4;
  27409. this._instanced = false;
  27410. /**
  27411. * Gets or sets a number used to scale line length
  27412. */
  27413. this.scaleLines = 1;
  27414. this.scaleLines = scaleLines;
  27415. if (!xAxis) {
  27416. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  27417. redColoredMaterial.disableLighting = true;
  27418. redColoredMaterial.emissiveColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5);
  27419. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  27420. }
  27421. if (!yAxis) {
  27422. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  27423. greenColoredMaterial.disableLighting = true;
  27424. greenColoredMaterial.emissiveColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5);
  27425. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  27426. }
  27427. if (!zAxis) {
  27428. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  27429. blueColoredMaterial.disableLighting = true;
  27430. blueColoredMaterial.emissiveColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5);
  27431. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  27432. }
  27433. this._xAxis = xAxis;
  27434. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  27435. this._yAxis = yAxis;
  27436. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  27437. this._zAxis = zAxis;
  27438. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  27439. if (renderingGroupId != null) {
  27440. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  27441. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  27442. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  27443. }
  27444. this.scene = scene;
  27445. this.update(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward());
  27446. }
  27447. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  27448. /** Gets the node hierarchy used to render x-axis */
  27449. get: function () {
  27450. return this._xAxis;
  27451. },
  27452. enumerable: true,
  27453. configurable: true
  27454. });
  27455. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  27456. /** Gets the node hierarchy used to render y-axis */
  27457. get: function () {
  27458. return this._yAxis;
  27459. },
  27460. enumerable: true,
  27461. configurable: true
  27462. });
  27463. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  27464. /** Gets the node hierarchy used to render z-axis */
  27465. get: function () {
  27466. return this._zAxis;
  27467. },
  27468. enumerable: true,
  27469. configurable: true
  27470. });
  27471. /**
  27472. * Force the viewer to update
  27473. * @param position defines the position of the viewer
  27474. * @param xaxis defines the x axis of the viewer
  27475. * @param yaxis defines the y axis of the viewer
  27476. * @param zaxis defines the z axis of the viewer
  27477. */
  27478. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  27479. this._xAxis.position.copyFrom(position);
  27480. this._xAxis.setDirection(xaxis);
  27481. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  27482. this._yAxis.position.copyFrom(position);
  27483. this._yAxis.setDirection(yaxis);
  27484. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  27485. this._zAxis.position.copyFrom(position);
  27486. this._zAxis.setDirection(zaxis);
  27487. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  27488. };
  27489. /**
  27490. * Creates an instance of this axes viewer.
  27491. * @returns a new axes viewer with instanced meshes
  27492. */
  27493. AxesViewer.prototype.createInstance = function () {
  27494. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  27495. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  27496. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  27497. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  27498. axesViewer._instanced = true;
  27499. return axesViewer;
  27500. };
  27501. /** Releases resources */
  27502. AxesViewer.prototype.dispose = function () {
  27503. if (this._xAxis) {
  27504. this._xAxis.dispose(false, !this._instanced);
  27505. delete this._xAxis;
  27506. }
  27507. if (this._yAxis) {
  27508. this._yAxis.dispose(false, !this._instanced);
  27509. delete this._yAxis;
  27510. }
  27511. if (this._zAxis) {
  27512. this._zAxis.dispose(false, !this._instanced);
  27513. delete this._zAxis;
  27514. }
  27515. delete this.scene;
  27516. };
  27517. AxesViewer._SetRenderingGroupId = function (node, id) {
  27518. node.getChildMeshes().forEach(function (mesh) {
  27519. mesh.renderingGroupId = id;
  27520. });
  27521. };
  27522. return AxesViewer;
  27523. }());
  27524. /***/ }),
  27525. /***/ "./Debug/boneAxesViewer.ts":
  27526. /*!*********************************!*\
  27527. !*** ./Debug/boneAxesViewer.ts ***!
  27528. \*********************************/
  27529. /*! exports provided: BoneAxesViewer */
  27530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27531. "use strict";
  27532. __webpack_require__.r(__webpack_exports__);
  27533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  27534. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27535. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  27536. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  27537. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  27538. /**
  27539. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  27540. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  27541. */
  27542. var BoneAxesViewer = /** @class */ (function (_super) {
  27543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  27544. /**
  27545. * Creates a new BoneAxesViewer
  27546. * @param scene defines the hosting scene
  27547. * @param bone defines the target bone
  27548. * @param mesh defines the target mesh
  27549. * @param scaleLines defines a scaling factor for line length (1 by default)
  27550. */
  27551. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  27552. if (scaleLines === void 0) { scaleLines = 1; }
  27553. var _this = _super.call(this, scene, scaleLines) || this;
  27554. /** Gets current position */
  27555. _this.pos = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  27556. /** Gets direction of X axis */
  27557. _this.xaxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  27558. /** Gets direction of Y axis */
  27559. _this.yaxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  27560. /** Gets direction of Z axis */
  27561. _this.zaxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  27562. _this.mesh = mesh;
  27563. _this.bone = bone;
  27564. return _this;
  27565. }
  27566. /**
  27567. * Force the viewer to update
  27568. */
  27569. BoneAxesViewer.prototype.update = function () {
  27570. if (!this.mesh || !this.bone) {
  27571. return;
  27572. }
  27573. var bone = this.bone;
  27574. bone._markAsDirtyAndCompose();
  27575. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  27576. bone.getDirectionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_3__["Axis"].X, this.mesh, this.xaxis);
  27577. bone.getDirectionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y, this.mesh, this.yaxis);
  27578. bone.getDirectionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_3__["Axis"].Z, this.mesh, this.zaxis);
  27579. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  27580. };
  27581. /** Releases resources */
  27582. BoneAxesViewer.prototype.dispose = function () {
  27583. if (this.mesh) {
  27584. this.mesh = null;
  27585. this.bone = null;
  27586. _super.prototype.dispose.call(this);
  27587. }
  27588. };
  27589. return BoneAxesViewer;
  27590. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  27591. /***/ }),
  27592. /***/ "./Debug/debugLayer.ts":
  27593. /*!*****************************!*\
  27594. !*** ./Debug/debugLayer.ts ***!
  27595. \*****************************/
  27596. /*! exports provided: DebugLayer */
  27597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27598. "use strict";
  27599. __webpack_require__.r(__webpack_exports__);
  27600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  27601. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27602. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27603. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27604. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  27605. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  27606. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  27607. get: function () {
  27608. if (!this._debugLayer) {
  27609. this._debugLayer = new DebugLayer(this);
  27610. }
  27611. return this._debugLayer;
  27612. },
  27613. enumerable: true,
  27614. configurable: true
  27615. });
  27616. /**
  27617. * The debug layer (aka Inspector) is the go to tool in order to better understand
  27618. * what is happening in your scene
  27619. * @see http://doc.babylonjs.com/features/playground_debuglayer
  27620. */
  27621. var DebugLayer = /** @class */ (function () {
  27622. /**
  27623. * Instantiates a new debug layer.
  27624. * The debug layer (aka Inspector) is the go to tool in order to better understand
  27625. * what is happening in your scene
  27626. * @see http://doc.babylonjs.com/features/playground_debuglayer
  27627. * @param scene Defines the scene to inspect
  27628. */
  27629. function DebugLayer(scene) {
  27630. var _this = this;
  27631. this.BJSINSPECTOR = this._getGlobalInspector();
  27632. this._scene = scene;
  27633. this._scene.onDisposeObservable.add(function () {
  27634. // Debug layer
  27635. if (_this._scene._debugLayer) {
  27636. _this._scene._debugLayer.hide();
  27637. }
  27638. });
  27639. }
  27640. Object.defineProperty(DebugLayer.prototype, "onPropertyChangedObservable", {
  27641. /**
  27642. * Observable triggered when a property is changed through the inspector.
  27643. */
  27644. get: function () {
  27645. if (this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector) {
  27646. return this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable;
  27647. }
  27648. if (!this._onPropertyChangedObservable) {
  27649. this._onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  27650. }
  27651. return this._onPropertyChangedObservable;
  27652. },
  27653. enumerable: true,
  27654. configurable: true
  27655. });
  27656. /** Creates the inspector window. */
  27657. DebugLayer.prototype._createInspector = function (config) {
  27658. if (this.isVisible()) {
  27659. return;
  27660. }
  27661. if (this._onPropertyChangedObservable) {
  27662. for (var _i = 0, _a = this._onPropertyChangedObservable.observers; _i < _a.length; _i++) {
  27663. var observer = _a[_i];
  27664. this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(observer);
  27665. }
  27666. this._onPropertyChangedObservable.clear();
  27667. this._onPropertyChangedObservable = undefined;
  27668. }
  27669. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  27670. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  27671. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  27672. };
  27673. /**
  27674. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  27675. * @param entity defines the entity to select
  27676. * @param lineContainerTitle defines the specific block to highlight
  27677. */
  27678. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  27679. if (this.BJSINSPECTOR) {
  27680. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  27681. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  27682. }
  27683. };
  27684. /** Get the inspector from bundle or global */
  27685. DebugLayer.prototype._getGlobalInspector = function () {
  27686. // UMD Global name detection from Webpack Bundle UMD Name.
  27687. if (typeof INSPECTOR !== 'undefined') {
  27688. return INSPECTOR;
  27689. }
  27690. // In case of module let s check the global emitted from the Inspector entry point.
  27691. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  27692. return BABYLON;
  27693. }
  27694. return undefined;
  27695. };
  27696. /**
  27697. * Get if the inspector is visible or not.
  27698. * @returns true if visible otherwise, false
  27699. */
  27700. DebugLayer.prototype.isVisible = function () {
  27701. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  27702. };
  27703. /**
  27704. * Hide the inspector and close its window.
  27705. */
  27706. DebugLayer.prototype.hide = function () {
  27707. if (this.BJSINSPECTOR) {
  27708. this.BJSINSPECTOR.Inspector.Hide();
  27709. }
  27710. };
  27711. /**
  27712. * Launch the debugLayer.
  27713. * @param config Define the configuration of the inspector
  27714. * @return a promise fulfilled when the debug layer is visible
  27715. */
  27716. DebugLayer.prototype.show = function (config) {
  27717. var _this = this;
  27718. return new Promise(function (resolve, reject) {
  27719. if (typeof _this.BJSINSPECTOR == 'undefined') {
  27720. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  27721. // Load inspector and add it to the DOM
  27722. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  27723. _this._createInspector(config);
  27724. resolve(_this);
  27725. });
  27726. }
  27727. else {
  27728. // Otherwise creates the inspector
  27729. _this._createInspector(config);
  27730. resolve(_this);
  27731. }
  27732. });
  27733. };
  27734. /**
  27735. * Define the url to get the inspector script from.
  27736. * By default it uses the babylonjs CDN.
  27737. * @ignoreNaming
  27738. */
  27739. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  27740. return DebugLayer;
  27741. }());
  27742. /***/ }),
  27743. /***/ "./Debug/index.ts":
  27744. /*!************************!*\
  27745. !*** ./Debug/index.ts ***!
  27746. \************************/
  27747. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  27748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27749. "use strict";
  27750. __webpack_require__.r(__webpack_exports__);
  27751. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  27752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  27753. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  27754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  27755. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  27756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  27757. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  27758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  27759. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  27760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  27761. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  27762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  27763. /***/ }),
  27764. /***/ "./Debug/physicsViewer.ts":
  27765. /*!********************************!*\
  27766. !*** ./Debug/physicsViewer.ts ***!
  27767. \********************************/
  27768. /*! exports provided: PhysicsViewer */
  27769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27770. "use strict";
  27771. __webpack_require__.r(__webpack_exports__);
  27772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  27773. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  27774. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  27775. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  27776. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  27777. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  27778. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  27779. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  27780. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  27781. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27782. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  27783. /**
  27784. * Used to show the physics impostor around the specific mesh
  27785. */
  27786. var PhysicsViewer = /** @class */ (function () {
  27787. /**
  27788. * Creates a new PhysicsViewer
  27789. * @param scene defines the hosting scene
  27790. */
  27791. function PhysicsViewer(scene) {
  27792. /** @hidden */
  27793. this._impostors = [];
  27794. /** @hidden */
  27795. this._meshes = [];
  27796. /** @hidden */
  27797. this._numMeshes = 0;
  27798. this._debugMeshMeshes = new Array();
  27799. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  27800. var physicEngine = this._scene.getPhysicsEngine();
  27801. if (physicEngine) {
  27802. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  27803. }
  27804. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"](this._scene, false);
  27805. this._utilityLayer.pickUtilitySceneFirst = false;
  27806. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27807. }
  27808. /** @hidden */
  27809. PhysicsViewer.prototype._updateDebugMeshes = function () {
  27810. var plugin = this._physicsEnginePlugin;
  27811. for (var i = 0; i < this._numMeshes; i++) {
  27812. var impostor = this._impostors[i];
  27813. if (!impostor) {
  27814. continue;
  27815. }
  27816. if (impostor.isDisposed) {
  27817. this.hideImpostor(this._impostors[i--]);
  27818. }
  27819. else {
  27820. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__["PhysicsImpostor"].MeshImpostor) {
  27821. continue;
  27822. }
  27823. var mesh = this._meshes[i];
  27824. if (mesh && plugin) {
  27825. plugin.syncMeshWithImpostor(mesh, impostor);
  27826. }
  27827. }
  27828. }
  27829. };
  27830. /**
  27831. * Renders a specified physic impostor
  27832. * @param impostor defines the impostor to render
  27833. * @param targetMesh defines the mesh represented by the impostor
  27834. * @returns the new debug mesh used to render the impostor
  27835. */
  27836. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  27837. if (!this._scene) {
  27838. return null;
  27839. }
  27840. for (var i = 0; i < this._numMeshes; i++) {
  27841. if (this._impostors[i] == impostor) {
  27842. return null;
  27843. }
  27844. }
  27845. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  27846. if (debugMesh) {
  27847. this._impostors[this._numMeshes] = impostor;
  27848. this._meshes[this._numMeshes] = debugMesh;
  27849. if (this._numMeshes === 0) {
  27850. this._renderFunction = this._updateDebugMeshes.bind(this);
  27851. this._scene.registerBeforeRender(this._renderFunction);
  27852. }
  27853. this._numMeshes++;
  27854. }
  27855. return debugMesh;
  27856. };
  27857. /**
  27858. * Hides a specified physic impostor
  27859. * @param impostor defines the impostor to hide
  27860. */
  27861. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  27862. if (!impostor || !this._scene || !this._utilityLayer) {
  27863. return;
  27864. }
  27865. var removed = false;
  27866. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27867. for (var i = 0; i < this._numMeshes; i++) {
  27868. if (this._impostors[i] == impostor) {
  27869. var mesh = this._meshes[i];
  27870. if (!mesh) {
  27871. continue;
  27872. }
  27873. utilityLayerScene.removeMesh(mesh);
  27874. mesh.dispose();
  27875. var index = this._debugMeshMeshes.indexOf(mesh);
  27876. if (index > -1) {
  27877. this._debugMeshMeshes.splice(index, 1);
  27878. }
  27879. this._numMeshes--;
  27880. if (this._numMeshes > 0) {
  27881. this._meshes[i] = this._meshes[this._numMeshes];
  27882. this._impostors[i] = this._impostors[this._numMeshes];
  27883. this._meshes[this._numMeshes] = null;
  27884. this._impostors[this._numMeshes] = null;
  27885. }
  27886. else {
  27887. this._meshes[0] = null;
  27888. this._impostors[0] = null;
  27889. }
  27890. removed = true;
  27891. break;
  27892. }
  27893. }
  27894. if (removed && this._numMeshes === 0) {
  27895. this._scene.unregisterBeforeRender(this._renderFunction);
  27896. }
  27897. };
  27898. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  27899. if (!this._debugMaterial) {
  27900. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]('', scene);
  27901. this._debugMaterial.wireframe = true;
  27902. this._debugMaterial.emissiveColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  27903. this._debugMaterial.disableLighting = true;
  27904. }
  27905. return this._debugMaterial;
  27906. };
  27907. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  27908. if (!this._debugBoxMesh) {
  27909. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  27910. this._debugBoxMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  27911. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  27912. this._debugBoxMesh.setEnabled(false);
  27913. }
  27914. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  27915. };
  27916. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  27917. if (!this._debugSphereMesh) {
  27918. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  27919. this._debugSphereMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  27920. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  27921. this._debugSphereMesh.setEnabled(false);
  27922. }
  27923. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  27924. };
  27925. PhysicsViewer.prototype._getDebugCylinderMesh = function (scene) {
  27926. if (!this._debugCylinderMesh) {
  27927. this._debugCylinderMesh = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_9__["CylinderBuilder"].CreateCylinder('physicsBodyCylinderViewMesh', { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);
  27928. this._debugCylinderMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  27929. this._debugCylinderMesh.material = this._getDebugMaterial(scene);
  27930. this._debugCylinderMesh.setEnabled(false);
  27931. }
  27932. return this._debugCylinderMesh.createInstance('physicsBodyBoxViewInstance');
  27933. };
  27934. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  27935. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  27936. wireframeOver.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  27937. wireframeOver.setParent(mesh);
  27938. wireframeOver.material = this._getDebugMaterial(scene);
  27939. this._debugMeshMeshes.push(wireframeOver);
  27940. return wireframeOver;
  27941. };
  27942. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  27943. var _this = this;
  27944. if (!this._utilityLayer) {
  27945. return null;
  27946. }
  27947. // Only create child impostor debug meshes when evaluating the parent
  27948. if (targetMesh && targetMesh.parent && targetMesh.parent.physicsImpostor) {
  27949. return null;
  27950. }
  27951. var mesh = null;
  27952. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27953. switch (impostor.type) {
  27954. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__["PhysicsImpostor"].BoxImpostor:
  27955. mesh = this._getDebugBoxMesh(utilityLayerScene);
  27956. impostor.getBoxSizeToRef(mesh.scaling);
  27957. break;
  27958. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__["PhysicsImpostor"].SphereImpostor:
  27959. mesh = this._getDebugSphereMesh(utilityLayerScene);
  27960. var radius = impostor.getRadius();
  27961. mesh.scaling.x = radius * 2;
  27962. mesh.scaling.y = radius * 2;
  27963. mesh.scaling.z = radius * 2;
  27964. break;
  27965. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__["PhysicsImpostor"].MeshImpostor:
  27966. if (targetMesh) {
  27967. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  27968. }
  27969. break;
  27970. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__["PhysicsImpostor"].NoImpostor:
  27971. if (targetMesh) {
  27972. // Handle compound impostors
  27973. var childMeshes = targetMesh.getChildMeshes().filter(function (c) { return c.physicsImpostor ? 1 : 0; });
  27974. childMeshes.forEach(function (m) {
  27975. var a = _this._getDebugBoxMesh(utilityLayerScene);
  27976. a.parent = m;
  27977. });
  27978. }
  27979. break;
  27980. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_7__["PhysicsImpostor"].CylinderImpostor:
  27981. mesh = this._getDebugCylinderMesh(utilityLayerScene);
  27982. var bi = impostor.object.getBoundingInfo();
  27983. mesh.scaling.x = bi.boundingBox.maximum.x - bi.boundingBox.minimum.x;
  27984. mesh.scaling.y = bi.boundingBox.maximum.y - bi.boundingBox.minimum.y;
  27985. mesh.scaling.z = bi.boundingBox.maximum.z - bi.boundingBox.minimum.z;
  27986. break;
  27987. }
  27988. return mesh;
  27989. };
  27990. /** Releases all resources */
  27991. PhysicsViewer.prototype.dispose = function () {
  27992. var count = this._numMeshes;
  27993. for (var index = 0; index < count; index++) {
  27994. this.hideImpostor(this._impostors[0]);
  27995. }
  27996. if (this._debugBoxMesh) {
  27997. this._debugBoxMesh.dispose();
  27998. }
  27999. if (this._debugSphereMesh) {
  28000. this._debugSphereMesh.dispose();
  28001. }
  28002. if (this._debugCylinderMesh) {
  28003. this._debugCylinderMesh.dispose();
  28004. }
  28005. if (this._debugMaterial) {
  28006. this._debugMaterial.dispose();
  28007. }
  28008. this._impostors.length = 0;
  28009. this._scene = null;
  28010. this._physicsEnginePlugin = null;
  28011. if (this._utilityLayer) {
  28012. this._utilityLayer.dispose();
  28013. this._utilityLayer = null;
  28014. }
  28015. };
  28016. return PhysicsViewer;
  28017. }());
  28018. /***/ }),
  28019. /***/ "./Debug/rayHelper.ts":
  28020. /*!****************************!*\
  28021. !*** ./Debug/rayHelper.ts ***!
  28022. \****************************/
  28023. /*! exports provided: RayHelper */
  28024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28025. "use strict";
  28026. __webpack_require__.r(__webpack_exports__);
  28027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  28028. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  28029. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  28030. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  28031. /**
  28032. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  28033. * in order to better appreciate the issue one might have.
  28034. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  28035. */
  28036. var RayHelper = /** @class */ (function () {
  28037. /**
  28038. * Instantiate a new ray helper.
  28039. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  28040. * in order to better appreciate the issue one might have.
  28041. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  28042. * @param ray Defines the ray we are currently tryin to visualize
  28043. */
  28044. function RayHelper(ray) {
  28045. this.ray = ray;
  28046. }
  28047. /**
  28048. * Helper function to create a colored helper in a scene in one line.
  28049. * @param ray Defines the ray we are currently tryin to visualize
  28050. * @param scene Defines the scene the ray is used in
  28051. * @param color Defines the color we want to see the ray in
  28052. * @returns The newly created ray helper.
  28053. */
  28054. RayHelper.CreateAndShow = function (ray, scene, color) {
  28055. var helper = new RayHelper(ray);
  28056. helper.show(scene, color);
  28057. return helper;
  28058. };
  28059. /**
  28060. * Shows the ray we are willing to debug.
  28061. * @param scene Defines the scene the ray needs to be rendered in
  28062. * @param color Defines the color the ray needs to be rendered in
  28063. */
  28064. RayHelper.prototype.show = function (scene, color) {
  28065. if (!this._renderFunction && this.ray) {
  28066. var ray = this.ray;
  28067. this._renderFunction = this._render.bind(this);
  28068. this._scene = scene;
  28069. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  28070. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  28071. if (this._renderFunction) {
  28072. this._scene.registerBeforeRender(this._renderFunction);
  28073. }
  28074. }
  28075. if (color && this._renderLine) {
  28076. this._renderLine.color.copyFrom(color);
  28077. }
  28078. };
  28079. /**
  28080. * Hides the ray we are debugging.
  28081. */
  28082. RayHelper.prototype.hide = function () {
  28083. if (this._renderFunction && this._scene) {
  28084. this._scene.unregisterBeforeRender(this._renderFunction);
  28085. this._scene = null;
  28086. this._renderFunction = null;
  28087. if (this._renderLine) {
  28088. this._renderLine.dispose();
  28089. this._renderLine = null;
  28090. }
  28091. this._renderPoints = [];
  28092. }
  28093. };
  28094. RayHelper.prototype._render = function () {
  28095. var ray = this.ray;
  28096. if (!ray) {
  28097. return;
  28098. }
  28099. var point = this._renderPoints[1];
  28100. var len = Math.min(ray.length, 1000000);
  28101. point.copyFrom(ray.direction);
  28102. point.scaleInPlace(len);
  28103. point.addInPlace(ray.origin);
  28104. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  28105. };
  28106. /**
  28107. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  28108. * @param mesh Defines the mesh we want the helper attached to
  28109. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  28110. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  28111. * @param length Defines the length of the ray
  28112. */
  28113. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  28114. this._attachedToMesh = mesh;
  28115. var ray = this.ray;
  28116. if (!ray) {
  28117. return;
  28118. }
  28119. if (!ray.direction) {
  28120. ray.direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  28121. }
  28122. if (!ray.origin) {
  28123. ray.origin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  28124. }
  28125. if (length) {
  28126. ray.length = length;
  28127. }
  28128. if (!meshSpaceOrigin) {
  28129. meshSpaceOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  28130. }
  28131. if (!meshSpaceDirection) {
  28132. // -1 so that this will work with Mesh.lookAt
  28133. meshSpaceDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  28134. }
  28135. if (!this._meshSpaceDirection) {
  28136. this._meshSpaceDirection = meshSpaceDirection.clone();
  28137. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  28138. }
  28139. else {
  28140. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  28141. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  28142. }
  28143. if (!this._updateToMeshFunction) {
  28144. this._updateToMeshFunction = this._updateToMesh.bind(this);
  28145. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  28146. }
  28147. this._updateToMesh();
  28148. };
  28149. /**
  28150. * Detach the ray helper from the mesh it has previously been attached to.
  28151. */
  28152. RayHelper.prototype.detachFromMesh = function () {
  28153. if (this._attachedToMesh) {
  28154. if (this._updateToMeshFunction) {
  28155. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  28156. }
  28157. this._attachedToMesh = null;
  28158. this._updateToMeshFunction = null;
  28159. }
  28160. };
  28161. RayHelper.prototype._updateToMesh = function () {
  28162. var ray = this.ray;
  28163. if (!this._attachedToMesh || !ray) {
  28164. return;
  28165. }
  28166. if (this._attachedToMesh._isDisposed) {
  28167. this.detachFromMesh();
  28168. return;
  28169. }
  28170. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  28171. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  28172. };
  28173. /**
  28174. * Dispose the helper and release its associated resources.
  28175. */
  28176. RayHelper.prototype.dispose = function () {
  28177. this.hide();
  28178. this.detachFromMesh();
  28179. this.ray = null;
  28180. };
  28181. return RayHelper;
  28182. }());
  28183. /***/ }),
  28184. /***/ "./Debug/skeletonViewer.ts":
  28185. /*!*********************************!*\
  28186. !*** ./Debug/skeletonViewer.ts ***!
  28187. \*********************************/
  28188. /*! exports provided: SkeletonViewer */
  28189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28190. "use strict";
  28191. __webpack_require__.r(__webpack_exports__);
  28192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  28193. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  28194. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  28195. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  28196. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  28197. /**
  28198. * Class used to render a debug view of a given skeleton
  28199. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  28200. */
  28201. var SkeletonViewer = /** @class */ (function () {
  28202. /**
  28203. * Creates a new SkeletonViewer
  28204. * @param skeleton defines the skeleton to render
  28205. * @param mesh defines the mesh attached to the skeleton
  28206. * @param scene defines the hosting scene
  28207. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  28208. * @param renderingGroupId defines the rendering group id to use with the viewer
  28209. */
  28210. function SkeletonViewer(
  28211. /** defines the skeleton to render */
  28212. skeleton,
  28213. /** defines the mesh attached to the skeleton */
  28214. mesh, scene,
  28215. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  28216. autoUpdateBonesMatrices,
  28217. /** defines the rendering group id to use with the viewer */
  28218. renderingGroupId) {
  28219. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  28220. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  28221. this.skeleton = skeleton;
  28222. this.mesh = mesh;
  28223. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  28224. this.renderingGroupId = renderingGroupId;
  28225. /** Gets or sets the color used to render the skeleton */
  28226. this.color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  28227. this._debugLines = new Array();
  28228. this._isEnabled = false;
  28229. this._scene = scene;
  28230. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](this._scene, false);
  28231. this._utilityLayer.pickUtilitySceneFirst = false;
  28232. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  28233. this.update();
  28234. this._renderFunction = this.update.bind(this);
  28235. }
  28236. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  28237. /**
  28238. * Returns the mesh used to render the bones
  28239. */
  28240. get: function () {
  28241. return this._debugMesh;
  28242. },
  28243. enumerable: true,
  28244. configurable: true
  28245. });
  28246. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  28247. get: function () {
  28248. return this._isEnabled;
  28249. },
  28250. /** Gets or sets a boolean indicating if the viewer is enabled */
  28251. set: function (value) {
  28252. if (this._isEnabled === value) {
  28253. return;
  28254. }
  28255. this._isEnabled = value;
  28256. if (value) {
  28257. this._scene.registerBeforeRender(this._renderFunction);
  28258. }
  28259. else {
  28260. this._scene.unregisterBeforeRender(this._renderFunction);
  28261. }
  28262. },
  28263. enumerable: true,
  28264. configurable: true
  28265. });
  28266. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  28267. if (x === void 0) { x = 0; }
  28268. if (y === void 0) { y = 0; }
  28269. if (z === void 0) { z = 0; }
  28270. var tmat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  28271. var parentBone = bone.getParent();
  28272. tmat.copyFrom(bone.getLocalMatrix());
  28273. if (x !== 0 || y !== 0 || z !== 0) {
  28274. var tmat2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[1];
  28275. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  28276. tmat2.setTranslationFromFloats(x, y, z);
  28277. tmat2.multiplyToRef(tmat, tmat);
  28278. }
  28279. if (parentBone) {
  28280. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  28281. }
  28282. tmat.multiplyToRef(meshMat, tmat);
  28283. position.x = tmat.m[12];
  28284. position.y = tmat.m[13];
  28285. position.z = tmat.m[14];
  28286. };
  28287. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  28288. var len = bones.length;
  28289. var mesh = this.mesh._effectiveMesh;
  28290. var meshPos = mesh.position;
  28291. for (var i = 0; i < len; i++) {
  28292. var bone = bones[i];
  28293. var points = this._debugLines[i];
  28294. if (!points) {
  28295. points = [_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  28296. this._debugLines[i] = points;
  28297. }
  28298. this._getBonePosition(points[0], bone, meshMat);
  28299. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  28300. points[0].subtractInPlace(meshPos);
  28301. points[1].subtractInPlace(meshPos);
  28302. }
  28303. };
  28304. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  28305. var len = bones.length;
  28306. var boneNum = 0;
  28307. var mesh = this.mesh._effectiveMesh;
  28308. var meshPos = mesh.position;
  28309. for (var i = len - 1; i >= 0; i--) {
  28310. var childBone = bones[i];
  28311. var parentBone = childBone.getParent();
  28312. if (!parentBone) {
  28313. continue;
  28314. }
  28315. var points = this._debugLines[boneNum];
  28316. if (!points) {
  28317. points = [_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  28318. this._debugLines[boneNum] = points;
  28319. }
  28320. childBone.getAbsolutePositionToRef(mesh, points[0]);
  28321. parentBone.getAbsolutePositionToRef(mesh, points[1]);
  28322. points[0].subtractInPlace(meshPos);
  28323. points[1].subtractInPlace(meshPos);
  28324. boneNum++;
  28325. }
  28326. };
  28327. /** Update the viewer to sync with current skeleton state */
  28328. SkeletonViewer.prototype.update = function () {
  28329. if (!this._utilityLayer) {
  28330. return;
  28331. }
  28332. if (this.autoUpdateBonesMatrices) {
  28333. this.skeleton.computeAbsoluteTransforms();
  28334. }
  28335. var mesh = this.mesh._effectiveMesh;
  28336. if (this.skeleton.bones[0].length === undefined) {
  28337. this._getLinesForBonesNoLength(this.skeleton.bones, mesh.getWorldMatrix());
  28338. }
  28339. else {
  28340. this._getLinesForBonesWithLength(this.skeleton.bones, mesh.getWorldMatrix());
  28341. }
  28342. var targetScene = this._utilityLayer.utilityLayerScene;
  28343. if (!this._debugMesh) {
  28344. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  28345. this._debugMesh.renderingGroupId = this.renderingGroupId;
  28346. }
  28347. else {
  28348. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  28349. }
  28350. this._debugMesh.position.copyFrom(this.mesh.position);
  28351. this._debugMesh.color = this.color;
  28352. };
  28353. /** Release associated resources */
  28354. SkeletonViewer.prototype.dispose = function () {
  28355. this.isEnabled = false;
  28356. if (this._debugMesh) {
  28357. this.isEnabled = false;
  28358. this._debugMesh.dispose();
  28359. this._debugMesh = null;
  28360. }
  28361. if (this._utilityLayer) {
  28362. this._utilityLayer.dispose();
  28363. this._utilityLayer = null;
  28364. }
  28365. };
  28366. return SkeletonViewer;
  28367. }());
  28368. /***/ }),
  28369. /***/ "./Engines/Extensions/engine.cubeTexture.ts":
  28370. /*!**************************************************!*\
  28371. !*** ./Engines/Extensions/engine.cubeTexture.ts ***!
  28372. \**************************************************/
  28373. /*! no exports provided */
  28374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28375. "use strict";
  28376. __webpack_require__.r(__webpack_exports__);
  28377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28378. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28379. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28380. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  28381. /* harmony import */ var _Misc_fileTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/fileTools */ "./Misc/fileTools.ts");
  28382. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._createDepthStencilCubeTexture = function (size, options) {
  28383. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_UNKNOWN);
  28384. internalTexture.isCube = true;
  28385. if (this.webGLVersion === 1) {
  28386. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  28387. return internalTexture;
  28388. }
  28389. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  28390. var gl = this._gl;
  28391. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  28392. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  28393. // Create the depth/stencil buffer
  28394. for (var face = 0; face < 6; face++) {
  28395. if (internalOptions.generateStencil) {
  28396. 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);
  28397. }
  28398. else {
  28399. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  28400. }
  28401. }
  28402. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28403. return internalTexture;
  28404. };
  28405. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  28406. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  28407. var onload = function (data) {
  28408. loadedFiles[index] = data;
  28409. loadedFiles._internalCount++;
  28410. if (loadedFiles._internalCount === 6) {
  28411. onfinish(loadedFiles);
  28412. }
  28413. };
  28414. var onerror = function (request, exception) {
  28415. if (onErrorCallBack && request) {
  28416. onErrorCallBack(request.status + " " + request.statusText, exception);
  28417. }
  28418. };
  28419. this._loadFile(url, onload, undefined, undefined, true, onerror);
  28420. };
  28421. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  28422. if (onError === void 0) { onError = null; }
  28423. var loadedFiles = [];
  28424. loadedFiles._internalCount = 0;
  28425. for (var index = 0; index < 6; index++) {
  28426. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  28427. }
  28428. };
  28429. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  28430. if (onError === void 0) { onError = null; }
  28431. var loadedImages = [];
  28432. loadedImages._internalCount = 0;
  28433. for (var index = 0; index < 6; index++) {
  28434. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  28435. }
  28436. };
  28437. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  28438. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  28439. var img;
  28440. var onload = function () {
  28441. loadedImages[index] = img;
  28442. loadedImages._internalCount++;
  28443. if (scene) {
  28444. scene._removePendingData(img);
  28445. }
  28446. if (loadedImages._internalCount === 6) {
  28447. onfinish(loadedImages);
  28448. }
  28449. };
  28450. var onerror = function (message, exception) {
  28451. if (scene) {
  28452. scene._removePendingData(img);
  28453. }
  28454. if (onErrorCallBack) {
  28455. onErrorCallBack(message, exception);
  28456. }
  28457. };
  28458. img = _Misc_fileTools__WEBPACK_IMPORTED_MODULE_4__["FileTools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  28459. if (scene) {
  28460. scene._addPendingData(img);
  28461. }
  28462. };
  28463. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  28464. var _this = this;
  28465. if (onLoad === void 0) { onLoad = null; }
  28466. if (onError === void 0) { onError = null; }
  28467. if (forcedExtension === void 0) { forcedExtension = null; }
  28468. if (createPolynomials === void 0) { createPolynomials = false; }
  28469. if (lodScale === void 0) { lodScale = 0; }
  28470. if (lodOffset === void 0) { lodOffset = 0; }
  28471. if (fallback === void 0) { fallback = null; }
  28472. if (excludeLoaders === void 0) { excludeLoaders = []; }
  28473. var gl = this._gl;
  28474. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_CUBE);
  28475. texture.isCube = true;
  28476. texture.url = rootUrl;
  28477. texture.generateMipMaps = !noMipmap;
  28478. texture._lodGenerationScale = lodScale;
  28479. texture._lodGenerationOffset = lodOffset;
  28480. if (!this._doNotHandleContextLost) {
  28481. texture._extension = forcedExtension;
  28482. texture._files = files;
  28483. }
  28484. var lastDot = rootUrl.lastIndexOf('.');
  28485. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  28486. var loader = null;
  28487. for (var _i = 0, _a = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders; _i < _a.length; _i++) {
  28488. var availableLoader = _a[_i];
  28489. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  28490. loader = availableLoader;
  28491. break;
  28492. }
  28493. }
  28494. var onInternalError = function (request, exception) {
  28495. if (loader) {
  28496. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  28497. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  28498. if (fallbackUrl) {
  28499. excludeLoaders.push(loader);
  28500. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  28501. return;
  28502. }
  28503. }
  28504. if (onError && request) {
  28505. onError(request.status + " " + request.statusText, exception);
  28506. }
  28507. };
  28508. if (loader) {
  28509. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  28510. var onloaddata = function (data) {
  28511. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28512. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  28513. };
  28514. if (files && files.length === 6) {
  28515. if (loader.supportCascades) {
  28516. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  28517. }
  28518. else {
  28519. if (onError) {
  28520. onError("Textures type does not support cascades.");
  28521. }
  28522. else {
  28523. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("Texture loader does not support cascades.");
  28524. }
  28525. }
  28526. }
  28527. else {
  28528. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  28529. }
  28530. }
  28531. else {
  28532. if (!files) {
  28533. throw new Error("Cannot load cubemap because files were not defined");
  28534. }
  28535. this._cascadeLoadImgs(scene, function (imgs) {
  28536. var width = _this.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  28537. var height = width;
  28538. _this._prepareWorkingCanvas();
  28539. if (!_this._workingCanvas || !_this._workingContext) {
  28540. return;
  28541. }
  28542. _this._workingCanvas.width = width;
  28543. _this._workingCanvas.height = height;
  28544. var faces = [
  28545. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  28546. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  28547. ];
  28548. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28549. _this._unpackFlipY(false);
  28550. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  28551. for (var index = 0; index < faces.length; index++) {
  28552. if (imgs[index].width !== width || imgs[index].height !== height) {
  28553. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  28554. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  28555. }
  28556. else {
  28557. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  28558. }
  28559. }
  28560. if (!noMipmap) {
  28561. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  28562. }
  28563. _this._setCubeMapTextureParams(!noMipmap);
  28564. texture.width = width;
  28565. texture.height = height;
  28566. texture.isReady = true;
  28567. if (format) {
  28568. texture.format = format;
  28569. }
  28570. texture.onLoadedObservable.notifyObservers(texture);
  28571. texture.onLoadedObservable.clear();
  28572. if (onLoad) {
  28573. onLoad();
  28574. }
  28575. }, files, onError);
  28576. }
  28577. this._internalTexturesCache.push(texture);
  28578. return texture;
  28579. };
  28580. /***/ }),
  28581. /***/ "./Engines/Extensions/engine.multiRender.ts":
  28582. /*!**************************************************!*\
  28583. !*** ./Engines/Extensions/engine.multiRender.ts ***!
  28584. \**************************************************/
  28585. /*! no exports provided */
  28586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28587. "use strict";
  28588. __webpack_require__.r(__webpack_exports__);
  28589. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28590. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28591. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  28592. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  28593. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28594. this._currentRenderTarget = null;
  28595. // If MSAA, we need to bitblt back to main texture
  28596. var gl = this._gl;
  28597. if (textures[0]._MSAAFramebuffer) {
  28598. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  28599. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  28600. var attachments = textures[0]._attachments;
  28601. if (!attachments) {
  28602. attachments = new Array(textures.length);
  28603. textures[0]._attachments = attachments;
  28604. }
  28605. for (var i = 0; i < textures.length; i++) {
  28606. var texture = textures[i];
  28607. for (var j = 0; j < attachments.length; j++) {
  28608. attachments[j] = gl.NONE;
  28609. }
  28610. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28611. gl.readBuffer(attachments[i]);
  28612. gl.drawBuffers(attachments);
  28613. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28614. }
  28615. for (var i = 0; i < attachments.length; i++) {
  28616. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28617. }
  28618. gl.drawBuffers(attachments);
  28619. }
  28620. for (var i = 0; i < textures.length; i++) {
  28621. var texture = textures[i];
  28622. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28623. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  28624. gl.generateMipmap(gl.TEXTURE_2D);
  28625. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28626. }
  28627. }
  28628. if (onBeforeUnbind) {
  28629. if (textures[0]._MSAAFramebuffer) {
  28630. // Bind the correct framebuffer
  28631. this._bindUnboundFramebuffer(textures[0]._framebuffer);
  28632. }
  28633. onBeforeUnbind();
  28634. }
  28635. this._bindUnboundFramebuffer(null);
  28636. };
  28637. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createMultipleRenderTarget = function (size, options) {
  28638. var generateMipMaps = false;
  28639. var generateDepthBuffer = true;
  28640. var generateStencilBuffer = false;
  28641. var generateDepthTexture = false;
  28642. var textureCount = 1;
  28643. var defaultType = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT;
  28644. var defaultSamplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  28645. var types = new Array();
  28646. var samplingModes = new Array();
  28647. if (options !== undefined) {
  28648. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  28649. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  28650. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  28651. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  28652. textureCount = options.textureCount || 1;
  28653. if (options.types) {
  28654. types = options.types;
  28655. }
  28656. if (options.samplingModes) {
  28657. samplingModes = options.samplingModes;
  28658. }
  28659. }
  28660. var gl = this._gl;
  28661. // Create the framebuffer
  28662. var framebuffer = gl.createFramebuffer();
  28663. this._bindUnboundFramebuffer(framebuffer);
  28664. var width = size.width || size;
  28665. var height = size.height || size;
  28666. var textures = [];
  28667. var attachments = [];
  28668. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  28669. for (var i = 0; i < textureCount; i++) {
  28670. var samplingMode = samplingModes[i] || defaultSamplingMode;
  28671. var type = types[i] || defaultType;
  28672. if (type === _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  28673. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  28674. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  28675. }
  28676. else if (type === _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  28677. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  28678. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  28679. }
  28680. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  28681. if (type === _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  28682. type = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT;
  28683. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  28684. }
  28685. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  28686. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28687. textures.push(texture);
  28688. attachments.push(attachment);
  28689. gl.activeTexture(gl["TEXTURE" + i]);
  28690. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  28691. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  28692. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  28693. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  28694. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  28695. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  28696. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  28697. if (generateMipMaps) {
  28698. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  28699. }
  28700. // Unbind
  28701. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28702. texture._framebuffer = framebuffer;
  28703. texture._depthStencilBuffer = depthStencilBuffer;
  28704. texture.baseWidth = width;
  28705. texture.baseHeight = height;
  28706. texture.width = width;
  28707. texture.height = height;
  28708. texture.isReady = true;
  28709. texture.samples = 1;
  28710. texture.generateMipMaps = generateMipMaps;
  28711. texture.samplingMode = samplingMode;
  28712. texture.type = type;
  28713. texture._generateDepthBuffer = generateDepthBuffer;
  28714. texture._generateStencilBuffer = generateStencilBuffer;
  28715. texture._attachments = attachments;
  28716. this._internalTexturesCache.push(texture);
  28717. }
  28718. if (generateDepthTexture && this._caps.depthTextureExtension) {
  28719. // Depth texture
  28720. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  28721. gl.activeTexture(gl.TEXTURE0);
  28722. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  28723. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  28724. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  28725. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  28726. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  28727. 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);
  28728. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  28729. depthTexture._framebuffer = framebuffer;
  28730. depthTexture.baseWidth = width;
  28731. depthTexture.baseHeight = height;
  28732. depthTexture.width = width;
  28733. depthTexture.height = height;
  28734. depthTexture.isReady = true;
  28735. depthTexture.samples = 1;
  28736. depthTexture.generateMipMaps = generateMipMaps;
  28737. depthTexture.samplingMode = gl.NEAREST;
  28738. depthTexture._generateDepthBuffer = generateDepthBuffer;
  28739. depthTexture._generateStencilBuffer = generateStencilBuffer;
  28740. textures.push(depthTexture);
  28741. this._internalTexturesCache.push(depthTexture);
  28742. }
  28743. gl.drawBuffers(attachments);
  28744. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  28745. this._bindUnboundFramebuffer(null);
  28746. this.resetTextureCache();
  28747. return textures;
  28748. };
  28749. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  28750. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  28751. return 1;
  28752. }
  28753. if (textures[0].samples === samples) {
  28754. return samples;
  28755. }
  28756. var gl = this._gl;
  28757. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  28758. // Dispose previous render buffers
  28759. if (textures[0]._depthStencilBuffer) {
  28760. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  28761. textures[0]._depthStencilBuffer = null;
  28762. }
  28763. if (textures[0]._MSAAFramebuffer) {
  28764. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  28765. textures[0]._MSAAFramebuffer = null;
  28766. }
  28767. for (var i = 0; i < textures.length; i++) {
  28768. if (textures[i]._MSAARenderBuffer) {
  28769. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  28770. textures[i]._MSAARenderBuffer = null;
  28771. }
  28772. }
  28773. if (samples > 1) {
  28774. var framebuffer = gl.createFramebuffer();
  28775. if (!framebuffer) {
  28776. throw new Error("Unable to create multi sampled framebuffer");
  28777. }
  28778. this._bindUnboundFramebuffer(framebuffer);
  28779. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  28780. var attachments = [];
  28781. for (var i = 0; i < textures.length; i++) {
  28782. var texture = textures[i];
  28783. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28784. var colorRenderbuffer = gl.createRenderbuffer();
  28785. if (!colorRenderbuffer) {
  28786. throw new Error("Unable to create multi sampled framebuffer");
  28787. }
  28788. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  28789. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  28790. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  28791. texture._MSAAFramebuffer = framebuffer;
  28792. texture._MSAARenderBuffer = colorRenderbuffer;
  28793. texture.samples = samples;
  28794. texture._depthStencilBuffer = depthStencilBuffer;
  28795. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  28796. attachments.push(attachment);
  28797. }
  28798. gl.drawBuffers(attachments);
  28799. }
  28800. else {
  28801. this._bindUnboundFramebuffer(textures[0]._framebuffer);
  28802. }
  28803. this._bindUnboundFramebuffer(null);
  28804. return samples;
  28805. };
  28806. /***/ }),
  28807. /***/ "./Engines/Extensions/engine.multiview.ts":
  28808. /*!************************************************!*\
  28809. !*** ./Engines/Extensions/engine.multiview.ts ***!
  28810. \************************************************/
  28811. /*! no exports provided */
  28812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28813. "use strict";
  28814. __webpack_require__.r(__webpack_exports__);
  28815. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  28816. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28817. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  28818. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28819. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  28820. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  28821. /* harmony import */ var _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/MultiviewRenderTarget */ "./Materials/Textures/MultiviewRenderTarget.ts");
  28822. /* harmony import */ var _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Maths/math.frustum */ "./Maths/math.frustum.ts");
  28823. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createMultiviewRenderTargetTexture = function (width, height) {
  28824. var gl = this._gl;
  28825. if (!this.getCaps().multiview) {
  28826. throw "Multiview is not supported";
  28827. }
  28828. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  28829. internalTexture.width = width;
  28830. internalTexture.height = height;
  28831. internalTexture._framebuffer = gl.createFramebuffer();
  28832. internalTexture._colorTextureArray = gl.createTexture();
  28833. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  28834. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  28835. internalTexture._depthStencilTextureArray = gl.createTexture();
  28836. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  28837. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  28838. internalTexture.isReady = true;
  28839. return internalTexture;
  28840. };
  28841. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  28842. var gl = this._gl;
  28843. var ext = this.getCaps().multiview;
  28844. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  28845. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  28846. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  28847. ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  28848. ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  28849. }
  28850. else {
  28851. throw "Invalid multiview frame buffer";
  28852. }
  28853. };
  28854. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._useMultiviewToSingleView = false;
  28855. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._multiviewTexture = null;
  28856. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  28857. if (!this._multiviewTexture) {
  28858. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  28859. }
  28860. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  28861. this._multiviewTexture.dispose();
  28862. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  28863. }
  28864. };
  28865. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._transformMatrixR = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  28866. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._multiviewSceneUbo = null;
  28867. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._createMultiviewUbo = function () {
  28868. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](this.getEngine(), undefined, true);
  28869. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  28870. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  28871. this._multiviewSceneUbo.addUniform("view", 16);
  28872. };
  28873. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._updateMultiviewUbo = function (viewR, projectionR) {
  28874. if (viewR && projectionR) {
  28875. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  28876. }
  28877. if (viewR && projectionR) {
  28878. viewR.multiplyToRef(projectionR, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Matrix[0]);
  28879. _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetRightPlaneToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  28880. }
  28881. if (this._multiviewSceneUbo) {
  28882. this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix());
  28883. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  28884. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  28885. this._multiviewSceneUbo.update();
  28886. }
  28887. };
  28888. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._renderMultiviewToSingleView = function (camera) {
  28889. // Multiview is only able to be displayed directly for API's such as webXR
  28890. // This displays a multiview image by rendering to the multiview image and then
  28891. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  28892. // Render to a multiview texture
  28893. 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));
  28894. if (!this._multiviewSceneUbo) {
  28895. this._createMultiviewUbo();
  28896. }
  28897. camera.outputRenderTarget = camera._multiviewTexture;
  28898. this._renderForCamera(camera);
  28899. camera.outputRenderTarget = null;
  28900. // Consume the multiview texture through a shader for each eye
  28901. for (var index = 0; index < camera._rigCameras.length; index++) {
  28902. var engine = this.getEngine();
  28903. this._activeCamera = camera._rigCameras[index];
  28904. engine.setViewport(this._activeCamera.viewport);
  28905. if (this.postProcessManager) {
  28906. this.postProcessManager._prepareFrame();
  28907. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  28908. }
  28909. }
  28910. };
  28911. /***/ }),
  28912. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  28913. /*!*****************************************************!*\
  28914. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  28915. \*****************************************************/
  28916. /*! exports provided: _OcclusionDataStorage */
  28917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28918. "use strict";
  28919. __webpack_require__.r(__webpack_exports__);
  28920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  28921. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28922. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  28923. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  28924. /** @hidden */
  28925. var _OcclusionDataStorage = /** @class */ (function () {
  28926. function _OcclusionDataStorage() {
  28927. /** @hidden */
  28928. this.occlusionInternalRetryCounter = 0;
  28929. /** @hidden */
  28930. this.isOcclusionQueryInProgress = false;
  28931. /** @hidden */
  28932. this.isOccluded = false;
  28933. /** @hidden */
  28934. this.occlusionRetryCount = -1;
  28935. /** @hidden */
  28936. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  28937. /** @hidden */
  28938. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  28939. }
  28940. return _OcclusionDataStorage;
  28941. }());
  28942. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  28943. return this._gl.createQuery();
  28944. };
  28945. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  28946. this._gl.deleteQuery(query);
  28947. return this;
  28948. };
  28949. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  28950. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  28951. };
  28952. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  28953. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  28954. };
  28955. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  28956. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  28957. this._gl.beginQuery(glAlgorithm, query);
  28958. return this;
  28959. };
  28960. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  28961. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  28962. this._gl.endQuery(glAlgorithm);
  28963. return this;
  28964. };
  28965. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  28966. var timerQuery = this.getCaps().timerQuery;
  28967. if (timerQuery.createQueryEXT) {
  28968. return timerQuery.createQueryEXT();
  28969. }
  28970. return this.createQuery();
  28971. };
  28972. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  28973. var timerQuery = this.getCaps().timerQuery;
  28974. if (timerQuery.deleteQueryEXT) {
  28975. timerQuery.deleteQueryEXT(query);
  28976. return;
  28977. }
  28978. this.deleteQuery(query);
  28979. };
  28980. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  28981. var timerQuery = this.getCaps().timerQuery;
  28982. if (timerQuery.getQueryObjectEXT) {
  28983. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  28984. }
  28985. return this.getQueryResult(query);
  28986. };
  28987. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  28988. var timerQuery = this.getCaps().timerQuery;
  28989. if (timerQuery.getQueryObjectEXT) {
  28990. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  28991. }
  28992. return this.isQueryResultAvailable(query);
  28993. };
  28994. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  28995. var caps = this.getCaps();
  28996. var timerQuery = caps.timerQuery;
  28997. if (!timerQuery) {
  28998. return null;
  28999. }
  29000. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  29001. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  29002. if (caps.canUseTimestampForTimerQuery) {
  29003. token._startTimeQuery = this._createTimeQuery();
  29004. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  29005. }
  29006. else {
  29007. if (this._currentNonTimestampToken) {
  29008. return this._currentNonTimestampToken;
  29009. }
  29010. token._timeElapsedQuery = this._createTimeQuery();
  29011. if (timerQuery.beginQueryEXT) {
  29012. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  29013. }
  29014. else {
  29015. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  29016. }
  29017. this._currentNonTimestampToken = token;
  29018. }
  29019. return token;
  29020. };
  29021. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  29022. var caps = this.getCaps();
  29023. var timerQuery = caps.timerQuery;
  29024. if (!timerQuery || !token) {
  29025. return -1;
  29026. }
  29027. if (caps.canUseTimestampForTimerQuery) {
  29028. if (!token._startTimeQuery) {
  29029. return -1;
  29030. }
  29031. if (!token._endTimeQuery) {
  29032. token._endTimeQuery = this._createTimeQuery();
  29033. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  29034. }
  29035. }
  29036. else if (!token._timeElapsedQueryEnded) {
  29037. if (!token._timeElapsedQuery) {
  29038. return -1;
  29039. }
  29040. if (timerQuery.endQueryEXT) {
  29041. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  29042. }
  29043. else {
  29044. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  29045. }
  29046. token._timeElapsedQueryEnded = true;
  29047. }
  29048. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  29049. var available = false;
  29050. if (token._endTimeQuery) {
  29051. available = this._getTimeQueryAvailability(token._endTimeQuery);
  29052. }
  29053. else if (token._timeElapsedQuery) {
  29054. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  29055. }
  29056. if (available && !disjoint) {
  29057. var result = 0;
  29058. if (caps.canUseTimestampForTimerQuery) {
  29059. if (!token._startTimeQuery || !token._endTimeQuery) {
  29060. return -1;
  29061. }
  29062. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  29063. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  29064. result = timeEnd - timeStart;
  29065. this._deleteTimeQuery(token._startTimeQuery);
  29066. this._deleteTimeQuery(token._endTimeQuery);
  29067. token._startTimeQuery = null;
  29068. token._endTimeQuery = null;
  29069. }
  29070. else {
  29071. if (!token._timeElapsedQuery) {
  29072. return -1;
  29073. }
  29074. result = this._getTimeQueryResult(token._timeElapsedQuery);
  29075. this._deleteTimeQuery(token._timeElapsedQuery);
  29076. token._timeElapsedQuery = null;
  29077. token._timeElapsedQueryEnded = false;
  29078. this._currentNonTimestampToken = null;
  29079. }
  29080. return result;
  29081. }
  29082. return -1;
  29083. };
  29084. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  29085. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  29086. };
  29087. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  29088. get: function () {
  29089. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  29090. },
  29091. enumerable: false,
  29092. configurable: true
  29093. });
  29094. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  29095. get: function () {
  29096. if (!this.__occlusionDataStorage) {
  29097. this.__occlusionDataStorage = new _OcclusionDataStorage();
  29098. }
  29099. return this.__occlusionDataStorage;
  29100. },
  29101. enumerable: false,
  29102. configurable: true
  29103. });
  29104. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  29105. get: function () {
  29106. return this._occlusionDataStorage.isOccluded;
  29107. },
  29108. set: function (value) {
  29109. this._occlusionDataStorage.isOccluded = value;
  29110. },
  29111. enumerable: true,
  29112. configurable: true
  29113. });
  29114. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  29115. get: function () {
  29116. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  29117. },
  29118. set: function (value) {
  29119. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  29120. },
  29121. enumerable: true,
  29122. configurable: true
  29123. });
  29124. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  29125. get: function () {
  29126. return this._occlusionDataStorage.occlusionType;
  29127. },
  29128. set: function (value) {
  29129. this._occlusionDataStorage.occlusionType = value;
  29130. },
  29131. enumerable: true,
  29132. configurable: true
  29133. });
  29134. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  29135. get: function () {
  29136. return this._occlusionDataStorage.occlusionRetryCount;
  29137. },
  29138. set: function (value) {
  29139. this._occlusionDataStorage.occlusionRetryCount = value;
  29140. },
  29141. enumerable: true,
  29142. configurable: true
  29143. });
  29144. // We also need to update AbstractMesh as there is a portion of the code there
  29145. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  29146. var dataStorage = this._occlusionDataStorage;
  29147. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  29148. dataStorage.isOccluded = false;
  29149. return false;
  29150. }
  29151. var engine = this.getEngine();
  29152. if (engine.webGLVersion < 2) {
  29153. dataStorage.isOccluded = false;
  29154. return false;
  29155. }
  29156. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  29157. dataStorage.isOccluded = false;
  29158. return false;
  29159. }
  29160. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  29161. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  29162. if (isOcclusionQueryAvailable) {
  29163. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  29164. dataStorage.isOcclusionQueryInProgress = false;
  29165. dataStorage.occlusionInternalRetryCounter = 0;
  29166. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  29167. }
  29168. else {
  29169. dataStorage.occlusionInternalRetryCounter++;
  29170. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  29171. dataStorage.isOcclusionQueryInProgress = false;
  29172. dataStorage.occlusionInternalRetryCounter = 0;
  29173. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  29174. // if strict continue the last state of the object.
  29175. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  29176. }
  29177. else {
  29178. return false;
  29179. }
  29180. }
  29181. }
  29182. var scene = this.getScene();
  29183. if (scene.getBoundingBoxRenderer) {
  29184. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  29185. if (!this._occlusionQuery) {
  29186. this._occlusionQuery = engine.createQuery();
  29187. }
  29188. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  29189. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  29190. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  29191. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  29192. }
  29193. return dataStorage.isOccluded;
  29194. };
  29195. /***/ }),
  29196. /***/ "./Engines/Extensions/engine.rawTexture.ts":
  29197. /*!*************************************************!*\
  29198. !*** ./Engines/Extensions/engine.rawTexture.ts ***!
  29199. \*************************************************/
  29200. /*! no exports provided */
  29201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29202. "use strict";
  29203. __webpack_require__.r(__webpack_exports__);
  29204. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  29205. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  29206. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  29207. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  29208. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  29209. if (compression === void 0) { compression = null; }
  29210. if (type === void 0) { type = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  29211. if (!texture) {
  29212. return;
  29213. }
  29214. // Babylon's internalSizedFomat but gl's texImage2D internalFormat
  29215. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  29216. // Babylon's internalFormat but gl's texImage2D format
  29217. var internalFormat = this._getInternalFormat(format);
  29218. var textureType = this._getWebGLTextureType(type);
  29219. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  29220. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  29221. if (!this._doNotHandleContextLost) {
  29222. texture._bufferView = data;
  29223. texture.format = format;
  29224. texture.type = type;
  29225. texture.invertY = invertY;
  29226. texture._compression = compression;
  29227. }
  29228. if (texture.width % 4 !== 0) {
  29229. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  29230. }
  29231. if (compression && data) {
  29232. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  29233. }
  29234. else {
  29235. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  29236. }
  29237. if (texture.generateMipMaps) {
  29238. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  29239. }
  29240. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  29241. // this.resetTextureCache();
  29242. texture.isReady = true;
  29243. };
  29244. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  29245. if (compression === void 0) { compression = null; }
  29246. if (type === void 0) { type = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  29247. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_RAW);
  29248. texture.baseWidth = width;
  29249. texture.baseHeight = height;
  29250. texture.width = width;
  29251. texture.height = height;
  29252. texture.format = format;
  29253. texture.generateMipMaps = generateMipMaps;
  29254. texture.samplingMode = samplingMode;
  29255. texture.invertY = invertY;
  29256. texture._compression = compression;
  29257. texture.type = type;
  29258. if (!this._doNotHandleContextLost) {
  29259. texture._bufferView = data;
  29260. }
  29261. this.updateRawTexture(texture, data, format, invertY, compression, type);
  29262. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  29263. // Filters
  29264. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  29265. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  29266. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  29267. if (generateMipMaps) {
  29268. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  29269. }
  29270. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  29271. this._internalTexturesCache.push(texture);
  29272. return texture;
  29273. };
  29274. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  29275. if (compression === void 0) { compression = null; }
  29276. var gl = this._gl;
  29277. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_CUBERAW);
  29278. texture.isCube = true;
  29279. texture.format = format;
  29280. texture.type = type;
  29281. if (!this._doNotHandleContextLost) {
  29282. texture._bufferViewArray = data;
  29283. }
  29284. var textureType = this._getWebGLTextureType(type);
  29285. var internalFormat = this._getInternalFormat(format);
  29286. if (internalFormat === gl.RGB) {
  29287. internalFormat = gl.RGBA;
  29288. }
  29289. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  29290. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  29291. generateMipMaps = false;
  29292. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  29293. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  29294. }
  29295. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  29296. generateMipMaps = false;
  29297. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  29298. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  29299. }
  29300. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  29301. generateMipMaps = false;
  29302. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  29303. }
  29304. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  29305. generateMipMaps = false;
  29306. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  29307. }
  29308. var width = size;
  29309. var height = width;
  29310. texture.width = width;
  29311. texture.height = height;
  29312. // Double check on POT to generate Mips.
  29313. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.height));
  29314. if (!isPot) {
  29315. generateMipMaps = false;
  29316. }
  29317. // Upload data if needed. The texture won't be ready until then.
  29318. if (data) {
  29319. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  29320. }
  29321. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  29322. // Filters
  29323. if (data && generateMipMaps) {
  29324. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  29325. }
  29326. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  29327. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  29328. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  29329. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  29330. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  29331. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29332. texture.generateMipMaps = generateMipMaps;
  29333. return texture;
  29334. };
  29335. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  29336. if (compression === void 0) { compression = null; }
  29337. if (level === void 0) { level = 0; }
  29338. texture._bufferViewArray = data;
  29339. texture.format = format;
  29340. texture.type = type;
  29341. texture.invertY = invertY;
  29342. texture._compression = compression;
  29343. var gl = this._gl;
  29344. var textureType = this._getWebGLTextureType(type);
  29345. var internalFormat = this._getInternalFormat(format);
  29346. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  29347. var needConversion = false;
  29348. if (internalFormat === gl.RGB) {
  29349. internalFormat = gl.RGBA;
  29350. needConversion = true;
  29351. }
  29352. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29353. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  29354. if (texture.width % 4 !== 0) {
  29355. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  29356. }
  29357. // Data are known to be in +X +Y +Z -X -Y -Z
  29358. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  29359. var faceData = data[faceIndex];
  29360. if (compression) {
  29361. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  29362. }
  29363. else {
  29364. if (needConversion) {
  29365. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  29366. }
  29367. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  29368. }
  29369. }
  29370. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.height));
  29371. if (isPot && texture.generateMipMaps && level === 0) {
  29372. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  29373. }
  29374. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  29375. // this.resetTextureCache();
  29376. texture.isReady = true;
  29377. };
  29378. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  29379. var _this = this;
  29380. if (onLoad === void 0) { onLoad = null; }
  29381. if (onError === void 0) { onError = null; }
  29382. if (samplingMode === void 0) { samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  29383. if (invertY === void 0) { invertY = false; }
  29384. var gl = this._gl;
  29385. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  29386. scene._addPendingData(texture);
  29387. texture.url = url;
  29388. this._internalTexturesCache.push(texture);
  29389. var onerror = function (request, exception) {
  29390. scene._removePendingData(texture);
  29391. if (onError && request) {
  29392. onError(request.status + " " + request.statusText, exception);
  29393. }
  29394. };
  29395. var internalCallback = function (data) {
  29396. var width = texture.width;
  29397. var faceDataArrays = callback(data);
  29398. if (!faceDataArrays) {
  29399. return;
  29400. }
  29401. if (mipmapGenerator) {
  29402. var textureType = _this._getWebGLTextureType(type);
  29403. var internalFormat = _this._getInternalFormat(format);
  29404. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  29405. var needConversion = false;
  29406. if (internalFormat === gl.RGB) {
  29407. internalFormat = gl.RGBA;
  29408. needConversion = true;
  29409. }
  29410. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29411. _this._unpackFlipY(false);
  29412. var mipData = mipmapGenerator(faceDataArrays);
  29413. for (var level = 0; level < mipData.length; level++) {
  29414. var mipSize = width >> level;
  29415. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  29416. var mipFaceData = mipData[level][faceIndex];
  29417. if (needConversion) {
  29418. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  29419. }
  29420. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  29421. }
  29422. }
  29423. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29424. }
  29425. else {
  29426. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  29427. }
  29428. texture.isReady = true;
  29429. // this.resetTextureCache();
  29430. scene._removePendingData(texture);
  29431. if (onLoad) {
  29432. onLoad();
  29433. }
  29434. };
  29435. this._loadFile(url, function (data) {
  29436. internalCallback(data);
  29437. }, undefined, scene.offlineProvider, true, onerror);
  29438. return texture;
  29439. };
  29440. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  29441. if (compression === void 0) { compression = null; }
  29442. if (textureType === void 0) { textureType = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  29443. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_RAW3D);
  29444. texture.baseWidth = width;
  29445. texture.baseHeight = height;
  29446. texture.baseDepth = depth;
  29447. texture.width = width;
  29448. texture.height = height;
  29449. texture.depth = depth;
  29450. texture.format = format;
  29451. texture.type = textureType;
  29452. texture.generateMipMaps = generateMipMaps;
  29453. texture.samplingMode = samplingMode;
  29454. texture.is3D = true;
  29455. if (!this._doNotHandleContextLost) {
  29456. texture._bufferView = data;
  29457. }
  29458. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  29459. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  29460. // Filters
  29461. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  29462. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  29463. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  29464. if (generateMipMaps) {
  29465. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  29466. }
  29467. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  29468. this._internalTexturesCache.push(texture);
  29469. return texture;
  29470. };
  29471. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  29472. if (compression === void 0) { compression = null; }
  29473. if (textureType === void 0) { textureType = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  29474. var internalType = this._getWebGLTextureType(textureType);
  29475. var internalFormat = this._getInternalFormat(format);
  29476. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  29477. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  29478. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  29479. if (!this._doNotHandleContextLost) {
  29480. texture._bufferView = data;
  29481. texture.format = format;
  29482. texture.invertY = invertY;
  29483. texture._compression = compression;
  29484. }
  29485. if (texture.width % 4 !== 0) {
  29486. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  29487. }
  29488. if (compression && data) {
  29489. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  29490. }
  29491. else {
  29492. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  29493. }
  29494. if (texture.generateMipMaps) {
  29495. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  29496. }
  29497. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  29498. // this.resetTextureCache();
  29499. texture.isReady = true;
  29500. };
  29501. /***/ }),
  29502. /***/ "./Engines/Extensions/engine.renderTarget.ts":
  29503. /*!***************************************************!*\
  29504. !*** ./Engines/Extensions/engine.renderTarget.ts ***!
  29505. \***************************************************/
  29506. /*! no exports provided */
  29507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29508. "use strict";
  29509. __webpack_require__.r(__webpack_exports__);
  29510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29511. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  29512. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  29513. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  29514. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createRenderTargetCubeTexture = function (size, options) {
  29515. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ generateMipMaps: true, generateDepthBuffer: true, generateStencilBuffer: false, type: _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_UNSIGNED_INT, samplingMode: _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURE_TRILINEAR_SAMPLINGMODE, format: _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA }, options);
  29516. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  29517. if (fullOptions.type === _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  29518. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  29519. fullOptions.samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  29520. }
  29521. else if (fullOptions.type === _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  29522. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  29523. fullOptions.samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  29524. }
  29525. var gl = this._gl;
  29526. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_RENDERTARGET);
  29527. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29528. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  29529. if (fullOptions.type === _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  29530. fullOptions.type = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_UNSIGNED_INT;
  29531. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  29532. }
  29533. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  29534. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  29535. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  29536. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  29537. for (var face = 0; face < 6; face++) {
  29538. 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);
  29539. }
  29540. // Create the framebuffer
  29541. var framebuffer = gl.createFramebuffer();
  29542. this._bindUnboundFramebuffer(framebuffer);
  29543. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  29544. // MipMaps
  29545. if (fullOptions.generateMipMaps) {
  29546. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29547. }
  29548. // Unbind
  29549. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29550. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  29551. this._bindUnboundFramebuffer(null);
  29552. texture._framebuffer = framebuffer;
  29553. texture.width = size;
  29554. texture.height = size;
  29555. texture.isReady = true;
  29556. texture.isCube = true;
  29557. texture.samples = 1;
  29558. texture.generateMipMaps = fullOptions.generateMipMaps;
  29559. texture.samplingMode = fullOptions.samplingMode;
  29560. texture.type = fullOptions.type;
  29561. texture.format = fullOptions.format;
  29562. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  29563. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  29564. this._internalTexturesCache.push(texture);
  29565. return texture;
  29566. };
  29567. /***/ }),
  29568. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  29569. /*!********************************************************!*\
  29570. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  29571. \********************************************************/
  29572. /*! exports provided: _forceTransformFeedbackToBundle */
  29573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29574. "use strict";
  29575. __webpack_require__.r(__webpack_exports__);
  29576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  29577. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  29578. /** @hidden */
  29579. var _forceTransformFeedbackToBundle = true;
  29580. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  29581. return this._gl.createTransformFeedback();
  29582. };
  29583. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  29584. this._gl.deleteTransformFeedback(value);
  29585. };
  29586. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  29587. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  29588. };
  29589. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  29590. if (usePoints === void 0) { usePoints = true; }
  29591. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  29592. };
  29593. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  29594. this._gl.endTransformFeedback();
  29595. };
  29596. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  29597. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  29598. };
  29599. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  29600. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value ? value.underlyingResource : null);
  29601. };
  29602. /***/ }),
  29603. /***/ "./Engines/Extensions/engine.webVR.ts":
  29604. /*!********************************************!*\
  29605. !*** ./Engines/Extensions/engine.webVR.ts ***!
  29606. \********************************************/
  29607. /*! no exports provided */
  29608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29609. "use strict";
  29610. __webpack_require__.r(__webpack_exports__);
  29611. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  29612. /* harmony import */ var _Maths_math_size__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.size */ "./Maths/math.size.ts");
  29613. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  29614. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  29615. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/domManagement */ "./Misc/domManagement.ts");
  29616. Object.defineProperty(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype, "isInVRExclusivePointerMode", {
  29617. get: function () {
  29618. return this._vrExclusivePointerMode;
  29619. },
  29620. enumerable: true,
  29621. configurable: true
  29622. });
  29623. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._prepareVRComponent = function () {
  29624. this._vrSupported = false;
  29625. this._vrExclusivePointerMode = false;
  29626. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  29627. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  29628. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  29629. };
  29630. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isVRDevicePresent = function () {
  29631. return !!this._vrDisplay;
  29632. };
  29633. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getVRDevice = function () {
  29634. return this._vrDisplay;
  29635. };
  29636. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.initWebVR = function () {
  29637. this.initWebVRAsync();
  29638. return this.onVRDisplayChangedObservable;
  29639. };
  29640. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.initWebVRAsync = function () {
  29641. var _this = this;
  29642. var notifyObservers = function () {
  29643. var eventArgs = {
  29644. vrDisplay: _this._vrDisplay,
  29645. vrSupported: _this._vrSupported
  29646. };
  29647. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29648. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29649. };
  29650. if (!this._onVrDisplayConnect) {
  29651. this._onVrDisplayConnect = function (event) {
  29652. _this._vrDisplay = event.display;
  29653. notifyObservers();
  29654. };
  29655. this._onVrDisplayDisconnect = function () {
  29656. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29657. _this._vrDisplay = undefined;
  29658. _this._frameHandler = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].QueueNewFrame(_this._bindedRenderFunction);
  29659. notifyObservers();
  29660. };
  29661. this._onVrDisplayPresentChange = function () {
  29662. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29663. };
  29664. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29665. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29666. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29667. }
  29668. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29669. this._webVRInitPromise.then(notifyObservers);
  29670. return this._webVRInitPromise;
  29671. };
  29672. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getVRDisplaysAsync = function () {
  29673. var _this = this;
  29674. return new Promise(function (res) {
  29675. if (navigator.getVRDisplays) {
  29676. navigator.getVRDisplays().then(function (devices) {
  29677. _this._vrSupported = true;
  29678. // note that devices may actually be an empty array. This is fine;
  29679. // we expect this._vrDisplay to be undefined in this case.
  29680. _this._vrDisplay = devices[0];
  29681. res({
  29682. vrDisplay: _this._vrDisplay,
  29683. vrSupported: _this._vrSupported
  29684. });
  29685. });
  29686. }
  29687. else {
  29688. _this._vrDisplay = undefined;
  29689. _this._vrSupported = false;
  29690. res({
  29691. vrDisplay: _this._vrDisplay,
  29692. vrSupported: _this._vrSupported
  29693. });
  29694. }
  29695. });
  29696. };
  29697. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.enableVR = function () {
  29698. var _this = this;
  29699. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29700. var onResolved = function () {
  29701. _this.onVRRequestPresentComplete.notifyObservers(true);
  29702. _this._onVRFullScreenTriggered();
  29703. };
  29704. var onRejected = function () {
  29705. _this.onVRRequestPresentComplete.notifyObservers(false);
  29706. };
  29707. this.onVRRequestPresentStart.notifyObservers(this);
  29708. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29709. }
  29710. };
  29711. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._onVRFullScreenTriggered = function () {
  29712. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29713. //get the old size before we change
  29714. this._oldSize = new _Maths_math_size__WEBPACK_IMPORTED_MODULE_1__["Size"](this.getRenderWidth(), this.getRenderHeight());
  29715. this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
  29716. //get the width and height, change the render size
  29717. var leftEye = this._vrDisplay.getEyeParameters('left');
  29718. this.setHardwareScalingLevel(1);
  29719. this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  29720. }
  29721. else {
  29722. this.setHardwareScalingLevel(this._oldHardwareScaleFactor);
  29723. this.setSize(this._oldSize.width, this._oldSize.height);
  29724. }
  29725. };
  29726. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.disableVR = function () {
  29727. var _this = this;
  29728. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29729. this._vrDisplay.exitPresent()
  29730. .then(function () { return _this._onVRFullScreenTriggered(); })
  29731. .catch(function () { return _this._onVRFullScreenTriggered(); });
  29732. }
  29733. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_4__["DomManagement"].IsWindowObjectExist()) {
  29734. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  29735. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  29736. if (this._onVrDisplayConnect) {
  29737. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29738. if (this._onVrDisplayDisconnect) {
  29739. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29740. }
  29741. if (this._onVrDisplayPresentChange) {
  29742. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29743. }
  29744. this._onVrDisplayConnect = null;
  29745. this._onVrDisplayDisconnect = null;
  29746. }
  29747. }
  29748. };
  29749. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._connectVREvents = function (canvas, document) {
  29750. this._onVRDisplayPointerRestricted = function () {
  29751. if (canvas) {
  29752. canvas.requestPointerLock();
  29753. }
  29754. };
  29755. this._onVRDisplayPointerUnrestricted = function () {
  29756. if (!document.exitPointerLock) {
  29757. return;
  29758. }
  29759. document.exitPointerLock();
  29760. };
  29761. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_4__["DomManagement"].IsWindowObjectExist()) {
  29762. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  29763. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  29764. }
  29765. };
  29766. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._submitVRFrame = function () {
  29767. // Submit frame to the vr device, if enabled
  29768. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29769. // TODO: We should only submit the frame if we read frameData successfully.
  29770. try {
  29771. this._vrDisplay.submitFrame();
  29772. }
  29773. catch (e) {
  29774. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29775. }
  29776. }
  29777. };
  29778. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isVRPresenting = function () {
  29779. return this._vrDisplay && this._vrDisplay.isPresenting;
  29780. };
  29781. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._requestVRFrame = function () {
  29782. this._frameHandler = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29783. };
  29784. /***/ }),
  29785. /***/ "./Engines/Extensions/index.ts":
  29786. /*!*************************************!*\
  29787. !*** ./Engines/Extensions/index.ts ***!
  29788. \*************************************/
  29789. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  29790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29791. "use strict";
  29792. __webpack_require__.r(__webpack_exports__);
  29793. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  29794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  29795. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  29796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  29797. /***/ }),
  29798. /***/ "./Engines/Processors/Expressions/Operators/shaderDefineAndOperator.ts":
  29799. /*!*****************************************************************************!*\
  29800. !*** ./Engines/Processors/Expressions/Operators/shaderDefineAndOperator.ts ***!
  29801. \*****************************************************************************/
  29802. /*! exports provided: ShaderDefineAndOperator */
  29803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29804. "use strict";
  29805. __webpack_require__.r(__webpack_exports__);
  29806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderDefineAndOperator", function() { return ShaderDefineAndOperator; });
  29807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29808. /* harmony import */ var _shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shaderDefineExpression */ "./Engines/Processors/Expressions/shaderDefineExpression.ts");
  29809. /** @hidden */
  29810. var ShaderDefineAndOperator = /** @class */ (function (_super) {
  29811. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderDefineAndOperator, _super);
  29812. function ShaderDefineAndOperator() {
  29813. return _super !== null && _super.apply(this, arguments) || this;
  29814. }
  29815. ShaderDefineAndOperator.prototype.isTrue = function (preprocessors) {
  29816. return this.leftOperand.isTrue(preprocessors) && this.rightOperand.isTrue(preprocessors);
  29817. };
  29818. return ShaderDefineAndOperator;
  29819. }(_shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__["ShaderDefineExpression"]));
  29820. /***/ }),
  29821. /***/ "./Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.ts":
  29822. /*!************************************************************************************!*\
  29823. !*** ./Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.ts ***!
  29824. \************************************************************************************/
  29825. /*! exports provided: ShaderDefineArithmeticOperator */
  29826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29827. "use strict";
  29828. __webpack_require__.r(__webpack_exports__);
  29829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderDefineArithmeticOperator", function() { return ShaderDefineArithmeticOperator; });
  29830. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29831. /* harmony import */ var _shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shaderDefineExpression */ "./Engines/Processors/Expressions/shaderDefineExpression.ts");
  29832. /** @hidden */
  29833. var ShaderDefineArithmeticOperator = /** @class */ (function (_super) {
  29834. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderDefineArithmeticOperator, _super);
  29835. function ShaderDefineArithmeticOperator(define, operand, testValue) {
  29836. var _this = _super.call(this) || this;
  29837. _this.define = define;
  29838. _this.operand = operand;
  29839. _this.testValue = testValue;
  29840. return _this;
  29841. }
  29842. ShaderDefineArithmeticOperator.prototype.isTrue = function (preprocessors) {
  29843. var value = preprocessors[this.define];
  29844. if (value === undefined) {
  29845. return false;
  29846. }
  29847. var condition = false;
  29848. var left = parseInt(value);
  29849. var right = parseInt(this.testValue);
  29850. switch (this.operand) {
  29851. case ">":
  29852. condition = left > right;
  29853. break;
  29854. case "<":
  29855. condition = left < right;
  29856. break;
  29857. case "<=":
  29858. condition = left <= right;
  29859. break;
  29860. case ">=":
  29861. condition = left >= right;
  29862. break;
  29863. case "==":
  29864. condition = left === right;
  29865. break;
  29866. }
  29867. return condition;
  29868. };
  29869. return ShaderDefineArithmeticOperator;
  29870. }(_shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__["ShaderDefineExpression"]));
  29871. /***/ }),
  29872. /***/ "./Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.ts":
  29873. /*!***********************************************************************************!*\
  29874. !*** ./Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.ts ***!
  29875. \***********************************************************************************/
  29876. /*! exports provided: ShaderDefineIsDefinedOperator */
  29877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29878. "use strict";
  29879. __webpack_require__.r(__webpack_exports__);
  29880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderDefineIsDefinedOperator", function() { return ShaderDefineIsDefinedOperator; });
  29881. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29882. /* harmony import */ var _shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shaderDefineExpression */ "./Engines/Processors/Expressions/shaderDefineExpression.ts");
  29883. /** @hidden */
  29884. var ShaderDefineIsDefinedOperator = /** @class */ (function (_super) {
  29885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderDefineIsDefinedOperator, _super);
  29886. function ShaderDefineIsDefinedOperator(define, not) {
  29887. if (not === void 0) { not = false; }
  29888. var _this = _super.call(this) || this;
  29889. _this.define = define;
  29890. _this.not = not;
  29891. return _this;
  29892. }
  29893. ShaderDefineIsDefinedOperator.prototype.isTrue = function (preprocessors) {
  29894. var condition = preprocessors[this.define] !== undefined;
  29895. if (this.not) {
  29896. condition = !condition;
  29897. }
  29898. return condition;
  29899. };
  29900. return ShaderDefineIsDefinedOperator;
  29901. }(_shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__["ShaderDefineExpression"]));
  29902. /***/ }),
  29903. /***/ "./Engines/Processors/Expressions/Operators/shaderDefineOrOperator.ts":
  29904. /*!****************************************************************************!*\
  29905. !*** ./Engines/Processors/Expressions/Operators/shaderDefineOrOperator.ts ***!
  29906. \****************************************************************************/
  29907. /*! exports provided: ShaderDefineOrOperator */
  29908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29909. "use strict";
  29910. __webpack_require__.r(__webpack_exports__);
  29911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderDefineOrOperator", function() { return ShaderDefineOrOperator; });
  29912. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29913. /* harmony import */ var _shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shaderDefineExpression */ "./Engines/Processors/Expressions/shaderDefineExpression.ts");
  29914. /** @hidden */
  29915. var ShaderDefineOrOperator = /** @class */ (function (_super) {
  29916. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderDefineOrOperator, _super);
  29917. function ShaderDefineOrOperator() {
  29918. return _super !== null && _super.apply(this, arguments) || this;
  29919. }
  29920. ShaderDefineOrOperator.prototype.isTrue = function (preprocessors) {
  29921. return this.leftOperand.isTrue(preprocessors) || this.rightOperand.isTrue(preprocessors);
  29922. };
  29923. return ShaderDefineOrOperator;
  29924. }(_shaderDefineExpression__WEBPACK_IMPORTED_MODULE_1__["ShaderDefineExpression"]));
  29925. /***/ }),
  29926. /***/ "./Engines/Processors/Expressions/shaderDefineExpression.ts":
  29927. /*!******************************************************************!*\
  29928. !*** ./Engines/Processors/Expressions/shaderDefineExpression.ts ***!
  29929. \******************************************************************/
  29930. /*! exports provided: ShaderDefineExpression */
  29931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29932. "use strict";
  29933. __webpack_require__.r(__webpack_exports__);
  29934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderDefineExpression", function() { return ShaderDefineExpression; });
  29935. /** @hidden */
  29936. var ShaderDefineExpression = /** @class */ (function () {
  29937. function ShaderDefineExpression() {
  29938. }
  29939. ShaderDefineExpression.prototype.isTrue = function (preprocessors) {
  29940. return true;
  29941. };
  29942. return ShaderDefineExpression;
  29943. }());
  29944. /***/ }),
  29945. /***/ "./Engines/Processors/shaderCodeConditionNode.ts":
  29946. /*!*******************************************************!*\
  29947. !*** ./Engines/Processors/shaderCodeConditionNode.ts ***!
  29948. \*******************************************************/
  29949. /*! exports provided: ShaderCodeConditionNode */
  29950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29951. "use strict";
  29952. __webpack_require__.r(__webpack_exports__);
  29953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderCodeConditionNode", function() { return ShaderCodeConditionNode; });
  29954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29955. /* harmony import */ var _shaderCodeNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shaderCodeNode */ "./Engines/Processors/shaderCodeNode.ts");
  29956. /** @hidden */
  29957. var ShaderCodeConditionNode = /** @class */ (function (_super) {
  29958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderCodeConditionNode, _super);
  29959. function ShaderCodeConditionNode() {
  29960. return _super !== null && _super.apply(this, arguments) || this;
  29961. }
  29962. ShaderCodeConditionNode.prototype.process = function (preprocessors, options) {
  29963. for (var index = 0; index < this.children.length; index++) {
  29964. var node = this.children[index];
  29965. if (node.isValid(preprocessors)) {
  29966. return node.process(preprocessors, options);
  29967. }
  29968. }
  29969. return "";
  29970. };
  29971. return ShaderCodeConditionNode;
  29972. }(_shaderCodeNode__WEBPACK_IMPORTED_MODULE_1__["ShaderCodeNode"]));
  29973. /***/ }),
  29974. /***/ "./Engines/Processors/shaderCodeCursor.ts":
  29975. /*!************************************************!*\
  29976. !*** ./Engines/Processors/shaderCodeCursor.ts ***!
  29977. \************************************************/
  29978. /*! exports provided: ShaderCodeCursor */
  29979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29980. "use strict";
  29981. __webpack_require__.r(__webpack_exports__);
  29982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderCodeCursor", function() { return ShaderCodeCursor; });
  29983. /** @hidden */
  29984. var ShaderCodeCursor = /** @class */ (function () {
  29985. function ShaderCodeCursor() {
  29986. }
  29987. Object.defineProperty(ShaderCodeCursor.prototype, "currentLine", {
  29988. get: function () {
  29989. return this._lines[this.lineIndex];
  29990. },
  29991. enumerable: true,
  29992. configurable: true
  29993. });
  29994. Object.defineProperty(ShaderCodeCursor.prototype, "canRead", {
  29995. get: function () {
  29996. return this.lineIndex < this._lines.length - 1;
  29997. },
  29998. enumerable: true,
  29999. configurable: true
  30000. });
  30001. Object.defineProperty(ShaderCodeCursor.prototype, "lines", {
  30002. set: function (value) {
  30003. this._lines = [];
  30004. for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
  30005. var line = value_1[_i];
  30006. // Prevent removing line break in macros.
  30007. if (line[0] === "#") {
  30008. this._lines.push(line);
  30009. continue;
  30010. }
  30011. var split = line.split(";");
  30012. for (var index = 0; index < split.length; index++) {
  30013. var subLine = split[index];
  30014. subLine = subLine.trim();
  30015. if (!subLine) {
  30016. continue;
  30017. }
  30018. this._lines.push(subLine + (index !== split.length - 1 ? ";" : ""));
  30019. }
  30020. }
  30021. },
  30022. enumerable: true,
  30023. configurable: true
  30024. });
  30025. return ShaderCodeCursor;
  30026. }());
  30027. /***/ }),
  30028. /***/ "./Engines/Processors/shaderCodeNode.ts":
  30029. /*!**********************************************!*\
  30030. !*** ./Engines/Processors/shaderCodeNode.ts ***!
  30031. \**********************************************/
  30032. /*! exports provided: ShaderCodeNode */
  30033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30034. "use strict";
  30035. __webpack_require__.r(__webpack_exports__);
  30036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderCodeNode", function() { return ShaderCodeNode; });
  30037. /* harmony import */ var _Misc_stringTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/stringTools */ "./Misc/stringTools.ts");
  30038. /** @hidden */
  30039. var ShaderCodeNode = /** @class */ (function () {
  30040. function ShaderCodeNode() {
  30041. this.children = [];
  30042. }
  30043. ShaderCodeNode.prototype.isValid = function (preprocessors) {
  30044. return true;
  30045. };
  30046. ShaderCodeNode.prototype.process = function (preprocessors, options) {
  30047. var result = "";
  30048. if (this.line) {
  30049. var value = this.line;
  30050. var processor = options.processor;
  30051. if (processor) {
  30052. if (processor.attributeProcessor && _Misc_stringTools__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(this.line, "attribute")) {
  30053. value = processor.attributeProcessor(this.line);
  30054. }
  30055. else if (processor.varyingProcessor && _Misc_stringTools__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(this.line, "varying")) {
  30056. value = processor.varyingProcessor(this.line, options.isFragment);
  30057. }
  30058. else if ((processor.uniformProcessor || processor.uniformBufferProcessor) && _Misc_stringTools__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(this.line, "uniform")) {
  30059. var regex = /uniform (.+) (.+)/;
  30060. if (regex.test(this.line)) { // uniform
  30061. if (processor.uniformProcessor) {
  30062. value = processor.uniformProcessor(this.line, options.isFragment);
  30063. }
  30064. }
  30065. else { // Uniform buffer
  30066. if (processor.uniformBufferProcessor) {
  30067. value = processor.uniformBufferProcessor(this.line, options.isFragment);
  30068. options.lookForClosingBracketForUniformBuffer = true;
  30069. }
  30070. }
  30071. }
  30072. if (processor.endOfUniformBufferProcessor) {
  30073. if (options.lookForClosingBracketForUniformBuffer && this.line.indexOf("}") !== -1) {
  30074. options.lookForClosingBracketForUniformBuffer = false;
  30075. value = processor.endOfUniformBufferProcessor(this.line, options.isFragment);
  30076. }
  30077. }
  30078. if (processor.lineProcessor) {
  30079. value = processor.lineProcessor(value, options.isFragment);
  30080. }
  30081. }
  30082. result += value + "\r\n";
  30083. }
  30084. this.children.forEach(function (child) {
  30085. result += child.process(preprocessors, options);
  30086. });
  30087. if (this.additionalDefineKey) {
  30088. preprocessors[this.additionalDefineKey] = this.additionalDefineValue || "true";
  30089. }
  30090. return result;
  30091. };
  30092. return ShaderCodeNode;
  30093. }());
  30094. /***/ }),
  30095. /***/ "./Engines/Processors/shaderCodeTestNode.ts":
  30096. /*!**************************************************!*\
  30097. !*** ./Engines/Processors/shaderCodeTestNode.ts ***!
  30098. \**************************************************/
  30099. /*! exports provided: ShaderCodeTestNode */
  30100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30101. "use strict";
  30102. __webpack_require__.r(__webpack_exports__);
  30103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderCodeTestNode", function() { return ShaderCodeTestNode; });
  30104. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  30105. /* harmony import */ var _shaderCodeNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shaderCodeNode */ "./Engines/Processors/shaderCodeNode.ts");
  30106. /** @hidden */
  30107. var ShaderCodeTestNode = /** @class */ (function (_super) {
  30108. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderCodeTestNode, _super);
  30109. function ShaderCodeTestNode() {
  30110. return _super !== null && _super.apply(this, arguments) || this;
  30111. }
  30112. ShaderCodeTestNode.prototype.isValid = function (preprocessors) {
  30113. return this.testExpression.isTrue(preprocessors);
  30114. };
  30115. return ShaderCodeTestNode;
  30116. }(_shaderCodeNode__WEBPACK_IMPORTED_MODULE_1__["ShaderCodeNode"]));
  30117. /***/ }),
  30118. /***/ "./Engines/Processors/shaderProcessor.ts":
  30119. /*!***********************************************!*\
  30120. !*** ./Engines/Processors/shaderProcessor.ts ***!
  30121. \***********************************************/
  30122. /*! exports provided: ShaderProcessor */
  30123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30124. "use strict";
  30125. __webpack_require__.r(__webpack_exports__);
  30126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderProcessor", function() { return ShaderProcessor; });
  30127. /* harmony import */ var _shaderCodeNode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shaderCodeNode */ "./Engines/Processors/shaderCodeNode.ts");
  30128. /* harmony import */ var _shaderCodeCursor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shaderCodeCursor */ "./Engines/Processors/shaderCodeCursor.ts");
  30129. /* harmony import */ var _shaderCodeConditionNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaderCodeConditionNode */ "./Engines/Processors/shaderCodeConditionNode.ts");
  30130. /* harmony import */ var _shaderCodeTestNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaderCodeTestNode */ "./Engines/Processors/shaderCodeTestNode.ts");
  30131. /* harmony import */ var _Expressions_Operators_shaderDefineIsDefinedOperator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Expressions/Operators/shaderDefineIsDefinedOperator */ "./Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.ts");
  30132. /* harmony import */ var _Expressions_Operators_shaderDefineOrOperator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Expressions/Operators/shaderDefineOrOperator */ "./Engines/Processors/Expressions/Operators/shaderDefineOrOperator.ts");
  30133. /* harmony import */ var _Expressions_Operators_shaderDefineAndOperator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Expressions/Operators/shaderDefineAndOperator */ "./Engines/Processors/Expressions/Operators/shaderDefineAndOperator.ts");
  30134. /* harmony import */ var _Expressions_Operators_shaderDefineArithmeticOperator__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Expressions/Operators/shaderDefineArithmeticOperator */ "./Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.ts");
  30135. /* harmony import */ var _Misc_fileTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/fileTools */ "./Misc/fileTools.ts");
  30136. /** @hidden */
  30137. var ShaderProcessor = /** @class */ (function () {
  30138. function ShaderProcessor() {
  30139. }
  30140. ShaderProcessor.Process = function (sourceCode, options, callback) {
  30141. var _this = this;
  30142. this._ProcessIncludes(sourceCode, options, function (codeWithIncludes) {
  30143. var migratedCode = _this._ProcessShaderConversion(codeWithIncludes, options);
  30144. callback(migratedCode);
  30145. });
  30146. };
  30147. ShaderProcessor._ProcessPrecision = function (source, options) {
  30148. var shouldUseHighPrecisionShader = options.shouldUseHighPrecisionShader;
  30149. if (source.indexOf("precision highp float") === -1) {
  30150. if (!shouldUseHighPrecisionShader) {
  30151. source = "precision mediump float;\n" + source;
  30152. }
  30153. else {
  30154. source = "precision highp float;\n" + source;
  30155. }
  30156. }
  30157. else {
  30158. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  30159. source = source.replace("precision highp float", "precision mediump float");
  30160. }
  30161. }
  30162. return source;
  30163. };
  30164. ShaderProcessor._ExtractOperation = function (expression) {
  30165. var regex = /defined\((.+)\)/;
  30166. var match = regex.exec(expression);
  30167. if (match && match.length) {
  30168. return new _Expressions_Operators_shaderDefineIsDefinedOperator__WEBPACK_IMPORTED_MODULE_4__["ShaderDefineIsDefinedOperator"](match[1].trim(), expression[0] === "!");
  30169. }
  30170. var operators = ["==", ">=", "<=", "<", ">"];
  30171. var operator = "";
  30172. var indexOperator = 0;
  30173. for (var _i = 0, operators_1 = operators; _i < operators_1.length; _i++) {
  30174. operator = operators_1[_i];
  30175. indexOperator = expression.indexOf(operator);
  30176. if (indexOperator > -1) {
  30177. break;
  30178. }
  30179. }
  30180. if (indexOperator === -1) {
  30181. return new _Expressions_Operators_shaderDefineIsDefinedOperator__WEBPACK_IMPORTED_MODULE_4__["ShaderDefineIsDefinedOperator"](expression);
  30182. }
  30183. var define = expression.substring(0, indexOperator).trim();
  30184. var value = expression.substring(indexOperator + operator.length).trim();
  30185. return new _Expressions_Operators_shaderDefineArithmeticOperator__WEBPACK_IMPORTED_MODULE_7__["ShaderDefineArithmeticOperator"](define, operator, value);
  30186. };
  30187. ShaderProcessor._BuildSubExpression = function (expression) {
  30188. var indexOr = expression.indexOf("||");
  30189. if (indexOr === -1) {
  30190. var indexAnd = expression.indexOf("&&");
  30191. if (indexAnd > -1) {
  30192. var andOperator = new _Expressions_Operators_shaderDefineAndOperator__WEBPACK_IMPORTED_MODULE_6__["ShaderDefineAndOperator"]();
  30193. var leftPart = expression.substring(0, indexAnd).trim();
  30194. var rightPart = expression.substring(indexAnd + 2).trim();
  30195. andOperator.leftOperand = this._BuildSubExpression(leftPart);
  30196. andOperator.rightOperand = this._BuildSubExpression(rightPart);
  30197. return andOperator;
  30198. }
  30199. else {
  30200. return this._ExtractOperation(expression);
  30201. }
  30202. }
  30203. else {
  30204. var orOperator = new _Expressions_Operators_shaderDefineOrOperator__WEBPACK_IMPORTED_MODULE_5__["ShaderDefineOrOperator"]();
  30205. var leftPart = expression.substring(0, indexOr).trim();
  30206. var rightPart = expression.substring(indexOr + 2).trim();
  30207. orOperator.leftOperand = this._BuildSubExpression(leftPart);
  30208. orOperator.rightOperand = this._BuildSubExpression(rightPart);
  30209. return orOperator;
  30210. }
  30211. };
  30212. ShaderProcessor._BuildExpression = function (line, start) {
  30213. var node = new _shaderCodeTestNode__WEBPACK_IMPORTED_MODULE_3__["ShaderCodeTestNode"]();
  30214. var command = line.substring(0, start);
  30215. var expression = line.substring(start).trim();
  30216. if (command === "#ifdef") {
  30217. node.testExpression = new _Expressions_Operators_shaderDefineIsDefinedOperator__WEBPACK_IMPORTED_MODULE_4__["ShaderDefineIsDefinedOperator"](expression);
  30218. }
  30219. else if (command === "#ifndef") {
  30220. node.testExpression = new _Expressions_Operators_shaderDefineIsDefinedOperator__WEBPACK_IMPORTED_MODULE_4__["ShaderDefineIsDefinedOperator"](expression, true);
  30221. }
  30222. else {
  30223. node.testExpression = this._BuildSubExpression(expression);
  30224. }
  30225. return node;
  30226. };
  30227. ShaderProcessor._MoveCursorWithinIf = function (cursor, rootNode, ifNode) {
  30228. var line = cursor.currentLine;
  30229. while (this._MoveCursor(cursor, ifNode)) {
  30230. line = cursor.currentLine;
  30231. var first5 = line.substring(0, 5).toLowerCase();
  30232. if (first5 === "#else") {
  30233. var elseNode = new _shaderCodeNode__WEBPACK_IMPORTED_MODULE_0__["ShaderCodeNode"]();
  30234. rootNode.children.push(elseNode);
  30235. this._MoveCursor(cursor, elseNode);
  30236. return;
  30237. }
  30238. else if (first5 === "#elif") {
  30239. var elifNode = this._BuildExpression(line, 5);
  30240. rootNode.children.push(elifNode);
  30241. ifNode = elifNode;
  30242. }
  30243. }
  30244. };
  30245. ShaderProcessor._MoveCursor = function (cursor, rootNode) {
  30246. while (cursor.canRead) {
  30247. cursor.lineIndex++;
  30248. var line = cursor.currentLine;
  30249. var keywords = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;
  30250. var matches = keywords.exec(line);
  30251. if (matches && matches.length) {
  30252. var keyword = matches[0];
  30253. switch (keyword) {
  30254. case "#ifdef": {
  30255. var newRootNode = new _shaderCodeConditionNode__WEBPACK_IMPORTED_MODULE_2__["ShaderCodeConditionNode"]();
  30256. rootNode.children.push(newRootNode);
  30257. var ifNode = this._BuildExpression(line, 6);
  30258. newRootNode.children.push(ifNode);
  30259. this._MoveCursorWithinIf(cursor, newRootNode, ifNode);
  30260. break;
  30261. }
  30262. case "#else":
  30263. case "#elif":
  30264. return true;
  30265. case "#endif":
  30266. return false;
  30267. case "#ifndef": {
  30268. var newRootNode = new _shaderCodeConditionNode__WEBPACK_IMPORTED_MODULE_2__["ShaderCodeConditionNode"]();
  30269. rootNode.children.push(newRootNode);
  30270. var ifNode = this._BuildExpression(line, 7);
  30271. newRootNode.children.push(ifNode);
  30272. this._MoveCursorWithinIf(cursor, newRootNode, ifNode);
  30273. break;
  30274. }
  30275. case "#if": {
  30276. var newRootNode = new _shaderCodeConditionNode__WEBPACK_IMPORTED_MODULE_2__["ShaderCodeConditionNode"]();
  30277. var ifNode = this._BuildExpression(line, 3);
  30278. rootNode.children.push(newRootNode);
  30279. newRootNode.children.push(ifNode);
  30280. this._MoveCursorWithinIf(cursor, newRootNode, ifNode);
  30281. break;
  30282. }
  30283. }
  30284. }
  30285. else {
  30286. var newNode = new _shaderCodeNode__WEBPACK_IMPORTED_MODULE_0__["ShaderCodeNode"]();
  30287. newNode.line = line;
  30288. rootNode.children.push(newNode);
  30289. // Detect additional defines
  30290. if (line[0] === "#" && line[1] === "d") {
  30291. var split = line.replace(";", "").split(" ");
  30292. newNode.additionalDefineKey = split[1];
  30293. if (split.length === 3) {
  30294. newNode.additionalDefineValue = split[2];
  30295. }
  30296. }
  30297. }
  30298. }
  30299. return false;
  30300. };
  30301. ShaderProcessor._EvaluatePreProcessors = function (sourceCode, preprocessors, options) {
  30302. var rootNode = new _shaderCodeNode__WEBPACK_IMPORTED_MODULE_0__["ShaderCodeNode"]();
  30303. var cursor = new _shaderCodeCursor__WEBPACK_IMPORTED_MODULE_1__["ShaderCodeCursor"]();
  30304. cursor.lineIndex = -1;
  30305. cursor.lines = sourceCode.split("\n");
  30306. // Decompose (We keep it in 2 steps so it is easier to maintain and perf hit is insignificant)
  30307. this._MoveCursor(cursor, rootNode);
  30308. // Recompose
  30309. return rootNode.process(preprocessors, options);
  30310. };
  30311. ShaderProcessor._PreparePreProcessors = function (options) {
  30312. var defines = options.defines;
  30313. var preprocessors = {};
  30314. for (var _i = 0, defines_1 = defines; _i < defines_1.length; _i++) {
  30315. var define = defines_1[_i];
  30316. var keyValue = define.replace("#define", "").replace(";", "").trim();
  30317. var split = keyValue.split(" ");
  30318. preprocessors[split[0]] = split.length > 1 ? split[1] : "";
  30319. }
  30320. preprocessors["GL_ES"] = "true";
  30321. preprocessors["__VERSION__"] = options.version;
  30322. preprocessors[options.platformName] = "true";
  30323. return preprocessors;
  30324. };
  30325. ShaderProcessor._ProcessShaderConversion = function (sourceCode, options) {
  30326. var preparedSourceCode = this._ProcessPrecision(sourceCode, options);
  30327. if (!options.processor) {
  30328. return preparedSourceCode;
  30329. }
  30330. // Already converted
  30331. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  30332. return preparedSourceCode.replace("#version 300 es", "");
  30333. }
  30334. var defines = options.defines;
  30335. var preprocessors = this._PreparePreProcessors(options);
  30336. // General pre processing
  30337. if (options.processor.preProcessor) {
  30338. preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, options.isFragment);
  30339. }
  30340. preparedSourceCode = this._EvaluatePreProcessors(preparedSourceCode, preprocessors, options);
  30341. // Post processing
  30342. if (options.processor.postProcessor) {
  30343. preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment);
  30344. }
  30345. return preparedSourceCode;
  30346. };
  30347. ShaderProcessor._ProcessIncludes = function (sourceCode, options, callback) {
  30348. var _this = this;
  30349. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  30350. var match = regex.exec(sourceCode);
  30351. var returnValue = new String(sourceCode);
  30352. while (match != null) {
  30353. var includeFile = match[1];
  30354. // Uniform declaration
  30355. if (includeFile.indexOf("__decl__") !== -1) {
  30356. includeFile = includeFile.replace(/__decl__/, "");
  30357. if (options.supportsUniformBuffers) {
  30358. includeFile = includeFile.replace(/Vertex/, "Ubo");
  30359. includeFile = includeFile.replace(/Fragment/, "Ubo");
  30360. }
  30361. includeFile = includeFile + "Declaration";
  30362. }
  30363. if (options.includesShadersStore[includeFile]) {
  30364. // Substitution
  30365. var includeContent = options.includesShadersStore[includeFile];
  30366. if (match[2]) {
  30367. var splits = match[3].split(",");
  30368. for (var index = 0; index < splits.length; index += 2) {
  30369. var source = new RegExp(splits[index], "g");
  30370. var dest = splits[index + 1];
  30371. includeContent = includeContent.replace(source, dest);
  30372. }
  30373. }
  30374. if (match[4]) {
  30375. var indexString = match[5];
  30376. if (indexString.indexOf("..") !== -1) {
  30377. var indexSplits = indexString.split("..");
  30378. var minIndex = parseInt(indexSplits[0]);
  30379. var maxIndex = parseInt(indexSplits[1]);
  30380. var sourceIncludeContent = includeContent.slice(0);
  30381. includeContent = "";
  30382. if (isNaN(maxIndex)) {
  30383. maxIndex = options.indexParameters[indexSplits[1]];
  30384. }
  30385. for (var i = minIndex; i < maxIndex; i++) {
  30386. if (!options.supportsUniformBuffers) {
  30387. // Ubo replacement
  30388. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  30389. return p1 + "{X}";
  30390. });
  30391. }
  30392. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  30393. }
  30394. }
  30395. else {
  30396. if (!options.supportsUniformBuffers) {
  30397. // Ubo replacement
  30398. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  30399. return p1 + "{X}";
  30400. });
  30401. }
  30402. includeContent = includeContent.replace(/\{X\}/g, indexString);
  30403. }
  30404. }
  30405. // Replace
  30406. returnValue = returnValue.replace(match[0], includeContent);
  30407. }
  30408. else {
  30409. var includeShaderUrl = options.shadersRepository + "ShadersInclude/" + includeFile + ".fx";
  30410. _Misc_fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].LoadFile(includeShaderUrl, function (fileContent) {
  30411. options.includesShadersStore[includeFile] = fileContent;
  30412. _this._ProcessIncludes(returnValue, options, callback);
  30413. });
  30414. return;
  30415. }
  30416. match = regex.exec(sourceCode);
  30417. }
  30418. callback(returnValue);
  30419. };
  30420. return ShaderProcessor;
  30421. }());
  30422. /***/ }),
  30423. /***/ "./Engines/WebGL/webGL2ShaderProcessors.ts":
  30424. /*!*************************************************!*\
  30425. !*** ./Engines/WebGL/webGL2ShaderProcessors.ts ***!
  30426. \*************************************************/
  30427. /*! exports provided: WebGL2ShaderProcessor */
  30428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30429. "use strict";
  30430. __webpack_require__.r(__webpack_exports__);
  30431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebGL2ShaderProcessor", function() { return WebGL2ShaderProcessor; });
  30432. /** @hidden */
  30433. var WebGL2ShaderProcessor = /** @class */ (function () {
  30434. function WebGL2ShaderProcessor() {
  30435. }
  30436. WebGL2ShaderProcessor.prototype.attributeProcessor = function (attribute) {
  30437. return attribute.replace("attribute", "in");
  30438. };
  30439. WebGL2ShaderProcessor.prototype.varyingProcessor = function (varying, isFragment) {
  30440. return varying.replace("varying", isFragment ? "in" : "out");
  30441. };
  30442. WebGL2ShaderProcessor.prototype.postProcessor = function (code, defines, isFragment) {
  30443. var hasDrawBuffersExtension = code.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  30444. // Remove extensions
  30445. var regex = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  30446. code = code.replace(regex, "");
  30447. // Replace instructions
  30448. code = code.replace(/texture2D\s*\(/g, "texture(");
  30449. if (isFragment) {
  30450. code = code.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  30451. code = code.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  30452. code = code.replace(/textureCube\s*\(/g, "texture(");
  30453. code = code.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  30454. code = code.replace(/gl_FragColor/g, "glFragColor");
  30455. code = code.replace(/gl_FragData/g, "glFragData");
  30456. code = code.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  30457. }
  30458. else {
  30459. var hasMultiviewExtension = defines.indexOf("#define MULTIVIEW") !== -1;
  30460. if (hasMultiviewExtension) {
  30461. return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + code;
  30462. }
  30463. }
  30464. return code;
  30465. };
  30466. return WebGL2ShaderProcessor;
  30467. }());
  30468. /***/ }),
  30469. /***/ "./Engines/WebGL/webGLPipelineContext.ts":
  30470. /*!***********************************************!*\
  30471. !*** ./Engines/WebGL/webGLPipelineContext.ts ***!
  30472. \***********************************************/
  30473. /*! exports provided: WebGLPipelineContext */
  30474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30475. "use strict";
  30476. __webpack_require__.r(__webpack_exports__);
  30477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return WebGLPipelineContext; });
  30478. /** @hidden */
  30479. var WebGLPipelineContext = /** @class */ (function () {
  30480. function WebGLPipelineContext() {
  30481. }
  30482. Object.defineProperty(WebGLPipelineContext.prototype, "isAsync", {
  30483. get: function () {
  30484. return this.isParallelCompiled;
  30485. },
  30486. enumerable: true,
  30487. configurable: true
  30488. });
  30489. Object.defineProperty(WebGLPipelineContext.prototype, "isReady", {
  30490. get: function () {
  30491. if (this.program) {
  30492. if (this.isParallelCompiled) {
  30493. return this.engine._isRenderingStateCompiled(this);
  30494. }
  30495. return true;
  30496. }
  30497. return false;
  30498. },
  30499. enumerable: true,
  30500. configurable: true
  30501. });
  30502. WebGLPipelineContext.prototype._handlesSpectorRebuildCallback = function (onCompiled) {
  30503. if (onCompiled && this.program) {
  30504. onCompiled(this.program);
  30505. }
  30506. };
  30507. return WebGLPipelineContext;
  30508. }());
  30509. /***/ }),
  30510. /***/ "./Engines/constants.ts":
  30511. /*!******************************!*\
  30512. !*** ./Engines/constants.ts ***!
  30513. \******************************/
  30514. /*! exports provided: Constants */
  30515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30516. "use strict";
  30517. __webpack_require__.r(__webpack_exports__);
  30518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  30519. /** Defines the cross module used constants to avoid circular dependncies */
  30520. var Constants = /** @class */ (function () {
  30521. function Constants() {
  30522. }
  30523. /** Defines that alpha blending is disabled */
  30524. Constants.ALPHA_DISABLE = 0;
  30525. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30526. Constants.ALPHA_ADD = 1;
  30527. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30528. Constants.ALPHA_COMBINE = 2;
  30529. /** Defines that alpha blending to DEST - SRC * DEST */
  30530. Constants.ALPHA_SUBTRACT = 3;
  30531. /** Defines that alpha blending to SRC * DEST */
  30532. Constants.ALPHA_MULTIPLY = 4;
  30533. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30534. Constants.ALPHA_MAXIMIZED = 5;
  30535. /** Defines that alpha blending to SRC + DEST */
  30536. Constants.ALPHA_ONEONE = 6;
  30537. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30538. Constants.ALPHA_PREMULTIPLIED = 7;
  30539. /**
  30540. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30541. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30542. */
  30543. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  30544. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30545. Constants.ALPHA_INTERPOLATE = 9;
  30546. /**
  30547. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30548. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30549. */
  30550. Constants.ALPHA_SCREENMODE = 10;
  30551. /** Defines that the ressource is not delayed*/
  30552. Constants.DELAYLOADSTATE_NONE = 0;
  30553. /** Defines that the ressource was successfully delay loaded */
  30554. Constants.DELAYLOADSTATE_LOADED = 1;
  30555. /** Defines that the ressource is currently delay loading */
  30556. Constants.DELAYLOADSTATE_LOADING = 2;
  30557. /** Defines that the ressource is delayed and has not started loading */
  30558. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  30559. // Depht or Stencil test Constants.
  30560. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30561. Constants.NEVER = 0x0200;
  30562. /** 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 */
  30563. Constants.ALWAYS = 0x0207;
  30564. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30565. Constants.LESS = 0x0201;
  30566. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30567. Constants.EQUAL = 0x0202;
  30568. /** 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 */
  30569. Constants.LEQUAL = 0x0203;
  30570. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30571. Constants.GREATER = 0x0204;
  30572. /** 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 */
  30573. Constants.GEQUAL = 0x0206;
  30574. /** 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 */
  30575. Constants.NOTEQUAL = 0x0205;
  30576. // Stencil Actions Constants.
  30577. /** Passed to stencilOperation to specify that stencil value must be kept */
  30578. Constants.KEEP = 0x1E00;
  30579. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30580. Constants.REPLACE = 0x1E01;
  30581. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30582. Constants.INCR = 0x1E02;
  30583. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30584. Constants.DECR = 0x1E03;
  30585. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30586. Constants.INVERT = 0x150A;
  30587. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30588. Constants.INCR_WRAP = 0x8507;
  30589. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30590. Constants.DECR_WRAP = 0x8508;
  30591. /** Texture is not repeating outside of 0..1 UVs */
  30592. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  30593. /** Texture is repeating outside of 0..1 UVs */
  30594. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  30595. /** Texture is repeating and mirrored */
  30596. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  30597. /** ALPHA */
  30598. Constants.TEXTUREFORMAT_ALPHA = 0;
  30599. /** LUMINANCE */
  30600. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  30601. /** LUMINANCE_ALPHA */
  30602. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  30603. /** RGB */
  30604. Constants.TEXTUREFORMAT_RGB = 4;
  30605. /** RGBA */
  30606. Constants.TEXTUREFORMAT_RGBA = 5;
  30607. /** RED */
  30608. Constants.TEXTUREFORMAT_RED = 6;
  30609. /** RED (2nd reference) */
  30610. Constants.TEXTUREFORMAT_R = 6;
  30611. /** RG */
  30612. Constants.TEXTUREFORMAT_RG = 7;
  30613. /** RED_INTEGER */
  30614. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  30615. /** RED_INTEGER (2nd reference) */
  30616. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  30617. /** RG_INTEGER */
  30618. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  30619. /** RGB_INTEGER */
  30620. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  30621. /** RGBA_INTEGER */
  30622. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  30623. /** UNSIGNED_BYTE */
  30624. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  30625. /** UNSIGNED_BYTE (2nd reference) */
  30626. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  30627. /** FLOAT */
  30628. Constants.TEXTURETYPE_FLOAT = 1;
  30629. /** HALF_FLOAT */
  30630. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  30631. /** BYTE */
  30632. Constants.TEXTURETYPE_BYTE = 3;
  30633. /** SHORT */
  30634. Constants.TEXTURETYPE_SHORT = 4;
  30635. /** UNSIGNED_SHORT */
  30636. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  30637. /** INT */
  30638. Constants.TEXTURETYPE_INT = 6;
  30639. /** UNSIGNED_INT */
  30640. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  30641. /** UNSIGNED_SHORT_4_4_4_4 */
  30642. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  30643. /** UNSIGNED_SHORT_5_5_5_1 */
  30644. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  30645. /** UNSIGNED_SHORT_5_6_5 */
  30646. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  30647. /** UNSIGNED_INT_2_10_10_10_REV */
  30648. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  30649. /** UNSIGNED_INT_24_8 */
  30650. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  30651. /** UNSIGNED_INT_10F_11F_11F_REV */
  30652. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  30653. /** UNSIGNED_INT_5_9_9_9_REV */
  30654. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  30655. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30656. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  30657. /** nearest is mag = nearest and min = nearest and mip = linear */
  30658. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  30659. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30660. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  30661. /** Trilinear is mag = linear and min = linear and mip = linear */
  30662. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  30663. /** nearest is mag = nearest and min = nearest and mip = linear */
  30664. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  30665. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30666. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  30667. /** Trilinear is mag = linear and min = linear and mip = linear */
  30668. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  30669. /** mag = nearest and min = nearest and mip = nearest */
  30670. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  30671. /** mag = nearest and min = linear and mip = nearest */
  30672. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  30673. /** mag = nearest and min = linear and mip = linear */
  30674. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  30675. /** mag = nearest and min = linear and mip = none */
  30676. Constants.TEXTURE_NEAREST_LINEAR = 7;
  30677. /** mag = nearest and min = nearest and mip = none */
  30678. Constants.TEXTURE_NEAREST_NEAREST = 8;
  30679. /** mag = linear and min = nearest and mip = nearest */
  30680. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  30681. /** mag = linear and min = nearest and mip = linear */
  30682. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  30683. /** mag = linear and min = linear and mip = none */
  30684. Constants.TEXTURE_LINEAR_LINEAR = 11;
  30685. /** mag = linear and min = nearest and mip = none */
  30686. Constants.TEXTURE_LINEAR_NEAREST = 12;
  30687. /** Explicit coordinates mode */
  30688. Constants.TEXTURE_EXPLICIT_MODE = 0;
  30689. /** Spherical coordinates mode */
  30690. Constants.TEXTURE_SPHERICAL_MODE = 1;
  30691. /** Planar coordinates mode */
  30692. Constants.TEXTURE_PLANAR_MODE = 2;
  30693. /** Cubic coordinates mode */
  30694. Constants.TEXTURE_CUBIC_MODE = 3;
  30695. /** Projection coordinates mode */
  30696. Constants.TEXTURE_PROJECTION_MODE = 4;
  30697. /** Skybox coordinates mode */
  30698. Constants.TEXTURE_SKYBOX_MODE = 5;
  30699. /** Inverse Cubic coordinates mode */
  30700. Constants.TEXTURE_INVCUBIC_MODE = 6;
  30701. /** Equirectangular coordinates mode */
  30702. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  30703. /** Equirectangular Fixed coordinates mode */
  30704. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  30705. /** Equirectangular Fixed Mirrored coordinates mode */
  30706. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  30707. // Texture rescaling mode
  30708. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30709. Constants.SCALEMODE_FLOOR = 1;
  30710. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30711. Constants.SCALEMODE_NEAREST = 2;
  30712. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30713. Constants.SCALEMODE_CEILING = 3;
  30714. /**
  30715. * The dirty texture flag value
  30716. */
  30717. Constants.MATERIAL_TextureDirtyFlag = 1;
  30718. /**
  30719. * The dirty light flag value
  30720. */
  30721. Constants.MATERIAL_LightDirtyFlag = 2;
  30722. /**
  30723. * The dirty fresnel flag value
  30724. */
  30725. Constants.MATERIAL_FresnelDirtyFlag = 4;
  30726. /**
  30727. * The dirty attribute flag value
  30728. */
  30729. Constants.MATERIAL_AttributesDirtyFlag = 8;
  30730. /**
  30731. * The dirty misc flag value
  30732. */
  30733. Constants.MATERIAL_MiscDirtyFlag = 16;
  30734. /**
  30735. * The all dirty flag value
  30736. */
  30737. Constants.MATERIAL_AllDirtyFlag = 31;
  30738. /**
  30739. * Returns the triangle fill mode
  30740. */
  30741. Constants.MATERIAL_TriangleFillMode = 0;
  30742. /**
  30743. * Returns the wireframe mode
  30744. */
  30745. Constants.MATERIAL_WireFrameFillMode = 1;
  30746. /**
  30747. * Returns the point fill mode
  30748. */
  30749. Constants.MATERIAL_PointFillMode = 2;
  30750. /**
  30751. * Returns the point list draw mode
  30752. */
  30753. Constants.MATERIAL_PointListDrawMode = 3;
  30754. /**
  30755. * Returns the line list draw mode
  30756. */
  30757. Constants.MATERIAL_LineListDrawMode = 4;
  30758. /**
  30759. * Returns the line loop draw mode
  30760. */
  30761. Constants.MATERIAL_LineLoopDrawMode = 5;
  30762. /**
  30763. * Returns the line strip draw mode
  30764. */
  30765. Constants.MATERIAL_LineStripDrawMode = 6;
  30766. /**
  30767. * Returns the triangle strip draw mode
  30768. */
  30769. Constants.MATERIAL_TriangleStripDrawMode = 7;
  30770. /**
  30771. * Returns the triangle fan draw mode
  30772. */
  30773. Constants.MATERIAL_TriangleFanDrawMode = 8;
  30774. /**
  30775. * Stores the clock-wise side orientation
  30776. */
  30777. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  30778. /**
  30779. * Stores the counter clock-wise side orientation
  30780. */
  30781. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  30782. /**
  30783. * Nothing
  30784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30785. */
  30786. Constants.ACTION_NothingTrigger = 0;
  30787. /**
  30788. * On pick
  30789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30790. */
  30791. Constants.ACTION_OnPickTrigger = 1;
  30792. /**
  30793. * On left pick
  30794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30795. */
  30796. Constants.ACTION_OnLeftPickTrigger = 2;
  30797. /**
  30798. * On right pick
  30799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30800. */
  30801. Constants.ACTION_OnRightPickTrigger = 3;
  30802. /**
  30803. * On center pick
  30804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30805. */
  30806. Constants.ACTION_OnCenterPickTrigger = 4;
  30807. /**
  30808. * On pick down
  30809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30810. */
  30811. Constants.ACTION_OnPickDownTrigger = 5;
  30812. /**
  30813. * On double pick
  30814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30815. */
  30816. Constants.ACTION_OnDoublePickTrigger = 6;
  30817. /**
  30818. * On pick up
  30819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30820. */
  30821. Constants.ACTION_OnPickUpTrigger = 7;
  30822. /**
  30823. * On pick out.
  30824. * This trigger will only be raised if you also declared a OnPickDown
  30825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30826. */
  30827. Constants.ACTION_OnPickOutTrigger = 16;
  30828. /**
  30829. * On long press
  30830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30831. */
  30832. Constants.ACTION_OnLongPressTrigger = 8;
  30833. /**
  30834. * On pointer over
  30835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30836. */
  30837. Constants.ACTION_OnPointerOverTrigger = 9;
  30838. /**
  30839. * On pointer out
  30840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30841. */
  30842. Constants.ACTION_OnPointerOutTrigger = 10;
  30843. /**
  30844. * On every frame
  30845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30846. */
  30847. Constants.ACTION_OnEveryFrameTrigger = 11;
  30848. /**
  30849. * On intersection enter
  30850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30851. */
  30852. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  30853. /**
  30854. * On intersection exit
  30855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30856. */
  30857. Constants.ACTION_OnIntersectionExitTrigger = 13;
  30858. /**
  30859. * On key down
  30860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30861. */
  30862. Constants.ACTION_OnKeyDownTrigger = 14;
  30863. /**
  30864. * On key up
  30865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  30866. */
  30867. Constants.ACTION_OnKeyUpTrigger = 15;
  30868. /**
  30869. * Billboard mode will only apply to Y axis
  30870. */
  30871. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  30872. /**
  30873. * Billboard mode will apply to all axes
  30874. */
  30875. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  30876. /**
  30877. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  30878. */
  30879. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  30880. /**
  30881. * Gets or sets base Assets URL
  30882. */
  30883. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  30884. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30885. * Test order :
  30886. * Is the bounding sphere outside the frustum ?
  30887. * If not, are the bounding box vertices outside the frustum ?
  30888. * It not, then the cullable object is in the frustum.
  30889. */
  30890. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  30891. /** Culling strategy : Bounding Sphere Only.
  30892. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30893. * It's also less accurate than the standard because some not visible objects can still be selected.
  30894. * Test : is the bounding sphere outside the frustum ?
  30895. * If not, then the cullable object is in the frustum.
  30896. */
  30897. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  30898. /** Culling strategy : Optimistic Inclusion.
  30899. * This in an inclusion test first, then the standard exclusion test.
  30900. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30901. * 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.
  30902. * Anyway, it's as accurate as the standard strategy.
  30903. * Test :
  30904. * Is the cullable object bounding sphere center in the frustum ?
  30905. * If not, apply the default culling strategy.
  30906. */
  30907. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  30908. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30909. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30910. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30911. * 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.
  30912. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30913. * Test :
  30914. * Is the cullable object bounding sphere center in the frustum ?
  30915. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30916. */
  30917. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  30918. /**
  30919. * No logging while loading
  30920. */
  30921. Constants.SCENELOADER_NO_LOGGING = 0;
  30922. /**
  30923. * Minimal logging while loading
  30924. */
  30925. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  30926. /**
  30927. * Summary logging while loading
  30928. */
  30929. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  30930. /**
  30931. * Detailled logging while loading
  30932. */
  30933. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  30934. return Constants;
  30935. }());
  30936. /***/ }),
  30937. /***/ "./Engines/engine.ts":
  30938. /*!***************************!*\
  30939. !*** ./Engines/engine.ts ***!
  30940. \***************************/
  30941. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  30942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30943. "use strict";
  30944. __webpack_require__.r(__webpack_exports__);
  30945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  30946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  30947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  30948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  30949. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  30950. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  30951. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  30952. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  30953. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  30954. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  30955. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  30956. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  30957. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  30958. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  30959. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  30960. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  30961. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  30962. /* harmony import */ var _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./WebGL/webGLPipelineContext */ "./Engines/WebGL/webGLPipelineContext.ts");
  30963. /* harmony import */ var _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Meshes/WebGL/webGLDataBuffer */ "./Meshes/WebGL/webGLDataBuffer.ts");
  30964. /* harmony import */ var _WebGL_webGL2ShaderProcessors__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./WebGL/webGL2ShaderProcessors */ "./Engines/WebGL/webGL2ShaderProcessors.ts");
  30965. /* harmony import */ var _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/perfCounter */ "./Misc/perfCounter.ts");
  30966. /* harmony import */ var _Misc_fileTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/fileTools */ "./Misc/fileTools.ts");
  30967. /**
  30968. * Keeps track of all the buffer info used in engine.
  30969. */
  30970. var BufferPointer = /** @class */ (function () {
  30971. function BufferPointer() {
  30972. }
  30973. return BufferPointer;
  30974. }());
  30975. /**
  30976. * Interface for attribute information associated with buffer instanciation
  30977. */
  30978. var InstancingAttributeInfo = /** @class */ (function () {
  30979. function InstancingAttributeInfo() {
  30980. }
  30981. return InstancingAttributeInfo;
  30982. }());
  30983. /**
  30984. * Define options used to create a depth texture
  30985. */
  30986. var DepthTextureCreationOptions = /** @class */ (function () {
  30987. function DepthTextureCreationOptions() {
  30988. }
  30989. return DepthTextureCreationOptions;
  30990. }());
  30991. /**
  30992. * Class used to describe the capabilities of the engine relatively to the current browser
  30993. */
  30994. var EngineCapabilities = /** @class */ (function () {
  30995. function EngineCapabilities() {
  30996. }
  30997. return EngineCapabilities;
  30998. }());
  30999. /**
  31000. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31001. */
  31002. var Engine = /** @class */ (function () {
  31003. /**
  31004. * Creates a new engine
  31005. * @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
  31006. * @param antialias defines enable antialiasing (default: false)
  31007. * @param options defines further options to be sent to the getContext() function
  31008. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31009. */
  31010. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  31011. var _this = this;
  31012. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  31013. /**
  31014. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31015. */
  31016. this.forcePOTTextures = false;
  31017. /**
  31018. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31019. */
  31020. this.isFullscreen = false;
  31021. /**
  31022. * Gets a boolean indicating if the pointer is currently locked
  31023. */
  31024. this.isPointerLock = false;
  31025. /**
  31026. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31027. */
  31028. this.cullBackFaces = true;
  31029. /**
  31030. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31031. */
  31032. this.renderEvenInBackground = true;
  31033. /**
  31034. * Gets or sets a boolean indicating that cache can be kept between frames
  31035. */
  31036. this.preventCacheWipeBetweenFrames = false;
  31037. /**
  31038. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31039. **/
  31040. this.enableOfflineSupport = false;
  31041. /**
  31042. * 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)
  31043. **/
  31044. this.disableManifestCheck = false;
  31045. /**
  31046. * Gets the list of created scenes
  31047. */
  31048. this.scenes = new Array();
  31049. /**
  31050. * Event raised when a new scene is created
  31051. */
  31052. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31053. /**
  31054. * Gets the list of created postprocesses
  31055. */
  31056. this.postProcesses = new Array();
  31057. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31058. this.validateShaderPrograms = false;
  31059. // Observables
  31060. /**
  31061. * Observable event triggered each time the rendering canvas is resized
  31062. */
  31063. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31064. /**
  31065. * Observable event triggered each time the canvas loses focus
  31066. */
  31067. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31068. /**
  31069. * Observable event triggered each time the canvas gains focus
  31070. */
  31071. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31072. /**
  31073. * Observable event triggered each time the canvas receives pointerout event
  31074. */
  31075. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31076. /**
  31077. * Observable event triggered before each texture is initialized
  31078. */
  31079. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31080. // Uniform buffers list
  31081. /**
  31082. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31083. */
  31084. this.disableUniformBuffers = false;
  31085. /** @hidden */
  31086. this._uniformBuffers = new Array();
  31087. // Observables
  31088. /**
  31089. * Observable raised when the engine begins a new frame
  31090. */
  31091. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31092. /**
  31093. * If set, will be used to request the next animation frame for the render loop
  31094. */
  31095. this.customAnimationFrameRequester = null;
  31096. /**
  31097. * Observable raised when the engine ends the current frame
  31098. */
  31099. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31100. /**
  31101. * Observable raised when the engine is about to compile a shader
  31102. */
  31103. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31104. /**
  31105. * Observable raised when the engine has jsut compiled a shader
  31106. */
  31107. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31108. this._windowIsBackground = false;
  31109. this._webGLVersion = 1.0;
  31110. this._highPrecisionShadersAllowed = true;
  31111. /** @hidden */
  31112. this._badOS = false;
  31113. /** @hidden */
  31114. this._badDesktopOS = false;
  31115. this._colorWrite = true;
  31116. /** @hidden */
  31117. this._drawCalls = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_16__["PerfCounter"]();
  31118. this._renderingQueueLaunched = false;
  31119. this._activeRenderLoops = new Array();
  31120. // Deterministic lockstepMaxSteps
  31121. this._deterministicLockstep = false;
  31122. this._lockstepMaxSteps = 4;
  31123. // Lost context
  31124. /**
  31125. * Observable signaled when a context lost event is raised
  31126. */
  31127. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31128. /**
  31129. * Observable signaled when a context restored event is raised
  31130. */
  31131. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  31132. this._contextWasLost = false;
  31133. /** @hidden */
  31134. this._doNotHandleContextLost = false;
  31135. // FPS
  31136. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  31137. this._fps = 60;
  31138. this._deltaTime = 0;
  31139. /**
  31140. * Turn this value on if you want to pause FPS computation when in background
  31141. */
  31142. this.disablePerformanceMonitorInBackground = false;
  31143. /**
  31144. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31145. */
  31146. this.disableVertexArrayObjects = false;
  31147. // States
  31148. /** @hidden */
  31149. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_6__["_DepthCullingState"]();
  31150. /** @hidden */
  31151. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_6__["_StencilState"]();
  31152. /** @hidden */
  31153. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_6__["_AlphaState"]();
  31154. /** @hidden */
  31155. this._alphaMode = Engine.ALPHA_DISABLE;
  31156. // Cache
  31157. /** @hidden */
  31158. this._internalTexturesCache = new Array();
  31159. /** @hidden */
  31160. this._activeChannel = 0;
  31161. this._currentTextureChannel = -1;
  31162. /** @hidden */
  31163. this._boundTexturesCache = {};
  31164. this._compiledEffects = {};
  31165. this._vertexAttribArraysEnabled = [];
  31166. this._uintIndicesCurrentlySet = false;
  31167. this._currentBoundBuffer = new Array();
  31168. /** @hidden */
  31169. this._currentFramebuffer = null;
  31170. this._currentBufferPointers = new Array();
  31171. this._currentInstanceLocations = new Array();
  31172. this._currentInstanceBuffers = new Array();
  31173. this._vaoRecordInProgress = false;
  31174. this._mustWipeVertexAttributes = false;
  31175. this._nextFreeTextureSlots = new Array();
  31176. this._maxSimultaneousTextures = 0;
  31177. this._activeRequests = new Array();
  31178. // Hardware supported Compressed Textures
  31179. this._texturesSupported = new Array();
  31180. /**
  31181. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31182. */
  31183. this.premultipliedAlpha = true;
  31184. this._viewportCached = { x: 0, y: 0, z: 0, w: 0 };
  31185. this._unpackFlipYCached = null;
  31186. /**
  31187. * In case you are sharing the context with other applications, it might
  31188. * be interested to not cache the unpack flip y state to ensure a consistent
  31189. * value would be set.
  31190. */
  31191. this.enableUnpackFlipYCached = true;
  31192. this._boundUniforms = {};
  31193. var canvas = null;
  31194. Engine.Instances.push(this);
  31195. if (!canvasOrContext) {
  31196. return;
  31197. }
  31198. options = options || {};
  31199. if (canvasOrContext.getContext) {
  31200. canvas = canvasOrContext;
  31201. this._renderingCanvas = canvas;
  31202. if (antialias != null) {
  31203. options.antialias = antialias;
  31204. }
  31205. if (options.deterministicLockstep === undefined) {
  31206. options.deterministicLockstep = false;
  31207. }
  31208. if (options.lockstepMaxSteps === undefined) {
  31209. options.lockstepMaxSteps = 4;
  31210. }
  31211. if (options.preserveDrawingBuffer === undefined) {
  31212. options.preserveDrawingBuffer = false;
  31213. }
  31214. if (options.audioEngine === undefined) {
  31215. options.audioEngine = true;
  31216. }
  31217. if (options.stencil === undefined) {
  31218. options.stencil = true;
  31219. }
  31220. if (options.premultipliedAlpha === false) {
  31221. this.premultipliedAlpha = false;
  31222. }
  31223. this._deterministicLockstep = options.deterministicLockstep;
  31224. this._lockstepMaxSteps = options.lockstepMaxSteps;
  31225. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  31226. // Exceptions
  31227. if (navigator && navigator.userAgent) {
  31228. var ua = navigator.userAgent;
  31229. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  31230. var exception = _a[_i];
  31231. var key = exception.key;
  31232. var targets = exception.targets;
  31233. var check = new RegExp(key);
  31234. if (check.test(ua)) {
  31235. if (exception.capture && exception.captureConstraint) {
  31236. var capture = exception.capture;
  31237. var constraint = exception.captureConstraint;
  31238. var regex = new RegExp(capture);
  31239. var matches = regex.exec(ua);
  31240. if (matches && matches.length > 0) {
  31241. var capturedValue = parseInt(matches[matches.length - 1]);
  31242. if (capturedValue >= constraint) {
  31243. continue;
  31244. }
  31245. }
  31246. }
  31247. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  31248. var target = targets_1[_b];
  31249. switch (target) {
  31250. case "uniformBuffer":
  31251. this.disableUniformBuffers = true;
  31252. break;
  31253. case "vao":
  31254. this.disableVertexArrayObjects = true;
  31255. break;
  31256. }
  31257. }
  31258. }
  31259. }
  31260. }
  31261. // Context lost
  31262. if (!this._doNotHandleContextLost) {
  31263. this._onContextLost = function (evt) {
  31264. evt.preventDefault();
  31265. _this._contextWasLost = true;
  31266. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("WebGL context lost.");
  31267. _this.onContextLostObservable.notifyObservers(_this);
  31268. };
  31269. this._onContextRestored = function () {
  31270. // Adding a timeout to avoid race condition at browser level
  31271. setTimeout(function () {
  31272. // Rebuild gl context
  31273. _this._initGLContext();
  31274. // Rebuild effects
  31275. _this._rebuildEffects();
  31276. // Rebuild textures
  31277. _this._rebuildInternalTextures();
  31278. // Rebuild buffers
  31279. _this._rebuildBuffers();
  31280. // Cache
  31281. _this.wipeCaches(true);
  31282. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("WebGL context successfully restored.");
  31283. _this.onContextRestoredObservable.notifyObservers(_this);
  31284. _this._contextWasLost = false;
  31285. }, 0);
  31286. };
  31287. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  31288. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  31289. options.powerPreference = "high-performance";
  31290. }
  31291. // GL
  31292. if (!options.disableWebGL2Support) {
  31293. try {
  31294. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  31295. if (this._gl) {
  31296. this._webGLVersion = 2.0;
  31297. // Prevent weird browsers to lie :-)
  31298. if (!this._gl.deleteQuery) {
  31299. this._webGLVersion = 1.0;
  31300. }
  31301. }
  31302. }
  31303. catch (e) {
  31304. // Do nothing
  31305. }
  31306. }
  31307. if (!this._gl) {
  31308. if (!canvas) {
  31309. throw new Error("The provided canvas is null or undefined.");
  31310. }
  31311. try {
  31312. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  31313. }
  31314. catch (e) {
  31315. throw new Error("WebGL not supported");
  31316. }
  31317. }
  31318. if (!this._gl) {
  31319. throw new Error("WebGL not supported");
  31320. }
  31321. // Ensures a consistent color space unpacking of textures cross browser.
  31322. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  31323. this._onCanvasFocus = function () {
  31324. _this.onCanvasFocusObservable.notifyObservers(_this);
  31325. };
  31326. this._onCanvasBlur = function () {
  31327. _this.onCanvasBlurObservable.notifyObservers(_this);
  31328. };
  31329. canvas.addEventListener("focus", this._onCanvasFocus);
  31330. canvas.addEventListener("blur", this._onCanvasBlur);
  31331. this._onBlur = function () {
  31332. if (_this.disablePerformanceMonitorInBackground) {
  31333. _this._performanceMonitor.disable();
  31334. }
  31335. _this._windowIsBackground = true;
  31336. };
  31337. this._onFocus = function () {
  31338. if (_this.disablePerformanceMonitorInBackground) {
  31339. _this._performanceMonitor.enable();
  31340. }
  31341. _this._windowIsBackground = false;
  31342. };
  31343. this._onCanvasPointerOut = function (ev) {
  31344. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  31345. };
  31346. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__["DomManagement"].IsWindowObjectExist()) {
  31347. window.addEventListener("blur", this._onBlur);
  31348. window.addEventListener("focus", this._onFocus);
  31349. }
  31350. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  31351. if (!options.doNotHandleTouchAction) {
  31352. this._disableTouchAction();
  31353. }
  31354. }
  31355. else {
  31356. this._gl = canvasOrContext;
  31357. this._renderingCanvas = this._gl.canvas;
  31358. if (this._gl.renderbufferStorageMultisample) {
  31359. this._webGLVersion = 2.0;
  31360. }
  31361. var attributes = this._gl.getContextAttributes();
  31362. if (attributes) {
  31363. options.stencil = attributes.stencil;
  31364. }
  31365. }
  31366. if (options.useHighPrecisionFloats !== undefined) {
  31367. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  31368. }
  31369. // Viewport
  31370. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  31371. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  31372. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  31373. this.resize();
  31374. this._isStencilEnable = options.stencil ? true : false;
  31375. this._initGLContext();
  31376. if (canvas) {
  31377. var anyDoc_1 = document;
  31378. // Fullscreen
  31379. this._onFullscreenChange = function () {
  31380. if (anyDoc_1.fullscreen !== undefined) {
  31381. _this.isFullscreen = anyDoc_1.fullscreen;
  31382. }
  31383. else if (anyDoc_1.mozFullScreen !== undefined) {
  31384. _this.isFullscreen = anyDoc_1.mozFullScreen;
  31385. }
  31386. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  31387. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  31388. }
  31389. else if (anyDoc_1.msIsFullScreen !== undefined) {
  31390. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  31391. }
  31392. // Pointer lock
  31393. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  31394. Engine._RequestPointerlock(canvas);
  31395. }
  31396. };
  31397. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  31398. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  31399. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  31400. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  31401. // Pointer lock
  31402. this._onPointerLockChange = function () {
  31403. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  31404. anyDoc_1.webkitPointerLockElement === canvas ||
  31405. anyDoc_1.msPointerLockElement === canvas ||
  31406. anyDoc_1.pointerLockElement === canvas);
  31407. };
  31408. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  31409. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  31410. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  31411. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  31412. this._connectVREvents(canvas, anyDoc_1);
  31413. }
  31414. // Create Audio Engine if needed.
  31415. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  31416. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  31417. }
  31418. // Prepare buffer pointers
  31419. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  31420. this._currentBufferPointers[i] = new BufferPointer();
  31421. }
  31422. // Load WebVR Devices
  31423. this._prepareVRComponent();
  31424. if (options.autoEnableWebVR) {
  31425. this.initWebVR();
  31426. }
  31427. // Shader processor
  31428. if (this.webGLVersion > 1) {
  31429. this._shaderProcessor = new _WebGL_webGL2ShaderProcessors__WEBPACK_IMPORTED_MODULE_15__["WebGL2ShaderProcessor"]();
  31430. }
  31431. // Detect if we are running on a faulty buggy OS.
  31432. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  31433. // Detect if we are running on a faulty buggy desktop OS.
  31434. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  31435. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  31436. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  31437. }
  31438. Object.defineProperty(Engine, "Instances", {
  31439. /** Gets the list of created engines */
  31440. get: function () {
  31441. return _engineStore__WEBPACK_IMPORTED_MODULE_10__["EngineStore"].Instances;
  31442. },
  31443. enumerable: true,
  31444. configurable: true
  31445. });
  31446. Object.defineProperty(Engine, "LastCreatedEngine", {
  31447. /**
  31448. * Gets the latest created engine
  31449. */
  31450. get: function () {
  31451. return _engineStore__WEBPACK_IMPORTED_MODULE_10__["EngineStore"].LastCreatedEngine;
  31452. },
  31453. enumerable: true,
  31454. configurable: true
  31455. });
  31456. Object.defineProperty(Engine, "LastCreatedScene", {
  31457. /**
  31458. * Gets the latest created scene
  31459. */
  31460. get: function () {
  31461. return _engineStore__WEBPACK_IMPORTED_MODULE_10__["EngineStore"].LastCreatedScene;
  31462. },
  31463. enumerable: true,
  31464. configurable: true
  31465. });
  31466. /**
  31467. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31468. * @param flag defines which part of the materials must be marked as dirty
  31469. * @param predicate defines a predicate used to filter which materials should be affected
  31470. */
  31471. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  31472. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  31473. var engine = Engine.Instances[engineIndex];
  31474. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  31475. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  31476. }
  31477. }
  31478. };
  31479. Object.defineProperty(Engine, "NpmPackage", {
  31480. /**
  31481. * Returns the current npm package of the sdk
  31482. */
  31483. // Not mixed with Version for tooling purpose.
  31484. get: function () {
  31485. return "babylonjs@4.1.0-alpha.10";
  31486. },
  31487. enumerable: true,
  31488. configurable: true
  31489. });
  31490. Object.defineProperty(Engine, "Version", {
  31491. /**
  31492. * Returns the current version of the framework
  31493. */
  31494. get: function () {
  31495. return "4.1.0-alpha.10";
  31496. },
  31497. enumerable: true,
  31498. configurable: true
  31499. });
  31500. Object.defineProperty(Engine.prototype, "description", {
  31501. /**
  31502. * Returns a string describing the current engine
  31503. */
  31504. get: function () {
  31505. var description = "WebGL" + this.webGLVersion;
  31506. if (this._caps.parallelShaderCompile) {
  31507. description += " - Parallel shader compilation";
  31508. }
  31509. return description;
  31510. },
  31511. enumerable: true,
  31512. configurable: true
  31513. });
  31514. Object.defineProperty(Engine, "ShadersRepository", {
  31515. /**
  31516. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31517. */
  31518. get: function () {
  31519. return _Materials_effect__WEBPACK_IMPORTED_MODULE_4__["Effect"].ShadersRepository;
  31520. },
  31521. set: function (value) {
  31522. _Materials_effect__WEBPACK_IMPORTED_MODULE_4__["Effect"].ShadersRepository = value;
  31523. },
  31524. enumerable: true,
  31525. configurable: true
  31526. });
  31527. /**
  31528. * Method called to create the default loading screen.
  31529. * This can be overriden in your own app.
  31530. * @param canvas The rendering canvas element
  31531. * @returns The loading screen
  31532. */
  31533. Engine.DefaultLoadingScreenFactory = function (canvas) {
  31534. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("LoadingScreen");
  31535. };
  31536. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  31537. /**
  31538. * Gets a boolean indicating that the engine supports uniform buffers
  31539. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31540. */
  31541. get: function () {
  31542. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  31543. },
  31544. enumerable: true,
  31545. configurable: true
  31546. });
  31547. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  31548. /** @hidden */
  31549. get: function () {
  31550. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  31551. },
  31552. enumerable: true,
  31553. configurable: true
  31554. });
  31555. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  31556. /**
  31557. * Gets a boolean indicating that only power of 2 textures are supported
  31558. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31559. */
  31560. get: function () {
  31561. return this._webGLVersion < 2 || this.forcePOTTextures;
  31562. },
  31563. enumerable: true,
  31564. configurable: true
  31565. });
  31566. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  31567. /**
  31568. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31570. */
  31571. get: function () {
  31572. return this._doNotHandleContextLost;
  31573. },
  31574. set: function (value) {
  31575. this._doNotHandleContextLost = value;
  31576. },
  31577. enumerable: true,
  31578. configurable: true
  31579. });
  31580. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  31581. /**
  31582. * Gets the performance monitor attached to this engine
  31583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31584. */
  31585. get: function () {
  31586. return this._performanceMonitor;
  31587. },
  31588. enumerable: true,
  31589. configurable: true
  31590. });
  31591. Object.defineProperty(Engine.prototype, "texturesSupported", {
  31592. /**
  31593. * Gets the list of texture formats supported
  31594. */
  31595. get: function () {
  31596. return this._texturesSupported;
  31597. },
  31598. enumerable: true,
  31599. configurable: true
  31600. });
  31601. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  31602. /**
  31603. * Gets the list of texture formats in use
  31604. */
  31605. get: function () {
  31606. return this._textureFormatInUse;
  31607. },
  31608. enumerable: true,
  31609. configurable: true
  31610. });
  31611. Object.defineProperty(Engine.prototype, "currentViewport", {
  31612. /**
  31613. * Gets the current viewport
  31614. */
  31615. get: function () {
  31616. return this._cachedViewport;
  31617. },
  31618. enumerable: true,
  31619. configurable: true
  31620. });
  31621. Object.defineProperty(Engine.prototype, "emptyTexture", {
  31622. /**
  31623. * Gets the default empty texture
  31624. */
  31625. get: function () {
  31626. if (!this._emptyTexture) {
  31627. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  31628. }
  31629. return this._emptyTexture;
  31630. },
  31631. enumerable: true,
  31632. configurable: true
  31633. });
  31634. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  31635. /**
  31636. * Gets the default empty 3D texture
  31637. */
  31638. get: function () {
  31639. if (!this._emptyTexture3D) {
  31640. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  31641. }
  31642. return this._emptyTexture3D;
  31643. },
  31644. enumerable: true,
  31645. configurable: true
  31646. });
  31647. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  31648. /**
  31649. * Gets the default empty cube texture
  31650. */
  31651. get: function () {
  31652. if (!this._emptyCubeTexture) {
  31653. var faceData = new Uint8Array(4);
  31654. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  31655. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  31656. }
  31657. return this._emptyCubeTexture;
  31658. },
  31659. enumerable: true,
  31660. configurable: true
  31661. });
  31662. // WebVR
  31663. /**
  31664. * Initializes a webVR display and starts listening to display change events
  31665. * The onVRDisplayChangedObservable will be notified upon these changes
  31666. * @returns The onVRDisplayChangedObservable
  31667. */
  31668. Engine.prototype.initWebVR = function () {
  31669. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("WebVRCamera");
  31670. };
  31671. /** @hidden */
  31672. Engine.prototype._prepareVRComponent = function () {
  31673. // Do nothing as the engine side effect will overload it
  31674. };
  31675. /** @hidden */
  31676. Engine.prototype._connectVREvents = function (canvas, document) {
  31677. // Do nothing as the engine side effect will overload it
  31678. };
  31679. /** @hidden */
  31680. Engine.prototype._submitVRFrame = function () {
  31681. // Do nothing as the engine side effect will overload it
  31682. };
  31683. /**
  31684. * Call this function to leave webVR mode
  31685. * Will do nothing if webVR is not supported or if there is no webVR device
  31686. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31687. */
  31688. Engine.prototype.disableVR = function () {
  31689. // Do nothing as the engine side effect will overload it
  31690. };
  31691. /**
  31692. * Gets a boolean indicating that the system is in VR mode and is presenting
  31693. * @returns true if VR mode is engaged
  31694. */
  31695. Engine.prototype.isVRPresenting = function () {
  31696. return false;
  31697. };
  31698. /** @hidden */
  31699. Engine.prototype._requestVRFrame = function () {
  31700. // Do nothing as the engine side effect will overload it
  31701. };
  31702. Engine.prototype._disableTouchAction = function () {
  31703. if (!this._renderingCanvas) {
  31704. return;
  31705. }
  31706. this._renderingCanvas.setAttribute("touch-action", "none");
  31707. this._renderingCanvas.style.touchAction = "none";
  31708. this._renderingCanvas.style.msTouchAction = "none";
  31709. };
  31710. Engine.prototype._rebuildInternalTextures = function () {
  31711. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  31712. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  31713. var internalTexture = currentState_1[_i];
  31714. internalTexture._rebuild();
  31715. }
  31716. };
  31717. Engine.prototype._rebuildEffects = function () {
  31718. for (var key in this._compiledEffects) {
  31719. var effect = this._compiledEffects[key];
  31720. effect._prepareEffect();
  31721. }
  31722. _Materials_effect__WEBPACK_IMPORTED_MODULE_4__["Effect"].ResetCache();
  31723. };
  31724. /**
  31725. * Gets a boolean indicating if all created effects are ready
  31726. * @returns true if all effects are ready
  31727. */
  31728. Engine.prototype.areAllEffectsReady = function () {
  31729. for (var key in this._compiledEffects) {
  31730. var effect = this._compiledEffects[key];
  31731. if (!effect.isReady()) {
  31732. return false;
  31733. }
  31734. }
  31735. return true;
  31736. };
  31737. Engine.prototype._rebuildBuffers = function () {
  31738. // Index / Vertex
  31739. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  31740. var scene = _a[_i];
  31741. scene.resetCachedMaterial();
  31742. scene._rebuildGeometries();
  31743. scene._rebuildTextures();
  31744. }
  31745. // Uniforms
  31746. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  31747. var uniformBuffer = _c[_b];
  31748. uniformBuffer._rebuild();
  31749. }
  31750. };
  31751. Engine.prototype._initGLContext = function () {
  31752. // Caps
  31753. this._caps = new EngineCapabilities();
  31754. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  31755. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  31756. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  31757. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  31758. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  31759. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  31760. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  31761. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  31762. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  31763. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  31764. // Infos
  31765. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  31766. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  31767. if (rendererInfo != null) {
  31768. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  31769. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  31770. }
  31771. if (!this._glVendor) {
  31772. this._glVendor = "Unknown vendor";
  31773. }
  31774. if (!this._glRenderer) {
  31775. this._glRenderer = "Unknown renderer";
  31776. }
  31777. // Constants
  31778. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  31779. if (this._gl.RGBA16F !== 0x881A) {
  31780. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  31781. }
  31782. if (this._gl.RGBA32F !== 0x8814) {
  31783. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  31784. }
  31785. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  31786. this._gl.DEPTH24_STENCIL8 = 35056;
  31787. }
  31788. // Extensions
  31789. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  31790. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  31791. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  31792. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  31793. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  31794. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  31795. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  31796. 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');
  31797. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  31798. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  31799. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  31800. this._caps.highPrecisionShaderSupported = false;
  31801. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  31802. if (this._caps.timerQuery) {
  31803. if (this._webGLVersion === 1) {
  31804. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  31805. }
  31806. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  31807. }
  31808. // Checks if some of the format renders first to allow the use of webgl inspector.
  31809. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  31810. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  31811. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  31812. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  31813. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  31814. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  31815. if (this._webGLVersion > 1) {
  31816. this._gl.HALF_FLOAT_OES = 0x140B;
  31817. }
  31818. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  31819. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  31820. this._caps.multiview = this._gl.getExtension('OVR_multiview2');
  31821. // Draw buffers
  31822. if (this._webGLVersion > 1) {
  31823. this._caps.drawBuffersExtension = true;
  31824. }
  31825. else {
  31826. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  31827. if (drawBuffersExtension !== null) {
  31828. this._caps.drawBuffersExtension = true;
  31829. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  31830. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  31831. for (var i = 0; i < 16; i++) {
  31832. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  31833. }
  31834. }
  31835. else {
  31836. this._caps.drawBuffersExtension = false;
  31837. }
  31838. }
  31839. // Shader compiler threads
  31840. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  31841. // Depth Texture
  31842. if (this._webGLVersion > 1) {
  31843. this._caps.depthTextureExtension = true;
  31844. }
  31845. else {
  31846. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  31847. if (depthTextureExtension != null) {
  31848. this._caps.depthTextureExtension = true;
  31849. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  31850. }
  31851. }
  31852. // Vertex array object
  31853. if (this.disableVertexArrayObjects) {
  31854. this._caps.vertexArrayObject = false;
  31855. }
  31856. else if (this._webGLVersion > 1) {
  31857. this._caps.vertexArrayObject = true;
  31858. }
  31859. else {
  31860. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  31861. if (vertexArrayObjectExtension != null) {
  31862. this._caps.vertexArrayObject = true;
  31863. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  31864. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  31865. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  31866. }
  31867. else {
  31868. this._caps.vertexArrayObject = false;
  31869. }
  31870. }
  31871. // Instances count
  31872. if (this._webGLVersion > 1) {
  31873. this._caps.instancedArrays = true;
  31874. }
  31875. else {
  31876. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  31877. if (instanceExtension != null) {
  31878. this._caps.instancedArrays = true;
  31879. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  31880. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  31881. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  31882. }
  31883. else {
  31884. this._caps.instancedArrays = false;
  31885. }
  31886. }
  31887. // Intelligently add supported compressed formats in order to check for.
  31888. // Check for ASTC support first as it is most powerful and to be very cross platform.
  31889. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  31890. // Likely no hardware which supports both PVR & DXT, so order matters little.
  31891. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  31892. if (this._caps.astc) {
  31893. this.texturesSupported.push('-astc.ktx');
  31894. }
  31895. if (this._caps.s3tc) {
  31896. this.texturesSupported.push('-dxt.ktx');
  31897. }
  31898. if (this._caps.pvrtc) {
  31899. this.texturesSupported.push('-pvrtc.ktx');
  31900. }
  31901. if (this._caps.etc2) {
  31902. this.texturesSupported.push('-etc2.ktx');
  31903. }
  31904. if (this._caps.etc1) {
  31905. this.texturesSupported.push('-etc1.ktx');
  31906. }
  31907. if (this._gl.getShaderPrecisionFormat) {
  31908. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  31909. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  31910. if (vertex_highp && fragment_highp) {
  31911. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  31912. }
  31913. }
  31914. // Depth buffer
  31915. this.setDepthBuffer(true);
  31916. this.setDepthFunctionToLessOrEqual();
  31917. this.setDepthWrite(true);
  31918. // Texture maps
  31919. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  31920. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  31921. this._nextFreeTextureSlots.push(slot);
  31922. }
  31923. };
  31924. Object.defineProperty(Engine.prototype, "webGLVersion", {
  31925. /**
  31926. * Gets version of the current webGL context
  31927. */
  31928. get: function () {
  31929. return this._webGLVersion;
  31930. },
  31931. enumerable: true,
  31932. configurable: true
  31933. });
  31934. /**
  31935. * Gets a string idenfifying the name of the class
  31936. * @returns "Engine" string
  31937. */
  31938. Engine.prototype.getClassName = function () {
  31939. return "Engine";
  31940. };
  31941. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  31942. /**
  31943. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31944. */
  31945. get: function () {
  31946. return this._isStencilEnable;
  31947. },
  31948. enumerable: true,
  31949. configurable: true
  31950. });
  31951. /** @hidden */
  31952. Engine.prototype._prepareWorkingCanvas = function () {
  31953. if (this._workingCanvas) {
  31954. return;
  31955. }
  31956. this._workingCanvas = document.createElement("canvas");
  31957. var context = this._workingCanvas.getContext("2d");
  31958. if (context) {
  31959. this._workingContext = context;
  31960. }
  31961. };
  31962. /**
  31963. * Reset the texture cache to empty state
  31964. */
  31965. Engine.prototype.resetTextureCache = function () {
  31966. for (var key in this._boundTexturesCache) {
  31967. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  31968. continue;
  31969. }
  31970. this._boundTexturesCache[key] = null;
  31971. }
  31972. this._currentTextureChannel = -1;
  31973. };
  31974. /**
  31975. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31977. * @returns true if engine is in deterministic lock step mode
  31978. */
  31979. Engine.prototype.isDeterministicLockStep = function () {
  31980. return this._deterministicLockstep;
  31981. };
  31982. /**
  31983. * Gets the max steps when engine is running in deterministic lock step
  31984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31985. * @returns the max steps
  31986. */
  31987. Engine.prototype.getLockstepMaxSteps = function () {
  31988. return this._lockstepMaxSteps;
  31989. };
  31990. /**
  31991. * Gets an object containing information about the current webGL context
  31992. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31993. */
  31994. Engine.prototype.getGlInfo = function () {
  31995. return {
  31996. vendor: this._glVendor,
  31997. renderer: this._glRenderer,
  31998. version: this._glVersion
  31999. };
  32000. };
  32001. /**
  32002. * Gets current aspect ratio
  32003. * @param viewportOwner defines the camera to use to get the aspect ratio
  32004. * @param useScreen defines if screen size must be used (or the current render target if any)
  32005. * @returns a number defining the aspect ratio
  32006. */
  32007. Engine.prototype.getAspectRatio = function (viewportOwner, useScreen) {
  32008. if (useScreen === void 0) { useScreen = false; }
  32009. var viewport = viewportOwner.viewport;
  32010. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  32011. };
  32012. /**
  32013. * Gets current screen aspect ratio
  32014. * @returns a number defining the aspect ratio
  32015. */
  32016. Engine.prototype.getScreenAspectRatio = function () {
  32017. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  32018. };
  32019. /**
  32020. * Gets the current render width
  32021. * @param useScreen defines if screen size must be used (or the current render target if any)
  32022. * @returns a number defining the current render width
  32023. */
  32024. Engine.prototype.getRenderWidth = function (useScreen) {
  32025. if (useScreen === void 0) { useScreen = false; }
  32026. if (!useScreen && this._currentRenderTarget) {
  32027. return this._currentRenderTarget.width;
  32028. }
  32029. return this._gl.drawingBufferWidth;
  32030. };
  32031. /**
  32032. * Gets the current render height
  32033. * @param useScreen defines if screen size must be used (or the current render target if any)
  32034. * @returns a number defining the current render height
  32035. */
  32036. Engine.prototype.getRenderHeight = function (useScreen) {
  32037. if (useScreen === void 0) { useScreen = false; }
  32038. if (!useScreen && this._currentRenderTarget) {
  32039. return this._currentRenderTarget.height;
  32040. }
  32041. return this._gl.drawingBufferHeight;
  32042. };
  32043. /**
  32044. * Gets the HTML canvas attached with the current webGL context
  32045. * @returns a HTML canvas
  32046. */
  32047. Engine.prototype.getRenderingCanvas = function () {
  32048. return this._renderingCanvas;
  32049. };
  32050. /**
  32051. * Gets the client rect of the HTML canvas attached with the current webGL context
  32052. * @returns a client rectanglee
  32053. */
  32054. Engine.prototype.getRenderingCanvasClientRect = function () {
  32055. if (!this._renderingCanvas) {
  32056. return null;
  32057. }
  32058. return this._renderingCanvas.getBoundingClientRect();
  32059. };
  32060. /**
  32061. * Defines the hardware scaling level.
  32062. * By default the hardware scaling level is computed from the window device ratio.
  32063. * 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.
  32064. * @param level defines the level to use
  32065. */
  32066. Engine.prototype.setHardwareScalingLevel = function (level) {
  32067. this._hardwareScalingLevel = level;
  32068. this.resize();
  32069. };
  32070. /**
  32071. * Gets the current hardware scaling level.
  32072. * By default the hardware scaling level is computed from the window device ratio.
  32073. * 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.
  32074. * @returns a number indicating the current hardware scaling level
  32075. */
  32076. Engine.prototype.getHardwareScalingLevel = function () {
  32077. return this._hardwareScalingLevel;
  32078. };
  32079. /**
  32080. * Gets the list of loaded textures
  32081. * @returns an array containing all loaded textures
  32082. */
  32083. Engine.prototype.getLoadedTexturesCache = function () {
  32084. return this._internalTexturesCache;
  32085. };
  32086. /**
  32087. * Gets the object containing all engine capabilities
  32088. * @returns the EngineCapabilities object
  32089. */
  32090. Engine.prototype.getCaps = function () {
  32091. return this._caps;
  32092. };
  32093. /**
  32094. * Gets the current depth function
  32095. * @returns a number defining the depth function
  32096. */
  32097. Engine.prototype.getDepthFunction = function () {
  32098. return this._depthCullingState.depthFunc;
  32099. };
  32100. /**
  32101. * Sets the current depth function
  32102. * @param depthFunc defines the function to use
  32103. */
  32104. Engine.prototype.setDepthFunction = function (depthFunc) {
  32105. this._depthCullingState.depthFunc = depthFunc;
  32106. };
  32107. /**
  32108. * Sets the current depth function to GREATER
  32109. */
  32110. Engine.prototype.setDepthFunctionToGreater = function () {
  32111. this._depthCullingState.depthFunc = this._gl.GREATER;
  32112. };
  32113. /**
  32114. * Sets the current depth function to GEQUAL
  32115. */
  32116. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  32117. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  32118. };
  32119. /**
  32120. * Sets the current depth function to LESS
  32121. */
  32122. Engine.prototype.setDepthFunctionToLess = function () {
  32123. this._depthCullingState.depthFunc = this._gl.LESS;
  32124. };
  32125. /**
  32126. * Caches the the state of the stencil buffer
  32127. */
  32128. Engine.prototype.cacheStencilState = function () {
  32129. this._cachedStencilBuffer = this.getStencilBuffer();
  32130. this._cachedStencilFunction = this.getStencilFunction();
  32131. this._cachedStencilMask = this.getStencilMask();
  32132. this._cachedStencilOperationPass = this.getStencilOperationPass();
  32133. this._cachedStencilOperationFail = this.getStencilOperationFail();
  32134. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  32135. this._cachedStencilReference = this.getStencilFunctionReference();
  32136. };
  32137. /**
  32138. * Restores the state of the stencil buffer
  32139. */
  32140. Engine.prototype.restoreStencilState = function () {
  32141. this.setStencilFunction(this._cachedStencilFunction);
  32142. this.setStencilMask(this._cachedStencilMask);
  32143. this.setStencilBuffer(this._cachedStencilBuffer);
  32144. this.setStencilOperationPass(this._cachedStencilOperationPass);
  32145. this.setStencilOperationFail(this._cachedStencilOperationFail);
  32146. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  32147. this.setStencilFunctionReference(this._cachedStencilReference);
  32148. };
  32149. /**
  32150. * Sets the current depth function to LEQUAL
  32151. */
  32152. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  32153. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  32154. };
  32155. /**
  32156. * Gets a boolean indicating if stencil buffer is enabled
  32157. * @returns the current stencil buffer state
  32158. */
  32159. Engine.prototype.getStencilBuffer = function () {
  32160. return this._stencilState.stencilTest;
  32161. };
  32162. /**
  32163. * Enable or disable the stencil buffer
  32164. * @param enable defines if the stencil buffer must be enabled or disabled
  32165. */
  32166. Engine.prototype.setStencilBuffer = function (enable) {
  32167. this._stencilState.stencilTest = enable;
  32168. };
  32169. /**
  32170. * Gets the current stencil mask
  32171. * @returns a number defining the new stencil mask to use
  32172. */
  32173. Engine.prototype.getStencilMask = function () {
  32174. return this._stencilState.stencilMask;
  32175. };
  32176. /**
  32177. * Sets the current stencil mask
  32178. * @param mask defines the new stencil mask to use
  32179. */
  32180. Engine.prototype.setStencilMask = function (mask) {
  32181. this._stencilState.stencilMask = mask;
  32182. };
  32183. /**
  32184. * Gets the current stencil function
  32185. * @returns a number defining the stencil function to use
  32186. */
  32187. Engine.prototype.getStencilFunction = function () {
  32188. return this._stencilState.stencilFunc;
  32189. };
  32190. /**
  32191. * Gets the current stencil reference value
  32192. * @returns a number defining the stencil reference value to use
  32193. */
  32194. Engine.prototype.getStencilFunctionReference = function () {
  32195. return this._stencilState.stencilFuncRef;
  32196. };
  32197. /**
  32198. * Gets the current stencil mask
  32199. * @returns a number defining the stencil mask to use
  32200. */
  32201. Engine.prototype.getStencilFunctionMask = function () {
  32202. return this._stencilState.stencilFuncMask;
  32203. };
  32204. /**
  32205. * Sets the current stencil function
  32206. * @param stencilFunc defines the new stencil function to use
  32207. */
  32208. Engine.prototype.setStencilFunction = function (stencilFunc) {
  32209. this._stencilState.stencilFunc = stencilFunc;
  32210. };
  32211. /**
  32212. * Sets the current stencil reference
  32213. * @param reference defines the new stencil reference to use
  32214. */
  32215. Engine.prototype.setStencilFunctionReference = function (reference) {
  32216. this._stencilState.stencilFuncRef = reference;
  32217. };
  32218. /**
  32219. * Sets the current stencil mask
  32220. * @param mask defines the new stencil mask to use
  32221. */
  32222. Engine.prototype.setStencilFunctionMask = function (mask) {
  32223. this._stencilState.stencilFuncMask = mask;
  32224. };
  32225. /**
  32226. * Gets the current stencil operation when stencil fails
  32227. * @returns a number defining stencil operation to use when stencil fails
  32228. */
  32229. Engine.prototype.getStencilOperationFail = function () {
  32230. return this._stencilState.stencilOpStencilFail;
  32231. };
  32232. /**
  32233. * Gets the current stencil operation when depth fails
  32234. * @returns a number defining stencil operation to use when depth fails
  32235. */
  32236. Engine.prototype.getStencilOperationDepthFail = function () {
  32237. return this._stencilState.stencilOpDepthFail;
  32238. };
  32239. /**
  32240. * Gets the current stencil operation when stencil passes
  32241. * @returns a number defining stencil operation to use when stencil passes
  32242. */
  32243. Engine.prototype.getStencilOperationPass = function () {
  32244. return this._stencilState.stencilOpStencilDepthPass;
  32245. };
  32246. /**
  32247. * Sets the stencil operation to use when stencil fails
  32248. * @param operation defines the stencil operation to use when stencil fails
  32249. */
  32250. Engine.prototype.setStencilOperationFail = function (operation) {
  32251. this._stencilState.stencilOpStencilFail = operation;
  32252. };
  32253. /**
  32254. * Sets the stencil operation to use when depth fails
  32255. * @param operation defines the stencil operation to use when depth fails
  32256. */
  32257. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  32258. this._stencilState.stencilOpDepthFail = operation;
  32259. };
  32260. /**
  32261. * Sets the stencil operation to use when stencil passes
  32262. * @param operation defines the stencil operation to use when stencil passes
  32263. */
  32264. Engine.prototype.setStencilOperationPass = function (operation) {
  32265. this._stencilState.stencilOpStencilDepthPass = operation;
  32266. };
  32267. /**
  32268. * Sets a boolean indicating if the dithering state is enabled or disabled
  32269. * @param value defines the dithering state
  32270. */
  32271. Engine.prototype.setDitheringState = function (value) {
  32272. if (value) {
  32273. this._gl.enable(this._gl.DITHER);
  32274. }
  32275. else {
  32276. this._gl.disable(this._gl.DITHER);
  32277. }
  32278. };
  32279. /**
  32280. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32281. * @param value defines the rasterizer state
  32282. */
  32283. Engine.prototype.setRasterizerState = function (value) {
  32284. if (value) {
  32285. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  32286. }
  32287. else {
  32288. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  32289. }
  32290. };
  32291. /**
  32292. * stop executing a render loop function and remove it from the execution array
  32293. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32294. */
  32295. Engine.prototype.stopRenderLoop = function (renderFunction) {
  32296. if (!renderFunction) {
  32297. this._activeRenderLoops = [];
  32298. return;
  32299. }
  32300. var index = this._activeRenderLoops.indexOf(renderFunction);
  32301. if (index >= 0) {
  32302. this._activeRenderLoops.splice(index, 1);
  32303. }
  32304. };
  32305. /** @hidden */
  32306. Engine.prototype._renderLoop = function () {
  32307. if (!this._contextWasLost) {
  32308. var shouldRender = true;
  32309. if (!this.renderEvenInBackground && this._windowIsBackground) {
  32310. shouldRender = false;
  32311. }
  32312. if (shouldRender) {
  32313. // Start new frame
  32314. this.beginFrame();
  32315. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  32316. var renderFunction = this._activeRenderLoops[index];
  32317. renderFunction();
  32318. }
  32319. // Present
  32320. this.endFrame();
  32321. }
  32322. }
  32323. if (this._activeRenderLoops.length > 0) {
  32324. // Register new frame
  32325. if (this.customAnimationFrameRequester) {
  32326. this.customAnimationFrameRequester.requestID = Engine.QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  32327. this._frameHandler = this.customAnimationFrameRequester.requestID;
  32328. }
  32329. else if (this.isVRPresenting()) {
  32330. this._requestVRFrame();
  32331. }
  32332. else {
  32333. this._frameHandler = Engine.QueueNewFrame(this._bindedRenderFunction);
  32334. }
  32335. }
  32336. else {
  32337. this._renderingQueueLaunched = false;
  32338. }
  32339. };
  32340. /**
  32341. * Register and execute a render loop. The engine can have more than one render function
  32342. * @param renderFunction defines the function to continuously execute
  32343. */
  32344. Engine.prototype.runRenderLoop = function (renderFunction) {
  32345. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  32346. return;
  32347. }
  32348. this._activeRenderLoops.push(renderFunction);
  32349. if (!this._renderingQueueLaunched) {
  32350. this._renderingQueueLaunched = true;
  32351. this._bindedRenderFunction = this._renderLoop.bind(this);
  32352. this._frameHandler = Engine.QueueNewFrame(this._bindedRenderFunction);
  32353. }
  32354. };
  32355. /**
  32356. * Toggle full screen mode
  32357. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32358. */
  32359. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  32360. if (this.isFullscreen) {
  32361. this.exitFullscreen();
  32362. }
  32363. else {
  32364. this.enterFullscreen(requestPointerLock);
  32365. }
  32366. };
  32367. /**
  32368. * Enters full screen mode
  32369. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32370. */
  32371. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  32372. if (!this.isFullscreen) {
  32373. this._pointerLockRequested = requestPointerLock;
  32374. if (this._renderingCanvas) {
  32375. Engine._RequestFullscreen(this._renderingCanvas);
  32376. }
  32377. }
  32378. };
  32379. /**
  32380. * Exits full screen mode
  32381. */
  32382. Engine.prototype.exitFullscreen = function () {
  32383. if (this.isFullscreen) {
  32384. Engine._ExitFullscreen();
  32385. }
  32386. };
  32387. /**
  32388. * Enters Pointerlock mode
  32389. */
  32390. Engine.prototype.enterPointerlock = function () {
  32391. if (this._renderingCanvas) {
  32392. Engine._RequestPointerlock(this._renderingCanvas);
  32393. }
  32394. };
  32395. /**
  32396. * Exits Pointerlock mode
  32397. */
  32398. Engine.prototype.exitPointerlock = function () {
  32399. Engine._ExitPointerlock();
  32400. };
  32401. /**
  32402. * Clear the current render buffer or the current render target (if any is set up)
  32403. * @param color defines the color to use
  32404. * @param backBuffer defines if the back buffer must be cleared
  32405. * @param depth defines if the depth buffer must be cleared
  32406. * @param stencil defines if the stencil buffer must be cleared
  32407. */
  32408. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  32409. if (stencil === void 0) { stencil = false; }
  32410. this.applyStates();
  32411. var mode = 0;
  32412. if (backBuffer && color) {
  32413. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  32414. mode |= this._gl.COLOR_BUFFER_BIT;
  32415. }
  32416. if (depth) {
  32417. this._gl.clearDepth(1.0);
  32418. mode |= this._gl.DEPTH_BUFFER_BIT;
  32419. }
  32420. if (stencil) {
  32421. this._gl.clearStencil(0);
  32422. mode |= this._gl.STENCIL_BUFFER_BIT;
  32423. }
  32424. this._gl.clear(mode);
  32425. };
  32426. /**
  32427. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32428. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32429. * @param y defines the y-coordinate of the corner of the clear rectangle
  32430. * @param width defines the width of the clear rectangle
  32431. * @param height defines the height of the clear rectangle
  32432. * @param clearColor defines the clear color
  32433. */
  32434. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  32435. this.enableScissor(x, y, width, height);
  32436. this.clear(clearColor, true, true, true);
  32437. this.disableScissor();
  32438. };
  32439. /**
  32440. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32441. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32442. * @param y defines the y-coordinate of the corner of the clear rectangle
  32443. * @param width defines the width of the clear rectangle
  32444. * @param height defines the height of the clear rectangle
  32445. */
  32446. Engine.prototype.enableScissor = function (x, y, width, height) {
  32447. var gl = this._gl;
  32448. // Change state
  32449. gl.enable(gl.SCISSOR_TEST);
  32450. gl.scissor(x, y, width, height);
  32451. };
  32452. /**
  32453. * Disable previously set scissor test rectangle
  32454. */
  32455. Engine.prototype.disableScissor = function () {
  32456. var gl = this._gl;
  32457. gl.disable(gl.SCISSOR_TEST);
  32458. };
  32459. /** @hidden */
  32460. Engine.prototype._viewport = function (x, y, width, height) {
  32461. if (x !== this._viewportCached.x ||
  32462. y !== this._viewportCached.y ||
  32463. width !== this._viewportCached.z ||
  32464. height !== this._viewportCached.w) {
  32465. this._viewportCached.x = x;
  32466. this._viewportCached.y = y;
  32467. this._viewportCached.z = width;
  32468. this._viewportCached.w = height;
  32469. this._gl.viewport(x, y, width, height);
  32470. }
  32471. };
  32472. /**
  32473. * Set the WebGL's viewport
  32474. * @param viewport defines the viewport element to be used
  32475. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32476. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32477. */
  32478. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  32479. var width = requiredWidth || this.getRenderWidth();
  32480. var height = requiredHeight || this.getRenderHeight();
  32481. var x = viewport.x || 0;
  32482. var y = viewport.y || 0;
  32483. this._cachedViewport = viewport;
  32484. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  32485. };
  32486. /**
  32487. * Directly set the WebGL Viewport
  32488. * @param x defines the x coordinate of the viewport (in screen space)
  32489. * @param y defines the y coordinate of the viewport (in screen space)
  32490. * @param width defines the width of the viewport (in screen space)
  32491. * @param height defines the height of the viewport (in screen space)
  32492. * @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
  32493. */
  32494. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  32495. var currentViewport = this._cachedViewport;
  32496. this._cachedViewport = null;
  32497. this._viewport(x, y, width, height);
  32498. return currentViewport;
  32499. };
  32500. /**
  32501. * Begin a new frame
  32502. */
  32503. Engine.prototype.beginFrame = function () {
  32504. this.onBeginFrameObservable.notifyObservers(this);
  32505. this._measureFps();
  32506. };
  32507. /**
  32508. * Enf the current frame
  32509. */
  32510. Engine.prototype.endFrame = function () {
  32511. // Force a flush in case we are using a bad OS.
  32512. if (this._badOS) {
  32513. this.flushFramebuffer();
  32514. }
  32515. this._submitVRFrame();
  32516. this.onEndFrameObservable.notifyObservers(this);
  32517. };
  32518. /**
  32519. * Resize the view according to the canvas' size
  32520. */
  32521. Engine.prototype.resize = function () {
  32522. // We're not resizing the size of the canvas while in VR mode & presenting
  32523. if (!this.isVRPresenting()) {
  32524. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  32525. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  32526. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  32527. }
  32528. };
  32529. /**
  32530. * Force a specific size of the canvas
  32531. * @param width defines the new canvas' width
  32532. * @param height defines the new canvas' height
  32533. */
  32534. Engine.prototype.setSize = function (width, height) {
  32535. if (!this._renderingCanvas) {
  32536. return;
  32537. }
  32538. width = width | 0;
  32539. height = height | 0;
  32540. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  32541. return;
  32542. }
  32543. this._renderingCanvas.width = width;
  32544. this._renderingCanvas.height = height;
  32545. for (var index = 0; index < this.scenes.length; index++) {
  32546. var scene = this.scenes[index];
  32547. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  32548. var cam = scene.cameras[camIndex];
  32549. cam._currentRenderId = 0;
  32550. }
  32551. }
  32552. if (this.onResizeObservable.hasObservers) {
  32553. this.onResizeObservable.notifyObservers(this);
  32554. }
  32555. };
  32556. /**
  32557. * Binds the frame buffer to the specified texture.
  32558. * @param texture The texture to render to or null for the default canvas
  32559. * @param faceIndex The face of the texture to render to in case of cube texture
  32560. * @param requiredWidth The width of the target to render to
  32561. * @param requiredHeight The height of the target to render to
  32562. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32563. * @param depthStencilTexture The depth stencil texture to use to render
  32564. * @param lodLevel defines le lod level to bind to the frame buffer
  32565. */
  32566. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  32567. if (lodLevel === void 0) { lodLevel = 0; }
  32568. if (this._currentRenderTarget) {
  32569. this.unBindFramebuffer(this._currentRenderTarget);
  32570. }
  32571. this._currentRenderTarget = texture;
  32572. this._bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  32573. var gl = this._gl;
  32574. if (texture.isCube) {
  32575. if (faceIndex === undefined) {
  32576. faceIndex = 0;
  32577. }
  32578. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  32579. if (depthStencilTexture) {
  32580. if (depthStencilTexture._generateStencilBuffer) {
  32581. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  32582. }
  32583. else {
  32584. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  32585. }
  32586. }
  32587. }
  32588. if (this._cachedViewport && !forceFullscreenViewport) {
  32589. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  32590. }
  32591. else {
  32592. if (!requiredWidth) {
  32593. requiredWidth = texture.width;
  32594. if (lodLevel) {
  32595. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  32596. }
  32597. }
  32598. if (!requiredHeight) {
  32599. requiredHeight = texture.height;
  32600. if (lodLevel) {
  32601. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  32602. }
  32603. }
  32604. this._viewport(0, 0, requiredWidth, requiredHeight);
  32605. }
  32606. this.wipeCaches();
  32607. };
  32608. /** @hidden */
  32609. Engine.prototype._bindUnboundFramebuffer = function (framebuffer) {
  32610. if (this._currentFramebuffer !== framebuffer) {
  32611. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  32612. this._currentFramebuffer = framebuffer;
  32613. }
  32614. };
  32615. /**
  32616. * Unbind the current render target texture from the webGL context
  32617. * @param texture defines the render target texture to unbind
  32618. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32619. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32620. */
  32621. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  32622. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  32623. this._currentRenderTarget = null;
  32624. // If MSAA, we need to bitblt back to main texture
  32625. var gl = this._gl;
  32626. if (texture._MSAAFramebuffer) {
  32627. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  32628. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  32629. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  32630. }
  32631. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  32632. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32633. gl.generateMipmap(gl.TEXTURE_2D);
  32634. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32635. }
  32636. if (onBeforeUnbind) {
  32637. if (texture._MSAAFramebuffer) {
  32638. // Bind the correct framebuffer
  32639. this._bindUnboundFramebuffer(texture._framebuffer);
  32640. }
  32641. onBeforeUnbind();
  32642. }
  32643. this._bindUnboundFramebuffer(null);
  32644. };
  32645. /**
  32646. * Force the mipmap generation for the given render target texture
  32647. * @param texture defines the render target texture to use
  32648. */
  32649. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  32650. if (texture.generateMipMaps) {
  32651. var gl = this._gl;
  32652. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32653. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32654. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32655. }
  32656. };
  32657. /**
  32658. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32659. */
  32660. Engine.prototype.flushFramebuffer = function () {
  32661. this._gl.flush();
  32662. };
  32663. /**
  32664. * Unbind the current render target and bind the default framebuffer
  32665. */
  32666. Engine.prototype.restoreDefaultFramebuffer = function () {
  32667. if (this._currentRenderTarget) {
  32668. this.unBindFramebuffer(this._currentRenderTarget);
  32669. }
  32670. else {
  32671. this._bindUnboundFramebuffer(null);
  32672. }
  32673. if (this._cachedViewport) {
  32674. this.setViewport(this._cachedViewport);
  32675. }
  32676. this.wipeCaches();
  32677. };
  32678. // UBOs
  32679. /**
  32680. * Create an uniform buffer
  32681. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32682. * @param elements defines the content of the uniform buffer
  32683. * @returns the webGL uniform buffer
  32684. */
  32685. Engine.prototype.createUniformBuffer = function (elements) {
  32686. var ubo = this._gl.createBuffer();
  32687. if (!ubo) {
  32688. throw new Error("Unable to create uniform buffer");
  32689. }
  32690. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__["WebGLDataBuffer"](ubo);
  32691. this.bindUniformBuffer(result);
  32692. if (elements instanceof Float32Array) {
  32693. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  32694. }
  32695. else {
  32696. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  32697. }
  32698. this.bindUniformBuffer(null);
  32699. result.references = 1;
  32700. return result;
  32701. };
  32702. /**
  32703. * Create a dynamic uniform buffer
  32704. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32705. * @param elements defines the content of the uniform buffer
  32706. * @returns the webGL uniform buffer
  32707. */
  32708. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  32709. var ubo = this._gl.createBuffer();
  32710. if (!ubo) {
  32711. throw new Error("Unable to create dynamic uniform buffer");
  32712. }
  32713. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__["WebGLDataBuffer"](ubo);
  32714. this.bindUniformBuffer(result);
  32715. if (elements instanceof Float32Array) {
  32716. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  32717. }
  32718. else {
  32719. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  32720. }
  32721. this.bindUniformBuffer(null);
  32722. result.references = 1;
  32723. return result;
  32724. };
  32725. /**
  32726. * Update an existing uniform buffer
  32727. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32728. * @param uniformBuffer defines the target uniform buffer
  32729. * @param elements defines the content to update
  32730. * @param offset defines the offset in the uniform buffer where update should start
  32731. * @param count defines the size of the data to update
  32732. */
  32733. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  32734. this.bindUniformBuffer(uniformBuffer);
  32735. if (offset === undefined) {
  32736. offset = 0;
  32737. }
  32738. if (count === undefined) {
  32739. if (elements instanceof Float32Array) {
  32740. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  32741. }
  32742. else {
  32743. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  32744. }
  32745. }
  32746. else {
  32747. if (elements instanceof Float32Array) {
  32748. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  32749. }
  32750. else {
  32751. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  32752. }
  32753. }
  32754. this.bindUniformBuffer(null);
  32755. };
  32756. // VBOs
  32757. Engine.prototype._resetVertexBufferBinding = function () {
  32758. this.bindArrayBuffer(null);
  32759. this._cachedVertexBuffers = null;
  32760. };
  32761. /**
  32762. * Creates a vertex buffer
  32763. * @param data the data for the vertex buffer
  32764. * @returns the new WebGL static buffer
  32765. */
  32766. Engine.prototype.createVertexBuffer = function (data) {
  32767. var vbo = this._gl.createBuffer();
  32768. if (!vbo) {
  32769. throw new Error("Unable to create vertex buffer");
  32770. }
  32771. var dataBuffer = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__["WebGLDataBuffer"](vbo);
  32772. this.bindArrayBuffer(dataBuffer);
  32773. if (data instanceof Array) {
  32774. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  32775. }
  32776. else {
  32777. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  32778. }
  32779. this._resetVertexBufferBinding();
  32780. dataBuffer.references = 1;
  32781. return dataBuffer;
  32782. };
  32783. /**
  32784. * Creates a dynamic vertex buffer
  32785. * @param data the data for the dynamic vertex buffer
  32786. * @returns the new WebGL dynamic buffer
  32787. */
  32788. Engine.prototype.createDynamicVertexBuffer = function (data) {
  32789. var vbo = this._gl.createBuffer();
  32790. if (!vbo) {
  32791. throw new Error("Unable to create dynamic vertex buffer");
  32792. }
  32793. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__["WebGLDataBuffer"](vbo);
  32794. this.bindArrayBuffer(result);
  32795. if (data instanceof Array) {
  32796. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  32797. }
  32798. else {
  32799. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  32800. }
  32801. this._resetVertexBufferBinding();
  32802. result.references = 1;
  32803. return result;
  32804. };
  32805. /**
  32806. * Update a dynamic index buffer
  32807. * @param indexBuffer defines the target index buffer
  32808. * @param indices defines the data to update
  32809. * @param offset defines the offset in the target index buffer where update should start
  32810. */
  32811. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  32812. if (offset === void 0) { offset = 0; }
  32813. // Force cache update
  32814. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  32815. this.bindIndexBuffer(indexBuffer);
  32816. var arrayBuffer;
  32817. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  32818. arrayBuffer = indices;
  32819. }
  32820. else {
  32821. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  32822. }
  32823. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  32824. this._resetIndexBufferBinding();
  32825. };
  32826. /**
  32827. * Updates a dynamic vertex buffer.
  32828. * @param vertexBuffer the vertex buffer to update
  32829. * @param data the data used to update the vertex buffer
  32830. * @param byteOffset the byte offset of the data
  32831. * @param byteLength the byte length of the data
  32832. */
  32833. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  32834. this.bindArrayBuffer(vertexBuffer);
  32835. if (byteOffset === undefined) {
  32836. byteOffset = 0;
  32837. }
  32838. if (byteLength === undefined) {
  32839. if (data instanceof Array) {
  32840. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  32841. }
  32842. else {
  32843. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  32844. }
  32845. }
  32846. else {
  32847. if (data instanceof Array) {
  32848. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  32849. }
  32850. else {
  32851. if (data instanceof ArrayBuffer) {
  32852. data = new Uint8Array(data, byteOffset, byteLength);
  32853. }
  32854. else {
  32855. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  32856. }
  32857. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  32858. }
  32859. }
  32860. this._resetVertexBufferBinding();
  32861. };
  32862. Engine.prototype._resetIndexBufferBinding = function () {
  32863. this.bindIndexBuffer(null);
  32864. this._cachedIndexBuffer = null;
  32865. };
  32866. /**
  32867. * Creates a new index buffer
  32868. * @param indices defines the content of the index buffer
  32869. * @param updatable defines if the index buffer must be updatable
  32870. * @returns a new webGL buffer
  32871. */
  32872. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  32873. var vbo = this._gl.createBuffer();
  32874. var dataBuffer = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__["WebGLDataBuffer"](vbo);
  32875. if (!vbo) {
  32876. throw new Error("Unable to create index buffer");
  32877. }
  32878. this.bindIndexBuffer(dataBuffer);
  32879. // Check for 32 bits indices
  32880. var arrayBuffer;
  32881. var need32Bits = false;
  32882. if (indices instanceof Uint16Array) {
  32883. arrayBuffer = indices;
  32884. }
  32885. else {
  32886. //check 32 bit support
  32887. if (this._caps.uintIndices) {
  32888. if (indices instanceof Uint32Array) {
  32889. arrayBuffer = indices;
  32890. need32Bits = true;
  32891. }
  32892. else {
  32893. //number[] or Int32Array, check if 32 bit is necessary
  32894. for (var index = 0; index < indices.length; index++) {
  32895. if (indices[index] > 65535) {
  32896. need32Bits = true;
  32897. break;
  32898. }
  32899. }
  32900. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  32901. }
  32902. }
  32903. else {
  32904. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  32905. arrayBuffer = new Uint16Array(indices);
  32906. }
  32907. }
  32908. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  32909. this._resetIndexBufferBinding();
  32910. dataBuffer.references = 1;
  32911. dataBuffer.is32Bits = need32Bits;
  32912. return dataBuffer;
  32913. };
  32914. /**
  32915. * Bind a webGL buffer to the webGL context
  32916. * @param buffer defines the buffer to bind
  32917. */
  32918. Engine.prototype.bindArrayBuffer = function (buffer) {
  32919. if (!this._vaoRecordInProgress) {
  32920. this._unbindVertexArrayObject();
  32921. }
  32922. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  32923. };
  32924. /**
  32925. * Bind an uniform buffer to the current webGL context
  32926. * @param buffer defines the buffer to bind
  32927. */
  32928. Engine.prototype.bindUniformBuffer = function (buffer) {
  32929. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer ? buffer.underlyingResource : null);
  32930. };
  32931. /**
  32932. * Bind a buffer to the current webGL context at a given location
  32933. * @param buffer defines the buffer to bind
  32934. * @param location defines the index where to bind the buffer
  32935. */
  32936. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  32937. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer ? buffer.underlyingResource : null);
  32938. };
  32939. /**
  32940. * Bind a specific block at a given index in a specific shader program
  32941. * @param pipelineContext defines the pipeline context to use
  32942. * @param blockName defines the block name
  32943. * @param index defines the index where to bind the block
  32944. */
  32945. Engine.prototype.bindUniformBlock = function (pipelineContext, blockName, index) {
  32946. var program = pipelineContext.program;
  32947. var uniformLocation = this._gl.getUniformBlockIndex(program, blockName);
  32948. this._gl.uniformBlockBinding(program, uniformLocation, index);
  32949. };
  32950. Engine.prototype.bindIndexBuffer = function (buffer) {
  32951. if (!this._vaoRecordInProgress) {
  32952. this._unbindVertexArrayObject();
  32953. }
  32954. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  32955. };
  32956. Engine.prototype.bindBuffer = function (buffer, target) {
  32957. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  32958. this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);
  32959. this._currentBoundBuffer[target] = buffer;
  32960. }
  32961. };
  32962. /**
  32963. * update the bound buffer with the given data
  32964. * @param data defines the data to update
  32965. */
  32966. Engine.prototype.updateArrayBuffer = function (data) {
  32967. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  32968. };
  32969. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  32970. var pointer = this._currentBufferPointers[indx];
  32971. var changed = false;
  32972. if (!pointer.active) {
  32973. changed = true;
  32974. pointer.active = true;
  32975. pointer.index = indx;
  32976. pointer.size = size;
  32977. pointer.type = type;
  32978. pointer.normalized = normalized;
  32979. pointer.stride = stride;
  32980. pointer.offset = offset;
  32981. pointer.buffer = buffer;
  32982. }
  32983. else {
  32984. if (pointer.buffer !== buffer) {
  32985. pointer.buffer = buffer;
  32986. changed = true;
  32987. }
  32988. if (pointer.size !== size) {
  32989. pointer.size = size;
  32990. changed = true;
  32991. }
  32992. if (pointer.type !== type) {
  32993. pointer.type = type;
  32994. changed = true;
  32995. }
  32996. if (pointer.normalized !== normalized) {
  32997. pointer.normalized = normalized;
  32998. changed = true;
  32999. }
  33000. if (pointer.stride !== stride) {
  33001. pointer.stride = stride;
  33002. changed = true;
  33003. }
  33004. if (pointer.offset !== offset) {
  33005. pointer.offset = offset;
  33006. changed = true;
  33007. }
  33008. }
  33009. if (changed || this._vaoRecordInProgress) {
  33010. this.bindArrayBuffer(buffer);
  33011. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  33012. }
  33013. };
  33014. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  33015. if (indexBuffer == null) {
  33016. return;
  33017. }
  33018. if (this._cachedIndexBuffer !== indexBuffer) {
  33019. this._cachedIndexBuffer = indexBuffer;
  33020. this.bindIndexBuffer(indexBuffer);
  33021. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  33022. }
  33023. };
  33024. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  33025. var attributes = effect.getAttributesNames();
  33026. if (!this._vaoRecordInProgress) {
  33027. this._unbindVertexArrayObject();
  33028. }
  33029. this.unbindAllAttributes();
  33030. for (var index = 0; index < attributes.length; index++) {
  33031. var order = effect.getAttributeLocation(index);
  33032. if (order >= 0) {
  33033. var vertexBuffer = vertexBuffers[attributes[index]];
  33034. if (!vertexBuffer) {
  33035. continue;
  33036. }
  33037. this._gl.enableVertexAttribArray(order);
  33038. if (!this._vaoRecordInProgress) {
  33039. this._vertexAttribArraysEnabled[order] = true;
  33040. }
  33041. var buffer = vertexBuffer.getBuffer();
  33042. if (buffer) {
  33043. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  33044. if (vertexBuffer.getIsInstanced()) {
  33045. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  33046. if (!this._vaoRecordInProgress) {
  33047. this._currentInstanceLocations.push(order);
  33048. this._currentInstanceBuffers.push(buffer);
  33049. }
  33050. }
  33051. }
  33052. }
  33053. }
  33054. };
  33055. /**
  33056. * Records a vertex array object
  33057. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33058. * @param vertexBuffers defines the list of vertex buffers to store
  33059. * @param indexBuffer defines the index buffer to store
  33060. * @param effect defines the effect to store
  33061. * @returns the new vertex array object
  33062. */
  33063. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  33064. var vao = this._gl.createVertexArray();
  33065. this._vaoRecordInProgress = true;
  33066. this._gl.bindVertexArray(vao);
  33067. this._mustWipeVertexAttributes = true;
  33068. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  33069. this.bindIndexBuffer(indexBuffer);
  33070. this._vaoRecordInProgress = false;
  33071. this._gl.bindVertexArray(null);
  33072. return vao;
  33073. };
  33074. /**
  33075. * Bind a specific vertex array object
  33076. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33077. * @param vertexArrayObject defines the vertex array object to bind
  33078. * @param indexBuffer defines the index buffer to bind
  33079. */
  33080. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  33081. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  33082. this._cachedVertexArrayObject = vertexArrayObject;
  33083. this._gl.bindVertexArray(vertexArrayObject);
  33084. this._cachedVertexBuffers = null;
  33085. this._cachedIndexBuffer = null;
  33086. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  33087. this._mustWipeVertexAttributes = true;
  33088. }
  33089. };
  33090. /**
  33091. * Bind webGl buffers directly to the webGL context
  33092. * @param vertexBuffer defines the vertex buffer to bind
  33093. * @param indexBuffer defines the index buffer to bind
  33094. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  33095. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  33096. * @param effect defines the effect associated with the vertex buffer
  33097. */
  33098. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  33099. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  33100. this._cachedVertexBuffers = vertexBuffer;
  33101. this._cachedEffectForVertexBuffers = effect;
  33102. var attributesCount = effect.getAttributesCount();
  33103. this._unbindVertexArrayObject();
  33104. this.unbindAllAttributes();
  33105. var offset = 0;
  33106. for (var index = 0; index < attributesCount; index++) {
  33107. if (index < vertexDeclaration.length) {
  33108. var order = effect.getAttributeLocation(index);
  33109. if (order >= 0) {
  33110. this._gl.enableVertexAttribArray(order);
  33111. this._vertexAttribArraysEnabled[order] = true;
  33112. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  33113. }
  33114. offset += vertexDeclaration[index] * 4;
  33115. }
  33116. }
  33117. }
  33118. this._bindIndexBufferWithCache(indexBuffer);
  33119. };
  33120. Engine.prototype._unbindVertexArrayObject = function () {
  33121. if (!this._cachedVertexArrayObject) {
  33122. return;
  33123. }
  33124. this._cachedVertexArrayObject = null;
  33125. this._gl.bindVertexArray(null);
  33126. };
  33127. /**
  33128. * Bind a list of vertex buffers to the webGL context
  33129. * @param vertexBuffers defines the list of vertex buffers to bind
  33130. * @param indexBuffer defines the index buffer to bind
  33131. * @param effect defines the effect associated with the vertex buffers
  33132. */
  33133. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  33134. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  33135. this._cachedVertexBuffers = vertexBuffers;
  33136. this._cachedEffectForVertexBuffers = effect;
  33137. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  33138. }
  33139. this._bindIndexBufferWithCache(indexBuffer);
  33140. };
  33141. /**
  33142. * Unbind all instance attributes
  33143. */
  33144. Engine.prototype.unbindInstanceAttributes = function () {
  33145. var boundBuffer;
  33146. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  33147. var instancesBuffer = this._currentInstanceBuffers[i];
  33148. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  33149. boundBuffer = instancesBuffer;
  33150. this.bindArrayBuffer(instancesBuffer);
  33151. }
  33152. var offsetLocation = this._currentInstanceLocations[i];
  33153. this._gl.vertexAttribDivisor(offsetLocation, 0);
  33154. }
  33155. this._currentInstanceBuffers.length = 0;
  33156. this._currentInstanceLocations.length = 0;
  33157. };
  33158. /**
  33159. * Release and free the memory of a vertex array object
  33160. * @param vao defines the vertex array object to delete
  33161. */
  33162. Engine.prototype.releaseVertexArrayObject = function (vao) {
  33163. this._gl.deleteVertexArray(vao);
  33164. };
  33165. /** @hidden */
  33166. Engine.prototype._releaseBuffer = function (buffer) {
  33167. buffer.references--;
  33168. if (buffer.references === 0) {
  33169. this._gl.deleteBuffer(buffer.underlyingResource);
  33170. return true;
  33171. }
  33172. return false;
  33173. };
  33174. /**
  33175. * Creates a webGL buffer to use with instanciation
  33176. * @param capacity defines the size of the buffer
  33177. * @returns the webGL buffer
  33178. */
  33179. Engine.prototype.createInstancesBuffer = function (capacity) {
  33180. var buffer = this._gl.createBuffer();
  33181. if (!buffer) {
  33182. throw new Error("Unable to create instance buffer");
  33183. }
  33184. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_14__["WebGLDataBuffer"](buffer);
  33185. result.capacity = capacity;
  33186. this.bindArrayBuffer(result);
  33187. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  33188. return result;
  33189. };
  33190. /**
  33191. * Delete a webGL buffer used with instanciation
  33192. * @param buffer defines the webGL buffer to delete
  33193. */
  33194. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  33195. this._gl.deleteBuffer(buffer);
  33196. };
  33197. /**
  33198. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33199. * @param instancesBuffer defines the webGL buffer to update and bind
  33200. * @param data defines the data to store in the buffer
  33201. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33202. */
  33203. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  33204. this.bindArrayBuffer(instancesBuffer);
  33205. if (data) {
  33206. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  33207. }
  33208. if (offsetLocations[0].index !== undefined) {
  33209. var stride = 0;
  33210. for (var i = 0; i < offsetLocations.length; i++) {
  33211. var ai = offsetLocations[i];
  33212. stride += ai.attributeSize * 4;
  33213. }
  33214. for (var i = 0; i < offsetLocations.length; i++) {
  33215. var ai = offsetLocations[i];
  33216. if (!this._vertexAttribArraysEnabled[ai.index]) {
  33217. this._gl.enableVertexAttribArray(ai.index);
  33218. this._vertexAttribArraysEnabled[ai.index] = true;
  33219. }
  33220. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  33221. this._gl.vertexAttribDivisor(ai.index, 1);
  33222. this._currentInstanceLocations.push(ai.index);
  33223. this._currentInstanceBuffers.push(instancesBuffer);
  33224. }
  33225. }
  33226. else {
  33227. for (var index = 0; index < 4; index++) {
  33228. var offsetLocation = offsetLocations[index];
  33229. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  33230. this._gl.enableVertexAttribArray(offsetLocation);
  33231. this._vertexAttribArraysEnabled[offsetLocation] = true;
  33232. }
  33233. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  33234. this._gl.vertexAttribDivisor(offsetLocation, 1);
  33235. this._currentInstanceLocations.push(offsetLocation);
  33236. this._currentInstanceBuffers.push(instancesBuffer);
  33237. }
  33238. }
  33239. };
  33240. /**
  33241. * Apply all cached states (depth, culling, stencil and alpha)
  33242. */
  33243. Engine.prototype.applyStates = function () {
  33244. this._depthCullingState.apply(this._gl);
  33245. this._stencilState.apply(this._gl);
  33246. this._alphaState.apply(this._gl);
  33247. };
  33248. /**
  33249. * Send a draw order
  33250. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33251. * @param indexStart defines the starting index
  33252. * @param indexCount defines the number of index to draw
  33253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33254. */
  33255. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  33256. this.drawElementsType(useTriangles ? _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleFillMode : _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_WireFrameFillMode, indexStart, indexCount, instancesCount);
  33257. };
  33258. /**
  33259. * Draw a list of points
  33260. * @param verticesStart defines the index of first vertex to draw
  33261. * @param verticesCount defines the count of vertices to draw
  33262. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33263. */
  33264. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  33265. this.drawArraysType(_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_PointFillMode, verticesStart, verticesCount, instancesCount);
  33266. };
  33267. /**
  33268. * Draw a list of unindexed primitives
  33269. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33270. * @param verticesStart defines the index of first vertex to draw
  33271. * @param verticesCount defines the count of vertices to draw
  33272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33273. */
  33274. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  33275. this.drawArraysType(useTriangles ? _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleFillMode : _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  33276. };
  33277. /**
  33278. * Draw a list of indexed primitives
  33279. * @param fillMode defines the primitive to use
  33280. * @param indexStart defines the starting index
  33281. * @param indexCount defines the number of index to draw
  33282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33283. */
  33284. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  33285. // Apply states
  33286. this.applyStates();
  33287. this._drawCalls.addCount(1, false);
  33288. // Render
  33289. var drawMode = this._drawMode(fillMode);
  33290. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  33291. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  33292. if (instancesCount) {
  33293. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  33294. }
  33295. else {
  33296. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  33297. }
  33298. };
  33299. /**
  33300. * Draw a list of unindexed primitives
  33301. * @param fillMode defines the primitive to use
  33302. * @param verticesStart defines the index of first vertex to draw
  33303. * @param verticesCount defines the count of vertices to draw
  33304. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33305. */
  33306. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  33307. // Apply states
  33308. this.applyStates();
  33309. this._drawCalls.addCount(1, false);
  33310. var drawMode = this._drawMode(fillMode);
  33311. if (instancesCount) {
  33312. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  33313. }
  33314. else {
  33315. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  33316. }
  33317. };
  33318. Engine.prototype._drawMode = function (fillMode) {
  33319. switch (fillMode) {
  33320. // Triangle views
  33321. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleFillMode:
  33322. return this._gl.TRIANGLES;
  33323. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_PointFillMode:
  33324. return this._gl.POINTS;
  33325. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_WireFrameFillMode:
  33326. return this._gl.LINES;
  33327. // Draw modes
  33328. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_PointListDrawMode:
  33329. return this._gl.POINTS;
  33330. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LineListDrawMode:
  33331. return this._gl.LINES;
  33332. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LineLoopDrawMode:
  33333. return this._gl.LINE_LOOP;
  33334. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LineStripDrawMode:
  33335. return this._gl.LINE_STRIP;
  33336. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleStripDrawMode:
  33337. return this._gl.TRIANGLE_STRIP;
  33338. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleFanDrawMode:
  33339. return this._gl.TRIANGLE_FAN;
  33340. default:
  33341. return this._gl.TRIANGLES;
  33342. }
  33343. };
  33344. // Shaders
  33345. /** @hidden */
  33346. Engine.prototype._releaseEffect = function (effect) {
  33347. if (this._compiledEffects[effect._key]) {
  33348. delete this._compiledEffects[effect._key];
  33349. this._deletePipelineContext(effect.getPipelineContext());
  33350. }
  33351. };
  33352. /** @hidden */
  33353. Engine.prototype._deletePipelineContext = function (pipelineContext) {
  33354. var webGLPipelineContext = pipelineContext;
  33355. if (webGLPipelineContext && webGLPipelineContext.program) {
  33356. webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;
  33357. if (webGLPipelineContext.transformFeedback) {
  33358. this.deleteTransformFeedback(webGLPipelineContext.transformFeedback);
  33359. webGLPipelineContext.transformFeedback = null;
  33360. }
  33361. this._gl.deleteProgram(webGLPipelineContext.program);
  33362. }
  33363. };
  33364. /**
  33365. * Create a new effect (used to store vertex/fragment shaders)
  33366. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33367. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  33368. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33369. * @param samplers defines an array of string used to represent textures
  33370. * @param defines defines the string containing the defines to use to compile the shaders
  33371. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33372. * @param onCompiled defines a function to call when the effect creation is successful
  33373. * @param onError defines a function to call when the effect creation has failed
  33374. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33375. * @returns the new Effect
  33376. */
  33377. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  33378. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  33379. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  33380. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  33381. if (this._compiledEffects[name]) {
  33382. var compiledEffect = this._compiledEffects[name];
  33383. if (onCompiled && compiledEffect.isReady()) {
  33384. onCompiled(compiledEffect);
  33385. }
  33386. return compiledEffect;
  33387. }
  33388. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_4__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  33389. effect._key = name;
  33390. this._compiledEffects[name] = effect;
  33391. return effect;
  33392. };
  33393. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  33394. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  33395. };
  33396. Engine.prototype._compileRawShader = function (source, type) {
  33397. var gl = this._gl;
  33398. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  33399. if (!shader) {
  33400. throw new Error("Something went wrong while compile the shader.");
  33401. }
  33402. gl.shaderSource(shader, source);
  33403. gl.compileShader(shader);
  33404. return shader;
  33405. };
  33406. /**
  33407. * Directly creates a webGL program
  33408. * @param pipelineContext defines the pipeline context to attach to
  33409. * @param vertexCode defines the vertex shader code to use
  33410. * @param fragmentCode defines the fragment shader code to use
  33411. * @param context defines the webGL context to use (if not set, the current one will be used)
  33412. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33413. * @returns the new webGL program
  33414. */
  33415. Engine.prototype.createRawShaderProgram = function (pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  33416. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  33417. context = context || this._gl;
  33418. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  33419. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  33420. return this._createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
  33421. };
  33422. /**
  33423. * Creates a webGL program
  33424. * @param pipelineContext defines the pipeline context to attach to
  33425. * @param vertexCode defines the vertex shader code to use
  33426. * @param fragmentCode defines the fragment shader code to use
  33427. * @param defines defines the string containing the defines to use to compile the shaders
  33428. * @param context defines the webGL context to use (if not set, the current one will be used)
  33429. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33430. * @returns the new webGL program
  33431. */
  33432. Engine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  33433. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  33434. context = context || this._gl;
  33435. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  33436. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  33437. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  33438. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  33439. var program = this._createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
  33440. this.onAfterShaderCompilationObservable.notifyObservers(this);
  33441. return program;
  33442. };
  33443. /**
  33444. * Creates a new pipeline context
  33445. * @returns the new pipeline
  33446. */
  33447. Engine.prototype.createPipelineContext = function () {
  33448. var pipelineContext = new _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_13__["WebGLPipelineContext"]();
  33449. pipelineContext.engine = this;
  33450. if (this._caps.parallelShaderCompile) {
  33451. pipelineContext.isParallelCompiled = true;
  33452. }
  33453. return pipelineContext;
  33454. };
  33455. Engine.prototype._createShaderProgram = function (pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  33456. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  33457. var shaderProgram = context.createProgram();
  33458. pipelineContext.program = shaderProgram;
  33459. if (!shaderProgram) {
  33460. throw new Error("Unable to create program");
  33461. }
  33462. context.attachShader(shaderProgram, vertexShader);
  33463. context.attachShader(shaderProgram, fragmentShader);
  33464. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  33465. var transformFeedback = this.createTransformFeedback();
  33466. this.bindTransformFeedback(transformFeedback);
  33467. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  33468. pipelineContext.transformFeedback = transformFeedback;
  33469. }
  33470. context.linkProgram(shaderProgram);
  33471. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  33472. this.bindTransformFeedback(null);
  33473. }
  33474. pipelineContext.context = context;
  33475. pipelineContext.vertexShader = vertexShader;
  33476. pipelineContext.fragmentShader = fragmentShader;
  33477. if (!pipelineContext.isParallelCompiled) {
  33478. this._finalizePipelineContext(pipelineContext);
  33479. }
  33480. return shaderProgram;
  33481. };
  33482. Engine.prototype._finalizePipelineContext = function (pipelineContext) {
  33483. var context = pipelineContext.context;
  33484. var vertexShader = pipelineContext.vertexShader;
  33485. var fragmentShader = pipelineContext.fragmentShader;
  33486. var program = pipelineContext.program;
  33487. var linked = context.getProgramParameter(program, context.LINK_STATUS);
  33488. if (!linked) { // Get more info
  33489. // Vertex
  33490. if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {
  33491. var log = this._gl.getShaderInfoLog(vertexShader);
  33492. if (log) {
  33493. throw new Error(log);
  33494. }
  33495. }
  33496. // Fragment
  33497. if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {
  33498. var log = this._gl.getShaderInfoLog(fragmentShader);
  33499. if (log) {
  33500. throw new Error(log);
  33501. }
  33502. }
  33503. var error = context.getProgramInfoLog(program);
  33504. if (error) {
  33505. throw new Error(error);
  33506. }
  33507. }
  33508. if (this.validateShaderPrograms) {
  33509. context.validateProgram(program);
  33510. var validated = context.getProgramParameter(program, context.VALIDATE_STATUS);
  33511. if (!validated) {
  33512. var error = context.getProgramInfoLog(program);
  33513. if (error) {
  33514. throw new Error(error);
  33515. }
  33516. }
  33517. }
  33518. context.deleteShader(vertexShader);
  33519. context.deleteShader(fragmentShader);
  33520. pipelineContext.vertexShader = undefined;
  33521. pipelineContext.fragmentShader = undefined;
  33522. if (pipelineContext.onCompiled) {
  33523. pipelineContext.onCompiled();
  33524. pipelineContext.onCompiled = undefined;
  33525. }
  33526. };
  33527. /** @hidden */
  33528. Engine.prototype._preparePipelineContext = function (pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rebuildRebind, defines, transformFeedbackVaryings) {
  33529. var webGLRenderingState = pipelineContext;
  33530. if (createAsRaw) {
  33531. webGLRenderingState.program = this.createRawShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, undefined, transformFeedbackVaryings);
  33532. }
  33533. else {
  33534. webGLRenderingState.program = this.createShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, defines, undefined, transformFeedbackVaryings);
  33535. }
  33536. webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;
  33537. };
  33538. /** @hidden */
  33539. Engine.prototype._isRenderingStateCompiled = function (pipelineContext) {
  33540. var webGLPipelineContext = pipelineContext;
  33541. if (this._gl.getProgramParameter(webGLPipelineContext.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  33542. this._finalizePipelineContext(webGLPipelineContext);
  33543. return true;
  33544. }
  33545. return false;
  33546. };
  33547. /** @hidden */
  33548. Engine.prototype._executeWhenRenderingStateIsCompiled = function (pipelineContext, action) {
  33549. var webGLPipelineContext = pipelineContext;
  33550. if (!webGLPipelineContext.isParallelCompiled) {
  33551. action();
  33552. return;
  33553. }
  33554. webGLPipelineContext.onCompiled = action;
  33555. };
  33556. /**
  33557. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33558. * @param pipelineContext defines the pipeline context to use
  33559. * @param uniformsNames defines the list of uniform names
  33560. * @returns an array of webGL uniform locations
  33561. */
  33562. Engine.prototype.getUniforms = function (pipelineContext, uniformsNames) {
  33563. var results = new Array();
  33564. var webGLPipelineContext = pipelineContext;
  33565. for (var index = 0; index < uniformsNames.length; index++) {
  33566. results.push(this._gl.getUniformLocation(webGLPipelineContext.program, uniformsNames[index]));
  33567. }
  33568. return results;
  33569. };
  33570. /**
  33571. * Gets the lsit of active attributes for a given webGL program
  33572. * @param pipelineContext defines the pipeline context to use
  33573. * @param attributesNames defines the list of attribute names to get
  33574. * @returns an array of indices indicating the offset of each attribute
  33575. */
  33576. Engine.prototype.getAttributes = function (pipelineContext, attributesNames) {
  33577. var results = [];
  33578. var webGLPipelineContext = pipelineContext;
  33579. for (var index = 0; index < attributesNames.length; index++) {
  33580. try {
  33581. results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));
  33582. }
  33583. catch (e) {
  33584. results.push(-1);
  33585. }
  33586. }
  33587. return results;
  33588. };
  33589. /**
  33590. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33591. * @param effect defines the effect to activate
  33592. */
  33593. Engine.prototype.enableEffect = function (effect) {
  33594. if (!effect || effect === this._currentEffect) {
  33595. return;
  33596. }
  33597. // Use program
  33598. this.bindSamplers(effect);
  33599. this._currentEffect = effect;
  33600. if (effect.onBind) {
  33601. effect.onBind(effect);
  33602. }
  33603. if (effect._onBindObservable) {
  33604. effect._onBindObservable.notifyObservers(effect);
  33605. }
  33606. };
  33607. /**
  33608. * Set the value of an uniform to an array of int32
  33609. * @param uniform defines the webGL uniform location where to store the value
  33610. * @param array defines the array of int32 to store
  33611. */
  33612. Engine.prototype.setIntArray = function (uniform, array) {
  33613. if (!uniform) {
  33614. return;
  33615. }
  33616. this._gl.uniform1iv(uniform, array);
  33617. };
  33618. /**
  33619. * Set the value of an uniform to an array of int32 (stored as vec2)
  33620. * @param uniform defines the webGL uniform location where to store the value
  33621. * @param array defines the array of int32 to store
  33622. */
  33623. Engine.prototype.setIntArray2 = function (uniform, array) {
  33624. if (!uniform || array.length % 2 !== 0) {
  33625. return;
  33626. }
  33627. this._gl.uniform2iv(uniform, array);
  33628. };
  33629. /**
  33630. * Set the value of an uniform to an array of int32 (stored as vec3)
  33631. * @param uniform defines the webGL uniform location where to store the value
  33632. * @param array defines the array of int32 to store
  33633. */
  33634. Engine.prototype.setIntArray3 = function (uniform, array) {
  33635. if (!uniform || array.length % 3 !== 0) {
  33636. return;
  33637. }
  33638. this._gl.uniform3iv(uniform, array);
  33639. };
  33640. /**
  33641. * Set the value of an uniform to an array of int32 (stored as vec4)
  33642. * @param uniform defines the webGL uniform location where to store the value
  33643. * @param array defines the array of int32 to store
  33644. */
  33645. Engine.prototype.setIntArray4 = function (uniform, array) {
  33646. if (!uniform || array.length % 4 !== 0) {
  33647. return;
  33648. }
  33649. this._gl.uniform4iv(uniform, array);
  33650. };
  33651. /**
  33652. * Set the value of an uniform to an array of float32
  33653. * @param uniform defines the webGL uniform location where to store the value
  33654. * @param array defines the array of float32 to store
  33655. */
  33656. Engine.prototype.setFloatArray = function (uniform, array) {
  33657. if (!uniform) {
  33658. return;
  33659. }
  33660. this._gl.uniform1fv(uniform, array);
  33661. };
  33662. /**
  33663. * Set the value of an uniform to an array of float32 (stored as vec2)
  33664. * @param uniform defines the webGL uniform location where to store the value
  33665. * @param array defines the array of float32 to store
  33666. */
  33667. Engine.prototype.setFloatArray2 = function (uniform, array) {
  33668. if (!uniform || array.length % 2 !== 0) {
  33669. return;
  33670. }
  33671. this._gl.uniform2fv(uniform, array);
  33672. };
  33673. /**
  33674. * Set the value of an uniform to an array of float32 (stored as vec3)
  33675. * @param uniform defines the webGL uniform location where to store the value
  33676. * @param array defines the array of float32 to store
  33677. */
  33678. Engine.prototype.setFloatArray3 = function (uniform, array) {
  33679. if (!uniform || array.length % 3 !== 0) {
  33680. return;
  33681. }
  33682. this._gl.uniform3fv(uniform, array);
  33683. };
  33684. /**
  33685. * Set the value of an uniform to an array of float32 (stored as vec4)
  33686. * @param uniform defines the webGL uniform location where to store the value
  33687. * @param array defines the array of float32 to store
  33688. */
  33689. Engine.prototype.setFloatArray4 = function (uniform, array) {
  33690. if (!uniform || array.length % 4 !== 0) {
  33691. return;
  33692. }
  33693. this._gl.uniform4fv(uniform, array);
  33694. };
  33695. /**
  33696. * Set the value of an uniform to an array of number
  33697. * @param uniform defines the webGL uniform location where to store the value
  33698. * @param array defines the array of number to store
  33699. */
  33700. Engine.prototype.setArray = function (uniform, array) {
  33701. if (!uniform) {
  33702. return;
  33703. }
  33704. this._gl.uniform1fv(uniform, array);
  33705. };
  33706. /**
  33707. * Set the value of an uniform to an array of number (stored as vec2)
  33708. * @param uniform defines the webGL uniform location where to store the value
  33709. * @param array defines the array of number to store
  33710. */
  33711. Engine.prototype.setArray2 = function (uniform, array) {
  33712. if (!uniform || array.length % 2 !== 0) {
  33713. return;
  33714. }
  33715. this._gl.uniform2fv(uniform, array);
  33716. };
  33717. /**
  33718. * Set the value of an uniform to an array of number (stored as vec3)
  33719. * @param uniform defines the webGL uniform location where to store the value
  33720. * @param array defines the array of number to store
  33721. */
  33722. Engine.prototype.setArray3 = function (uniform, array) {
  33723. if (!uniform || array.length % 3 !== 0) {
  33724. return;
  33725. }
  33726. this._gl.uniform3fv(uniform, array);
  33727. };
  33728. /**
  33729. * Set the value of an uniform to an array of number (stored as vec4)
  33730. * @param uniform defines the webGL uniform location where to store the value
  33731. * @param array defines the array of number to store
  33732. */
  33733. Engine.prototype.setArray4 = function (uniform, array) {
  33734. if (!uniform || array.length % 4 !== 0) {
  33735. return;
  33736. }
  33737. this._gl.uniform4fv(uniform, array);
  33738. };
  33739. /**
  33740. * Set the value of an uniform to an array of float32 (stored as matrices)
  33741. * @param uniform defines the webGL uniform location where to store the value
  33742. * @param matrices defines the array of float32 to store
  33743. */
  33744. Engine.prototype.setMatrices = function (uniform, matrices) {
  33745. if (!uniform) {
  33746. return;
  33747. }
  33748. this._gl.uniformMatrix4fv(uniform, false, matrices);
  33749. };
  33750. /**
  33751. * Set the value of an uniform to a matrix (3x3)
  33752. * @param uniform defines the webGL uniform location where to store the value
  33753. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33754. */
  33755. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  33756. if (!uniform) {
  33757. return;
  33758. }
  33759. this._gl.uniformMatrix3fv(uniform, false, matrix);
  33760. };
  33761. /**
  33762. * Set the value of an uniform to a matrix (2x2)
  33763. * @param uniform defines the webGL uniform location where to store the value
  33764. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33765. */
  33766. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  33767. if (!uniform) {
  33768. return;
  33769. }
  33770. this._gl.uniformMatrix2fv(uniform, false, matrix);
  33771. };
  33772. /**
  33773. * Set the value of an uniform to a number (int)
  33774. * @param uniform defines the webGL uniform location where to store the value
  33775. * @param value defines the int number to store
  33776. */
  33777. Engine.prototype.setInt = function (uniform, value) {
  33778. if (!uniform) {
  33779. return;
  33780. }
  33781. this._gl.uniform1i(uniform, value);
  33782. };
  33783. /**
  33784. * Set the value of an uniform to a number (float)
  33785. * @param uniform defines the webGL uniform location where to store the value
  33786. * @param value defines the float number to store
  33787. */
  33788. Engine.prototype.setFloat = function (uniform, value) {
  33789. if (!uniform) {
  33790. return;
  33791. }
  33792. this._gl.uniform1f(uniform, value);
  33793. };
  33794. /**
  33795. * Set the value of an uniform to a vec2
  33796. * @param uniform defines the webGL uniform location where to store the value
  33797. * @param x defines the 1st component of the value
  33798. * @param y defines the 2nd component of the value
  33799. */
  33800. Engine.prototype.setFloat2 = function (uniform, x, y) {
  33801. if (!uniform) {
  33802. return;
  33803. }
  33804. this._gl.uniform2f(uniform, x, y);
  33805. };
  33806. /**
  33807. * Set the value of an uniform to a vec3
  33808. * @param uniform defines the webGL uniform location where to store the value
  33809. * @param x defines the 1st component of the value
  33810. * @param y defines the 2nd component of the value
  33811. * @param z defines the 3rd component of the value
  33812. */
  33813. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  33814. if (!uniform) {
  33815. return;
  33816. }
  33817. this._gl.uniform3f(uniform, x, y, z);
  33818. };
  33819. /**
  33820. * Set the value of an uniform to a boolean
  33821. * @param uniform defines the webGL uniform location where to store the value
  33822. * @param bool defines the boolean to store
  33823. */
  33824. Engine.prototype.setBool = function (uniform, bool) {
  33825. if (!uniform) {
  33826. return;
  33827. }
  33828. this._gl.uniform1i(uniform, bool);
  33829. };
  33830. /**
  33831. * Set the value of an uniform to a vec4
  33832. * @param uniform defines the webGL uniform location where to store the value
  33833. * @param x defines the 1st component of the value
  33834. * @param y defines the 2nd component of the value
  33835. * @param z defines the 3rd component of the value
  33836. * @param w defines the 4th component of the value
  33837. */
  33838. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  33839. if (!uniform) {
  33840. return;
  33841. }
  33842. this._gl.uniform4f(uniform, x, y, z, w);
  33843. };
  33844. /**
  33845. * Sets a Color4 on a uniform variable
  33846. * @param uniform defines the uniform location
  33847. * @param color4 defines the value to be set
  33848. */
  33849. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  33850. if (!uniform) {
  33851. return;
  33852. }
  33853. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  33854. };
  33855. // States
  33856. /**
  33857. * Set various states to the webGL context
  33858. * @param culling defines backface culling state
  33859. * @param zOffset defines the value to apply to zOffset (0 by default)
  33860. * @param force defines if states must be applied even if cache is up to date
  33861. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33862. */
  33863. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  33864. if (zOffset === void 0) { zOffset = 0; }
  33865. if (reverseSide === void 0) { reverseSide = false; }
  33866. // Culling
  33867. if (this._depthCullingState.cull !== culling || force) {
  33868. this._depthCullingState.cull = culling;
  33869. }
  33870. // Cull face
  33871. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  33872. if (this._depthCullingState.cullFace !== cullFace || force) {
  33873. this._depthCullingState.cullFace = cullFace;
  33874. }
  33875. // Z offset
  33876. this.setZOffset(zOffset);
  33877. // Front face
  33878. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  33879. if (this._depthCullingState.frontFace !== frontFace || force) {
  33880. this._depthCullingState.frontFace = frontFace;
  33881. }
  33882. };
  33883. /**
  33884. * Set the z offset to apply to current rendering
  33885. * @param value defines the offset to apply
  33886. */
  33887. Engine.prototype.setZOffset = function (value) {
  33888. this._depthCullingState.zOffset = value;
  33889. };
  33890. /**
  33891. * Gets the current value of the zOffset
  33892. * @returns the current zOffset state
  33893. */
  33894. Engine.prototype.getZOffset = function () {
  33895. return this._depthCullingState.zOffset;
  33896. };
  33897. /**
  33898. * Enable or disable depth buffering
  33899. * @param enable defines the state to set
  33900. */
  33901. Engine.prototype.setDepthBuffer = function (enable) {
  33902. this._depthCullingState.depthTest = enable;
  33903. };
  33904. /**
  33905. * Gets a boolean indicating if depth writing is enabled
  33906. * @returns the current depth writing state
  33907. */
  33908. Engine.prototype.getDepthWrite = function () {
  33909. return this._depthCullingState.depthMask;
  33910. };
  33911. /**
  33912. * Enable or disable depth writing
  33913. * @param enable defines the state to set
  33914. */
  33915. Engine.prototype.setDepthWrite = function (enable) {
  33916. this._depthCullingState.depthMask = enable;
  33917. };
  33918. /**
  33919. * Enable or disable color writing
  33920. * @param enable defines the state to set
  33921. */
  33922. Engine.prototype.setColorWrite = function (enable) {
  33923. this._gl.colorMask(enable, enable, enable, enable);
  33924. this._colorWrite = enable;
  33925. };
  33926. /**
  33927. * Gets a boolean indicating if color writing is enabled
  33928. * @returns the current color writing state
  33929. */
  33930. Engine.prototype.getColorWrite = function () {
  33931. return this._colorWrite;
  33932. };
  33933. /**
  33934. * Sets alpha constants used by some alpha blending modes
  33935. * @param r defines the red component
  33936. * @param g defines the green component
  33937. * @param b defines the blue component
  33938. * @param a defines the alpha component
  33939. */
  33940. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  33941. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  33942. };
  33943. /**
  33944. * Sets the current alpha mode
  33945. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33946. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33947. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33948. */
  33949. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  33950. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  33951. if (this._alphaMode === mode) {
  33952. return;
  33953. }
  33954. switch (mode) {
  33955. case Engine.ALPHA_DISABLE:
  33956. this._alphaState.alphaBlend = false;
  33957. break;
  33958. case Engine.ALPHA_PREMULTIPLIED:
  33959. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  33960. this._alphaState.alphaBlend = true;
  33961. break;
  33962. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  33963. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  33964. this._alphaState.alphaBlend = true;
  33965. break;
  33966. case Engine.ALPHA_COMBINE:
  33967. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  33968. this._alphaState.alphaBlend = true;
  33969. break;
  33970. case Engine.ALPHA_ONEONE:
  33971. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  33972. this._alphaState.alphaBlend = true;
  33973. break;
  33974. case Engine.ALPHA_ADD:
  33975. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  33976. this._alphaState.alphaBlend = true;
  33977. break;
  33978. case Engine.ALPHA_SUBTRACT:
  33979. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  33980. this._alphaState.alphaBlend = true;
  33981. break;
  33982. case Engine.ALPHA_MULTIPLY:
  33983. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  33984. this._alphaState.alphaBlend = true;
  33985. break;
  33986. case Engine.ALPHA_MAXIMIZED:
  33987. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  33988. this._alphaState.alphaBlend = true;
  33989. break;
  33990. case Engine.ALPHA_INTERPOLATE:
  33991. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  33992. this._alphaState.alphaBlend = true;
  33993. break;
  33994. case Engine.ALPHA_SCREENMODE:
  33995. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  33996. this._alphaState.alphaBlend = true;
  33997. break;
  33998. }
  33999. if (!noDepthWriteChange) {
  34000. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  34001. }
  34002. this._alphaMode = mode;
  34003. };
  34004. /**
  34005. * Gets the current alpha mode
  34006. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34007. * @returns the current alpha mode
  34008. */
  34009. Engine.prototype.getAlphaMode = function () {
  34010. return this._alphaMode;
  34011. };
  34012. // Textures
  34013. /**
  34014. * Clears the list of texture accessible through engine.
  34015. * This can help preventing texture load conflict due to name collision.
  34016. */
  34017. Engine.prototype.clearInternalTexturesCache = function () {
  34018. this._internalTexturesCache = [];
  34019. };
  34020. /**
  34021. * Force the entire cache to be cleared
  34022. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34023. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34024. */
  34025. Engine.prototype.wipeCaches = function (bruteForce) {
  34026. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  34027. return;
  34028. }
  34029. this._currentEffect = null;
  34030. this._viewportCached.x = 0;
  34031. this._viewportCached.y = 0;
  34032. this._viewportCached.z = 0;
  34033. this._viewportCached.w = 0;
  34034. if (bruteForce) {
  34035. this.resetTextureCache();
  34036. this._currentProgram = null;
  34037. this._stencilState.reset();
  34038. this._depthCullingState.reset();
  34039. this.setDepthFunctionToLessOrEqual();
  34040. this._alphaState.reset();
  34041. this._unpackFlipYCached = null;
  34042. }
  34043. this._resetVertexBufferBinding();
  34044. this._cachedIndexBuffer = null;
  34045. this._cachedEffectForVertexBuffers = null;
  34046. this._unbindVertexArrayObject();
  34047. this.bindIndexBuffer(null);
  34048. };
  34049. /**
  34050. * Set the compressed texture format to use, based on the formats you have, and the formats
  34051. * supported by the hardware / browser.
  34052. *
  34053. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34054. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34055. * to API arguments needed to compressed textures. This puts the burden on the container
  34056. * generator to house the arcane code for determining these for current & future formats.
  34057. *
  34058. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34059. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34060. *
  34061. * Note: The result of this call is not taken into account when a texture is base64.
  34062. *
  34063. * @param formatsAvailable defines the list of those format families you have created
  34064. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34065. *
  34066. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34067. * @returns The extension selected.
  34068. */
  34069. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  34070. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  34071. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  34072. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  34073. return this._textureFormatInUse = this._texturesSupported[i];
  34074. }
  34075. }
  34076. }
  34077. // actively set format to nothing, to allow this to be called more than once
  34078. // and possibly fail the 2nd time
  34079. this._textureFormatInUse = null;
  34080. return null;
  34081. };
  34082. /** @hidden */
  34083. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  34084. var gl = this._gl;
  34085. var magFilter = gl.NEAREST;
  34086. var minFilter = gl.NEAREST;
  34087. switch (samplingMode) {
  34088. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  34089. magFilter = gl.LINEAR;
  34090. if (generateMipMaps) {
  34091. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  34092. }
  34093. else {
  34094. minFilter = gl.LINEAR;
  34095. }
  34096. break;
  34097. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  34098. magFilter = gl.LINEAR;
  34099. if (generateMipMaps) {
  34100. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  34101. }
  34102. else {
  34103. minFilter = gl.LINEAR;
  34104. }
  34105. break;
  34106. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  34107. magFilter = gl.NEAREST;
  34108. if (generateMipMaps) {
  34109. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  34110. }
  34111. else {
  34112. minFilter = gl.NEAREST;
  34113. }
  34114. break;
  34115. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  34116. magFilter = gl.NEAREST;
  34117. if (generateMipMaps) {
  34118. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  34119. }
  34120. else {
  34121. minFilter = gl.NEAREST;
  34122. }
  34123. break;
  34124. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  34125. magFilter = gl.NEAREST;
  34126. if (generateMipMaps) {
  34127. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  34128. }
  34129. else {
  34130. minFilter = gl.LINEAR;
  34131. }
  34132. break;
  34133. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  34134. magFilter = gl.NEAREST;
  34135. if (generateMipMaps) {
  34136. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  34137. }
  34138. else {
  34139. minFilter = gl.LINEAR;
  34140. }
  34141. break;
  34142. case Engine.TEXTURE_NEAREST_LINEAR:
  34143. magFilter = gl.NEAREST;
  34144. minFilter = gl.LINEAR;
  34145. break;
  34146. case Engine.TEXTURE_NEAREST_NEAREST:
  34147. magFilter = gl.NEAREST;
  34148. minFilter = gl.NEAREST;
  34149. break;
  34150. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  34151. magFilter = gl.LINEAR;
  34152. if (generateMipMaps) {
  34153. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  34154. }
  34155. else {
  34156. minFilter = gl.NEAREST;
  34157. }
  34158. break;
  34159. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  34160. magFilter = gl.LINEAR;
  34161. if (generateMipMaps) {
  34162. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  34163. }
  34164. else {
  34165. minFilter = gl.NEAREST;
  34166. }
  34167. break;
  34168. case Engine.TEXTURE_LINEAR_LINEAR:
  34169. magFilter = gl.LINEAR;
  34170. minFilter = gl.LINEAR;
  34171. break;
  34172. case Engine.TEXTURE_LINEAR_NEAREST:
  34173. magFilter = gl.LINEAR;
  34174. minFilter = gl.NEAREST;
  34175. break;
  34176. }
  34177. return {
  34178. min: minFilter,
  34179. mag: magFilter
  34180. };
  34181. };
  34182. /** @hidden */
  34183. Engine.prototype._createTexture = function () {
  34184. var texture = this._gl.createTexture();
  34185. if (!texture) {
  34186. throw new Error("Unable to create texture");
  34187. }
  34188. return texture;
  34189. };
  34190. /**
  34191. * Usually called from Texture.ts.
  34192. * Passed information to create a WebGLTexture
  34193. * @param urlArg defines a value which contains one of the following:
  34194. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34195. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34196. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34197. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34198. * @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)
  34199. * @param scene needed for loading to the correct scene
  34200. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34201. * @param onLoad optional callback to be called upon successful completion
  34202. * @param onError optional callback to be called upon failure
  34203. * @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
  34204. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34205. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34206. * @param forcedExtension defines the extension to use to pick the right loader
  34207. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  34208. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34209. */
  34210. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  34211. var _this = this;
  34212. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34213. if (onLoad === void 0) { onLoad = null; }
  34214. if (onError === void 0) { onError = null; }
  34215. if (buffer === void 0) { buffer = null; }
  34216. if (fallback === void 0) { fallback = null; }
  34217. if (format === void 0) { format = null; }
  34218. if (forcedExtension === void 0) { forcedExtension = null; }
  34219. if (excludeLoaders === void 0) { excludeLoaders = []; }
  34220. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  34221. var fromData = url.substr(0, 5) === "data:";
  34222. var fromBlob = url.substr(0, 5) === "blob:";
  34223. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  34224. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"].DATASOURCE_URL);
  34225. // establish the file extension, if possible
  34226. var lastDot = url.lastIndexOf('.');
  34227. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  34228. var loader = null;
  34229. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  34230. var availableLoader = _a[_i];
  34231. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  34232. loader = availableLoader;
  34233. break;
  34234. }
  34235. }
  34236. if (loader) {
  34237. url = loader.transformUrl(url, this._textureFormatInUse);
  34238. }
  34239. if (scene) {
  34240. scene._addPendingData(texture);
  34241. }
  34242. texture.url = url;
  34243. texture.generateMipMaps = !noMipmap;
  34244. texture.samplingMode = samplingMode;
  34245. texture.invertY = invertY;
  34246. if (!this._doNotHandleContextLost) {
  34247. // Keep a link to the buffer only if we plan to handle context lost
  34248. texture._buffer = buffer;
  34249. }
  34250. var onLoadObserver = null;
  34251. if (onLoad && !fallback) {
  34252. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  34253. }
  34254. if (!fallback) {
  34255. this._internalTexturesCache.push(texture);
  34256. }
  34257. var onInternalError = function (message, exception) {
  34258. if (scene) {
  34259. scene._removePendingData(texture);
  34260. }
  34261. var customFallback = false;
  34262. if (loader) {
  34263. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  34264. if (fallbackUrl) {
  34265. // Add Back
  34266. customFallback = true;
  34267. excludeLoaders.push(loader);
  34268. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, onError, buffer, texture, undefined, undefined, excludeLoaders);
  34269. return;
  34270. }
  34271. }
  34272. if (!customFallback) {
  34273. if (onLoadObserver) {
  34274. texture.onLoadedObservable.remove(onLoadObserver);
  34275. }
  34276. if (_engineStore__WEBPACK_IMPORTED_MODULE_10__["EngineStore"].UseFallbackTexture) {
  34277. _this.createTexture(_engineStore__WEBPACK_IMPORTED_MODULE_10__["EngineStore"].FallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, onError, buffer, texture);
  34278. return;
  34279. }
  34280. }
  34281. if (onError) {
  34282. onError(message || "Unknown error", exception);
  34283. }
  34284. };
  34285. // processing for non-image formats
  34286. if (loader) {
  34287. var callback = function (data) {
  34288. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  34289. if (loadFailed) {
  34290. onInternalError("TextureLoader failed to load data");
  34291. }
  34292. else {
  34293. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  34294. done();
  34295. return false;
  34296. }, samplingMode);
  34297. }
  34298. });
  34299. };
  34300. if (!buffer) {
  34301. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  34302. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  34303. });
  34304. }
  34305. else {
  34306. callback(buffer);
  34307. }
  34308. }
  34309. else {
  34310. var onload = function (img) {
  34311. if (fromBlob && !_this._doNotHandleContextLost) {
  34312. // We need to store the image if we need to rebuild the texture
  34313. // in case of a webgl context lost
  34314. texture._buffer = img;
  34315. }
  34316. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  34317. var gl = _this._gl;
  34318. var isPot = (img.width === potWidth && img.height === potHeight);
  34319. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  34320. if (isPot) {
  34321. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  34322. return false;
  34323. }
  34324. var maxTextureSize = _this._caps.maxTextureSize;
  34325. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  34326. _this._prepareWorkingCanvas();
  34327. if (!_this._workingCanvas || !_this._workingContext) {
  34328. return false;
  34329. }
  34330. _this._workingCanvas.width = potWidth;
  34331. _this._workingCanvas.height = potHeight;
  34332. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  34333. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  34334. texture.width = potWidth;
  34335. texture.height = potHeight;
  34336. return false;
  34337. }
  34338. else {
  34339. // Using shaders when possible to rescale because canvas.drawImage is lossy
  34340. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"].DATASOURCE_TEMP);
  34341. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  34342. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  34343. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  34344. _this._releaseTexture(source_1);
  34345. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  34346. continuationCallback();
  34347. });
  34348. }
  34349. return true;
  34350. }, samplingMode);
  34351. };
  34352. if (!fromData || isBase64) {
  34353. if (buffer instanceof HTMLImageElement) {
  34354. onload(buffer);
  34355. }
  34356. else {
  34357. _Misc_fileTools__WEBPACK_IMPORTED_MODULE_17__["FileTools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  34358. }
  34359. }
  34360. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  34361. _Misc_fileTools__WEBPACK_IMPORTED_MODULE_17__["FileTools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  34362. }
  34363. else {
  34364. onload(buffer);
  34365. }
  34366. }
  34367. return texture;
  34368. };
  34369. /**
  34370. * @hidden
  34371. * Rescales a texture
  34372. * @param source input texutre
  34373. * @param destination destination texture
  34374. * @param scene scene to use to render the resize
  34375. * @param internalFormat format to use when resizing
  34376. * @param onComplete callback to be called when resize has completed
  34377. */
  34378. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  34379. var _this = this;
  34380. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR);
  34381. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR);
  34382. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE);
  34383. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
  34384. var rtt = this.createRenderTargetTexture({
  34385. width: destination.width,
  34386. height: destination.height,
  34387. }, {
  34388. generateMipMaps: false,
  34389. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  34390. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  34391. generateDepthBuffer: false,
  34392. generateStencilBuffer: false
  34393. });
  34394. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  34395. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  34396. }
  34397. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  34398. _this._rescalePostProcess.onApply = function (effect) {
  34399. effect._bindTexture("textureSampler", source);
  34400. };
  34401. var hostingScene = scene;
  34402. if (!hostingScene) {
  34403. hostingScene = _this.scenes[_this.scenes.length - 1];
  34404. }
  34405. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  34406. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  34407. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  34408. _this.unBindFramebuffer(rtt);
  34409. _this._releaseTexture(rtt);
  34410. if (onComplete) {
  34411. onComplete();
  34412. }
  34413. });
  34414. };
  34415. /**
  34416. * Creates a raw texture
  34417. * @param data defines the data to store in the texture
  34418. * @param width defines the width of the texture
  34419. * @param height defines the height of the texture
  34420. * @param format defines the format of the data
  34421. * @param generateMipMaps defines if the engine should generate the mip levels
  34422. * @param invertY defines if data must be stored with Y axis inverted
  34423. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34424. * @param compression defines the compression used (null by default)
  34425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  34426. * @returns the raw texture inside an InternalTexture
  34427. */
  34428. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  34429. if (compression === void 0) { compression = null; }
  34430. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  34431. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("Engine.RawTexture");
  34432. };
  34433. /** @hidden */
  34434. Engine.prototype._unpackFlipY = function (value) {
  34435. if (this._unpackFlipYCached !== value) {
  34436. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  34437. if (this.enableUnpackFlipYCached) {
  34438. this._unpackFlipYCached = value;
  34439. }
  34440. }
  34441. };
  34442. /** @hidden */
  34443. Engine.prototype._getUnpackAlignement = function () {
  34444. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  34445. };
  34446. /**
  34447. * Creates a dynamic texture
  34448. * @param width defines the width of the texture
  34449. * @param height defines the height of the texture
  34450. * @param generateMipMaps defines if the engine should generate the mip levels
  34451. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34452. * @returns the dynamic texture inside an InternalTexture
  34453. */
  34454. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  34455. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"].DATASOURCE_DYNAMIC);
  34456. texture.baseWidth = width;
  34457. texture.baseHeight = height;
  34458. if (generateMipMaps) {
  34459. width = this.needPOTTextures ? Engine.GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  34460. height = this.needPOTTextures ? Engine.GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  34461. }
  34462. // this.resetTextureCache();
  34463. texture.width = width;
  34464. texture.height = height;
  34465. texture.isReady = false;
  34466. texture.generateMipMaps = generateMipMaps;
  34467. texture.samplingMode = samplingMode;
  34468. this.updateTextureSamplingMode(samplingMode, texture);
  34469. this._internalTexturesCache.push(texture);
  34470. return texture;
  34471. };
  34472. /**
  34473. * Update the sampling mode of a given texture
  34474. * @param samplingMode defines the required sampling mode
  34475. * @param texture defines the texture to update
  34476. */
  34477. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34478. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  34479. if (texture.isCube) {
  34480. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  34481. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  34482. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  34483. }
  34484. else if (texture.is3D) {
  34485. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  34486. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  34487. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  34488. }
  34489. else {
  34490. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  34491. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  34492. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  34493. }
  34494. texture.samplingMode = samplingMode;
  34495. };
  34496. /**
  34497. * Update the content of a dynamic texture
  34498. * @param texture defines the texture to update
  34499. * @param canvas defines the canvas containing the source
  34500. * @param invertY defines if data must be stored with Y axis inverted
  34501. * @param premulAlpha defines if alpha is stored as premultiplied
  34502. * @param format defines the format of the data
  34503. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34504. */
  34505. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  34506. if (premulAlpha === void 0) { premulAlpha = false; }
  34507. if (forceBindTexture === void 0) { forceBindTexture = false; }
  34508. if (!texture) {
  34509. return;
  34510. }
  34511. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  34512. this._unpackFlipY(invertY);
  34513. if (premulAlpha) {
  34514. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  34515. }
  34516. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  34517. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  34518. if (texture.generateMipMaps) {
  34519. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  34520. }
  34521. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  34522. if (premulAlpha) {
  34523. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  34524. }
  34525. texture.isReady = true;
  34526. };
  34527. /**
  34528. * Update a video texture
  34529. * @param texture defines the texture to update
  34530. * @param video defines the video element to use
  34531. * @param invertY defines if data must be stored with Y axis inverted
  34532. */
  34533. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  34534. if (!texture || texture._isDisabled) {
  34535. return;
  34536. }
  34537. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  34538. this._unpackFlipY(!invertY); // Video are upside down by default
  34539. try {
  34540. // Testing video texture support
  34541. if (this._videoTextureSupported === undefined) {
  34542. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  34543. if (this._gl.getError() !== 0) {
  34544. this._videoTextureSupported = false;
  34545. }
  34546. else {
  34547. this._videoTextureSupported = true;
  34548. }
  34549. }
  34550. // Copy video through the current working canvas if video texture is not supported
  34551. if (!this._videoTextureSupported) {
  34552. if (!texture._workingCanvas) {
  34553. texture._workingCanvas = document.createElement("canvas");
  34554. var context = texture._workingCanvas.getContext("2d");
  34555. if (!context) {
  34556. throw new Error("Unable to get 2d context");
  34557. }
  34558. texture._workingContext = context;
  34559. texture._workingCanvas.width = texture.width;
  34560. texture._workingCanvas.height = texture.height;
  34561. }
  34562. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  34563. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  34564. }
  34565. else {
  34566. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  34567. }
  34568. if (texture.generateMipMaps) {
  34569. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  34570. }
  34571. if (!wasPreviouslyBound) {
  34572. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  34573. }
  34574. // this.resetTextureCache();
  34575. texture.isReady = true;
  34576. }
  34577. catch (ex) {
  34578. // Something unexpected
  34579. // Let's disable the texture
  34580. texture._isDisabled = true;
  34581. }
  34582. };
  34583. /**
  34584. * Updates a depth texture Comparison Mode and Function.
  34585. * If the comparison Function is equal to 0, the mode will be set to none.
  34586. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34587. * @param texture The texture to set the comparison function for
  34588. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34589. */
  34590. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  34591. if (this.webGLVersion === 1) {
  34592. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error("WebGL 1 does not support texture comparison.");
  34593. return;
  34594. }
  34595. var gl = this._gl;
  34596. if (texture.isCube) {
  34597. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  34598. if (comparisonFunction === 0) {
  34599. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  34600. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  34601. }
  34602. else {
  34603. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  34604. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  34605. }
  34606. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  34607. }
  34608. else {
  34609. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  34610. if (comparisonFunction === 0) {
  34611. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  34612. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  34613. }
  34614. else {
  34615. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  34616. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  34617. }
  34618. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  34619. }
  34620. texture._comparisonFunction = comparisonFunction;
  34621. };
  34622. /** @hidden */
  34623. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  34624. var width = size.width || size;
  34625. var height = size.height || size;
  34626. internalTexture.baseWidth = width;
  34627. internalTexture.baseHeight = height;
  34628. internalTexture.width = width;
  34629. internalTexture.height = height;
  34630. internalTexture.isReady = true;
  34631. internalTexture.samples = 1;
  34632. internalTexture.generateMipMaps = false;
  34633. internalTexture._generateDepthBuffer = true;
  34634. internalTexture._generateStencilBuffer = generateStencil;
  34635. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  34636. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  34637. internalTexture._comparisonFunction = comparisonFunction;
  34638. var gl = this._gl;
  34639. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  34640. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  34641. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  34642. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  34643. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  34644. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  34645. if (comparisonFunction === 0) {
  34646. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  34647. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  34648. }
  34649. else {
  34650. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  34651. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  34652. }
  34653. };
  34654. /**
  34655. * Creates a depth stencil texture.
  34656. * This is only available in WebGL 2 or with the depth texture extension available.
  34657. * @param size The size of face edge in the texture.
  34658. * @param options The options defining the texture.
  34659. * @returns The texture
  34660. */
  34661. Engine.prototype.createDepthStencilTexture = function (size, options) {
  34662. if (options.isCube) {
  34663. var width = size.width || size;
  34664. return this._createDepthStencilCubeTexture(width, options);
  34665. }
  34666. else {
  34667. return this._createDepthStencilTexture(size, options);
  34668. }
  34669. };
  34670. /**
  34671. * Creates a depth stencil texture.
  34672. * This is only available in WebGL 2 or with the depth texture extension available.
  34673. * @param size The size of face edge in the texture.
  34674. * @param options The options defining the texture.
  34675. * @returns The texture
  34676. */
  34677. Engine.prototype._createDepthStencilTexture = function (size, options) {
  34678. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  34679. if (!this._caps.depthTextureExtension) {
  34680. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  34681. return internalTexture;
  34682. }
  34683. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  34684. var gl = this._gl;
  34685. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  34686. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  34687. if (this.webGLVersion > 1) {
  34688. if (internalOptions.generateStencil) {
  34689. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  34690. }
  34691. else {
  34692. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  34693. }
  34694. }
  34695. else {
  34696. if (internalOptions.generateStencil) {
  34697. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  34698. }
  34699. else {
  34700. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  34701. }
  34702. }
  34703. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  34704. return internalTexture;
  34705. };
  34706. /**
  34707. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34708. * @param renderTarget The render target to set the frame buffer for
  34709. */
  34710. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  34711. // Create the framebuffer
  34712. var internalTexture = renderTarget.getInternalTexture();
  34713. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  34714. return;
  34715. }
  34716. var gl = this._gl;
  34717. var depthStencilTexture = renderTarget.depthStencilTexture;
  34718. this._bindUnboundFramebuffer(internalTexture._framebuffer);
  34719. if (depthStencilTexture.isCube) {
  34720. if (depthStencilTexture._generateStencilBuffer) {
  34721. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  34722. }
  34723. else {
  34724. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  34725. }
  34726. }
  34727. else {
  34728. if (depthStencilTexture._generateStencilBuffer) {
  34729. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  34730. }
  34731. else {
  34732. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  34733. }
  34734. }
  34735. this._bindUnboundFramebuffer(null);
  34736. };
  34737. /**
  34738. * Creates a new render target texture
  34739. * @param size defines the size of the texture
  34740. * @param options defines the options used to create the texture
  34741. * @returns a new render target texture stored in an InternalTexture
  34742. */
  34743. Engine.prototype.createRenderTargetTexture = function (size, options) {
  34744. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_11__["RenderTargetCreationOptions"]();
  34745. if (options !== undefined && typeof options === "object") {
  34746. fullOptions.generateMipMaps = options.generateMipMaps;
  34747. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34748. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34749. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  34750. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34751. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  34752. }
  34753. else {
  34754. fullOptions.generateMipMaps = options;
  34755. fullOptions.generateDepthBuffer = true;
  34756. fullOptions.generateStencilBuffer = false;
  34757. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  34758. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  34759. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  34760. }
  34761. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  34762. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  34763. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  34764. }
  34765. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  34766. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  34767. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  34768. }
  34769. var gl = this._gl;
  34770. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34771. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  34772. var width = size.width || size;
  34773. var height = size.height || size;
  34774. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  34775. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  34776. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  34777. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  34778. }
  34779. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  34780. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  34781. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  34782. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  34783. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  34784. // Create the framebuffer
  34785. var currentFrameBuffer = this._currentFramebuffer;
  34786. var framebuffer = gl.createFramebuffer();
  34787. this._bindUnboundFramebuffer(framebuffer);
  34788. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  34789. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  34790. if (fullOptions.generateMipMaps) {
  34791. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  34792. }
  34793. // Unbind
  34794. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  34795. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  34796. this._bindUnboundFramebuffer(currentFrameBuffer);
  34797. texture._framebuffer = framebuffer;
  34798. texture.baseWidth = width;
  34799. texture.baseHeight = height;
  34800. texture.width = width;
  34801. texture.height = height;
  34802. texture.isReady = true;
  34803. texture.samples = 1;
  34804. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34805. texture.samplingMode = fullOptions.samplingMode;
  34806. texture.type = fullOptions.type;
  34807. texture.format = fullOptions.format;
  34808. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34809. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34810. // this.resetTextureCache();
  34811. this._internalTexturesCache.push(texture);
  34812. return texture;
  34813. };
  34814. /** @hidden */
  34815. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  34816. if (samples === void 0) { samples = 1; }
  34817. var depthStencilBuffer = null;
  34818. var gl = this._gl;
  34819. // Create the depth/stencil buffer
  34820. if (generateStencilBuffer) {
  34821. depthStencilBuffer = gl.createRenderbuffer();
  34822. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  34823. if (samples > 1) {
  34824. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  34825. }
  34826. else {
  34827. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  34828. }
  34829. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  34830. }
  34831. else if (generateDepthBuffer) {
  34832. depthStencilBuffer = gl.createRenderbuffer();
  34833. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  34834. if (samples > 1) {
  34835. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  34836. }
  34837. else {
  34838. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  34839. }
  34840. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  34841. }
  34842. return depthStencilBuffer;
  34843. };
  34844. /**
  34845. * Updates the sample count of a render target texture
  34846. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34847. * @param texture defines the texture to update
  34848. * @param samples defines the sample count to set
  34849. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34850. */
  34851. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  34852. if (this.webGLVersion < 2 || !texture) {
  34853. return 1;
  34854. }
  34855. if (texture.samples === samples) {
  34856. return samples;
  34857. }
  34858. var gl = this._gl;
  34859. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  34860. // Dispose previous render buffers
  34861. if (texture._depthStencilBuffer) {
  34862. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  34863. texture._depthStencilBuffer = null;
  34864. }
  34865. if (texture._MSAAFramebuffer) {
  34866. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  34867. texture._MSAAFramebuffer = null;
  34868. }
  34869. if (texture._MSAARenderBuffer) {
  34870. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  34871. texture._MSAARenderBuffer = null;
  34872. }
  34873. if (samples > 1) {
  34874. var framebuffer = gl.createFramebuffer();
  34875. if (!framebuffer) {
  34876. throw new Error("Unable to create multi sampled framebuffer");
  34877. }
  34878. texture._MSAAFramebuffer = framebuffer;
  34879. this._bindUnboundFramebuffer(texture._MSAAFramebuffer);
  34880. var colorRenderbuffer = gl.createRenderbuffer();
  34881. if (!colorRenderbuffer) {
  34882. throw new Error("Unable to create multi sampled framebuffer");
  34883. }
  34884. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  34885. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  34886. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  34887. texture._MSAARenderBuffer = colorRenderbuffer;
  34888. }
  34889. else {
  34890. this._bindUnboundFramebuffer(texture._framebuffer);
  34891. }
  34892. texture.samples = samples;
  34893. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  34894. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  34895. this._bindUnboundFramebuffer(null);
  34896. return samples;
  34897. };
  34898. /** @hidden */
  34899. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34900. if (faceIndex === void 0) { faceIndex = 0; }
  34901. if (lod === void 0) { lod = 0; }
  34902. var gl = this._gl;
  34903. var target = gl.TEXTURE_2D;
  34904. if (texture.isCube) {
  34905. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  34906. }
  34907. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  34908. };
  34909. /** @hidden */
  34910. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod, babylonInternalFormat, useTextureWidthAndHeight) {
  34911. if (faceIndex === void 0) { faceIndex = 0; }
  34912. if (lod === void 0) { lod = 0; }
  34913. if (useTextureWidthAndHeight === void 0) { useTextureWidthAndHeight = false; }
  34914. var gl = this._gl;
  34915. var textureType = this._getWebGLTextureType(texture.type);
  34916. var format = this._getInternalFormat(texture.format);
  34917. var internalFormat = babylonInternalFormat === undefined ? this._getRGBABufferInternalSizedFormat(texture.type, format) : this._getInternalFormat(babylonInternalFormat);
  34918. this._unpackFlipY(texture.invertY);
  34919. var target = gl.TEXTURE_2D;
  34920. if (texture.isCube) {
  34921. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  34922. }
  34923. var lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);
  34924. var lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);
  34925. var width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  34926. var height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  34927. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  34928. };
  34929. /** @hidden */
  34930. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34931. if (faceIndex === void 0) { faceIndex = 0; }
  34932. if (lod === void 0) { lod = 0; }
  34933. var gl = this._gl;
  34934. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  34935. this._bindTextureDirectly(bindTarget, texture, true);
  34936. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  34937. this._bindTextureDirectly(bindTarget, null, true);
  34938. };
  34939. /** @hidden */
  34940. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34941. if (faceIndex === void 0) { faceIndex = 0; }
  34942. if (lod === void 0) { lod = 0; }
  34943. var gl = this._gl;
  34944. var textureType = this._getWebGLTextureType(texture.type);
  34945. var format = this._getInternalFormat(texture.format);
  34946. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  34947. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  34948. this._bindTextureDirectly(bindTarget, texture, true);
  34949. this._unpackFlipY(texture.invertY);
  34950. var target = gl.TEXTURE_2D;
  34951. if (texture.isCube) {
  34952. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  34953. }
  34954. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  34955. this._bindTextureDirectly(bindTarget, null, true);
  34956. };
  34957. /**
  34958. * @hidden
  34959. */
  34960. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  34961. var gl = this._gl;
  34962. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  34963. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  34964. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  34965. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  34966. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  34967. };
  34968. /**
  34969. * Creates a new raw cube texture
  34970. * @param data defines the array of data to use to create each face
  34971. * @param size defines the size of the textures
  34972. * @param format defines the format of the data
  34973. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  34974. * @param generateMipMaps defines if the engine should generate the mip levels
  34975. * @param invertY defines if data must be stored with Y axis inverted
  34976. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  34977. * @param compression defines the compression used (null by default)
  34978. * @returns the cube texture as an InternalTexture
  34979. */
  34980. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  34981. if (compression === void 0) { compression = null; }
  34982. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("Engine.RawTexture");
  34983. };
  34984. /**
  34985. * Creates a new raw 3D texture
  34986. * @param data defines the data used to create the texture
  34987. * @param width defines the width of the texture
  34988. * @param height defines the height of the texture
  34989. * @param depth defines the depth of the texture
  34990. * @param format defines the format of the texture
  34991. * @param generateMipMaps defines if the engine must generate mip levels
  34992. * @param invertY defines if data must be stored with Y axis inverted
  34993. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  34994. * @param compression defines the compressed used (can be null)
  34995. * @param textureType defines the compressed used (can be null)
  34996. * @returns a new raw 3D texture (stored in an InternalTexture)
  34997. */
  34998. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  34999. if (compression === void 0) { compression = null; }
  35000. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  35001. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("Engine.RawTexture");
  35002. };
  35003. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  35004. var gl = this._gl;
  35005. if (!gl) {
  35006. return;
  35007. }
  35008. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  35009. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  35010. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  35011. if (!noMipmap && !isCompressed) {
  35012. gl.generateMipmap(gl.TEXTURE_2D);
  35013. }
  35014. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  35015. // this.resetTextureCache();
  35016. if (scene) {
  35017. scene._removePendingData(texture);
  35018. }
  35019. texture.onLoadedObservable.notifyObservers(texture);
  35020. texture.onLoadedObservable.clear();
  35021. };
  35022. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  35023. var _this = this;
  35024. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  35025. var maxTextureSize = this.getCaps().maxTextureSize;
  35026. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? Engine.GetExponentOfTwo(width, maxTextureSize) : width);
  35027. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? Engine.GetExponentOfTwo(height, maxTextureSize) : height);
  35028. var gl = this._gl;
  35029. if (!gl) {
  35030. return;
  35031. }
  35032. if (!texture._webGLTexture) {
  35033. // this.resetTextureCache();
  35034. if (scene) {
  35035. scene._removePendingData(texture);
  35036. }
  35037. return;
  35038. }
  35039. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  35040. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  35041. texture.baseWidth = width;
  35042. texture.baseHeight = height;
  35043. texture.width = potWidth;
  35044. texture.height = potHeight;
  35045. texture.isReady = true;
  35046. if (processFunction(potWidth, potHeight, function () {
  35047. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  35048. })) {
  35049. // Returning as texture needs extra async steps
  35050. return;
  35051. }
  35052. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  35053. };
  35054. /** @hidden */
  35055. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  35056. // Create new RGBA data container.
  35057. var rgbaData;
  35058. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  35059. rgbaData = new Float32Array(width * height * 4);
  35060. }
  35061. else {
  35062. rgbaData = new Uint32Array(width * height * 4);
  35063. }
  35064. // Convert each pixel.
  35065. for (var x = 0; x < width; x++) {
  35066. for (var y = 0; y < height; y++) {
  35067. var index = (y * width + x) * 3;
  35068. var newIndex = (y * width + x) * 4;
  35069. // Map Old Value to new value.
  35070. rgbaData[newIndex + 0] = rgbData[index + 0];
  35071. rgbaData[newIndex + 1] = rgbData[index + 1];
  35072. rgbaData[newIndex + 2] = rgbData[index + 2];
  35073. // Add fully opaque alpha channel.
  35074. rgbaData[newIndex + 3] = 1;
  35075. }
  35076. }
  35077. return rgbaData;
  35078. };
  35079. /** @hidden */
  35080. Engine.prototype._releaseFramebufferObjects = function (texture) {
  35081. var gl = this._gl;
  35082. if (texture._framebuffer) {
  35083. gl.deleteFramebuffer(texture._framebuffer);
  35084. texture._framebuffer = null;
  35085. }
  35086. if (texture._depthStencilBuffer) {
  35087. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  35088. texture._depthStencilBuffer = null;
  35089. }
  35090. if (texture._MSAAFramebuffer) {
  35091. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  35092. texture._MSAAFramebuffer = null;
  35093. }
  35094. if (texture._MSAARenderBuffer) {
  35095. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  35096. texture._MSAARenderBuffer = null;
  35097. }
  35098. };
  35099. /** @hidden */
  35100. Engine.prototype._releaseTexture = function (texture) {
  35101. var gl = this._gl;
  35102. this._releaseFramebufferObjects(texture);
  35103. gl.deleteTexture(texture._webGLTexture);
  35104. // Unbind channels
  35105. this.unbindAllTextures();
  35106. var index = this._internalTexturesCache.indexOf(texture);
  35107. if (index !== -1) {
  35108. this._internalTexturesCache.splice(index, 1);
  35109. }
  35110. // Integrated fixed lod samplers.
  35111. if (texture._lodTextureHigh) {
  35112. texture._lodTextureHigh.dispose();
  35113. }
  35114. if (texture._lodTextureMid) {
  35115. texture._lodTextureMid.dispose();
  35116. }
  35117. if (texture._lodTextureLow) {
  35118. texture._lodTextureLow.dispose();
  35119. }
  35120. // Integrated irradiance map.
  35121. if (texture._irradianceTexture) {
  35122. texture._irradianceTexture.dispose();
  35123. }
  35124. // Set output texture of post process to null if the texture has been released/disposed
  35125. this.scenes.forEach(function (scene) {
  35126. scene.postProcesses.forEach(function (postProcess) {
  35127. if (postProcess._outputTexture == texture) {
  35128. postProcess._outputTexture = null;
  35129. }
  35130. });
  35131. scene.cameras.forEach(function (camera) {
  35132. camera._postProcesses.forEach(function (postProcess) {
  35133. if (postProcess) {
  35134. if (postProcess._outputTexture == texture) {
  35135. postProcess._outputTexture = null;
  35136. }
  35137. }
  35138. });
  35139. });
  35140. });
  35141. };
  35142. Engine.prototype.setProgram = function (program) {
  35143. if (this._currentProgram !== program) {
  35144. this._gl.useProgram(program);
  35145. this._currentProgram = program;
  35146. }
  35147. };
  35148. /**
  35149. * Binds an effect to the webGL context
  35150. * @param effect defines the effect to bind
  35151. */
  35152. Engine.prototype.bindSamplers = function (effect) {
  35153. var webGLPipelineContext = effect.getPipelineContext();
  35154. this.setProgram(webGLPipelineContext.program);
  35155. var samplers = effect.getSamplers();
  35156. for (var index = 0; index < samplers.length; index++) {
  35157. var uniform = effect.getUniform(samplers[index]);
  35158. if (uniform) {
  35159. this._boundUniforms[index] = uniform;
  35160. }
  35161. }
  35162. this._currentEffect = null;
  35163. };
  35164. Engine.prototype._activateCurrentTexture = function () {
  35165. if (this._currentTextureChannel !== this._activeChannel) {
  35166. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  35167. this._currentTextureChannel = this._activeChannel;
  35168. }
  35169. };
  35170. /** @hidden */
  35171. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  35172. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  35173. if (force === void 0) { force = false; }
  35174. var wasPreviouslyBound = false;
  35175. var isTextureForRendering = texture && texture._associatedChannel > -1;
  35176. if (forTextureDataUpdate && isTextureForRendering) {
  35177. this._activeChannel = texture._associatedChannel;
  35178. }
  35179. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  35180. if (currentTextureBound !== texture || force) {
  35181. this._activateCurrentTexture();
  35182. if (texture && texture.isMultiview) {
  35183. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  35184. }
  35185. else {
  35186. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  35187. }
  35188. this._boundTexturesCache[this._activeChannel] = texture;
  35189. if (texture) {
  35190. texture._associatedChannel = this._activeChannel;
  35191. }
  35192. }
  35193. else if (forTextureDataUpdate) {
  35194. wasPreviouslyBound = true;
  35195. this._activateCurrentTexture();
  35196. }
  35197. if (isTextureForRendering && !forTextureDataUpdate) {
  35198. this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);
  35199. }
  35200. return wasPreviouslyBound;
  35201. };
  35202. /** @hidden */
  35203. Engine.prototype._bindTexture = function (channel, texture) {
  35204. if (channel === undefined) {
  35205. return;
  35206. }
  35207. if (texture) {
  35208. texture._associatedChannel = channel;
  35209. }
  35210. this._activeChannel = channel;
  35211. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  35212. };
  35213. /**
  35214. * Sets a texture to the webGL context from a postprocess
  35215. * @param channel defines the channel to use
  35216. * @param postProcess defines the source postprocess
  35217. */
  35218. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  35219. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  35220. };
  35221. /**
  35222. * Binds the output of the passed in post process to the texture channel specified
  35223. * @param channel The channel the texture should be bound to
  35224. * @param postProcess The post process which's output should be bound
  35225. */
  35226. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  35227. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  35228. };
  35229. /**
  35230. * Unbind all textures from the webGL context
  35231. */
  35232. Engine.prototype.unbindAllTextures = function () {
  35233. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  35234. this._activeChannel = channel;
  35235. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  35236. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  35237. if (this.webGLVersion > 1) {
  35238. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  35239. }
  35240. }
  35241. };
  35242. /**
  35243. * Sets a texture to the according uniform.
  35244. * @param channel The texture channel
  35245. * @param uniform The uniform to set
  35246. * @param texture The texture to apply
  35247. */
  35248. Engine.prototype.setTexture = function (channel, uniform, texture) {
  35249. if (channel === undefined) {
  35250. return;
  35251. }
  35252. if (uniform) {
  35253. this._boundUniforms[channel] = uniform;
  35254. }
  35255. this._setTexture(channel, texture);
  35256. };
  35257. /**
  35258. * Sets a depth stencil texture from a render target to the according uniform.
  35259. * @param channel The texture channel
  35260. * @param uniform The uniform to set
  35261. * @param texture The render target texture containing the depth stencil texture to apply
  35262. */
  35263. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  35264. if (channel === undefined) {
  35265. return;
  35266. }
  35267. if (uniform) {
  35268. this._boundUniforms[channel] = uniform;
  35269. }
  35270. if (!texture || !texture.depthStencilTexture) {
  35271. this._setTexture(channel, null);
  35272. }
  35273. else {
  35274. this._setTexture(channel, texture, false, true);
  35275. }
  35276. };
  35277. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  35278. var uniform = this._boundUniforms[sourceSlot];
  35279. if (uniform._currentState === destination) {
  35280. return;
  35281. }
  35282. this._gl.uniform1i(uniform, destination);
  35283. uniform._currentState = destination;
  35284. };
  35285. Engine.prototype._getTextureWrapMode = function (mode) {
  35286. switch (mode) {
  35287. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  35288. return this._gl.REPEAT;
  35289. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  35290. return this._gl.CLAMP_TO_EDGE;
  35291. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  35292. return this._gl.MIRRORED_REPEAT;
  35293. }
  35294. return this._gl.REPEAT;
  35295. };
  35296. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  35297. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  35298. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  35299. // Not ready?
  35300. if (!texture) {
  35301. if (this._boundTexturesCache[channel] != null) {
  35302. this._activeChannel = channel;
  35303. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  35304. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  35305. if (this.webGLVersion > 1) {
  35306. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  35307. }
  35308. }
  35309. return false;
  35310. }
  35311. // Video
  35312. if (texture.video) {
  35313. this._activeChannel = channel;
  35314. texture.update();
  35315. }
  35316. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  35317. texture.delayLoad();
  35318. return false;
  35319. }
  35320. var internalTexture;
  35321. if (depthStencilTexture) {
  35322. internalTexture = texture.depthStencilTexture;
  35323. }
  35324. else if (texture.isReady()) {
  35325. internalTexture = texture.getInternalTexture();
  35326. }
  35327. else if (texture.isCube) {
  35328. internalTexture = this.emptyCubeTexture;
  35329. }
  35330. else if (texture.is3D) {
  35331. internalTexture = this.emptyTexture3D;
  35332. }
  35333. else {
  35334. internalTexture = this.emptyTexture;
  35335. }
  35336. if (!isPartOfTextureArray && internalTexture) {
  35337. internalTexture._associatedChannel = channel;
  35338. }
  35339. var needToBind = true;
  35340. if (this._boundTexturesCache[channel] === internalTexture) {
  35341. if (!isPartOfTextureArray) {
  35342. this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);
  35343. }
  35344. needToBind = false;
  35345. }
  35346. this._activeChannel = channel;
  35347. if (internalTexture && internalTexture.isMultiview) {
  35348. if (needToBind) {
  35349. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  35350. }
  35351. }
  35352. else if (internalTexture && internalTexture.is3D) {
  35353. if (needToBind) {
  35354. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  35355. }
  35356. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  35357. internalTexture._cachedWrapU = texture.wrapU;
  35358. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  35359. }
  35360. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  35361. internalTexture._cachedWrapV = texture.wrapV;
  35362. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  35363. }
  35364. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  35365. internalTexture._cachedWrapR = texture.wrapR;
  35366. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  35367. }
  35368. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  35369. }
  35370. else if (internalTexture && internalTexture.isCube) {
  35371. if (needToBind) {
  35372. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  35373. }
  35374. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  35375. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  35376. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  35377. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  35378. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  35379. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  35380. }
  35381. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  35382. }
  35383. else {
  35384. if (needToBind) {
  35385. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  35386. }
  35387. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  35388. internalTexture._cachedWrapU = texture.wrapU;
  35389. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  35390. }
  35391. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  35392. internalTexture._cachedWrapV = texture.wrapV;
  35393. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  35394. }
  35395. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  35396. }
  35397. return true;
  35398. };
  35399. /**
  35400. * Sets an array of texture to the webGL context
  35401. * @param channel defines the channel where the texture array must be set
  35402. * @param uniform defines the associated uniform location
  35403. * @param textures defines the array of textures to bind
  35404. */
  35405. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  35406. if (channel === undefined || !uniform) {
  35407. return;
  35408. }
  35409. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  35410. this._textureUnits = new Int32Array(textures.length);
  35411. }
  35412. for (var i = 0; i < textures.length; i++) {
  35413. var texture = textures[i].getInternalTexture();
  35414. if (texture) {
  35415. this._textureUnits[i] = channel + i;
  35416. texture._associatedChannel = channel + i;
  35417. }
  35418. else {
  35419. this._textureUnits[i] = -1;
  35420. }
  35421. }
  35422. this._gl.uniform1iv(uniform, this._textureUnits);
  35423. for (var index = 0; index < textures.length; index++) {
  35424. this._setTexture(this._textureUnits[index], textures[index], true);
  35425. }
  35426. };
  35427. /** @hidden */
  35428. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  35429. var internalTexture = texture.getInternalTexture();
  35430. if (!internalTexture) {
  35431. return;
  35432. }
  35433. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  35434. var value = texture.anisotropicFilteringLevel;
  35435. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  35436. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  35437. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  35438. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  35439. }
  35440. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  35441. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  35442. internalTexture._cachedAnisotropicFilteringLevel = value;
  35443. }
  35444. };
  35445. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  35446. this._bindTextureDirectly(target, texture, true, true);
  35447. this._gl.texParameterf(target, parameter, value);
  35448. };
  35449. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  35450. if (texture) {
  35451. this._bindTextureDirectly(target, texture, true, true);
  35452. }
  35453. this._gl.texParameteri(target, parameter, value);
  35454. };
  35455. /**
  35456. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35457. * @param x defines the x coordinate of the rectangle where pixels must be read
  35458. * @param y defines the y coordinate of the rectangle where pixels must be read
  35459. * @param width defines the width of the rectangle where pixels must be read
  35460. * @param height defines the height of the rectangle where pixels must be read
  35461. * @returns a Uint8Array containing RGBA colors
  35462. */
  35463. Engine.prototype.readPixels = function (x, y, width, height) {
  35464. var data = new Uint8Array(height * width * 4);
  35465. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  35466. return data;
  35467. };
  35468. /**
  35469. * Add an externaly attached data from its key.
  35470. * This method call will fail and return false, if such key already exists.
  35471. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35472. * @param key the unique key that identifies the data
  35473. * @param data the data object to associate to the key for this Engine instance
  35474. * @return true if no such key were already present and the data was added successfully, false otherwise
  35475. */
  35476. Engine.prototype.addExternalData = function (key, data) {
  35477. if (!this._externalData) {
  35478. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  35479. }
  35480. return this._externalData.add(key, data);
  35481. };
  35482. /**
  35483. * Get an externaly attached data from its key
  35484. * @param key the unique key that identifies the data
  35485. * @return the associated data, if present (can be null), or undefined if not present
  35486. */
  35487. Engine.prototype.getExternalData = function (key) {
  35488. if (!this._externalData) {
  35489. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  35490. }
  35491. return this._externalData.get(key);
  35492. };
  35493. /**
  35494. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35495. * @param key the unique key that identifies the data
  35496. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35497. * @return the associated data, can be null if the factory returned null.
  35498. */
  35499. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  35500. if (!this._externalData) {
  35501. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  35502. }
  35503. return this._externalData.getOrAddWithFactory(key, factory);
  35504. };
  35505. /**
  35506. * Remove an externaly attached data from the Engine instance
  35507. * @param key the unique key that identifies the data
  35508. * @return true if the data was successfully removed, false if it doesn't exist
  35509. */
  35510. Engine.prototype.removeExternalData = function (key) {
  35511. if (!this._externalData) {
  35512. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  35513. }
  35514. return this._externalData.remove(key);
  35515. };
  35516. /**
  35517. * Unbind all vertex attributes from the webGL context
  35518. */
  35519. Engine.prototype.unbindAllAttributes = function () {
  35520. if (this._mustWipeVertexAttributes) {
  35521. this._mustWipeVertexAttributes = false;
  35522. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  35523. this._gl.disableVertexAttribArray(i);
  35524. this._vertexAttribArraysEnabled[i] = false;
  35525. this._currentBufferPointers[i].active = false;
  35526. }
  35527. return;
  35528. }
  35529. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  35530. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  35531. continue;
  35532. }
  35533. this._gl.disableVertexAttribArray(i);
  35534. this._vertexAttribArraysEnabled[i] = false;
  35535. this._currentBufferPointers[i].active = false;
  35536. }
  35537. };
  35538. /**
  35539. * 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
  35540. */
  35541. Engine.prototype.releaseEffects = function () {
  35542. for (var name in this._compiledEffects) {
  35543. var webGLPipelineContext = this._compiledEffects[name].getPipelineContext();
  35544. this._deletePipelineContext(webGLPipelineContext);
  35545. }
  35546. this._compiledEffects = {};
  35547. };
  35548. /**
  35549. * Dispose and release all associated resources
  35550. */
  35551. Engine.prototype.dispose = function () {
  35552. this.hideLoadingUI();
  35553. this.stopRenderLoop();
  35554. this.onNewSceneAddedObservable.clear();
  35555. // Release postProcesses
  35556. while (this.postProcesses.length) {
  35557. this.postProcesses[0].dispose();
  35558. }
  35559. // Empty texture
  35560. if (this._emptyTexture) {
  35561. this._releaseTexture(this._emptyTexture);
  35562. this._emptyTexture = null;
  35563. }
  35564. if (this._emptyCubeTexture) {
  35565. this._releaseTexture(this._emptyCubeTexture);
  35566. this._emptyCubeTexture = null;
  35567. }
  35568. // Rescale PP
  35569. if (this._rescalePostProcess) {
  35570. this._rescalePostProcess.dispose();
  35571. }
  35572. // Release scenes
  35573. while (this.scenes.length) {
  35574. this.scenes[0].dispose();
  35575. }
  35576. // Release audio engine
  35577. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  35578. Engine.audioEngine.dispose();
  35579. }
  35580. // Release effects
  35581. this.releaseEffects();
  35582. // Unbind
  35583. this.unbindAllAttributes();
  35584. this._boundUniforms = [];
  35585. if (this._dummyFramebuffer) {
  35586. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  35587. }
  35588. //WebVR
  35589. this.disableVR();
  35590. // Events
  35591. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__["DomManagement"].IsWindowObjectExist()) {
  35592. window.removeEventListener("blur", this._onBlur);
  35593. window.removeEventListener("focus", this._onFocus);
  35594. if (this._renderingCanvas) {
  35595. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  35596. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  35597. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  35598. if (!this._doNotHandleContextLost) {
  35599. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  35600. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  35601. }
  35602. }
  35603. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  35604. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  35605. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  35606. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  35607. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  35608. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  35609. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  35610. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  35611. }
  35612. // Remove from Instances
  35613. var index = Engine.Instances.indexOf(this);
  35614. if (index >= 0) {
  35615. Engine.Instances.splice(index, 1);
  35616. }
  35617. this._workingCanvas = null;
  35618. this._workingContext = null;
  35619. this._currentBufferPointers = [];
  35620. this._renderingCanvas = null;
  35621. this._currentProgram = null;
  35622. this._bindedRenderFunction = null;
  35623. this.onResizeObservable.clear();
  35624. this.onCanvasBlurObservable.clear();
  35625. this.onCanvasFocusObservable.clear();
  35626. this.onCanvasPointerOutObservable.clear();
  35627. this.onBeginFrameObservable.clear();
  35628. this.onEndFrameObservable.clear();
  35629. _Materials_effect__WEBPACK_IMPORTED_MODULE_4__["Effect"].ResetCache();
  35630. // Abort active requests
  35631. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  35632. var request = _a[_i];
  35633. request.abort();
  35634. }
  35635. };
  35636. // Loading screen
  35637. /**
  35638. * Display the loading screen
  35639. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35640. */
  35641. Engine.prototype.displayLoadingUI = function () {
  35642. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__["DomManagement"].IsWindowObjectExist()) {
  35643. return;
  35644. }
  35645. var loadingScreen = this.loadingScreen;
  35646. if (loadingScreen) {
  35647. loadingScreen.displayLoadingUI();
  35648. }
  35649. };
  35650. /**
  35651. * Hide the loading screen
  35652. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35653. */
  35654. Engine.prototype.hideLoadingUI = function () {
  35655. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__["DomManagement"].IsWindowObjectExist()) {
  35656. return;
  35657. }
  35658. var loadingScreen = this._loadingScreen;
  35659. if (loadingScreen) {
  35660. loadingScreen.hideLoadingUI();
  35661. }
  35662. };
  35663. Object.defineProperty(Engine.prototype, "loadingScreen", {
  35664. /**
  35665. * Gets the current loading screen object
  35666. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35667. */
  35668. get: function () {
  35669. if (!this._loadingScreen && this._renderingCanvas) {
  35670. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  35671. }
  35672. return this._loadingScreen;
  35673. },
  35674. /**
  35675. * Sets the current loading screen object
  35676. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35677. */
  35678. set: function (loadingScreen) {
  35679. this._loadingScreen = loadingScreen;
  35680. },
  35681. enumerable: true,
  35682. configurable: true
  35683. });
  35684. Object.defineProperty(Engine.prototype, "loadingUIText", {
  35685. /**
  35686. * Sets the current loading screen text
  35687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35688. */
  35689. set: function (text) {
  35690. this.loadingScreen.loadingUIText = text;
  35691. },
  35692. enumerable: true,
  35693. configurable: true
  35694. });
  35695. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  35696. /**
  35697. * Sets the current loading screen background color
  35698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35699. */
  35700. set: function (color) {
  35701. this.loadingScreen.loadingUIBackgroundColor = color;
  35702. },
  35703. enumerable: true,
  35704. configurable: true
  35705. });
  35706. /**
  35707. * Attach a new callback raised when context lost event is fired
  35708. * @param callback defines the callback to call
  35709. */
  35710. Engine.prototype.attachContextLostEvent = function (callback) {
  35711. if (this._renderingCanvas) {
  35712. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  35713. }
  35714. };
  35715. /**
  35716. * Attach a new callback raised when context restored event is fired
  35717. * @param callback defines the callback to call
  35718. */
  35719. Engine.prototype.attachContextRestoredEvent = function (callback) {
  35720. if (this._renderingCanvas) {
  35721. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  35722. }
  35723. };
  35724. /**
  35725. * Gets the source code of the vertex shader associated with a specific webGL program
  35726. * @param program defines the program to use
  35727. * @returns a string containing the source code of the vertex shader associated with the program
  35728. */
  35729. Engine.prototype.getVertexShaderSource = function (program) {
  35730. var shaders = this._gl.getAttachedShaders(program);
  35731. if (!shaders) {
  35732. return null;
  35733. }
  35734. return this._gl.getShaderSource(shaders[0]);
  35735. };
  35736. /**
  35737. * Gets the source code of the fragment shader associated with a specific webGL program
  35738. * @param program defines the program to use
  35739. * @returns a string containing the source code of the fragment shader associated with the program
  35740. */
  35741. Engine.prototype.getFragmentShaderSource = function (program) {
  35742. var shaders = this._gl.getAttachedShaders(program);
  35743. if (!shaders) {
  35744. return null;
  35745. }
  35746. return this._gl.getShaderSource(shaders[1]);
  35747. };
  35748. /**
  35749. * Get the current error code of the webGL context
  35750. * @returns the error code
  35751. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35752. */
  35753. Engine.prototype.getError = function () {
  35754. return this._gl.getError();
  35755. };
  35756. // FPS
  35757. /**
  35758. * Gets the current framerate
  35759. * @returns a number representing the framerate
  35760. */
  35761. Engine.prototype.getFps = function () {
  35762. return this._fps;
  35763. };
  35764. /**
  35765. * Gets the time spent between current and previous frame
  35766. * @returns a number representing the delta time in ms
  35767. */
  35768. Engine.prototype.getDeltaTime = function () {
  35769. return this._deltaTime;
  35770. };
  35771. Engine.prototype._measureFps = function () {
  35772. this._performanceMonitor.sampleFrame();
  35773. this._fps = this._performanceMonitor.averageFPS;
  35774. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  35775. };
  35776. /** @hidden */
  35777. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  35778. if (faceIndex === void 0) { faceIndex = -1; }
  35779. if (level === void 0) { level = 0; }
  35780. if (buffer === void 0) { buffer = null; }
  35781. var gl = this._gl;
  35782. if (!this._dummyFramebuffer) {
  35783. var dummy = gl.createFramebuffer();
  35784. if (!dummy) {
  35785. throw new Error("Unable to create dummy framebuffer");
  35786. }
  35787. this._dummyFramebuffer = dummy;
  35788. }
  35789. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  35790. if (faceIndex > -1) {
  35791. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  35792. }
  35793. else {
  35794. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  35795. }
  35796. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  35797. switch (readType) {
  35798. case gl.UNSIGNED_BYTE:
  35799. if (!buffer) {
  35800. buffer = new Uint8Array(4 * width * height);
  35801. }
  35802. readType = gl.UNSIGNED_BYTE;
  35803. break;
  35804. default:
  35805. if (!buffer) {
  35806. buffer = new Float32Array(4 * width * height);
  35807. }
  35808. readType = gl.FLOAT;
  35809. break;
  35810. }
  35811. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  35812. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  35813. return buffer;
  35814. };
  35815. Engine.prototype._canRenderToFloatFramebuffer = function () {
  35816. if (this._webGLVersion > 1) {
  35817. return this._caps.colorBufferFloat;
  35818. }
  35819. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  35820. };
  35821. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  35822. if (this._webGLVersion > 1) {
  35823. return this._caps.colorBufferFloat;
  35824. }
  35825. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  35826. };
  35827. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  35828. Engine.prototype._canRenderToFramebuffer = function (type) {
  35829. var gl = this._gl;
  35830. //clear existing errors
  35831. while (gl.getError() !== gl.NO_ERROR) { }
  35832. var successful = true;
  35833. var texture = gl.createTexture();
  35834. gl.bindTexture(gl.TEXTURE_2D, texture);
  35835. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  35836. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  35837. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  35838. var fb = gl.createFramebuffer();
  35839. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  35840. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  35841. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  35842. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  35843. successful = successful && (gl.getError() === gl.NO_ERROR);
  35844. //try render by clearing frame buffer's color buffer
  35845. if (successful) {
  35846. gl.clear(gl.COLOR_BUFFER_BIT);
  35847. successful = successful && (gl.getError() === gl.NO_ERROR);
  35848. }
  35849. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  35850. if (successful) {
  35851. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  35852. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  35853. var readFormat = gl.RGBA;
  35854. var readType = gl.UNSIGNED_BYTE;
  35855. var buffer = new Uint8Array(4);
  35856. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  35857. successful = successful && (gl.getError() === gl.NO_ERROR);
  35858. }
  35859. //clean up
  35860. gl.deleteTexture(texture);
  35861. gl.deleteFramebuffer(fb);
  35862. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  35863. //clear accumulated errors
  35864. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  35865. return successful;
  35866. };
  35867. /** @hidden */
  35868. Engine.prototype._getWebGLTextureType = function (type) {
  35869. if (this._webGLVersion === 1) {
  35870. switch (type) {
  35871. case Engine.TEXTURETYPE_FLOAT:
  35872. return this._gl.FLOAT;
  35873. case Engine.TEXTURETYPE_HALF_FLOAT:
  35874. return this._gl.HALF_FLOAT_OES;
  35875. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  35876. return this._gl.UNSIGNED_BYTE;
  35877. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  35878. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  35879. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  35880. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  35881. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  35882. return this._gl.UNSIGNED_SHORT_5_6_5;
  35883. }
  35884. return this._gl.UNSIGNED_BYTE;
  35885. }
  35886. switch (type) {
  35887. case Engine.TEXTURETYPE_BYTE:
  35888. return this._gl.BYTE;
  35889. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  35890. return this._gl.UNSIGNED_BYTE;
  35891. case Engine.TEXTURETYPE_SHORT:
  35892. return this._gl.SHORT;
  35893. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  35894. return this._gl.UNSIGNED_SHORT;
  35895. case Engine.TEXTURETYPE_INT:
  35896. return this._gl.INT;
  35897. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  35898. return this._gl.UNSIGNED_INT;
  35899. case Engine.TEXTURETYPE_FLOAT:
  35900. return this._gl.FLOAT;
  35901. case Engine.TEXTURETYPE_HALF_FLOAT:
  35902. return this._gl.HALF_FLOAT;
  35903. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  35904. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  35905. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  35906. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  35907. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  35908. return this._gl.UNSIGNED_SHORT_5_6_5;
  35909. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  35910. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  35911. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  35912. return this._gl.UNSIGNED_INT_24_8;
  35913. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  35914. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  35915. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  35916. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  35917. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  35918. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  35919. }
  35920. return this._gl.UNSIGNED_BYTE;
  35921. };
  35922. /** @hidden */
  35923. Engine.prototype._getInternalFormat = function (format) {
  35924. var internalFormat = this._gl.RGBA;
  35925. switch (format) {
  35926. case Engine.TEXTUREFORMAT_ALPHA:
  35927. internalFormat = this._gl.ALPHA;
  35928. break;
  35929. case Engine.TEXTUREFORMAT_LUMINANCE:
  35930. internalFormat = this._gl.LUMINANCE;
  35931. break;
  35932. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  35933. internalFormat = this._gl.LUMINANCE_ALPHA;
  35934. break;
  35935. case Engine.TEXTUREFORMAT_RED:
  35936. internalFormat = this._gl.RED;
  35937. break;
  35938. case Engine.TEXTUREFORMAT_RG:
  35939. internalFormat = this._gl.RG;
  35940. break;
  35941. case Engine.TEXTUREFORMAT_RGB:
  35942. internalFormat = this._gl.RGB;
  35943. break;
  35944. case Engine.TEXTUREFORMAT_RGBA:
  35945. internalFormat = this._gl.RGBA;
  35946. break;
  35947. }
  35948. if (this._webGLVersion > 1) {
  35949. switch (format) {
  35950. case Engine.TEXTUREFORMAT_RED_INTEGER:
  35951. internalFormat = this._gl.RED_INTEGER;
  35952. break;
  35953. case Engine.TEXTUREFORMAT_RG_INTEGER:
  35954. internalFormat = this._gl.RG_INTEGER;
  35955. break;
  35956. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  35957. internalFormat = this._gl.RGB_INTEGER;
  35958. break;
  35959. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  35960. internalFormat = this._gl.RGBA_INTEGER;
  35961. break;
  35962. }
  35963. }
  35964. return internalFormat;
  35965. };
  35966. /** @hidden */
  35967. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  35968. if (this._webGLVersion === 1) {
  35969. if (format !== undefined) {
  35970. switch (format) {
  35971. case Engine.TEXTUREFORMAT_ALPHA:
  35972. return this._gl.ALPHA;
  35973. case Engine.TEXTUREFORMAT_LUMINANCE:
  35974. return this._gl.LUMINANCE;
  35975. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  35976. return this._gl.LUMINANCE_ALPHA;
  35977. }
  35978. }
  35979. return this._gl.RGBA;
  35980. }
  35981. switch (type) {
  35982. case Engine.TEXTURETYPE_BYTE:
  35983. switch (format) {
  35984. case Engine.TEXTUREFORMAT_RED:
  35985. return this._gl.R8_SNORM;
  35986. case Engine.TEXTUREFORMAT_RG:
  35987. return this._gl.RG8_SNORM;
  35988. case Engine.TEXTUREFORMAT_RGB:
  35989. return this._gl.RGB8_SNORM;
  35990. case Engine.TEXTUREFORMAT_RED_INTEGER:
  35991. return this._gl.R8I;
  35992. case Engine.TEXTUREFORMAT_RG_INTEGER:
  35993. return this._gl.RG8I;
  35994. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  35995. return this._gl.RGB8I;
  35996. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  35997. return this._gl.RGBA8I;
  35998. default:
  35999. return this._gl.RGBA8_SNORM;
  36000. }
  36001. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  36002. switch (format) {
  36003. case Engine.TEXTUREFORMAT_RED:
  36004. return this._gl.R8;
  36005. case Engine.TEXTUREFORMAT_RG:
  36006. return this._gl.RG8;
  36007. case Engine.TEXTUREFORMAT_RGB:
  36008. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  36009. case Engine.TEXTUREFORMAT_RGBA:
  36010. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  36011. case Engine.TEXTUREFORMAT_RED_INTEGER:
  36012. return this._gl.R8UI;
  36013. case Engine.TEXTUREFORMAT_RG_INTEGER:
  36014. return this._gl.RG8UI;
  36015. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  36016. return this._gl.RGB8UI;
  36017. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  36018. return this._gl.RGBA8UI;
  36019. case Engine.TEXTUREFORMAT_ALPHA:
  36020. return this._gl.ALPHA;
  36021. case Engine.TEXTUREFORMAT_LUMINANCE:
  36022. return this._gl.LUMINANCE;
  36023. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  36024. return this._gl.LUMINANCE_ALPHA;
  36025. default:
  36026. return this._gl.RGBA8;
  36027. }
  36028. case Engine.TEXTURETYPE_SHORT:
  36029. switch (format) {
  36030. case Engine.TEXTUREFORMAT_RED_INTEGER:
  36031. return this._gl.R16I;
  36032. case Engine.TEXTUREFORMAT_RG_INTEGER:
  36033. return this._gl.RG16I;
  36034. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  36035. return this._gl.RGB16I;
  36036. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  36037. return this._gl.RGBA16I;
  36038. default:
  36039. return this._gl.RGBA16I;
  36040. }
  36041. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  36042. switch (format) {
  36043. case Engine.TEXTUREFORMAT_RED_INTEGER:
  36044. return this._gl.R16UI;
  36045. case Engine.TEXTUREFORMAT_RG_INTEGER:
  36046. return this._gl.RG16UI;
  36047. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  36048. return this._gl.RGB16UI;
  36049. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  36050. return this._gl.RGBA16UI;
  36051. default:
  36052. return this._gl.RGBA16UI;
  36053. }
  36054. case Engine.TEXTURETYPE_INT:
  36055. switch (format) {
  36056. case Engine.TEXTUREFORMAT_RED_INTEGER:
  36057. return this._gl.R32I;
  36058. case Engine.TEXTUREFORMAT_RG_INTEGER:
  36059. return this._gl.RG32I;
  36060. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  36061. return this._gl.RGB32I;
  36062. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  36063. return this._gl.RGBA32I;
  36064. default:
  36065. return this._gl.RGBA32I;
  36066. }
  36067. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  36068. switch (format) {
  36069. case Engine.TEXTUREFORMAT_RED_INTEGER:
  36070. return this._gl.R32UI;
  36071. case Engine.TEXTUREFORMAT_RG_INTEGER:
  36072. return this._gl.RG32UI;
  36073. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  36074. return this._gl.RGB32UI;
  36075. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  36076. return this._gl.RGBA32UI;
  36077. default:
  36078. return this._gl.RGBA32UI;
  36079. }
  36080. case Engine.TEXTURETYPE_FLOAT:
  36081. switch (format) {
  36082. case Engine.TEXTUREFORMAT_RED:
  36083. return this._gl.R32F; // By default. Other possibility is R16F.
  36084. case Engine.TEXTUREFORMAT_RG:
  36085. return this._gl.RG32F; // By default. Other possibility is RG16F.
  36086. case Engine.TEXTUREFORMAT_RGB:
  36087. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  36088. case Engine.TEXTUREFORMAT_RGBA:
  36089. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  36090. default:
  36091. return this._gl.RGBA32F;
  36092. }
  36093. case Engine.TEXTURETYPE_HALF_FLOAT:
  36094. switch (format) {
  36095. case Engine.TEXTUREFORMAT_RED:
  36096. return this._gl.R16F;
  36097. case Engine.TEXTUREFORMAT_RG:
  36098. return this._gl.RG16F;
  36099. case Engine.TEXTUREFORMAT_RGB:
  36100. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  36101. case Engine.TEXTUREFORMAT_RGBA:
  36102. return this._gl.RGBA16F;
  36103. default:
  36104. return this._gl.RGBA16F;
  36105. }
  36106. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  36107. return this._gl.RGB565;
  36108. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  36109. return this._gl.R11F_G11F_B10F;
  36110. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  36111. return this._gl.RGB9_E5;
  36112. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  36113. return this._gl.RGBA4;
  36114. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  36115. return this._gl.RGB5_A1;
  36116. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  36117. switch (format) {
  36118. case Engine.TEXTUREFORMAT_RGBA:
  36119. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  36120. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  36121. return this._gl.RGB10_A2UI;
  36122. default:
  36123. return this._gl.RGB10_A2;
  36124. }
  36125. }
  36126. return this._gl.RGBA8;
  36127. };
  36128. /** @hidden */
  36129. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  36130. if (type === Engine.TEXTURETYPE_FLOAT) {
  36131. return this._gl.RGBA32F;
  36132. }
  36133. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  36134. return this._gl.RGBA16F;
  36135. }
  36136. return this._gl.RGBA8;
  36137. };
  36138. /** @hidden */
  36139. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  36140. var _this = this;
  36141. var request = _Misc_fileTools__WEBPACK_IMPORTED_MODULE_17__["FileTools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  36142. this._activeRequests.push(request);
  36143. request.onCompleteObservable.add(function (request) {
  36144. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  36145. });
  36146. return request;
  36147. };
  36148. /** @hidden */
  36149. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  36150. var _this = this;
  36151. return new Promise(function (resolve, reject) {
  36152. _this._loadFile(url, function (data) {
  36153. resolve(data);
  36154. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  36155. reject(exception);
  36156. });
  36157. });
  36158. };
  36159. // Statics
  36160. /**
  36161. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36162. * @returns true if the engine can be created
  36163. * @ignorenaming
  36164. */
  36165. Engine.isSupported = function () {
  36166. try {
  36167. var tempcanvas = document.createElement("canvas");
  36168. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  36169. return gl != null && !!window.WebGLRenderingContext;
  36170. }
  36171. catch (e) {
  36172. return false;
  36173. }
  36174. };
  36175. /**
  36176. * Find the next highest power of two.
  36177. * @param x Number to start search from.
  36178. * @return Next highest power of two.
  36179. */
  36180. Engine.CeilingPOT = function (x) {
  36181. x--;
  36182. x |= x >> 1;
  36183. x |= x >> 2;
  36184. x |= x >> 4;
  36185. x |= x >> 8;
  36186. x |= x >> 16;
  36187. x++;
  36188. return x;
  36189. };
  36190. /**
  36191. * Find the next lowest power of two.
  36192. * @param x Number to start search from.
  36193. * @return Next lowest power of two.
  36194. */
  36195. Engine.FloorPOT = function (x) {
  36196. x = x | (x >> 1);
  36197. x = x | (x >> 2);
  36198. x = x | (x >> 4);
  36199. x = x | (x >> 8);
  36200. x = x | (x >> 16);
  36201. return x - (x >> 1);
  36202. };
  36203. /**
  36204. * Find the nearest power of two.
  36205. * @param x Number to start search from.
  36206. * @return Next nearest power of two.
  36207. */
  36208. Engine.NearestPOT = function (x) {
  36209. var c = Engine.CeilingPOT(x);
  36210. var f = Engine.FloorPOT(x);
  36211. return (c - x) > (x - f) ? f : c;
  36212. };
  36213. /**
  36214. * Get the closest exponent of two
  36215. * @param value defines the value to approximate
  36216. * @param max defines the maximum value to return
  36217. * @param mode defines how to define the closest value
  36218. * @returns closest exponent of two of the given value
  36219. */
  36220. Engine.GetExponentOfTwo = function (value, max, mode) {
  36221. if (mode === void 0) { mode = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_NEAREST; }
  36222. var pot;
  36223. switch (mode) {
  36224. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_FLOOR:
  36225. pot = Engine.FloorPOT(value);
  36226. break;
  36227. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_NEAREST:
  36228. pot = Engine.NearestPOT(value);
  36229. break;
  36230. case _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_CEILING:
  36231. default:
  36232. pot = Engine.CeilingPOT(value);
  36233. break;
  36234. }
  36235. return Math.min(pot, max);
  36236. };
  36237. /**
  36238. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36239. * @param func - the function to be called
  36240. * @param requester - the object that will request the next frame. Falls back to window.
  36241. * @returns frame number
  36242. */
  36243. Engine.QueueNewFrame = function (func, requester) {
  36244. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_8__["DomManagement"].IsWindowObjectExist()) {
  36245. return setTimeout(func, 16);
  36246. }
  36247. if (!requester) {
  36248. requester = window;
  36249. }
  36250. if (requester.requestAnimationFrame) {
  36251. return requester.requestAnimationFrame(func);
  36252. }
  36253. else if (requester.msRequestAnimationFrame) {
  36254. return requester.msRequestAnimationFrame(func);
  36255. }
  36256. else if (requester.webkitRequestAnimationFrame) {
  36257. return requester.webkitRequestAnimationFrame(func);
  36258. }
  36259. else if (requester.mozRequestAnimationFrame) {
  36260. return requester.mozRequestAnimationFrame(func);
  36261. }
  36262. else if (requester.oRequestAnimationFrame) {
  36263. return requester.oRequestAnimationFrame(func);
  36264. }
  36265. else {
  36266. return window.setTimeout(func, 16);
  36267. }
  36268. };
  36269. /**
  36270. * Ask the browser to promote the current element to pointerlock mode
  36271. * @param element defines the DOM element to promote
  36272. */
  36273. Engine._RequestPointerlock = function (element) {
  36274. element.requestPointerLock = element.requestPointerLock || element.msRequestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;
  36275. if (element.requestPointerLock) {
  36276. element.requestPointerLock();
  36277. }
  36278. };
  36279. /**
  36280. * Asks the browser to exit pointerlock mode
  36281. */
  36282. Engine._ExitPointerlock = function () {
  36283. var anyDoc = document;
  36284. document.exitPointerLock = document.exitPointerLock || anyDoc.msExitPointerLock || anyDoc.mozExitPointerLock || anyDoc.webkitExitPointerLock;
  36285. if (document.exitPointerLock) {
  36286. document.exitPointerLock();
  36287. }
  36288. };
  36289. /**
  36290. * Ask the browser to promote the current element to fullscreen rendering mode
  36291. * @param element defines the DOM element to promote
  36292. */
  36293. Engine._RequestFullscreen = function (element) {
  36294. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  36295. if (!requestFunction) {
  36296. return;
  36297. }
  36298. requestFunction.call(element);
  36299. };
  36300. /**
  36301. * Asks the browser to exit fullscreen mode
  36302. */
  36303. Engine._ExitFullscreen = function () {
  36304. var anyDoc = document;
  36305. if (document.exitFullscreen) {
  36306. document.exitFullscreen();
  36307. }
  36308. else if (anyDoc.mozCancelFullScreen) {
  36309. anyDoc.mozCancelFullScreen();
  36310. }
  36311. else if (anyDoc.webkitCancelFullScreen) {
  36312. anyDoc.webkitCancelFullScreen();
  36313. }
  36314. else if (anyDoc.msCancelFullScreen) {
  36315. anyDoc.msCancelFullScreen();
  36316. }
  36317. };
  36318. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36319. Engine.ExceptionList = [
  36320. { key: "Chrome\/63\.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  36321. { key: "Firefox\/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  36322. { key: "Firefox\/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  36323. { key: "Chrome\/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  36324. { key: "Chrome\/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  36325. { key: "Chrome\/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  36326. { key: "Mac OS.+Chrome\/71", capture: null, captureConstraint: null, targets: ["vao"] },
  36327. { key: "Mac OS.+Chrome\/72", capture: null, captureConstraint: null, targets: ["vao"] }
  36328. ];
  36329. /** @hidden */
  36330. Engine._TextureLoaders = [];
  36331. // Const statics
  36332. /** Defines that alpha blending is disabled */
  36333. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_DISABLE;
  36334. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36335. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_ADD;
  36336. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36337. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_COMBINE;
  36338. /** Defines that alpha blending to DEST - SRC * DEST */
  36339. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_SUBTRACT;
  36340. /** Defines that alpha blending to SRC * DEST */
  36341. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_MULTIPLY;
  36342. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36343. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_MAXIMIZED;
  36344. /** Defines that alpha blending to SRC + DEST */
  36345. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_ONEONE;
  36346. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36347. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_PREMULTIPLIED;
  36348. /**
  36349. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36350. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36351. */
  36352. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  36353. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36354. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_INTERPOLATE;
  36355. /**
  36356. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36357. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36358. */
  36359. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_SCREENMODE;
  36360. /** Defines that the ressource is not delayed*/
  36361. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  36362. /** Defines that the ressource was successfully delay loaded */
  36363. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  36364. /** Defines that the ressource is currently delay loading */
  36365. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING;
  36366. /** Defines that the ressource is delayed and has not started loading */
  36367. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  36368. // Depht or Stencil test Constants.
  36369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36370. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].NEVER;
  36371. /** 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 */
  36372. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALWAYS;
  36373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36374. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].LESS;
  36375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36376. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].EQUAL;
  36377. /** 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 */
  36378. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].LEQUAL;
  36379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36380. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].GREATER;
  36381. /** 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 */
  36382. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].GEQUAL;
  36383. /** 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 */
  36384. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].NOTEQUAL;
  36385. // Stencil Actions Constants.
  36386. /** Passed to stencilOperation to specify that stencil value must be kept */
  36387. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].KEEP;
  36388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36389. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].REPLACE;
  36390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36391. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].INCR;
  36392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36393. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DECR;
  36394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36395. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].INVERT;
  36396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36397. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].INCR_WRAP;
  36398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36399. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DECR_WRAP;
  36400. /** Texture is not repeating outside of 0..1 UVs */
  36401. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  36402. /** Texture is repeating outside of 0..1 UVs */
  36403. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  36404. /** Texture is repeating and mirrored */
  36405. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  36406. /** ALPHA */
  36407. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_ALPHA;
  36408. /** LUMINANCE */
  36409. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_LUMINANCE;
  36410. /** LUMINANCE_ALPHA */
  36411. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  36412. /** RGB */
  36413. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGB;
  36414. /** RGBA */
  36415. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  36416. /** RED */
  36417. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RED;
  36418. /** RED (2nd reference) */
  36419. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_R;
  36420. /** RG */
  36421. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RG;
  36422. /** RED_INTEGER */
  36423. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  36424. /** RED_INTEGER (2nd reference) */
  36425. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_R_INTEGER;
  36426. /** RG_INTEGER */
  36427. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  36428. /** RGB_INTEGER */
  36429. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  36430. /** RGBA_INTEGER */
  36431. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  36432. /** UNSIGNED_BYTE */
  36433. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  36434. /** UNSIGNED_BYTE (2nd reference) */
  36435. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  36436. /** FLOAT */
  36437. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_FLOAT;
  36438. /** HALF_FLOAT */
  36439. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_HALF_FLOAT;
  36440. /** BYTE */
  36441. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_BYTE;
  36442. /** SHORT */
  36443. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_SHORT;
  36444. /** UNSIGNED_SHORT */
  36445. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  36446. /** INT */
  36447. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_INT;
  36448. /** UNSIGNED_INT */
  36449. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  36450. /** UNSIGNED_SHORT_4_4_4_4 */
  36451. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  36452. /** UNSIGNED_SHORT_5_5_5_1 */
  36453. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  36454. /** UNSIGNED_SHORT_5_6_5 */
  36455. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  36456. /** UNSIGNED_INT_2_10_10_10_REV */
  36457. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  36458. /** UNSIGNED_INT_24_8 */
  36459. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  36460. /** UNSIGNED_INT_10F_11F_11F_REV */
  36461. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  36462. /** UNSIGNED_INT_5_9_9_9_REV */
  36463. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  36464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36465. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  36466. /** nearest is mag = nearest and min = nearest and mip = linear */
  36467. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  36468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36469. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  36470. /** Trilinear is mag = linear and min = linear and mip = linear */
  36471. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  36472. /** nearest is mag = nearest and min = nearest and mip = linear */
  36473. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  36474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36475. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  36476. /** Trilinear is mag = linear and min = linear and mip = linear */
  36477. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  36478. /** mag = nearest and min = nearest and mip = nearest */
  36479. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  36480. /** mag = nearest and min = linear and mip = nearest */
  36481. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  36482. /** mag = nearest and min = linear and mip = linear */
  36483. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  36484. /** mag = nearest and min = linear and mip = none */
  36485. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_LINEAR;
  36486. /** mag = nearest and min = nearest and mip = none */
  36487. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_NEAREST;
  36488. /** mag = linear and min = nearest and mip = nearest */
  36489. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  36490. /** mag = linear and min = nearest and mip = linear */
  36491. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  36492. /** mag = linear and min = linear and mip = none */
  36493. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_LINEAR_LINEAR;
  36494. /** mag = linear and min = nearest and mip = none */
  36495. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_LINEAR_NEAREST;
  36496. /** Explicit coordinates mode */
  36497. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  36498. /** Spherical coordinates mode */
  36499. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_SPHERICAL_MODE;
  36500. /** Planar coordinates mode */
  36501. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_PLANAR_MODE;
  36502. /** Cubic coordinates mode */
  36503. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_CUBIC_MODE;
  36504. /** Projection coordinates mode */
  36505. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_PROJECTION_MODE;
  36506. /** Skybox coordinates mode */
  36507. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_SKYBOX_MODE;
  36508. /** Inverse Cubic coordinates mode */
  36509. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_INVCUBIC_MODE;
  36510. /** Equirectangular coordinates mode */
  36511. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  36512. /** Equirectangular Fixed coordinates mode */
  36513. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  36514. /** Equirectangular Fixed Mirrored coordinates mode */
  36515. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  36516. // Texture rescaling mode
  36517. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36518. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_FLOOR;
  36519. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36520. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_NEAREST;
  36521. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36522. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCALEMODE_CEILING;
  36523. // Updatable statics so stick with vars here
  36524. /**
  36525. * Gets or sets the epsilon value used by collision engine
  36526. */
  36527. Engine.CollisionsEpsilon = 0.001;
  36528. /**
  36529. * Method called to create the default rescale post process on each engine.
  36530. */
  36531. Engine._RescalePostProcessFactory = null;
  36532. return Engine;
  36533. }());
  36534. /***/ }),
  36535. /***/ "./Engines/engineStore.ts":
  36536. /*!********************************!*\
  36537. !*** ./Engines/engineStore.ts ***!
  36538. \********************************/
  36539. /*! exports provided: EngineStore */
  36540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36541. "use strict";
  36542. __webpack_require__.r(__webpack_exports__);
  36543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  36544. /**
  36545. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36546. * during the life time of the application.
  36547. */
  36548. var EngineStore = /** @class */ (function () {
  36549. function EngineStore() {
  36550. }
  36551. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  36552. /**
  36553. * Gets the latest created engine
  36554. */
  36555. get: function () {
  36556. if (this.Instances.length === 0) {
  36557. return null;
  36558. }
  36559. return this.Instances[this.Instances.length - 1];
  36560. },
  36561. enumerable: true,
  36562. configurable: true
  36563. });
  36564. Object.defineProperty(EngineStore, "LastCreatedScene", {
  36565. /**
  36566. * Gets the latest created scene
  36567. */
  36568. get: function () {
  36569. return this._LastCreatedScene;
  36570. },
  36571. enumerable: true,
  36572. configurable: true
  36573. });
  36574. /** Gets the list of created engines */
  36575. EngineStore.Instances = new Array();
  36576. /** @hidden */
  36577. EngineStore._LastCreatedScene = null;
  36578. /**
  36579. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36580. * @ignorenaming
  36581. */
  36582. EngineStore.UseFallbackTexture = true;
  36583. /**
  36584. * Texture content used if a texture cannot loaded
  36585. * @ignorenaming
  36586. */
  36587. EngineStore.FallbackTexture = "";
  36588. return EngineStore;
  36589. }());
  36590. /***/ }),
  36591. /***/ "./Engines/index.ts":
  36592. /*!**************************!*\
  36593. !*** ./Engines/index.ts ***!
  36594. \**************************/
  36595. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, WebGLPipelineContext, WebGL2ShaderProcessor, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  36596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36597. "use strict";
  36598. __webpack_require__.r(__webpack_exports__);
  36599. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  36600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  36601. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  36602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  36603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  36604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  36605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  36606. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  36607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  36608. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  36609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  36610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  36611. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  36612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  36613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  36614. /* harmony import */ var _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./WebGL/webGLPipelineContext */ "./Engines/WebGL/webGLPipelineContext.ts");
  36615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_5__["WebGLPipelineContext"]; });
  36616. /* harmony import */ var _WebGL_webGL2ShaderProcessors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./WebGL/webGL2ShaderProcessors */ "./Engines/WebGL/webGL2ShaderProcessors.ts");
  36617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGL2ShaderProcessor", function() { return _WebGL_webGL2ShaderProcessors__WEBPACK_IMPORTED_MODULE_6__["WebGL2ShaderProcessor"]; });
  36618. /***/ }),
  36619. /***/ "./Engines/nullEngine.ts":
  36620. /*!*******************************!*\
  36621. !*** ./Engines/nullEngine.ts ***!
  36622. \*******************************/
  36623. /*! exports provided: NullEngineOptions, NullEngine */
  36624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36625. "use strict";
  36626. __webpack_require__.r(__webpack_exports__);
  36627. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  36628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  36629. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36630. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  36631. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  36632. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  36633. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  36634. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  36635. /* harmony import */ var _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/dataBuffer */ "./Meshes/dataBuffer.ts");
  36636. /**
  36637. * Options to create the null engine
  36638. */
  36639. var NullEngineOptions = /** @class */ (function () {
  36640. function NullEngineOptions() {
  36641. /**
  36642. * Render width (Default: 512)
  36643. */
  36644. this.renderWidth = 512;
  36645. /**
  36646. * Render height (Default: 256)
  36647. */
  36648. this.renderHeight = 256;
  36649. /**
  36650. * Texture size (Default: 512)
  36651. */
  36652. this.textureSize = 512;
  36653. /**
  36654. * If delta time between frames should be constant
  36655. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36656. */
  36657. this.deterministicLockstep = false;
  36658. /**
  36659. * Maximum about of steps between frames (Default: 4)
  36660. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36661. */
  36662. this.lockstepMaxSteps = 4;
  36663. }
  36664. return NullEngineOptions;
  36665. }());
  36666. /**
  36667. * The null engine class provides support for headless version of babylon.js.
  36668. * This can be used in server side scenario or for testing purposes
  36669. */
  36670. var NullEngine = /** @class */ (function (_super) {
  36671. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  36672. function NullEngine(options) {
  36673. if (options === void 0) { options = new NullEngineOptions(); }
  36674. var _this = _super.call(this, null) || this;
  36675. if (options.deterministicLockstep === undefined) {
  36676. options.deterministicLockstep = false;
  36677. }
  36678. if (options.lockstepMaxSteps === undefined) {
  36679. options.lockstepMaxSteps = 4;
  36680. }
  36681. _this._options = options;
  36682. // Init caps
  36683. // We consider we are on a webgl1 capable device
  36684. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  36685. _this._caps.maxTexturesImageUnits = 16;
  36686. _this._caps.maxVertexTextureImageUnits = 16;
  36687. _this._caps.maxTextureSize = 512;
  36688. _this._caps.maxCubemapTextureSize = 512;
  36689. _this._caps.maxRenderTextureSize = 512;
  36690. _this._caps.maxVertexAttribs = 16;
  36691. _this._caps.maxVaryingVectors = 16;
  36692. _this._caps.maxFragmentUniformVectors = 16;
  36693. _this._caps.maxVertexUniformVectors = 16;
  36694. // Extensions
  36695. _this._caps.standardDerivatives = false;
  36696. _this._caps.astc = null;
  36697. _this._caps.s3tc = null;
  36698. _this._caps.pvrtc = null;
  36699. _this._caps.etc1 = null;
  36700. _this._caps.etc2 = null;
  36701. _this._caps.textureAnisotropicFilterExtension = null;
  36702. _this._caps.maxAnisotropy = 0;
  36703. _this._caps.uintIndices = false;
  36704. _this._caps.fragmentDepthSupported = false;
  36705. _this._caps.highPrecisionShaderSupported = true;
  36706. _this._caps.colorBufferFloat = false;
  36707. _this._caps.textureFloat = false;
  36708. _this._caps.textureFloatLinearFiltering = false;
  36709. _this._caps.textureFloatRender = false;
  36710. _this._caps.textureHalfFloat = false;
  36711. _this._caps.textureHalfFloatLinearFiltering = false;
  36712. _this._caps.textureHalfFloatRender = false;
  36713. _this._caps.textureLOD = false;
  36714. _this._caps.drawBuffersExtension = false;
  36715. _this._caps.depthTextureExtension = false;
  36716. _this._caps.vertexArrayObject = false;
  36717. _this._caps.instancedArrays = false;
  36718. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  36719. // Wrappers
  36720. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  36721. if (typeof URL === "undefined") {
  36722. theCurrentGlobal.URL = {
  36723. createObjectURL: function () { },
  36724. revokeObjectURL: function () { }
  36725. };
  36726. }
  36727. if (typeof Blob === "undefined") {
  36728. theCurrentGlobal.Blob = function () { };
  36729. }
  36730. return _this;
  36731. }
  36732. /**
  36733. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36734. */
  36735. NullEngine.prototype.isDeterministicLockStep = function () {
  36736. return this._options.deterministicLockstep;
  36737. };
  36738. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  36739. NullEngine.prototype.getLockstepMaxSteps = function () {
  36740. return this._options.lockstepMaxSteps;
  36741. };
  36742. /**
  36743. * Sets hardware scaling, used to save performance if needed
  36744. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36745. */
  36746. NullEngine.prototype.getHardwareScalingLevel = function () {
  36747. return 1.0;
  36748. };
  36749. NullEngine.prototype.createVertexBuffer = function (vertices) {
  36750. var buffer = new _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__["DataBuffer"]();
  36751. buffer.references = 1;
  36752. return buffer;
  36753. };
  36754. NullEngine.prototype.createIndexBuffer = function (indices) {
  36755. var buffer = new _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__["DataBuffer"]();
  36756. buffer.references = 1;
  36757. return buffer;
  36758. };
  36759. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  36760. if (stencil === void 0) { stencil = false; }
  36761. };
  36762. NullEngine.prototype.getRenderWidth = function (useScreen) {
  36763. if (useScreen === void 0) { useScreen = false; }
  36764. if (!useScreen && this._currentRenderTarget) {
  36765. return this._currentRenderTarget.width;
  36766. }
  36767. return this._options.renderWidth;
  36768. };
  36769. NullEngine.prototype.getRenderHeight = function (useScreen) {
  36770. if (useScreen === void 0) { useScreen = false; }
  36771. if (!useScreen && this._currentRenderTarget) {
  36772. return this._currentRenderTarget.height;
  36773. }
  36774. return this._options.renderHeight;
  36775. };
  36776. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  36777. this._cachedViewport = viewport;
  36778. };
  36779. NullEngine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context) {
  36780. return {
  36781. __SPECTOR_rebuildProgram: null,
  36782. };
  36783. };
  36784. NullEngine.prototype.getUniforms = function (pipelineContext, uniformsNames) {
  36785. return [];
  36786. };
  36787. NullEngine.prototype.getAttributes = function (pipelineContext, attributesNames) {
  36788. return [];
  36789. };
  36790. NullEngine.prototype.bindSamplers = function (effect) {
  36791. this._currentEffect = null;
  36792. };
  36793. NullEngine.prototype.enableEffect = function (effect) {
  36794. this._currentEffect = effect;
  36795. if (effect.onBind) {
  36796. effect.onBind(effect);
  36797. }
  36798. if (effect._onBindObservable) {
  36799. effect._onBindObservable.notifyObservers(effect);
  36800. }
  36801. };
  36802. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  36803. if (zOffset === void 0) { zOffset = 0; }
  36804. if (reverseSide === void 0) { reverseSide = false; }
  36805. };
  36806. NullEngine.prototype.setIntArray = function (uniform, array) {
  36807. };
  36808. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  36809. };
  36810. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  36811. };
  36812. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  36813. };
  36814. NullEngine.prototype.setFloatArray = function (uniform, array) {
  36815. };
  36816. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  36817. };
  36818. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  36819. };
  36820. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  36821. };
  36822. NullEngine.prototype.setArray = function (uniform, array) {
  36823. };
  36824. NullEngine.prototype.setArray2 = function (uniform, array) {
  36825. };
  36826. NullEngine.prototype.setArray3 = function (uniform, array) {
  36827. };
  36828. NullEngine.prototype.setArray4 = function (uniform, array) {
  36829. };
  36830. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  36831. };
  36832. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  36833. };
  36834. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  36835. };
  36836. NullEngine.prototype.setFloat = function (uniform, value) {
  36837. };
  36838. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  36839. };
  36840. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  36841. };
  36842. NullEngine.prototype.setBool = function (uniform, bool) {
  36843. };
  36844. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  36845. };
  36846. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  36847. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  36848. if (this._alphaMode === mode) {
  36849. return;
  36850. }
  36851. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  36852. if (!noDepthWriteChange) {
  36853. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  36854. }
  36855. this._alphaMode = mode;
  36856. };
  36857. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  36858. };
  36859. NullEngine.prototype.wipeCaches = function (bruteForce) {
  36860. if (this.preventCacheWipeBetweenFrames) {
  36861. return;
  36862. }
  36863. this.resetTextureCache();
  36864. this._currentEffect = null;
  36865. if (bruteForce) {
  36866. this._currentProgram = null;
  36867. this._stencilState.reset();
  36868. this._depthCullingState.reset();
  36869. this._alphaState.reset();
  36870. }
  36871. this._cachedVertexBuffers = null;
  36872. this._cachedIndexBuffer = null;
  36873. this._cachedEffectForVertexBuffers = null;
  36874. };
  36875. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  36876. };
  36877. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  36878. };
  36879. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  36880. };
  36881. /** @hidden */
  36882. NullEngine.prototype._createTexture = function () {
  36883. return {};
  36884. };
  36885. /** @hidden */
  36886. NullEngine.prototype._releaseTexture = function (texture) {
  36887. };
  36888. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  36889. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  36890. if (onLoad === void 0) { onLoad = null; }
  36891. if (onError === void 0) { onError = null; }
  36892. if (buffer === void 0) { buffer = null; }
  36893. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  36894. var url = String(urlArg);
  36895. texture.url = url;
  36896. texture.generateMipMaps = !noMipmap;
  36897. texture.samplingMode = samplingMode;
  36898. texture.invertY = invertY;
  36899. texture.baseWidth = this._options.textureSize;
  36900. texture.baseHeight = this._options.textureSize;
  36901. texture.width = this._options.textureSize;
  36902. texture.height = this._options.textureSize;
  36903. if (format) {
  36904. texture.format = format;
  36905. }
  36906. texture.isReady = true;
  36907. if (onLoad) {
  36908. onLoad();
  36909. }
  36910. this._internalTexturesCache.push(texture);
  36911. return texture;
  36912. };
  36913. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  36914. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  36915. if (options !== undefined && typeof options === "object") {
  36916. fullOptions.generateMipMaps = options.generateMipMaps;
  36917. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  36918. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  36919. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  36920. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  36921. }
  36922. else {
  36923. fullOptions.generateMipMaps = options;
  36924. fullOptions.generateDepthBuffer = true;
  36925. fullOptions.generateStencilBuffer = false;
  36926. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  36927. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  36928. }
  36929. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  36930. var width = size.width || size;
  36931. var height = size.height || size;
  36932. texture._depthStencilBuffer = {};
  36933. texture._framebuffer = {};
  36934. texture.baseWidth = width;
  36935. texture.baseHeight = height;
  36936. texture.width = width;
  36937. texture.height = height;
  36938. texture.isReady = true;
  36939. texture.samples = 1;
  36940. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  36941. texture.samplingMode = fullOptions.samplingMode;
  36942. texture.type = fullOptions.type;
  36943. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  36944. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  36945. this._internalTexturesCache.push(texture);
  36946. return texture;
  36947. };
  36948. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  36949. texture.samplingMode = samplingMode;
  36950. };
  36951. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  36952. if (this._currentRenderTarget) {
  36953. this.unBindFramebuffer(this._currentRenderTarget);
  36954. }
  36955. this._currentRenderTarget = texture;
  36956. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  36957. if (this._cachedViewport && !forceFullscreenViewport) {
  36958. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  36959. }
  36960. };
  36961. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  36962. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  36963. this._currentRenderTarget = null;
  36964. if (onBeforeUnbind) {
  36965. if (texture._MSAAFramebuffer) {
  36966. this._currentFramebuffer = texture._framebuffer;
  36967. }
  36968. onBeforeUnbind();
  36969. }
  36970. this._currentFramebuffer = null;
  36971. };
  36972. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  36973. var buffer = new _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__["DataBuffer"]();
  36974. buffer.references = 1;
  36975. buffer.capacity = 1;
  36976. return buffer;
  36977. };
  36978. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  36979. if (premulAlpha === void 0) { premulAlpha = false; }
  36980. };
  36981. NullEngine.prototype.areAllEffectsReady = function () {
  36982. return true;
  36983. };
  36984. /**
  36985. * @hidden
  36986. * Get the current error code of the webGL context
  36987. * @returns the error code
  36988. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36989. */
  36990. NullEngine.prototype.getError = function () {
  36991. return 0;
  36992. };
  36993. /** @hidden */
  36994. NullEngine.prototype._getUnpackAlignement = function () {
  36995. return 1;
  36996. };
  36997. /** @hidden */
  36998. NullEngine.prototype._unpackFlipY = function (value) {
  36999. };
  37000. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  37001. if (offset === void 0) { offset = 0; }
  37002. };
  37003. /**
  37004. * Updates a dynamic vertex buffer.
  37005. * @param vertexBuffer the vertex buffer to update
  37006. * @param data the data used to update the vertex buffer
  37007. * @param byteOffset the byte offset of the data (optional)
  37008. * @param byteLength the byte length of the data (optional)
  37009. */
  37010. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  37011. };
  37012. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  37013. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  37014. this._boundTexturesCache[this._activeChannel] = texture;
  37015. return true;
  37016. }
  37017. return false;
  37018. };
  37019. /** @hidden */
  37020. NullEngine.prototype._bindTexture = function (channel, texture) {
  37021. if (channel < 0) {
  37022. return;
  37023. }
  37024. this._bindTextureDirectly(0, texture);
  37025. };
  37026. /** @hidden */
  37027. NullEngine.prototype._releaseBuffer = function (buffer) {
  37028. buffer.references--;
  37029. if (buffer.references === 0) {
  37030. return true;
  37031. }
  37032. return false;
  37033. };
  37034. NullEngine.prototype.releaseEffects = function () {
  37035. };
  37036. NullEngine.prototype.displayLoadingUI = function () {
  37037. };
  37038. NullEngine.prototype.hideLoadingUI = function () {
  37039. };
  37040. /** @hidden */
  37041. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  37042. if (faceIndex === void 0) { faceIndex = 0; }
  37043. if (lod === void 0) { lod = 0; }
  37044. };
  37045. /** @hidden */
  37046. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  37047. if (faceIndex === void 0) { faceIndex = 0; }
  37048. if (lod === void 0) { lod = 0; }
  37049. };
  37050. /** @hidden */
  37051. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  37052. if (faceIndex === void 0) { faceIndex = 0; }
  37053. if (lod === void 0) { lod = 0; }
  37054. };
  37055. /** @hidden */
  37056. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  37057. if (faceIndex === void 0) { faceIndex = 0; }
  37058. if (lod === void 0) { lod = 0; }
  37059. };
  37060. return NullEngine;
  37061. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  37062. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  37063. /***/ }),
  37064. /***/ "./Events/clipboardEvents.ts":
  37065. /*!***********************************!*\
  37066. !*** ./Events/clipboardEvents.ts ***!
  37067. \***********************************/
  37068. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  37069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37070. "use strict";
  37071. __webpack_require__.r(__webpack_exports__);
  37072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  37073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  37074. /**
  37075. * Gather the list of clipboard event types as constants.
  37076. */
  37077. var ClipboardEventTypes = /** @class */ (function () {
  37078. function ClipboardEventTypes() {
  37079. }
  37080. /**
  37081. * The clipboard event is fired when a copy command is active (pressed).
  37082. */
  37083. ClipboardEventTypes.COPY = 0x01; //
  37084. /**
  37085. * The clipboard event is fired when a cut command is active (pressed).
  37086. */
  37087. ClipboardEventTypes.CUT = 0x02;
  37088. /**
  37089. * The clipboard event is fired when a paste command is active (pressed).
  37090. */
  37091. ClipboardEventTypes.PASTE = 0x03;
  37092. return ClipboardEventTypes;
  37093. }());
  37094. /**
  37095. * This class is used to store clipboard related info for the onClipboardObservable event.
  37096. */
  37097. var ClipboardInfo = /** @class */ (function () {
  37098. /**
  37099. *Creates an instance of ClipboardInfo.
  37100. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  37101. * @param event Defines the related dom event
  37102. */
  37103. function ClipboardInfo(
  37104. /**
  37105. * Defines the type of event (BABYLON.ClipboardEventTypes)
  37106. */
  37107. type,
  37108. /**
  37109. * Defines the related dom event
  37110. */
  37111. event) {
  37112. this.type = type;
  37113. this.event = event;
  37114. }
  37115. /**
  37116. * Get the clipboard event's type from the keycode.
  37117. * @param keyCode Defines the keyCode for the current keyboard event.
  37118. * @return {number}
  37119. */
  37120. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  37121. var charCode = keyCode;
  37122. //TODO: add codes for extended ASCII
  37123. switch (charCode) {
  37124. case 67: return ClipboardEventTypes.COPY;
  37125. case 86: return ClipboardEventTypes.PASTE;
  37126. case 88: return ClipboardEventTypes.CUT;
  37127. default: return -1;
  37128. }
  37129. };
  37130. return ClipboardInfo;
  37131. }());
  37132. /***/ }),
  37133. /***/ "./Events/index.ts":
  37134. /*!*************************!*\
  37135. !*** ./Events/index.ts ***!
  37136. \*************************/
  37137. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  37138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37139. "use strict";
  37140. __webpack_require__.r(__webpack_exports__);
  37141. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  37142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  37143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  37144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  37145. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  37146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  37147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  37148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  37149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  37150. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  37151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  37152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  37153. /***/ }),
  37154. /***/ "./Events/keyboardEvents.ts":
  37155. /*!**********************************!*\
  37156. !*** ./Events/keyboardEvents.ts ***!
  37157. \**********************************/
  37158. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  37159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37160. "use strict";
  37161. __webpack_require__.r(__webpack_exports__);
  37162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  37163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  37164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  37165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37166. /**
  37167. * Gather the list of keyboard event types as constants.
  37168. */
  37169. var KeyboardEventTypes = /** @class */ (function () {
  37170. function KeyboardEventTypes() {
  37171. }
  37172. /**
  37173. * The keydown event is fired when a key becomes active (pressed).
  37174. */
  37175. KeyboardEventTypes.KEYDOWN = 0x01;
  37176. /**
  37177. * The keyup event is fired when a key has been released.
  37178. */
  37179. KeyboardEventTypes.KEYUP = 0x02;
  37180. return KeyboardEventTypes;
  37181. }());
  37182. /**
  37183. * This class is used to store keyboard related info for the onKeyboardObservable event.
  37184. */
  37185. var KeyboardInfo = /** @class */ (function () {
  37186. /**
  37187. * Instantiates a new keyboard info.
  37188. * This class is used to store keyboard related info for the onKeyboardObservable event.
  37189. * @param type Defines the type of event (KeyboardEventTypes)
  37190. * @param event Defines the related dom event
  37191. */
  37192. function KeyboardInfo(
  37193. /**
  37194. * Defines the type of event (KeyboardEventTypes)
  37195. */
  37196. type,
  37197. /**
  37198. * Defines the related dom event
  37199. */
  37200. event) {
  37201. this.type = type;
  37202. this.event = event;
  37203. }
  37204. return KeyboardInfo;
  37205. }());
  37206. /**
  37207. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  37208. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  37209. */
  37210. var KeyboardInfoPre = /** @class */ (function (_super) {
  37211. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  37212. /**
  37213. * Instantiates a new keyboard pre info.
  37214. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  37215. * @param type Defines the type of event (KeyboardEventTypes)
  37216. * @param event Defines the related dom event
  37217. */
  37218. function KeyboardInfoPre(
  37219. /**
  37220. * Defines the type of event (KeyboardEventTypes)
  37221. */
  37222. type,
  37223. /**
  37224. * Defines the related dom event
  37225. */
  37226. event) {
  37227. var _this = _super.call(this, type, event) || this;
  37228. _this.type = type;
  37229. _this.event = event;
  37230. _this.skipOnPointerObservable = false;
  37231. return _this;
  37232. }
  37233. return KeyboardInfoPre;
  37234. }(KeyboardInfo));
  37235. /***/ }),
  37236. /***/ "./Events/pointerEvents.ts":
  37237. /*!*********************************!*\
  37238. !*** ./Events/pointerEvents.ts ***!
  37239. \*********************************/
  37240. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  37241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37242. "use strict";
  37243. __webpack_require__.r(__webpack_exports__);
  37244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  37245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  37246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  37247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  37248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37249. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  37250. /**
  37251. * Gather the list of pointer event types as constants.
  37252. */
  37253. var PointerEventTypes = /** @class */ (function () {
  37254. function PointerEventTypes() {
  37255. }
  37256. /**
  37257. * 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.
  37258. */
  37259. PointerEventTypes.POINTERDOWN = 0x01;
  37260. /**
  37261. * The pointerup event is fired when a pointer is no longer active.
  37262. */
  37263. PointerEventTypes.POINTERUP = 0x02;
  37264. /**
  37265. * The pointermove event is fired when a pointer changes coordinates.
  37266. */
  37267. PointerEventTypes.POINTERMOVE = 0x04;
  37268. /**
  37269. * The pointerwheel event is fired when a mouse wheel has been rotated.
  37270. */
  37271. PointerEventTypes.POINTERWHEEL = 0x08;
  37272. /**
  37273. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  37274. */
  37275. PointerEventTypes.POINTERPICK = 0x10;
  37276. /**
  37277. * The pointertap event is fired when a the object has been touched and released without drag.
  37278. */
  37279. PointerEventTypes.POINTERTAP = 0x20;
  37280. /**
  37281. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  37282. */
  37283. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  37284. return PointerEventTypes;
  37285. }());
  37286. /**
  37287. * Base class of pointer info types.
  37288. */
  37289. var PointerInfoBase = /** @class */ (function () {
  37290. /**
  37291. * Instantiates the base class of pointers info.
  37292. * @param type Defines the type of event (PointerEventTypes)
  37293. * @param event Defines the related dom event
  37294. */
  37295. function PointerInfoBase(
  37296. /**
  37297. * Defines the type of event (PointerEventTypes)
  37298. */
  37299. type,
  37300. /**
  37301. * Defines the related dom event
  37302. */
  37303. event) {
  37304. this.type = type;
  37305. this.event = event;
  37306. }
  37307. return PointerInfoBase;
  37308. }());
  37309. /**
  37310. * This class is used to store pointer related info for the onPrePointerObservable event.
  37311. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  37312. */
  37313. var PointerInfoPre = /** @class */ (function (_super) {
  37314. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  37315. /**
  37316. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  37317. * @param type Defines the type of event (PointerEventTypes)
  37318. * @param event Defines the related dom event
  37319. * @param localX Defines the local x coordinates of the pointer when the event occured
  37320. * @param localY Defines the local y coordinates of the pointer when the event occured
  37321. */
  37322. function PointerInfoPre(type, event, localX, localY) {
  37323. var _this = _super.call(this, type, event) || this;
  37324. /**
  37325. * Ray from a pointer if availible (eg. 6dof controller)
  37326. */
  37327. _this.ray = null;
  37328. _this.skipOnPointerObservable = false;
  37329. _this.localPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  37330. return _this;
  37331. }
  37332. return PointerInfoPre;
  37333. }(PointerInfoBase));
  37334. /**
  37335. * This type contains all the data related to a pointer event in Babylon.js.
  37336. * 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.
  37337. */
  37338. var PointerInfo = /** @class */ (function (_super) {
  37339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  37340. /**
  37341. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  37342. * @param type Defines the type of event (PointerEventTypes)
  37343. * @param event Defines the related dom event
  37344. * @param pickInfo Defines the picking info associated to the info (if any)\
  37345. */
  37346. function PointerInfo(type, event,
  37347. /**
  37348. * Defines the picking info associated to the info (if any)\
  37349. */
  37350. pickInfo) {
  37351. var _this = _super.call(this, type, event) || this;
  37352. _this.pickInfo = pickInfo;
  37353. return _this;
  37354. }
  37355. return PointerInfo;
  37356. }(PointerInfoBase));
  37357. /***/ }),
  37358. /***/ "./Gamepads/Controllers/daydreamController.ts":
  37359. /*!****************************************************!*\
  37360. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  37361. \****************************************************/
  37362. /*! exports provided: DaydreamController */
  37363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37364. "use strict";
  37365. __webpack_require__.r(__webpack_exports__);
  37366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  37367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37368. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  37369. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  37370. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  37371. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37372. /**
  37373. * Google Daydream controller
  37374. */
  37375. var DaydreamController = /** @class */ (function (_super) {
  37376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  37377. /**
  37378. * Creates a new DaydreamController from a gamepad
  37379. * @param vrGamepad the gamepad that the controller should be created from
  37380. */
  37381. function DaydreamController(vrGamepad) {
  37382. var _this = _super.call(this, vrGamepad) || this;
  37383. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  37384. return _this;
  37385. }
  37386. /**
  37387. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  37388. * @param scene scene in which to add meshes
  37389. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  37390. */
  37391. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  37392. var _this = this;
  37393. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  37394. _this._defaultModel = newMeshes[1];
  37395. _this.attachToMesh(_this._defaultModel);
  37396. if (meshLoaded) {
  37397. meshLoaded(_this._defaultModel);
  37398. }
  37399. });
  37400. };
  37401. /**
  37402. * Called once for each button that changed state since the last frame
  37403. * @param buttonIdx Which button index changed
  37404. * @param state New state of the button
  37405. * @param changes Which properties on the state changed since last frame
  37406. */
  37407. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  37408. // Daydream controller only has 1 GamepadButton (on the trackpad).
  37409. if (buttonIdx === 0) {
  37410. var observable = this.onTriggerStateChangedObservable;
  37411. if (observable) {
  37412. observable.notifyObservers(state);
  37413. }
  37414. }
  37415. else {
  37416. // If the app or home buttons are ever made available
  37417. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  37418. }
  37419. };
  37420. /**
  37421. * Base Url for the controller model.
  37422. */
  37423. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  37424. /**
  37425. * File name for the controller model.
  37426. */
  37427. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  37428. /**
  37429. * Gamepad Id prefix used to identify Daydream Controller.
  37430. */
  37431. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  37432. return DaydreamController;
  37433. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  37434. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37435. canCreate: function (gamepadInfo) {
  37436. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  37437. },
  37438. create: function (gamepadInfo) {
  37439. return new DaydreamController(gamepadInfo);
  37440. }
  37441. });
  37442. /***/ }),
  37443. /***/ "./Gamepads/Controllers/gearVRController.ts":
  37444. /*!**************************************************!*\
  37445. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  37446. \**************************************************/
  37447. /*! exports provided: GearVRController */
  37448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37449. "use strict";
  37450. __webpack_require__.r(__webpack_exports__);
  37451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  37452. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37453. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  37454. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  37455. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  37456. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  37457. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37458. /**
  37459. * Gear VR Controller
  37460. */
  37461. var GearVRController = /** @class */ (function (_super) {
  37462. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  37463. /**
  37464. * Creates a new GearVRController from a gamepad
  37465. * @param vrGamepad the gamepad that the controller should be created from
  37466. */
  37467. function GearVRController(vrGamepad) {
  37468. var _this = _super.call(this, vrGamepad) || this;
  37469. _this._buttonIndexToObservableNameMap = [
  37470. 'onPadStateChangedObservable',
  37471. 'onTriggerStateChangedObservable' // Trigger
  37472. ];
  37473. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  37474. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  37475. _this._calculatedPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  37476. _this._disableTrackPosition(_this._calculatedPosition);
  37477. return _this;
  37478. }
  37479. /**
  37480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  37481. * @param scene scene in which to add meshes
  37482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  37483. */
  37484. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  37485. var _this = this;
  37486. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  37487. // Offset the controller so it will rotate around the users wrist
  37488. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  37489. newMeshes[1].parent = mesh;
  37490. newMeshes[1].position.z = -0.15;
  37491. _this._defaultModel = mesh;
  37492. _this.attachToMesh(_this._defaultModel);
  37493. if (meshLoaded) {
  37494. meshLoaded(_this._defaultModel);
  37495. }
  37496. });
  37497. };
  37498. /**
  37499. * Called once for each button that changed state since the last frame
  37500. * @param buttonIdx Which button index changed
  37501. * @param state New state of the button
  37502. * @param changes Which properties on the state changed since last frame
  37503. */
  37504. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  37505. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  37506. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  37507. // Only emit events for buttons that we know how to map from index to observable
  37508. var observable = this[observableName];
  37509. if (observable) {
  37510. observable.notifyObservers(state);
  37511. }
  37512. }
  37513. };
  37514. /**
  37515. * Base Url for the controller model.
  37516. */
  37517. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  37518. /**
  37519. * File name for the controller model.
  37520. */
  37521. GearVRController.MODEL_FILENAME = 'generic.babylon';
  37522. /**
  37523. * Gamepad Id prefix used to identify this controller.
  37524. */
  37525. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  37526. return GearVRController;
  37527. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  37528. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37529. canCreate: function (gamepadInfo) {
  37530. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  37531. gamepadInfo.id.indexOf('Oculus Go') !== -1 ||
  37532. gamepadInfo.id.indexOf('Vive Focus') !== -1;
  37533. },
  37534. create: function (gamepadInfo) {
  37535. return new GearVRController(gamepadInfo);
  37536. }
  37537. });
  37538. /***/ }),
  37539. /***/ "./Gamepads/Controllers/genericController.ts":
  37540. /*!***************************************************!*\
  37541. !*** ./Gamepads/Controllers/genericController.ts ***!
  37542. \***************************************************/
  37543. /*! exports provided: GenericController */
  37544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37545. "use strict";
  37546. __webpack_require__.r(__webpack_exports__);
  37547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  37548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37549. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  37550. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  37551. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37552. /**
  37553. * Generic Controller
  37554. */
  37555. var GenericController = /** @class */ (function (_super) {
  37556. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  37557. /**
  37558. * Creates a new GenericController from a gamepad
  37559. * @param vrGamepad the gamepad that the controller should be created from
  37560. */
  37561. function GenericController(vrGamepad) {
  37562. return _super.call(this, vrGamepad) || this;
  37563. }
  37564. /**
  37565. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  37566. * @param scene scene in which to add meshes
  37567. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  37568. */
  37569. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  37570. var _this = this;
  37571. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  37572. _this._defaultModel = newMeshes[1];
  37573. _this.attachToMesh(_this._defaultModel);
  37574. if (meshLoaded) {
  37575. meshLoaded(_this._defaultModel);
  37576. }
  37577. });
  37578. };
  37579. /**
  37580. * Called once for each button that changed state since the last frame
  37581. * @param buttonIdx Which button index changed
  37582. * @param state New state of the button
  37583. * @param changes Which properties on the state changed since last frame
  37584. */
  37585. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  37586. console.log("Button id: " + buttonIdx + "state: ");
  37587. console.dir(state);
  37588. };
  37589. /**
  37590. * Base Url for the controller model.
  37591. */
  37592. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  37593. /**
  37594. * File name for the controller model.
  37595. */
  37596. GenericController.MODEL_FILENAME = 'generic.babylon';
  37597. return GenericController;
  37598. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  37599. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  37600. /***/ }),
  37601. /***/ "./Gamepads/Controllers/index.ts":
  37602. /*!***************************************!*\
  37603. !*** ./Gamepads/Controllers/index.ts ***!
  37604. \***************************************/
  37605. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  37606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37607. "use strict";
  37608. __webpack_require__.r(__webpack_exports__);
  37609. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  37610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37611. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  37612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  37613. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  37614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  37615. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  37616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  37617. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  37619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  37620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  37621. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  37622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  37623. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  37624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  37625. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  37626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  37627. /***/ }),
  37628. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  37629. /*!*******************************************************!*\
  37630. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  37631. \*******************************************************/
  37632. /*! exports provided: OculusTouchController */
  37633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37634. "use strict";
  37635. __webpack_require__.r(__webpack_exports__);
  37636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  37637. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37638. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  37639. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  37640. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  37641. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37642. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  37643. /**
  37644. * Oculus Touch Controller
  37645. */
  37646. var OculusTouchController = /** @class */ (function (_super) {
  37647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  37648. /**
  37649. * Creates a new OculusTouchController from a gamepad
  37650. * @param vrGamepad the gamepad that the controller should be created from
  37651. */
  37652. function OculusTouchController(vrGamepad) {
  37653. var _this = _super.call(this, vrGamepad) || this;
  37654. /**
  37655. * Fired when the secondary trigger on this controller is modified
  37656. */
  37657. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37658. /**
  37659. * Fired when the thumb rest on this controller is modified
  37660. */
  37661. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37662. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  37663. return _this;
  37664. }
  37665. /**
  37666. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  37667. * @param scene scene in which to add meshes
  37668. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  37669. */
  37670. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  37671. var _this = this;
  37672. var meshName;
  37673. // Hand
  37674. if (this.hand === 'left') {
  37675. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  37676. }
  37677. else { // Right is the default if no hand is specified
  37678. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  37679. }
  37680. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController._IsQuest ? OculusTouchController.QUEST_MODEL_BASE_URL : OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  37681. /*
  37682. Parent Mesh name: oculus_touch_left
  37683. - body
  37684. - trigger
  37685. - thumbstick
  37686. - grip
  37687. - button_y
  37688. - button_x
  37689. - button_enter
  37690. */
  37691. _this._defaultModel = OculusTouchController._IsQuest ? newMeshes[0] : newMeshes[1];
  37692. _this.attachToMesh(_this._defaultModel);
  37693. if (meshLoaded) {
  37694. meshLoaded(_this._defaultModel);
  37695. }
  37696. });
  37697. };
  37698. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  37699. /**
  37700. * Fired when the A button on this controller is modified
  37701. */
  37702. get: function () {
  37703. if (this.hand === 'right') {
  37704. return this.onMainButtonStateChangedObservable;
  37705. }
  37706. else {
  37707. throw new Error('No A button on left hand');
  37708. }
  37709. },
  37710. enumerable: true,
  37711. configurable: true
  37712. });
  37713. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  37714. /**
  37715. * Fired when the B button on this controller is modified
  37716. */
  37717. get: function () {
  37718. if (this.hand === 'right') {
  37719. return this.onSecondaryButtonStateChangedObservable;
  37720. }
  37721. else {
  37722. throw new Error('No B button on left hand');
  37723. }
  37724. },
  37725. enumerable: true,
  37726. configurable: true
  37727. });
  37728. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  37729. /**
  37730. * Fired when the X button on this controller is modified
  37731. */
  37732. get: function () {
  37733. if (this.hand === 'left') {
  37734. return this.onMainButtonStateChangedObservable;
  37735. }
  37736. else {
  37737. throw new Error('No X button on right hand');
  37738. }
  37739. },
  37740. enumerable: true,
  37741. configurable: true
  37742. });
  37743. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  37744. /**
  37745. * Fired when the Y button on this controller is modified
  37746. */
  37747. get: function () {
  37748. if (this.hand === 'left') {
  37749. return this.onSecondaryButtonStateChangedObservable;
  37750. }
  37751. else {
  37752. throw new Error('No Y button on right hand');
  37753. }
  37754. },
  37755. enumerable: true,
  37756. configurable: true
  37757. });
  37758. /**
  37759. * Called once for each button that changed state since the last frame
  37760. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  37761. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  37762. * 2) secondary trigger (same)
  37763. * 3) A (right) X (left), touch, pressed = value
  37764. * 4) B / Y
  37765. * 5) thumb rest
  37766. * @param buttonIdx Which button index changed
  37767. * @param state New state of the button
  37768. * @param changes Which properties on the state changed since last frame
  37769. */
  37770. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  37771. var notifyObject = state; //{ state: state, changes: changes };
  37772. var triggerDirection = this.hand === 'right' ? -1 : 1;
  37773. switch (buttonIdx) {
  37774. case 0:
  37775. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  37776. return;
  37777. case 1: // index trigger
  37778. if (!OculusTouchController._IsQuest && this._defaultModel) {
  37779. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  37780. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  37781. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  37782. }
  37783. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  37784. return;
  37785. case 2: // secondary trigger
  37786. if (!OculusTouchController._IsQuest && this._defaultModel) {
  37787. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  37788. }
  37789. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  37790. return;
  37791. case 3:
  37792. if (!OculusTouchController._IsQuest && this._defaultModel) {
  37793. if (notifyObject.pressed) {
  37794. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  37795. }
  37796. else {
  37797. (this._defaultModel.getChildren()[1]).position.y = 0;
  37798. }
  37799. }
  37800. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  37801. return;
  37802. case 4:
  37803. if (!OculusTouchController._IsQuest && this._defaultModel) {
  37804. if (notifyObject.pressed) {
  37805. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  37806. }
  37807. else {
  37808. (this._defaultModel.getChildren()[2]).position.y = 0;
  37809. }
  37810. }
  37811. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  37812. return;
  37813. case 5:
  37814. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  37815. return;
  37816. }
  37817. };
  37818. /**
  37819. * Base Url for the controller model.
  37820. */
  37821. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  37822. /**
  37823. * File name for the left controller model.
  37824. */
  37825. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  37826. /**
  37827. * File name for the right controller model.
  37828. */
  37829. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  37830. /**
  37831. * Base Url for the Quest controller model.
  37832. */
  37833. OculusTouchController.QUEST_MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculusQuest/';
  37834. /**
  37835. * @hidden
  37836. * If the controllers are running on a device that needs the updated Quest controller models
  37837. */
  37838. OculusTouchController._IsQuest = false;
  37839. return OculusTouchController;
  37840. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  37841. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37842. canCreate: function (gamepadInfo) {
  37843. // If the headset reports being an Oculus Quest, use the Quest controller models
  37844. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].LastCreatedEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].LastCreatedEngine._vrDisplay && _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].LastCreatedEngine._vrDisplay.displayName === "Oculus Quest") {
  37845. OculusTouchController._IsQuest = true;
  37846. }
  37847. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  37848. },
  37849. create: function (gamepadInfo) {
  37850. return new OculusTouchController(gamepadInfo);
  37851. }
  37852. });
  37853. /***/ }),
  37854. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  37855. /*!*******************************************************!*\
  37856. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  37857. \*******************************************************/
  37858. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  37859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37860. "use strict";
  37861. __webpack_require__.r(__webpack_exports__);
  37862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  37863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  37864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  37865. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37866. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  37867. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  37868. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  37869. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  37870. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37871. /**
  37872. * Defines the types of pose enabled controllers that are supported
  37873. */
  37874. var PoseEnabledControllerType;
  37875. (function (PoseEnabledControllerType) {
  37876. /**
  37877. * HTC Vive
  37878. */
  37879. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  37880. /**
  37881. * Oculus Rift
  37882. */
  37883. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  37884. /**
  37885. * Windows mixed reality
  37886. */
  37887. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  37888. /**
  37889. * Samsung gear VR
  37890. */
  37891. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  37892. /**
  37893. * Google Daydream
  37894. */
  37895. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  37896. /**
  37897. * Generic
  37898. */
  37899. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  37900. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  37901. /**
  37902. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  37903. */
  37904. var PoseEnabledControllerHelper = /** @class */ (function () {
  37905. function PoseEnabledControllerHelper() {
  37906. }
  37907. /**
  37908. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  37909. * @param vrGamepad the gamepad to initialized
  37910. * @returns a vr controller of the type the gamepad identified as
  37911. */
  37912. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  37913. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  37914. var factory = _a[_i];
  37915. if (factory.canCreate(vrGamepad)) {
  37916. return factory.create(vrGamepad);
  37917. }
  37918. }
  37919. if (this._DefaultControllerFactory) {
  37920. return this._DefaultControllerFactory(vrGamepad);
  37921. }
  37922. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  37923. };
  37924. /** @hidden */
  37925. PoseEnabledControllerHelper._ControllerFactories = [];
  37926. /** @hidden */
  37927. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  37928. return PoseEnabledControllerHelper;
  37929. }());
  37930. /**
  37931. * Defines the PoseEnabledController object that contains state of a vr capable controller
  37932. */
  37933. var PoseEnabledController = /** @class */ (function (_super) {
  37934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  37935. /**
  37936. * Creates a new PoseEnabledController from a gamepad
  37937. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  37938. */
  37939. function PoseEnabledController(browserGamepad) {
  37940. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  37941. /**
  37942. * If the controller is used in a webXR session
  37943. */
  37944. _this.isXR = false;
  37945. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  37946. _this._deviceRoomPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  37947. _this._deviceRoomRotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37948. /**
  37949. * The device position in babylon space
  37950. */
  37951. _this.devicePosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  37952. /**
  37953. * The device rotation in babylon space
  37954. */
  37955. _this.deviceRotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37956. /**
  37957. * The scale factor of the device in babylon space
  37958. */
  37959. _this.deviceScaleFactor = 1;
  37960. // Used to convert 6dof controllers to 3dof
  37961. _this._trackPosition = true;
  37962. _this._maxRotationDistFromHeadset = Math.PI / 5;
  37963. _this._draggedRoomRotation = 0;
  37964. _this._leftHandSystemQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37965. /**
  37966. * Internal, matrix used to convert room space to babylon space
  37967. * @hidden
  37968. */
  37969. _this._deviceToWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  37970. /**
  37971. * Node to be used when casting a ray from the controller
  37972. * @hidden
  37973. */
  37974. _this._pointingPoseNode = null;
  37975. _this._workingMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  37976. /**
  37977. * @hidden
  37978. */
  37979. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37980. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  37981. _this.controllerType = PoseEnabledControllerType.GENERIC;
  37982. _this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  37983. _this.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37984. _this._calculatedPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  37985. _this._calculatedRotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37986. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  37987. return _this;
  37988. }
  37989. /**
  37990. * @hidden
  37991. */
  37992. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  37993. if (this._trackPosition) {
  37994. this._calculatedPosition.copyFrom(fixedPosition);
  37995. this._trackPosition = false;
  37996. }
  37997. };
  37998. /**
  37999. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  38000. */
  38001. PoseEnabledController.prototype.update = function () {
  38002. if (this.isXR) {
  38003. return;
  38004. }
  38005. _super.prototype.update.call(this);
  38006. this._updatePoseAndMesh();
  38007. };
  38008. /**
  38009. * Updates only the pose device and mesh without doing any button event checking
  38010. */
  38011. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  38012. if (this.isXR) {
  38013. return;
  38014. }
  38015. var pose = this.browserGamepad.pose;
  38016. this.updateFromDevice(pose);
  38017. 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) {
  38018. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  38019. camera._computeDevicePosition();
  38020. this._deviceToWorld.setTranslation(camera.devicePosition);
  38021. if (camera.deviceRotationQuaternion) {
  38022. var camera = camera;
  38023. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Vector3[0]);
  38024. // Find the radian distance away that the headset is from the controllers rotation
  38025. var distanceAway = Math.atan2(Math.sin(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Vector3[0].y - this._draggedRoomRotation), Math.cos(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["TmpVectors"].Vector3[0].y - this._draggedRoomRotation));
  38026. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  38027. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  38028. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  38029. this._draggedRoomRotation += rotationAmount;
  38030. // Rotate controller around headset
  38031. var sin = Math.sin(-rotationAmount);
  38032. var cos = Math.cos(-rotationAmount);
  38033. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  38034. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  38035. }
  38036. }
  38037. }
  38038. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  38039. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  38040. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  38041. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  38042. if (this._mesh) {
  38043. this._mesh.position.copyFrom(this.devicePosition);
  38044. if (this._mesh.rotationQuaternion) {
  38045. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  38046. }
  38047. }
  38048. };
  38049. /**
  38050. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  38051. * @param poseData raw pose fromthe device
  38052. */
  38053. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  38054. if (this.isXR) {
  38055. return;
  38056. }
  38057. if (poseData) {
  38058. this.rawPose = poseData;
  38059. if (poseData.position) {
  38060. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  38061. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  38062. this._deviceRoomPosition.z *= -1;
  38063. }
  38064. if (this._trackPosition) {
  38065. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  38066. }
  38067. this._calculatedPosition.addInPlace(this.position);
  38068. }
  38069. var pose = this.rawPose;
  38070. if (poseData.orientation && pose.orientation) {
  38071. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  38072. if (this._mesh) {
  38073. if (this._mesh.getScene().useRightHandedSystem) {
  38074. this._deviceRoomRotationQuaternion.z *= -1;
  38075. this._deviceRoomRotationQuaternion.w *= -1;
  38076. }
  38077. else {
  38078. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  38079. }
  38080. }
  38081. // if the camera is set, rotate to the camera's rotation
  38082. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  38083. }
  38084. }
  38085. };
  38086. /**
  38087. * Attaches a mesh to the controller
  38088. * @param mesh the mesh to be attached
  38089. */
  38090. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  38091. if (this._mesh) {
  38092. this._mesh.parent = null;
  38093. }
  38094. this._mesh = mesh;
  38095. if (this._poseControlledCamera) {
  38096. this._mesh.parent = this._poseControlledCamera;
  38097. }
  38098. if (!this._mesh.rotationQuaternion) {
  38099. this._mesh.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38100. }
  38101. // 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
  38102. if (!this.isXR) {
  38103. this._updatePoseAndMesh();
  38104. if (this._pointingPoseNode) {
  38105. var parents = [];
  38106. var obj = this._pointingPoseNode;
  38107. while (obj.parent) {
  38108. parents.push(obj.parent);
  38109. obj = obj.parent;
  38110. }
  38111. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  38112. }
  38113. }
  38114. this._meshAttachedObservable.notifyObservers(mesh);
  38115. };
  38116. /**
  38117. * Attaches the controllers mesh to a camera
  38118. * @param camera the camera the mesh should be attached to
  38119. */
  38120. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  38121. this._poseControlledCamera = camera;
  38122. if (this._mesh) {
  38123. this._mesh.parent = this._poseControlledCamera;
  38124. }
  38125. };
  38126. /**
  38127. * Disposes of the controller
  38128. */
  38129. PoseEnabledController.prototype.dispose = function () {
  38130. if (this._mesh) {
  38131. this._mesh.dispose();
  38132. }
  38133. this._mesh = null;
  38134. _super.prototype.dispose.call(this);
  38135. };
  38136. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  38137. /**
  38138. * The mesh that is attached to the controller
  38139. */
  38140. get: function () {
  38141. return this._mesh;
  38142. },
  38143. enumerable: true,
  38144. configurable: true
  38145. });
  38146. /**
  38147. * Gets the ray of the controller in the direction the controller is pointing
  38148. * @param length the length the resulting ray should be
  38149. * @returns a ray in the direction the controller is pointing
  38150. */
  38151. PoseEnabledController.prototype.getForwardRay = function (length) {
  38152. if (length === void 0) { length = 100; }
  38153. if (!this.mesh) {
  38154. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1), length);
  38155. }
  38156. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  38157. var origin = m.getTranslation();
  38158. var forward = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  38159. var forwardWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  38160. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  38161. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  38162. };
  38163. /**
  38164. * Name of the child mesh that can be used to cast a ray from the controller
  38165. */
  38166. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  38167. return PoseEnabledController;
  38168. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  38169. /***/ }),
  38170. /***/ "./Gamepads/Controllers/viveController.ts":
  38171. /*!************************************************!*\
  38172. !*** ./Gamepads/Controllers/viveController.ts ***!
  38173. \************************************************/
  38174. /*! exports provided: ViveController */
  38175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38176. "use strict";
  38177. __webpack_require__.r(__webpack_exports__);
  38178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  38179. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38180. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  38181. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  38182. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  38183. /**
  38184. * Vive Controller
  38185. */
  38186. var ViveController = /** @class */ (function (_super) {
  38187. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  38188. /**
  38189. * Creates a new ViveController from a gamepad
  38190. * @param vrGamepad the gamepad that the controller should be created from
  38191. */
  38192. function ViveController(vrGamepad) {
  38193. var _this = _super.call(this, vrGamepad) || this;
  38194. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  38195. _this._invertLeftStickY = true;
  38196. return _this;
  38197. }
  38198. /**
  38199. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38200. * @param scene scene in which to add meshes
  38201. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38202. */
  38203. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  38204. var _this = this;
  38205. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  38206. /*
  38207. Parent Mesh name: ViveWand
  38208. - body
  38209. - r_gripper
  38210. - l_gripper
  38211. - menu_button
  38212. - system_button
  38213. - trackpad
  38214. - trigger
  38215. - LED
  38216. */
  38217. _this._defaultModel = newMeshes[1];
  38218. _this.attachToMesh(_this._defaultModel);
  38219. if (meshLoaded) {
  38220. meshLoaded(_this._defaultModel);
  38221. }
  38222. });
  38223. };
  38224. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  38225. /**
  38226. * Fired when the left button on this controller is modified
  38227. */
  38228. get: function () {
  38229. return this.onMainButtonStateChangedObservable;
  38230. },
  38231. enumerable: true,
  38232. configurable: true
  38233. });
  38234. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  38235. /**
  38236. * Fired when the right button on this controller is modified
  38237. */
  38238. get: function () {
  38239. return this.onMainButtonStateChangedObservable;
  38240. },
  38241. enumerable: true,
  38242. configurable: true
  38243. });
  38244. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  38245. /**
  38246. * Fired when the menu button on this controller is modified
  38247. */
  38248. get: function () {
  38249. return this.onSecondaryButtonStateChangedObservable;
  38250. },
  38251. enumerable: true,
  38252. configurable: true
  38253. });
  38254. /**
  38255. * Called once for each button that changed state since the last frame
  38256. * Vive mapping:
  38257. * 0: touchpad
  38258. * 1: trigger
  38259. * 2: left AND right buttons
  38260. * 3: menu button
  38261. * @param buttonIdx Which button index changed
  38262. * @param state New state of the button
  38263. * @param changes Which properties on the state changed since last frame
  38264. */
  38265. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  38266. var notifyObject = state; //{ state: state, changes: changes };
  38267. switch (buttonIdx) {
  38268. case 0:
  38269. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  38270. return;
  38271. case 1: // index trigger
  38272. if (this._defaultModel) {
  38273. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  38274. }
  38275. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  38276. return;
  38277. case 2: // left AND right button
  38278. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  38279. return;
  38280. case 3:
  38281. if (this._defaultModel) {
  38282. if (notifyObject.pressed) {
  38283. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  38284. }
  38285. else {
  38286. (this._defaultModel.getChildren()[2]).position.y = 0;
  38287. }
  38288. }
  38289. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  38290. return;
  38291. }
  38292. };
  38293. /**
  38294. * Base Url for the controller model.
  38295. */
  38296. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  38297. /**
  38298. * File name for the controller model.
  38299. */
  38300. ViveController.MODEL_FILENAME = 'wand.babylon';
  38301. return ViveController;
  38302. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  38303. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  38304. canCreate: function (gamepadInfo) {
  38305. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  38306. },
  38307. create: function (gamepadInfo) {
  38308. return new ViveController(gamepadInfo);
  38309. }
  38310. });
  38311. /***/ }),
  38312. /***/ "./Gamepads/Controllers/webVRController.ts":
  38313. /*!*************************************************!*\
  38314. !*** ./Gamepads/Controllers/webVRController.ts ***!
  38315. \*************************************************/
  38316. /*! exports provided: WebVRController */
  38317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38318. "use strict";
  38319. __webpack_require__.r(__webpack_exports__);
  38320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  38321. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38322. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  38323. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  38324. /**
  38325. * Defines the WebVRController object that represents controllers tracked in 3D space
  38326. */
  38327. var WebVRController = /** @class */ (function (_super) {
  38328. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  38329. /**
  38330. * Creates a new WebVRController from a gamepad
  38331. * @param vrGamepad the gamepad that the WebVRController should be created from
  38332. */
  38333. function WebVRController(vrGamepad) {
  38334. var _this = _super.call(this, vrGamepad) || this;
  38335. // Observables
  38336. /**
  38337. * Fired when the trigger state has changed
  38338. */
  38339. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38340. /**
  38341. * Fired when the main button state has changed
  38342. */
  38343. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38344. /**
  38345. * Fired when the secondary button state has changed
  38346. */
  38347. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38348. /**
  38349. * Fired when the pad state has changed
  38350. */
  38351. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38352. /**
  38353. * Fired when controllers stick values have changed
  38354. */
  38355. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38356. /**
  38357. * X and Y axis corresponding to the controllers joystick
  38358. */
  38359. _this.pad = { x: 0, y: 0 };
  38360. // avoid GC, store state in a tmp object
  38361. _this._changes = {
  38362. pressChanged: false,
  38363. touchChanged: false,
  38364. valueChanged: false,
  38365. changed: false
  38366. };
  38367. _this._buttons = new Array(vrGamepad.buttons.length);
  38368. _this.hand = vrGamepad.hand;
  38369. return _this;
  38370. }
  38371. /**
  38372. * Fired when a controller button's state has changed
  38373. * @param callback the callback containing the button that was modified
  38374. */
  38375. WebVRController.prototype.onButtonStateChange = function (callback) {
  38376. this._onButtonStateChange = callback;
  38377. };
  38378. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  38379. /**
  38380. * The default controller model for the controller
  38381. */
  38382. get: function () {
  38383. return this._defaultModel;
  38384. },
  38385. enumerable: true,
  38386. configurable: true
  38387. });
  38388. /**
  38389. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  38390. */
  38391. WebVRController.prototype.update = function () {
  38392. _super.prototype.update.call(this);
  38393. for (var index = 0; index < this._buttons.length; index++) {
  38394. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  38395. }
  38396. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  38397. this.pad.x = this.leftStick.x;
  38398. this.pad.y = this.leftStick.y;
  38399. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  38400. }
  38401. };
  38402. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  38403. if (!newState) {
  38404. newState = {
  38405. pressed: false,
  38406. touched: false,
  38407. value: 0
  38408. };
  38409. }
  38410. if (!currentState) {
  38411. this._buttons[buttonIndex] = {
  38412. pressed: newState.pressed,
  38413. touched: newState.touched,
  38414. value: newState.value
  38415. };
  38416. return;
  38417. }
  38418. this._checkChanges(newState, currentState);
  38419. if (this._changes.changed) {
  38420. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  38421. this._handleButtonChange(buttonIndex, newState, this._changes);
  38422. }
  38423. this._buttons[buttonIndex].pressed = newState.pressed;
  38424. this._buttons[buttonIndex].touched = newState.touched;
  38425. // oculus triggers are never 0, thou not touched.
  38426. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  38427. };
  38428. WebVRController.prototype._checkChanges = function (newState, currentState) {
  38429. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  38430. this._changes.touchChanged = newState.touched !== currentState.touched;
  38431. this._changes.valueChanged = newState.value !== currentState.value;
  38432. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  38433. return this._changes;
  38434. };
  38435. /**
  38436. * Disposes of th webVRCOntroller
  38437. */
  38438. WebVRController.prototype.dispose = function () {
  38439. _super.prototype.dispose.call(this);
  38440. this.onTriggerStateChangedObservable.clear();
  38441. this.onMainButtonStateChangedObservable.clear();
  38442. this.onSecondaryButtonStateChangedObservable.clear();
  38443. this.onPadStateChangedObservable.clear();
  38444. this.onPadValuesChangedObservable.clear();
  38445. };
  38446. return WebVRController;
  38447. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  38448. /***/ }),
  38449. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  38450. /*!*********************************************************!*\
  38451. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  38452. \*********************************************************/
  38453. /*! exports provided: WindowsMotionController */
  38454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38455. "use strict";
  38456. __webpack_require__.r(__webpack_exports__);
  38457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  38458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38459. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  38460. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  38461. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  38462. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  38463. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  38464. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  38465. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  38466. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  38467. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  38468. /**
  38469. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  38470. */
  38471. var LoadedMeshInfo = /** @class */ (function () {
  38472. function LoadedMeshInfo() {
  38473. /**
  38474. * Map of the button meshes contained in the controller
  38475. */
  38476. this.buttonMeshes = {};
  38477. /**
  38478. * Map of the axis meshes contained in the controller
  38479. */
  38480. this.axisMeshes = {};
  38481. }
  38482. return LoadedMeshInfo;
  38483. }());
  38484. /**
  38485. * Defines the WindowsMotionController object that the state of the windows motion controller
  38486. */
  38487. var WindowsMotionController = /** @class */ (function (_super) {
  38488. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  38489. /**
  38490. * Creates a new WindowsMotionController from a gamepad
  38491. * @param vrGamepad the gamepad that the controller should be created from
  38492. */
  38493. function WindowsMotionController(vrGamepad) {
  38494. var _this = _super.call(this, vrGamepad) || this;
  38495. _this._mapping = {
  38496. // Semantic button names
  38497. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  38498. // A mapping of the button name to glTF model node name
  38499. // that should be transformed by button value.
  38500. buttonMeshNames: {
  38501. 'trigger': 'SELECT',
  38502. 'menu': 'MENU',
  38503. 'grip': 'GRASP',
  38504. 'thumbstick': 'THUMBSTICK_PRESS',
  38505. 'trackpad': 'TOUCHPAD_PRESS'
  38506. },
  38507. // This mapping is used to translate from the Motion Controller to Babylon semantics
  38508. buttonObservableNames: {
  38509. 'trigger': 'onTriggerStateChangedObservable',
  38510. 'menu': 'onSecondaryButtonStateChangedObservable',
  38511. 'grip': 'onMainButtonStateChangedObservable',
  38512. 'thumbstick': 'onPadStateChangedObservable',
  38513. 'trackpad': 'onTrackpadChangedObservable'
  38514. },
  38515. // A mapping of the axis name to glTF model node name
  38516. // that should be transformed by axis value.
  38517. // This array mirrors the browserGamepad.axes array, such that
  38518. // the mesh corresponding to axis 0 is in this array index 0.
  38519. axisMeshNames: [
  38520. 'THUMBSTICK_X',
  38521. 'THUMBSTICK_Y',
  38522. 'TOUCHPAD_TOUCH_X',
  38523. 'TOUCHPAD_TOUCH_Y'
  38524. ],
  38525. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  38526. };
  38527. /**
  38528. * Fired when the trackpad on this controller is clicked
  38529. */
  38530. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38531. /**
  38532. * Fired when the trackpad on this controller is modified
  38533. */
  38534. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38535. /**
  38536. * The current x and y values of this controller's trackpad
  38537. */
  38538. _this.trackpad = { x: 0, y: 0 };
  38539. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  38540. _this._loadedMeshInfo = null;
  38541. return _this;
  38542. }
  38543. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  38544. /**
  38545. * Fired when the trigger on this controller is modified
  38546. */
  38547. get: function () {
  38548. return this.onTriggerStateChangedObservable;
  38549. },
  38550. enumerable: true,
  38551. configurable: true
  38552. });
  38553. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  38554. /**
  38555. * Fired when the menu button on this controller is modified
  38556. */
  38557. get: function () {
  38558. return this.onSecondaryButtonStateChangedObservable;
  38559. },
  38560. enumerable: true,
  38561. configurable: true
  38562. });
  38563. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  38564. /**
  38565. * Fired when the grip button on this controller is modified
  38566. */
  38567. get: function () {
  38568. return this.onMainButtonStateChangedObservable;
  38569. },
  38570. enumerable: true,
  38571. configurable: true
  38572. });
  38573. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  38574. /**
  38575. * Fired when the thumbstick button on this controller is modified
  38576. */
  38577. get: function () {
  38578. return this.onPadStateChangedObservable;
  38579. },
  38580. enumerable: true,
  38581. configurable: true
  38582. });
  38583. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  38584. /**
  38585. * Fired when the touchpad button on this controller is modified
  38586. */
  38587. get: function () {
  38588. return this.onTrackpadChangedObservable;
  38589. },
  38590. enumerable: true,
  38591. configurable: true
  38592. });
  38593. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  38594. /**
  38595. * Fired when the touchpad values on this controller are modified
  38596. */
  38597. get: function () {
  38598. return this.onTrackpadValuesChangedObservable;
  38599. },
  38600. enumerable: true,
  38601. configurable: true
  38602. });
  38603. WindowsMotionController.prototype._updateTrackpad = function () {
  38604. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  38605. this.trackpad.x = this.browserGamepad["axes"][2];
  38606. this.trackpad.y = this.browserGamepad["axes"][3];
  38607. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  38608. }
  38609. };
  38610. /**
  38611. * Called once per frame by the engine.
  38612. */
  38613. WindowsMotionController.prototype.update = function () {
  38614. _super.prototype.update.call(this);
  38615. if (this.browserGamepad.axes) {
  38616. this._updateTrackpad();
  38617. // Only need to animate axes if there is a loaded mesh
  38618. if (this._loadedMeshInfo) {
  38619. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  38620. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  38621. }
  38622. }
  38623. }
  38624. };
  38625. /**
  38626. * Called once for each button that changed state since the last frame
  38627. * @param buttonIdx Which button index changed
  38628. * @param state New state of the button
  38629. * @param changes Which properties on the state changed since last frame
  38630. */
  38631. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  38632. var buttonName = this._mapping.buttons[buttonIdx];
  38633. if (!buttonName) {
  38634. return;
  38635. }
  38636. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  38637. this._updateTrackpad();
  38638. // Only emit events for buttons that we know how to map from index to name
  38639. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  38640. if (observable) {
  38641. observable.notifyObservers(state);
  38642. }
  38643. this._lerpButtonTransform(buttonName, state.value);
  38644. };
  38645. /**
  38646. * Moves the buttons on the controller mesh based on their current state
  38647. * @param buttonName the name of the button to move
  38648. * @param buttonValue the value of the button which determines the buttons new position
  38649. */
  38650. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  38651. // If there is no loaded mesh, there is nothing to transform.
  38652. if (!this._loadedMeshInfo) {
  38653. return;
  38654. }
  38655. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  38656. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  38657. return;
  38658. }
  38659. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  38660. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  38661. };
  38662. /**
  38663. * Moves the axis on the controller mesh based on its current state
  38664. * @param axis the index of the axis
  38665. * @param axisValue the value of the axis which determines the meshes new position
  38666. * @hidden
  38667. */
  38668. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  38669. if (!this._loadedMeshInfo) {
  38670. return;
  38671. }
  38672. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  38673. if (!meshInfo) {
  38674. return;
  38675. }
  38676. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  38677. return;
  38678. }
  38679. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  38680. var lerpValue = axisValue * 0.5 + 0.5;
  38681. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  38682. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  38683. };
  38684. /**
  38685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38686. * @param scene scene in which to add meshes
  38687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38688. */
  38689. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  38690. var _this = this;
  38691. if (forceDefault === void 0) { forceDefault = false; }
  38692. var path;
  38693. var filename;
  38694. // Checking if GLB loader is present
  38695. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  38696. // Determine the device specific folder based on the ID suffix
  38697. var device = 'default';
  38698. if (this.id && !forceDefault) {
  38699. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  38700. device = ((match && match[0]) || device);
  38701. }
  38702. // Hand
  38703. if (this.hand === 'left') {
  38704. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  38705. }
  38706. else { // Right is the default if no hand is specified
  38707. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  38708. }
  38709. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  38710. }
  38711. else {
  38712. _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");
  38713. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  38714. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  38715. }
  38716. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  38717. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  38718. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  38719. if (!_this._loadedMeshInfo) {
  38720. return;
  38721. }
  38722. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  38723. _this.attachToMesh(_this._defaultModel);
  38724. if (meshLoaded) {
  38725. meshLoaded(_this._defaultModel);
  38726. }
  38727. }, null, function (scene, message) {
  38728. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  38729. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  38730. if (!forceDefault) {
  38731. _this.initControllerMesh(scene, meshLoaded, true);
  38732. }
  38733. });
  38734. };
  38735. /**
  38736. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  38737. * can be transformed by button presses and axes values, based on this._mapping.
  38738. *
  38739. * @param scene scene in which the meshes exist
  38740. * @param meshes list of meshes that make up the controller model to process
  38741. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  38742. */
  38743. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  38744. var loadedMeshInfo = null;
  38745. // Create a new mesh to contain the glTF hierarchy
  38746. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  38747. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  38748. var childMesh = null;
  38749. for (var i = 0; i < meshes.length; i++) {
  38750. var mesh = meshes[i];
  38751. if (!mesh.parent) {
  38752. // Exclude controller meshes from picking results
  38753. mesh.isPickable = false;
  38754. // Handle root node, attach to the new parentMesh
  38755. childMesh = mesh;
  38756. break;
  38757. }
  38758. }
  38759. if (childMesh) {
  38760. childMesh.setParent(parentMesh);
  38761. // Create our mesh info. Note that this method will always return non-null.
  38762. loadedMeshInfo = this.createMeshInfo(parentMesh);
  38763. }
  38764. else {
  38765. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  38766. }
  38767. return loadedMeshInfo;
  38768. };
  38769. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  38770. var loadedMeshInfo = new LoadedMeshInfo();
  38771. var i;
  38772. loadedMeshInfo.rootNode = rootNode;
  38773. // Reset the caches
  38774. loadedMeshInfo.buttonMeshes = {};
  38775. loadedMeshInfo.axisMeshes = {};
  38776. // Button Meshes
  38777. for (i = 0; i < this._mapping.buttons.length; i++) {
  38778. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  38779. if (!buttonMeshName) {
  38780. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  38781. continue;
  38782. }
  38783. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  38784. if (!buttonMesh) {
  38785. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  38786. continue;
  38787. }
  38788. var buttonMeshInfo = {
  38789. index: i,
  38790. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  38791. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  38792. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  38793. };
  38794. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  38795. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  38796. }
  38797. else {
  38798. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  38799. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  38800. '(VALUE: ' + !!buttonMeshInfo.value +
  38801. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  38802. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  38803. ')');
  38804. }
  38805. }
  38806. // Axis Meshes
  38807. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  38808. var axisMeshName = this._mapping.axisMeshNames[i];
  38809. if (!axisMeshName) {
  38810. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  38811. continue;
  38812. }
  38813. var axisMesh = getChildByName(rootNode, axisMeshName);
  38814. if (!axisMesh) {
  38815. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  38816. continue;
  38817. }
  38818. var axisMeshInfo = {
  38819. index: i,
  38820. value: getImmediateChildByName(axisMesh, 'VALUE'),
  38821. min: getImmediateChildByName(axisMesh, 'MIN'),
  38822. max: getImmediateChildByName(axisMesh, 'MAX')
  38823. };
  38824. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  38825. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  38826. }
  38827. else {
  38828. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  38829. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  38830. '(VALUE: ' + !!axisMeshInfo.value +
  38831. ', MIN: ' + !!axisMeshInfo.min +
  38832. ', MAX:' + !!axisMeshInfo.max +
  38833. ')');
  38834. }
  38835. }
  38836. // Pointing Ray
  38837. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  38838. if (!loadedMeshInfo.pointingPoseNode) {
  38839. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  38840. }
  38841. else {
  38842. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  38843. }
  38844. return loadedMeshInfo;
  38845. // Look through all children recursively. This will return null if no mesh exists with the given name.
  38846. function getChildByName(node, name) {
  38847. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  38848. }
  38849. // Look through only immediate children. This will return null if no mesh exists with the given name.
  38850. function getImmediateChildByName(node, name) {
  38851. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  38852. }
  38853. };
  38854. /**
  38855. * Gets the ray of the controller in the direction the controller is pointing
  38856. * @param length the length the resulting ray should be
  38857. * @returns a ray in the direction the controller is pointing
  38858. */
  38859. WindowsMotionController.prototype.getForwardRay = function (length) {
  38860. if (length === void 0) { length = 100; }
  38861. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  38862. return _super.prototype.getForwardRay.call(this, length);
  38863. }
  38864. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  38865. var origin = m.getTranslation();
  38866. var forward = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  38867. var forwardWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  38868. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  38869. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  38870. };
  38871. /**
  38872. * Disposes of the controller
  38873. */
  38874. WindowsMotionController.prototype.dispose = function () {
  38875. _super.prototype.dispose.call(this);
  38876. this.onTrackpadChangedObservable.clear();
  38877. };
  38878. /**
  38879. * The base url used to load the left and right controller models
  38880. */
  38881. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  38882. /**
  38883. * The name of the left controller model file
  38884. */
  38885. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  38886. /**
  38887. * The name of the right controller model file
  38888. */
  38889. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  38890. /**
  38891. * The controller name prefix for this controller type
  38892. */
  38893. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  38894. /**
  38895. * The controller id pattern for this controller type
  38896. */
  38897. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  38898. return WindowsMotionController;
  38899. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  38900. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  38901. canCreate: function (gamepadInfo) {
  38902. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  38903. },
  38904. create: function (gamepadInfo) {
  38905. return new WindowsMotionController(gamepadInfo);
  38906. }
  38907. });
  38908. /***/ }),
  38909. /***/ "./Gamepads/gamepad.ts":
  38910. /*!*****************************!*\
  38911. !*** ./Gamepads/gamepad.ts ***!
  38912. \*****************************/
  38913. /*! exports provided: StickValues, Gamepad, GenericPad */
  38914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38915. "use strict";
  38916. __webpack_require__.r(__webpack_exports__);
  38917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  38918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  38919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  38920. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38921. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38922. /**
  38923. * Represents a gamepad control stick position
  38924. */
  38925. var StickValues = /** @class */ (function () {
  38926. /**
  38927. * Initializes the gamepad x and y control stick values
  38928. * @param x The x component of the gamepad control stick value
  38929. * @param y The y component of the gamepad control stick value
  38930. */
  38931. function StickValues(
  38932. /**
  38933. * The x component of the control stick
  38934. */
  38935. x,
  38936. /**
  38937. * The y component of the control stick
  38938. */
  38939. y) {
  38940. this.x = x;
  38941. this.y = y;
  38942. }
  38943. return StickValues;
  38944. }());
  38945. /**
  38946. * Represents a gamepad
  38947. */
  38948. var Gamepad = /** @class */ (function () {
  38949. /**
  38950. * Initializes the gamepad
  38951. * @param id The id of the gamepad
  38952. * @param index The index of the gamepad
  38953. * @param browserGamepad The browser gamepad
  38954. * @param leftStickX The x component of the left joystick
  38955. * @param leftStickY The y component of the left joystick
  38956. * @param rightStickX The x component of the right joystick
  38957. * @param rightStickY The y component of the right joystick
  38958. */
  38959. function Gamepad(
  38960. /**
  38961. * The id of the gamepad
  38962. */
  38963. id,
  38964. /**
  38965. * The index of the gamepad
  38966. */
  38967. index,
  38968. /**
  38969. * The browser gamepad
  38970. */
  38971. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  38972. if (leftStickX === void 0) { leftStickX = 0; }
  38973. if (leftStickY === void 0) { leftStickY = 1; }
  38974. if (rightStickX === void 0) { rightStickX = 2; }
  38975. if (rightStickY === void 0) { rightStickY = 3; }
  38976. this.id = id;
  38977. this.index = index;
  38978. this.browserGamepad = browserGamepad;
  38979. this._leftStick = { x: 0, y: 0 };
  38980. this._rightStick = { x: 0, y: 0 };
  38981. /** @hidden */
  38982. this._isConnected = true;
  38983. /**
  38984. * Specifies whether the left control stick should be Y-inverted
  38985. */
  38986. this._invertLeftStickY = false;
  38987. this.type = Gamepad.GAMEPAD;
  38988. this._leftStickAxisX = leftStickX;
  38989. this._leftStickAxisY = leftStickY;
  38990. this._rightStickAxisX = rightStickX;
  38991. this._rightStickAxisY = rightStickY;
  38992. if (this.browserGamepad.axes.length >= 2) {
  38993. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  38994. }
  38995. if (this.browserGamepad.axes.length >= 4) {
  38996. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  38997. }
  38998. }
  38999. Object.defineProperty(Gamepad.prototype, "isConnected", {
  39000. /**
  39001. * Specifies if the gamepad has been connected
  39002. */
  39003. get: function () {
  39004. return this._isConnected;
  39005. },
  39006. enumerable: true,
  39007. configurable: true
  39008. });
  39009. /**
  39010. * Callback triggered when the left joystick has changed
  39011. * @param callback
  39012. */
  39013. Gamepad.prototype.onleftstickchanged = function (callback) {
  39014. this._onleftstickchanged = callback;
  39015. };
  39016. /**
  39017. * Callback triggered when the right joystick has changed
  39018. * @param callback
  39019. */
  39020. Gamepad.prototype.onrightstickchanged = function (callback) {
  39021. this._onrightstickchanged = callback;
  39022. };
  39023. Object.defineProperty(Gamepad.prototype, "leftStick", {
  39024. /**
  39025. * Gets the left joystick
  39026. */
  39027. get: function () {
  39028. return this._leftStick;
  39029. },
  39030. /**
  39031. * Sets the left joystick values
  39032. */
  39033. set: function (newValues) {
  39034. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  39035. this._onleftstickchanged(newValues);
  39036. }
  39037. this._leftStick = newValues;
  39038. },
  39039. enumerable: true,
  39040. configurable: true
  39041. });
  39042. Object.defineProperty(Gamepad.prototype, "rightStick", {
  39043. /**
  39044. * Gets the right joystick
  39045. */
  39046. get: function () {
  39047. return this._rightStick;
  39048. },
  39049. /**
  39050. * Sets the right joystick value
  39051. */
  39052. set: function (newValues) {
  39053. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  39054. this._onrightstickchanged(newValues);
  39055. }
  39056. this._rightStick = newValues;
  39057. },
  39058. enumerable: true,
  39059. configurable: true
  39060. });
  39061. /**
  39062. * Updates the gamepad joystick positions
  39063. */
  39064. Gamepad.prototype.update = function () {
  39065. if (this._leftStick) {
  39066. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  39067. if (this._invertLeftStickY) {
  39068. this.leftStick.y *= -1;
  39069. }
  39070. }
  39071. if (this._rightStick) {
  39072. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  39073. }
  39074. };
  39075. /**
  39076. * Disposes the gamepad
  39077. */
  39078. Gamepad.prototype.dispose = function () {
  39079. };
  39080. /**
  39081. * Represents a gamepad controller
  39082. */
  39083. Gamepad.GAMEPAD = 0;
  39084. /**
  39085. * Represents a generic controller
  39086. */
  39087. Gamepad.GENERIC = 1;
  39088. /**
  39089. * Represents an XBox controller
  39090. */
  39091. Gamepad.XBOX = 2;
  39092. /**
  39093. * Represents a pose-enabled controller
  39094. */
  39095. Gamepad.POSE_ENABLED = 3;
  39096. return Gamepad;
  39097. }());
  39098. /**
  39099. * Represents a generic gamepad
  39100. */
  39101. var GenericPad = /** @class */ (function (_super) {
  39102. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  39103. /**
  39104. * Initializes the generic gamepad
  39105. * @param id The id of the generic gamepad
  39106. * @param index The index of the generic gamepad
  39107. * @param browserGamepad The browser gamepad
  39108. */
  39109. function GenericPad(id, index, browserGamepad) {
  39110. var _this = _super.call(this, id, index, browserGamepad) || this;
  39111. /**
  39112. * Observable triggered when a button has been pressed
  39113. */
  39114. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39115. /**
  39116. * Observable triggered when a button has been released
  39117. */
  39118. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39119. _this.type = Gamepad.GENERIC;
  39120. _this._buttons = new Array(browserGamepad.buttons.length);
  39121. return _this;
  39122. }
  39123. /**
  39124. * Callback triggered when a button has been pressed
  39125. * @param callback Called when a button has been pressed
  39126. */
  39127. GenericPad.prototype.onbuttondown = function (callback) {
  39128. this._onbuttondown = callback;
  39129. };
  39130. /**
  39131. * Callback triggered when a button has been released
  39132. * @param callback Called when a button has been released
  39133. */
  39134. GenericPad.prototype.onbuttonup = function (callback) {
  39135. this._onbuttonup = callback;
  39136. };
  39137. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  39138. if (newValue !== currentValue) {
  39139. if (newValue === 1) {
  39140. if (this._onbuttondown) {
  39141. this._onbuttondown(buttonIndex);
  39142. }
  39143. this.onButtonDownObservable.notifyObservers(buttonIndex);
  39144. }
  39145. if (newValue === 0) {
  39146. if (this._onbuttonup) {
  39147. this._onbuttonup(buttonIndex);
  39148. }
  39149. this.onButtonUpObservable.notifyObservers(buttonIndex);
  39150. }
  39151. }
  39152. return newValue;
  39153. };
  39154. /**
  39155. * Updates the generic gamepad
  39156. */
  39157. GenericPad.prototype.update = function () {
  39158. _super.prototype.update.call(this);
  39159. for (var index = 0; index < this._buttons.length; index++) {
  39160. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  39161. }
  39162. };
  39163. /**
  39164. * Disposes the generic gamepad
  39165. */
  39166. GenericPad.prototype.dispose = function () {
  39167. _super.prototype.dispose.call(this);
  39168. this.onButtonDownObservable.clear();
  39169. this.onButtonUpObservable.clear();
  39170. };
  39171. return GenericPad;
  39172. }(Gamepad));
  39173. /***/ }),
  39174. /***/ "./Gamepads/gamepadManager.ts":
  39175. /*!************************************!*\
  39176. !*** ./Gamepads/gamepadManager.ts ***!
  39177. \************************************/
  39178. /*! exports provided: GamepadManager */
  39179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39180. "use strict";
  39181. __webpack_require__.r(__webpack_exports__);
  39182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  39183. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39184. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  39185. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  39186. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  39187. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  39188. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  39189. /**
  39190. * Manager for handling gamepads
  39191. */
  39192. var GamepadManager = /** @class */ (function () {
  39193. /**
  39194. * Initializes the gamepad manager
  39195. * @param _scene BabylonJS scene
  39196. */
  39197. function GamepadManager(_scene) {
  39198. var _this = this;
  39199. this._scene = _scene;
  39200. this._babylonGamepads = [];
  39201. this._oneGamepadConnected = false;
  39202. /** @hidden */
  39203. this._isMonitoring = false;
  39204. /**
  39205. * observable to be triggered when the gamepad controller has been disconnected
  39206. */
  39207. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39208. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].IsWindowObjectExist()) {
  39209. this._gamepadEventSupported = false;
  39210. }
  39211. else {
  39212. this._gamepadEventSupported = 'GamepadEvent' in window;
  39213. this._gamepadSupport = (navigator.getGamepads ||
  39214. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  39215. }
  39216. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"](function (observer) {
  39217. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  39218. for (var i in _this._babylonGamepads) {
  39219. var gamepad = _this._babylonGamepads[i];
  39220. if (gamepad && gamepad._isConnected) {
  39221. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  39222. }
  39223. }
  39224. });
  39225. this._onGamepadConnectedEvent = function (evt) {
  39226. var gamepad = evt.gamepad;
  39227. if (gamepad.index in _this._babylonGamepads) {
  39228. if (_this._babylonGamepads[gamepad.index].isConnected) {
  39229. return;
  39230. }
  39231. }
  39232. var newGamepad;
  39233. if (_this._babylonGamepads[gamepad.index]) {
  39234. newGamepad = _this._babylonGamepads[gamepad.index];
  39235. newGamepad.browserGamepad = gamepad;
  39236. newGamepad._isConnected = true;
  39237. }
  39238. else {
  39239. newGamepad = _this._addNewGamepad(gamepad);
  39240. }
  39241. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  39242. _this._startMonitoringGamepads();
  39243. };
  39244. this._onGamepadDisconnectedEvent = function (evt) {
  39245. var gamepad = evt.gamepad;
  39246. // Remove the gamepad from the list of gamepads to monitor.
  39247. for (var i in _this._babylonGamepads) {
  39248. if (_this._babylonGamepads[i].index === gamepad.index) {
  39249. var disconnectedGamepad = _this._babylonGamepads[i];
  39250. disconnectedGamepad._isConnected = false;
  39251. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  39252. break;
  39253. }
  39254. }
  39255. };
  39256. if (this._gamepadSupport) {
  39257. //first add already-connected gamepads
  39258. this._updateGamepadObjects();
  39259. if (this._babylonGamepads.length) {
  39260. this._startMonitoringGamepads();
  39261. }
  39262. // Checking if the gamepad connected event is supported (like in Firefox)
  39263. if (this._gamepadEventSupported) {
  39264. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  39265. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  39266. }
  39267. else {
  39268. this._startMonitoringGamepads();
  39269. }
  39270. }
  39271. }
  39272. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  39273. /**
  39274. * The gamepads in the game pad manager
  39275. */
  39276. get: function () {
  39277. return this._babylonGamepads;
  39278. },
  39279. enumerable: true,
  39280. configurable: true
  39281. });
  39282. /**
  39283. * Get the gamepad controllers based on type
  39284. * @param type The type of gamepad controller
  39285. * @returns Nullable gamepad
  39286. */
  39287. GamepadManager.prototype.getGamepadByType = function (type) {
  39288. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX; }
  39289. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  39290. var gamepad = _a[_i];
  39291. if (gamepad && gamepad.type === type) {
  39292. return gamepad;
  39293. }
  39294. }
  39295. return null;
  39296. };
  39297. /**
  39298. * Disposes the gamepad manager
  39299. */
  39300. GamepadManager.prototype.dispose = function () {
  39301. if (this._gamepadEventSupported) {
  39302. if (this._onGamepadConnectedEvent) {
  39303. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  39304. }
  39305. if (this._onGamepadDisconnectedEvent) {
  39306. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  39307. }
  39308. this._onGamepadConnectedEvent = null;
  39309. this._onGamepadDisconnectedEvent = null;
  39310. }
  39311. this._babylonGamepads.forEach(function (gamepad) {
  39312. gamepad.dispose();
  39313. });
  39314. this.onGamepadConnectedObservable.clear();
  39315. this.onGamepadDisconnectedObservable.clear();
  39316. this._oneGamepadConnected = false;
  39317. this._stopMonitoringGamepads();
  39318. this._babylonGamepads = [];
  39319. };
  39320. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  39321. if (!this._oneGamepadConnected) {
  39322. this._oneGamepadConnected = true;
  39323. }
  39324. var newGamepad;
  39325. var dualShock = (gamepad.id.search("054c") !== -1);
  39326. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  39327. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  39328. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_3__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  39329. }
  39330. // if pose is supported, use the (WebVR) pose enabled controller, ignore DualShock (ps4) as they have a pose but should not be used for webVR
  39331. else if (gamepad.pose && !dualShock) {
  39332. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  39333. }
  39334. else {
  39335. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_4__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  39336. }
  39337. this._babylonGamepads[newGamepad.index] = newGamepad;
  39338. return newGamepad;
  39339. };
  39340. GamepadManager.prototype._startMonitoringGamepads = function () {
  39341. if (!this._isMonitoring) {
  39342. this._isMonitoring = true;
  39343. //back-comp
  39344. if (!this._scene) {
  39345. this._checkGamepadsStatus();
  39346. }
  39347. }
  39348. };
  39349. GamepadManager.prototype._stopMonitoringGamepads = function () {
  39350. this._isMonitoring = false;
  39351. };
  39352. /** @hidden */
  39353. GamepadManager.prototype._checkGamepadsStatus = function () {
  39354. var _this = this;
  39355. // Hack to be compatible Chrome
  39356. this._updateGamepadObjects();
  39357. for (var i in this._babylonGamepads) {
  39358. var gamepad = this._babylonGamepads[i];
  39359. if (!gamepad || !gamepad.isConnected) {
  39360. continue;
  39361. }
  39362. gamepad.update();
  39363. }
  39364. if (this._isMonitoring && !this._scene) {
  39365. _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  39366. }
  39367. };
  39368. // This function is called only on Chrome, which does not properly support
  39369. // connection/disconnection events and forces you to recopy again the gamepad object
  39370. GamepadManager.prototype._updateGamepadObjects = function () {
  39371. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  39372. for (var i = 0; i < gamepads.length; i++) {
  39373. var gamepad = gamepads[i];
  39374. if (gamepad) {
  39375. if (!this._babylonGamepads[gamepad.index]) {
  39376. var newGamepad = this._addNewGamepad(gamepad);
  39377. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  39378. }
  39379. else {
  39380. // Forced to copy again this object for Chrome for unknown reason
  39381. this._babylonGamepads[i].browserGamepad = gamepad;
  39382. if (!this._babylonGamepads[i].isConnected) {
  39383. this._babylonGamepads[i]._isConnected = true;
  39384. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  39385. }
  39386. }
  39387. }
  39388. }
  39389. };
  39390. return GamepadManager;
  39391. }());
  39392. /***/ }),
  39393. /***/ "./Gamepads/gamepadSceneComponent.ts":
  39394. /*!*******************************************!*\
  39395. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  39396. \*******************************************/
  39397. /*! exports provided: GamepadSystemSceneComponent */
  39398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39399. "use strict";
  39400. __webpack_require__.r(__webpack_exports__);
  39401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  39402. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39403. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  39404. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  39405. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  39406. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  39407. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  39408. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  39409. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  39410. get: function () {
  39411. if (!this._gamepadManager) {
  39412. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  39413. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  39414. if (!component) {
  39415. component = new GamepadSystemSceneComponent(this);
  39416. this._addComponent(component);
  39417. }
  39418. }
  39419. return this._gamepadManager;
  39420. },
  39421. enumerable: true,
  39422. configurable: true
  39423. });
  39424. /**
  39425. * Adds a gamepad to the free camera inputs manager
  39426. */
  39427. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  39428. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  39429. return this;
  39430. };
  39431. /**
  39432. * Adds a gamepad to the arc rotate camera inputs manager
  39433. */
  39434. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  39435. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  39436. return this;
  39437. };
  39438. /**
  39439. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39440. */
  39441. var GamepadSystemSceneComponent = /** @class */ (function () {
  39442. /**
  39443. * Creates a new instance of the component for the given scene
  39444. * @param scene Defines the scene to register the component in
  39445. */
  39446. function GamepadSystemSceneComponent(scene) {
  39447. /**
  39448. * The component name helpfull to identify the component in the list of scene components.
  39449. */
  39450. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  39451. this.scene = scene;
  39452. }
  39453. /**
  39454. * Registers the component in a given scene
  39455. */
  39456. GamepadSystemSceneComponent.prototype.register = function () {
  39457. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  39458. };
  39459. /**
  39460. * Rebuilds the elements related to this component in case of
  39461. * context lost for instance.
  39462. */
  39463. GamepadSystemSceneComponent.prototype.rebuild = function () {
  39464. // Nothing to do for gamepads
  39465. };
  39466. /**
  39467. * Disposes the component and the associated ressources
  39468. */
  39469. GamepadSystemSceneComponent.prototype.dispose = function () {
  39470. var gamepadManager = this.scene._gamepadManager;
  39471. if (gamepadManager) {
  39472. gamepadManager.dispose();
  39473. this.scene._gamepadManager = null;
  39474. }
  39475. };
  39476. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  39477. var gamepadManager = this.scene._gamepadManager;
  39478. if (gamepadManager && gamepadManager._isMonitoring) {
  39479. gamepadManager._checkGamepadsStatus();
  39480. }
  39481. };
  39482. return GamepadSystemSceneComponent;
  39483. }());
  39484. /***/ }),
  39485. /***/ "./Gamepads/index.ts":
  39486. /*!***************************!*\
  39487. !*** ./Gamepads/index.ts ***!
  39488. \***************************/
  39489. /*! exports provided: StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  39490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39491. "use strict";
  39492. __webpack_require__.r(__webpack_exports__);
  39493. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  39494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  39495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  39496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  39497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  39498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  39499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  39500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  39501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  39502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  39503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  39504. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  39505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  39506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  39507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  39508. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  39509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  39510. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  39511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  39512. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  39513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  39514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  39515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  39516. /***/ }),
  39517. /***/ "./Gamepads/xboxGamepad.ts":
  39518. /*!*********************************!*\
  39519. !*** ./Gamepads/xboxGamepad.ts ***!
  39520. \*********************************/
  39521. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  39522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39523. "use strict";
  39524. __webpack_require__.r(__webpack_exports__);
  39525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  39526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  39527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  39528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39529. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39530. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  39531. /**
  39532. * Defines supported buttons for XBox360 compatible gamepads
  39533. */
  39534. var Xbox360Button;
  39535. (function (Xbox360Button) {
  39536. /** A */
  39537. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  39538. /** B */
  39539. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  39540. /** X */
  39541. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  39542. /** Y */
  39543. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  39544. /** Start */
  39545. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  39546. /** Back */
  39547. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  39548. /** Left button */
  39549. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  39550. /** Right button */
  39551. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  39552. /** Left stick */
  39553. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  39554. /** Right stick */
  39555. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  39556. })(Xbox360Button || (Xbox360Button = {}));
  39557. /** Defines values for XBox360 DPad */
  39558. var Xbox360Dpad;
  39559. (function (Xbox360Dpad) {
  39560. /** Up */
  39561. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  39562. /** Down */
  39563. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  39564. /** Left */
  39565. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  39566. /** Right */
  39567. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  39568. })(Xbox360Dpad || (Xbox360Dpad = {}));
  39569. /**
  39570. * Defines a XBox360 gamepad
  39571. */
  39572. var Xbox360Pad = /** @class */ (function (_super) {
  39573. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  39574. /**
  39575. * Creates a new XBox360 gamepad object
  39576. * @param id defines the id of this gamepad
  39577. * @param index defines its index
  39578. * @param gamepad defines the internal HTML gamepad object
  39579. * @param xboxOne defines if it is a XBox One gamepad
  39580. */
  39581. function Xbox360Pad(id, index, gamepad, xboxOne) {
  39582. if (xboxOne === void 0) { xboxOne = false; }
  39583. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  39584. _this._leftTrigger = 0;
  39585. _this._rightTrigger = 0;
  39586. /** Observable raised when a button is pressed */
  39587. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39588. /** Observable raised when a button is released */
  39589. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39590. /** Observable raised when a pad is pressed */
  39591. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39592. /** Observable raised when a pad is released */
  39593. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39594. _this._buttonA = 0;
  39595. _this._buttonB = 0;
  39596. _this._buttonX = 0;
  39597. _this._buttonY = 0;
  39598. _this._buttonBack = 0;
  39599. _this._buttonStart = 0;
  39600. _this._buttonLB = 0;
  39601. _this._buttonRB = 0;
  39602. _this._buttonLeftStick = 0;
  39603. _this._buttonRightStick = 0;
  39604. _this._dPadUp = 0;
  39605. _this._dPadDown = 0;
  39606. _this._dPadLeft = 0;
  39607. _this._dPadRight = 0;
  39608. _this._isXboxOnePad = false;
  39609. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  39610. _this._isXboxOnePad = xboxOne;
  39611. return _this;
  39612. }
  39613. /**
  39614. * Defines the callback to call when left trigger is pressed
  39615. * @param callback defines the callback to use
  39616. */
  39617. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  39618. this._onlefttriggerchanged = callback;
  39619. };
  39620. /**
  39621. * Defines the callback to call when right trigger is pressed
  39622. * @param callback defines the callback to use
  39623. */
  39624. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  39625. this._onrighttriggerchanged = callback;
  39626. };
  39627. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  39628. /**
  39629. * Gets the left trigger value
  39630. */
  39631. get: function () {
  39632. return this._leftTrigger;
  39633. },
  39634. /**
  39635. * Sets the left trigger value
  39636. */
  39637. set: function (newValue) {
  39638. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  39639. this._onlefttriggerchanged(newValue);
  39640. }
  39641. this._leftTrigger = newValue;
  39642. },
  39643. enumerable: true,
  39644. configurable: true
  39645. });
  39646. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  39647. /**
  39648. * Gets the right trigger value
  39649. */
  39650. get: function () {
  39651. return this._rightTrigger;
  39652. },
  39653. /**
  39654. * Sets the right trigger value
  39655. */
  39656. set: function (newValue) {
  39657. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  39658. this._onrighttriggerchanged(newValue);
  39659. }
  39660. this._rightTrigger = newValue;
  39661. },
  39662. enumerable: true,
  39663. configurable: true
  39664. });
  39665. /**
  39666. * Defines the callback to call when a button is pressed
  39667. * @param callback defines the callback to use
  39668. */
  39669. Xbox360Pad.prototype.onbuttondown = function (callback) {
  39670. this._onbuttondown = callback;
  39671. };
  39672. /**
  39673. * Defines the callback to call when a button is released
  39674. * @param callback defines the callback to use
  39675. */
  39676. Xbox360Pad.prototype.onbuttonup = function (callback) {
  39677. this._onbuttonup = callback;
  39678. };
  39679. /**
  39680. * Defines the callback to call when a pad is pressed
  39681. * @param callback defines the callback to use
  39682. */
  39683. Xbox360Pad.prototype.ondpaddown = function (callback) {
  39684. this._ondpaddown = callback;
  39685. };
  39686. /**
  39687. * Defines the callback to call when a pad is released
  39688. * @param callback defines the callback to use
  39689. */
  39690. Xbox360Pad.prototype.ondpadup = function (callback) {
  39691. this._ondpadup = callback;
  39692. };
  39693. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  39694. if (newValue !== currentValue) {
  39695. if (newValue === 1) {
  39696. if (this._onbuttondown) {
  39697. this._onbuttondown(buttonType);
  39698. }
  39699. this.onButtonDownObservable.notifyObservers(buttonType);
  39700. }
  39701. if (newValue === 0) {
  39702. if (this._onbuttonup) {
  39703. this._onbuttonup(buttonType);
  39704. }
  39705. this.onButtonUpObservable.notifyObservers(buttonType);
  39706. }
  39707. }
  39708. return newValue;
  39709. };
  39710. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  39711. if (newValue !== currentValue) {
  39712. if (newValue === 1) {
  39713. if (this._ondpaddown) {
  39714. this._ondpaddown(buttonType);
  39715. }
  39716. this.onPadDownObservable.notifyObservers(buttonType);
  39717. }
  39718. if (newValue === 0) {
  39719. if (this._ondpadup) {
  39720. this._ondpadup(buttonType);
  39721. }
  39722. this.onPadUpObservable.notifyObservers(buttonType);
  39723. }
  39724. }
  39725. return newValue;
  39726. };
  39727. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  39728. /**
  39729. * Gets the value of the `A` button
  39730. */
  39731. get: function () {
  39732. return this._buttonA;
  39733. },
  39734. /**
  39735. * Sets the value of the `A` button
  39736. */
  39737. set: function (value) {
  39738. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  39739. },
  39740. enumerable: true,
  39741. configurable: true
  39742. });
  39743. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  39744. /**
  39745. * Gets the value of the `B` button
  39746. */
  39747. get: function () {
  39748. return this._buttonB;
  39749. },
  39750. /**
  39751. * Sets the value of the `B` button
  39752. */
  39753. set: function (value) {
  39754. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  39755. },
  39756. enumerable: true,
  39757. configurable: true
  39758. });
  39759. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  39760. /**
  39761. * Gets the value of the `X` button
  39762. */
  39763. get: function () {
  39764. return this._buttonX;
  39765. },
  39766. /**
  39767. * Sets the value of the `X` button
  39768. */
  39769. set: function (value) {
  39770. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  39771. },
  39772. enumerable: true,
  39773. configurable: true
  39774. });
  39775. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  39776. /**
  39777. * Gets the value of the `Y` button
  39778. */
  39779. get: function () {
  39780. return this._buttonY;
  39781. },
  39782. /**
  39783. * Sets the value of the `Y` button
  39784. */
  39785. set: function (value) {
  39786. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  39787. },
  39788. enumerable: true,
  39789. configurable: true
  39790. });
  39791. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  39792. /**
  39793. * Gets the value of the `Start` button
  39794. */
  39795. get: function () {
  39796. return this._buttonStart;
  39797. },
  39798. /**
  39799. * Sets the value of the `Start` button
  39800. */
  39801. set: function (value) {
  39802. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  39803. },
  39804. enumerable: true,
  39805. configurable: true
  39806. });
  39807. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  39808. /**
  39809. * Gets the value of the `Back` button
  39810. */
  39811. get: function () {
  39812. return this._buttonBack;
  39813. },
  39814. /**
  39815. * Sets the value of the `Back` button
  39816. */
  39817. set: function (value) {
  39818. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  39819. },
  39820. enumerable: true,
  39821. configurable: true
  39822. });
  39823. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  39824. /**
  39825. * Gets the value of the `Left` button
  39826. */
  39827. get: function () {
  39828. return this._buttonLB;
  39829. },
  39830. /**
  39831. * Sets the value of the `Left` button
  39832. */
  39833. set: function (value) {
  39834. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  39835. },
  39836. enumerable: true,
  39837. configurable: true
  39838. });
  39839. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  39840. /**
  39841. * Gets the value of the `Right` button
  39842. */
  39843. get: function () {
  39844. return this._buttonRB;
  39845. },
  39846. /**
  39847. * Sets the value of the `Right` button
  39848. */
  39849. set: function (value) {
  39850. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  39851. },
  39852. enumerable: true,
  39853. configurable: true
  39854. });
  39855. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  39856. /**
  39857. * Gets the value of the Left joystick
  39858. */
  39859. get: function () {
  39860. return this._buttonLeftStick;
  39861. },
  39862. /**
  39863. * Sets the value of the Left joystick
  39864. */
  39865. set: function (value) {
  39866. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  39867. },
  39868. enumerable: true,
  39869. configurable: true
  39870. });
  39871. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  39872. /**
  39873. * Gets the value of the Right joystick
  39874. */
  39875. get: function () {
  39876. return this._buttonRightStick;
  39877. },
  39878. /**
  39879. * Sets the value of the Right joystick
  39880. */
  39881. set: function (value) {
  39882. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  39883. },
  39884. enumerable: true,
  39885. configurable: true
  39886. });
  39887. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  39888. /**
  39889. * Gets the value of D-pad up
  39890. */
  39891. get: function () {
  39892. return this._dPadUp;
  39893. },
  39894. /**
  39895. * Sets the value of D-pad up
  39896. */
  39897. set: function (value) {
  39898. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  39899. },
  39900. enumerable: true,
  39901. configurable: true
  39902. });
  39903. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  39904. /**
  39905. * Gets the value of D-pad down
  39906. */
  39907. get: function () {
  39908. return this._dPadDown;
  39909. },
  39910. /**
  39911. * Sets the value of D-pad down
  39912. */
  39913. set: function (value) {
  39914. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  39915. },
  39916. enumerable: true,
  39917. configurable: true
  39918. });
  39919. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  39920. /**
  39921. * Gets the value of D-pad left
  39922. */
  39923. get: function () {
  39924. return this._dPadLeft;
  39925. },
  39926. /**
  39927. * Sets the value of D-pad left
  39928. */
  39929. set: function (value) {
  39930. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  39931. },
  39932. enumerable: true,
  39933. configurable: true
  39934. });
  39935. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  39936. /**
  39937. * Gets the value of D-pad right
  39938. */
  39939. get: function () {
  39940. return this._dPadRight;
  39941. },
  39942. /**
  39943. * Sets the value of D-pad right
  39944. */
  39945. set: function (value) {
  39946. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  39947. },
  39948. enumerable: true,
  39949. configurable: true
  39950. });
  39951. /**
  39952. * Force the gamepad to synchronize with device values
  39953. */
  39954. Xbox360Pad.prototype.update = function () {
  39955. _super.prototype.update.call(this);
  39956. if (this._isXboxOnePad) {
  39957. this.buttonA = this.browserGamepad.buttons[0].value;
  39958. this.buttonB = this.browserGamepad.buttons[1].value;
  39959. this.buttonX = this.browserGamepad.buttons[2].value;
  39960. this.buttonY = this.browserGamepad.buttons[3].value;
  39961. this.buttonLB = this.browserGamepad.buttons[4].value;
  39962. this.buttonRB = this.browserGamepad.buttons[5].value;
  39963. this.leftTrigger = this.browserGamepad.buttons[6].value;
  39964. this.rightTrigger = this.browserGamepad.buttons[7].value;
  39965. this.buttonBack = this.browserGamepad.buttons[8].value;
  39966. this.buttonStart = this.browserGamepad.buttons[9].value;
  39967. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  39968. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  39969. this.dPadUp = this.browserGamepad.buttons[12].value;
  39970. this.dPadDown = this.browserGamepad.buttons[13].value;
  39971. this.dPadLeft = this.browserGamepad.buttons[14].value;
  39972. this.dPadRight = this.browserGamepad.buttons[15].value;
  39973. }
  39974. else {
  39975. this.buttonA = this.browserGamepad.buttons[0].value;
  39976. this.buttonB = this.browserGamepad.buttons[1].value;
  39977. this.buttonX = this.browserGamepad.buttons[2].value;
  39978. this.buttonY = this.browserGamepad.buttons[3].value;
  39979. this.buttonLB = this.browserGamepad.buttons[4].value;
  39980. this.buttonRB = this.browserGamepad.buttons[5].value;
  39981. this.leftTrigger = this.browserGamepad.buttons[6].value;
  39982. this.rightTrigger = this.browserGamepad.buttons[7].value;
  39983. this.buttonBack = this.browserGamepad.buttons[8].value;
  39984. this.buttonStart = this.browserGamepad.buttons[9].value;
  39985. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  39986. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  39987. this.dPadUp = this.browserGamepad.buttons[12].value;
  39988. this.dPadDown = this.browserGamepad.buttons[13].value;
  39989. this.dPadLeft = this.browserGamepad.buttons[14].value;
  39990. this.dPadRight = this.browserGamepad.buttons[15].value;
  39991. }
  39992. };
  39993. /**
  39994. * Disposes the gamepad
  39995. */
  39996. Xbox360Pad.prototype.dispose = function () {
  39997. _super.prototype.dispose.call(this);
  39998. this.onButtonDownObservable.clear();
  39999. this.onButtonUpObservable.clear();
  40000. this.onPadDownObservable.clear();
  40001. this.onPadUpObservable.clear();
  40002. };
  40003. return Xbox360Pad;
  40004. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  40005. /***/ }),
  40006. /***/ "./Gizmos/axisDragGizmo.ts":
  40007. /*!*********************************!*\
  40008. !*** ./Gizmos/axisDragGizmo.ts ***!
  40009. \*********************************/
  40010. /*! exports provided: AxisDragGizmo */
  40011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40012. "use strict";
  40013. __webpack_require__.r(__webpack_exports__);
  40014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  40015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40016. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40017. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  40018. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40019. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  40020. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  40021. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40022. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40023. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40024. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  40025. /**
  40026. * Single axis drag gizmo
  40027. */
  40028. var AxisDragGizmo = /** @class */ (function (_super) {
  40029. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  40030. /**
  40031. * Creates an AxisDragGizmo
  40032. * @param gizmoLayer The utility layer the gizmo will be added to
  40033. * @param dragAxis The axis which the gizmo will be able to drag on
  40034. * @param color The color of the gizmo
  40035. */
  40036. function AxisDragGizmo(dragAxis, color, gizmoLayer, parent) {
  40037. if (color === void 0) { color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color3"].Gray(); }
  40038. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40039. if (parent === void 0) { parent = null; }
  40040. var _this = _super.call(this, gizmoLayer) || this;
  40041. _this._pointerObserver = null;
  40042. /**
  40043. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40044. */
  40045. _this.snapDistance = 0;
  40046. /**
  40047. * Event that fires each time the gizmo snaps to a new location.
  40048. * * snapDistance is the the change in distance
  40049. */
  40050. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40051. _this._isEnabled = true;
  40052. _this._parent = null;
  40053. _this._parent = parent;
  40054. // Create Material
  40055. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  40056. _this._coloredMaterial.diffuseColor = color;
  40057. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.1, 0.1, 0.1));
  40058. _this._hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  40059. _this._hoverMaterial.diffuseColor = color.add(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.3, 0.3, 0.3));
  40060. // Build mesh on root node
  40061. _this._arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, _this._coloredMaterial);
  40062. _this._arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  40063. _this._arrow.scaling.scaleInPlace(1 / 3);
  40064. _this._arrow.parent = _this._rootMesh;
  40065. var currentSnapDragDistance = 0;
  40066. var tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  40067. var tmpSnapEvent = { snapDistance: 0 };
  40068. // Add drag behavior to handle events when the gizmo is dragged
  40069. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  40070. _this.dragBehavior.moveAttached = false;
  40071. _this._rootMesh.addBehavior(_this.dragBehavior);
  40072. var localDelta = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  40073. var tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  40074. _this.dragBehavior.onDragObservable.add(function (event) {
  40075. if (_this.attachedMesh) {
  40076. // Convert delta to local translation if it has a parent
  40077. if (_this.attachedMesh.parent) {
  40078. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  40079. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  40080. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  40081. }
  40082. else {
  40083. localDelta.copyFrom(event.delta);
  40084. }
  40085. // Snapping logic
  40086. if (_this.snapDistance == 0) {
  40087. _this.attachedMesh.position.addInPlace(localDelta);
  40088. }
  40089. else {
  40090. currentSnapDragDistance += event.dragDistance;
  40091. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  40092. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  40093. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  40094. localDelta.normalizeToRef(tmpVector);
  40095. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  40096. _this.attachedMesh.position.addInPlace(tmpVector);
  40097. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  40098. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  40099. }
  40100. }
  40101. }
  40102. });
  40103. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  40104. if (_this._customMeshSet) {
  40105. return;
  40106. }
  40107. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  40108. var material = isHovered ? _this._hoverMaterial : _this._coloredMaterial;
  40109. _this._rootMesh.getChildMeshes().forEach(function (m) {
  40110. m.material = material;
  40111. if (m.color) {
  40112. m.color = material.diffuseColor;
  40113. }
  40114. });
  40115. });
  40116. var light = gizmoLayer._getSharedGizmoLight();
  40117. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  40118. return _this;
  40119. }
  40120. /** @hidden */
  40121. AxisDragGizmo._CreateArrow = function (scene, material) {
  40122. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  40123. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  40124. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  40125. line.material = material;
  40126. cylinder.parent = arrow;
  40127. line.parent = arrow;
  40128. // Position arrow pointing in its drag axis
  40129. cylinder.material = material;
  40130. cylinder.rotation.x = Math.PI / 2;
  40131. cylinder.position.z += 0.3;
  40132. line.position.z += 0.275 / 2;
  40133. line.rotation.x = Math.PI / 2;
  40134. return arrow;
  40135. };
  40136. /** @hidden */
  40137. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  40138. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  40139. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  40140. var mesh = _a[_i];
  40141. var childInstance = mesh.createInstance(mesh.name);
  40142. childInstance.parent = instance;
  40143. }
  40144. return instance;
  40145. };
  40146. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  40147. if (this.dragBehavior) {
  40148. this.dragBehavior.enabled = value ? true : false;
  40149. }
  40150. };
  40151. Object.defineProperty(AxisDragGizmo.prototype, "isEnabled", {
  40152. get: function () {
  40153. return this._isEnabled;
  40154. },
  40155. /**
  40156. * If the gizmo is enabled
  40157. */
  40158. set: function (value) {
  40159. this._isEnabled = value;
  40160. if (!value) {
  40161. this.attachedMesh = null;
  40162. }
  40163. else {
  40164. if (this._parent) {
  40165. this.attachedMesh = this._parent.attachedMesh;
  40166. }
  40167. }
  40168. },
  40169. enumerable: true,
  40170. configurable: true
  40171. });
  40172. /**
  40173. * Disposes of the gizmo
  40174. */
  40175. AxisDragGizmo.prototype.dispose = function () {
  40176. this.onSnapObservable.clear();
  40177. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  40178. this.dragBehavior.detach();
  40179. if (this._arrow) {
  40180. this._arrow.dispose();
  40181. }
  40182. [this._coloredMaterial, this._hoverMaterial].forEach(function (matl) {
  40183. if (matl) {
  40184. matl.dispose();
  40185. }
  40186. });
  40187. _super.prototype.dispose.call(this);
  40188. };
  40189. return AxisDragGizmo;
  40190. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  40191. /***/ }),
  40192. /***/ "./Gizmos/axisScaleGizmo.ts":
  40193. /*!**********************************!*\
  40194. !*** ./Gizmos/axisScaleGizmo.ts ***!
  40195. \**********************************/
  40196. /*! exports provided: AxisScaleGizmo */
  40197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40198. "use strict";
  40199. __webpack_require__.r(__webpack_exports__);
  40200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  40201. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40202. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40203. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  40204. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  40205. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40206. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  40207. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40208. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  40209. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40210. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40211. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  40212. /**
  40213. * Single axis scale gizmo
  40214. */
  40215. var AxisScaleGizmo = /** @class */ (function (_super) {
  40216. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  40217. /**
  40218. * Creates an AxisScaleGizmo
  40219. * @param gizmoLayer The utility layer the gizmo will be added to
  40220. * @param dragAxis The axis which the gizmo will be able to scale on
  40221. * @param color The color of the gizmo
  40222. */
  40223. function AxisScaleGizmo(dragAxis, color, gizmoLayer, parent) {
  40224. if (color === void 0) { color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"].Gray(); }
  40225. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40226. if (parent === void 0) { parent = null; }
  40227. var _this = _super.call(this, gizmoLayer) || this;
  40228. _this._pointerObserver = null;
  40229. /**
  40230. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40231. */
  40232. _this.snapDistance = 0;
  40233. /**
  40234. * Event that fires each time the gizmo snaps to a new location.
  40235. * * snapDistance is the the change in distance
  40236. */
  40237. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40238. /**
  40239. * If the scaling operation should be done on all axis (default: false)
  40240. */
  40241. _this.uniformScaling = false;
  40242. _this._isEnabled = true;
  40243. _this._parent = null;
  40244. _this._parent = parent;
  40245. // Create Material
  40246. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  40247. _this._coloredMaterial.diffuseColor = color;
  40248. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.1, 0.1, 0.1));
  40249. _this._hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  40250. _this._hoverMaterial.diffuseColor = color.add(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color3"](0.3, 0.3, 0.3));
  40251. // Build mesh on root node
  40252. _this._arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  40253. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  40254. 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);
  40255. arrowTail.material = _this._coloredMaterial;
  40256. _this._arrow.addChild(arrowMesh);
  40257. _this._arrow.addChild(arrowTail);
  40258. // Position arrow pointing in its drag axis
  40259. arrowMesh.scaling.scaleInPlace(0.1);
  40260. arrowMesh.material = _this._coloredMaterial;
  40261. arrowMesh.rotation.x = Math.PI / 2;
  40262. arrowMesh.position.z += 0.3;
  40263. arrowTail.position.z += 0.275 / 2;
  40264. arrowTail.rotation.x = Math.PI / 2;
  40265. _this._arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  40266. _this._rootMesh.addChild(_this._arrow);
  40267. _this._arrow.scaling.scaleInPlace(1 / 3);
  40268. // Add drag behavior to handle events when the gizmo is dragged
  40269. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  40270. _this.dragBehavior.moveAttached = false;
  40271. _this._rootMesh.addBehavior(_this.dragBehavior);
  40272. var currentSnapDragDistance = 0;
  40273. var tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  40274. var tmpSnapEvent = { snapDistance: 0 };
  40275. _this.dragBehavior.onDragObservable.add(function (event) {
  40276. if (_this.attachedMesh) {
  40277. // Drag strength is modified by the scale of the gizmo (eg. for small objects like boombox the strength will be increased to match the behavior of larger objects)
  40278. var dragStrength = event.dragDistance * ((_this.scaleRatio * 3) / _this._rootMesh.scaling.length());
  40279. // Snapping logic
  40280. var snapped = false;
  40281. var dragSteps = 0;
  40282. if (_this.uniformScaling) {
  40283. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  40284. if (tmpVector.y < 0) {
  40285. tmpVector.scaleInPlace(-1);
  40286. }
  40287. }
  40288. else {
  40289. tmpVector.copyFrom(dragAxis);
  40290. }
  40291. if (_this.snapDistance == 0) {
  40292. tmpVector.scaleToRef(dragStrength, tmpVector);
  40293. }
  40294. else {
  40295. currentSnapDragDistance += dragStrength;
  40296. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  40297. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  40298. if (currentSnapDragDistance < 0) {
  40299. dragSteps *= -1;
  40300. }
  40301. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  40302. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  40303. snapped = true;
  40304. }
  40305. else {
  40306. tmpVector.scaleInPlace(0);
  40307. }
  40308. }
  40309. _this.attachedMesh.scaling.addInPlace(tmpVector);
  40310. if (snapped) {
  40311. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  40312. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  40313. }
  40314. }
  40315. });
  40316. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  40317. if (_this._customMeshSet) {
  40318. return;
  40319. }
  40320. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  40321. var material = isHovered ? _this._hoverMaterial : _this._coloredMaterial;
  40322. _this._rootMesh.getChildMeshes().forEach(function (m) {
  40323. m.material = material;
  40324. if (m.color) {
  40325. m.color = material.diffuseColor;
  40326. }
  40327. });
  40328. });
  40329. var light = gizmoLayer._getSharedGizmoLight();
  40330. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes());
  40331. return _this;
  40332. }
  40333. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  40334. if (this.dragBehavior) {
  40335. this.dragBehavior.enabled = value ? true : false;
  40336. }
  40337. };
  40338. Object.defineProperty(AxisScaleGizmo.prototype, "isEnabled", {
  40339. get: function () {
  40340. return this._isEnabled;
  40341. },
  40342. /**
  40343. * If the gizmo is enabled
  40344. */
  40345. set: function (value) {
  40346. this._isEnabled = value;
  40347. if (!value) {
  40348. this.attachedMesh = null;
  40349. }
  40350. else {
  40351. if (this._parent) {
  40352. this.attachedMesh = this._parent.attachedMesh;
  40353. }
  40354. }
  40355. },
  40356. enumerable: true,
  40357. configurable: true
  40358. });
  40359. /**
  40360. * Disposes of the gizmo
  40361. */
  40362. AxisScaleGizmo.prototype.dispose = function () {
  40363. this.onSnapObservable.clear();
  40364. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  40365. this.dragBehavior.detach();
  40366. if (this._arrow) {
  40367. this._arrow.dispose();
  40368. }
  40369. [this._coloredMaterial, this._hoverMaterial].forEach(function (matl) {
  40370. if (matl) {
  40371. matl.dispose();
  40372. }
  40373. });
  40374. _super.prototype.dispose.call(this);
  40375. };
  40376. /**
  40377. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40378. * @param mesh The mesh to replace the default mesh of the gizmo
  40379. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  40380. */
  40381. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  40382. var _this = this;
  40383. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  40384. _super.prototype.setCustomMesh.call(this, mesh);
  40385. if (useGizmoMaterial) {
  40386. this._rootMesh.getChildMeshes().forEach(function (m) {
  40387. m.material = _this._coloredMaterial;
  40388. if (m.color) {
  40389. m.color = _this._coloredMaterial.diffuseColor;
  40390. }
  40391. });
  40392. this._customMeshSet = false;
  40393. }
  40394. };
  40395. return AxisScaleGizmo;
  40396. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  40397. /***/ }),
  40398. /***/ "./Gizmos/boundingBoxGizmo.ts":
  40399. /*!************************************!*\
  40400. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  40401. \************************************/
  40402. /*! exports provided: BoundingBoxGizmo */
  40403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40404. "use strict";
  40405. __webpack_require__.r(__webpack_exports__);
  40406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  40407. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40408. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40409. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40410. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  40411. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  40412. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40413. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40414. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40415. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  40416. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  40417. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40418. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40419. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40420. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  40421. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  40422. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  40423. /**
  40424. * Bounding box gizmo
  40425. */
  40426. var BoundingBoxGizmo = /** @class */ (function (_super) {
  40427. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  40428. /**
  40429. * Creates an BoundingBoxGizmo
  40430. * @param gizmoLayer The utility layer the gizmo will be added to
  40431. * @param color The color of the gizmo
  40432. */
  40433. function BoundingBoxGizmo(color, gizmoLayer) {
  40434. if (color === void 0) { color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__["Color3"].Gray(); }
  40435. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  40436. var _this = _super.call(this, gizmoLayer) || this;
  40437. _this._boundingDimensions = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  40438. _this._renderObserver = null;
  40439. _this._pointerObserver = null;
  40440. _this._scaleDragSpeed = 0.2;
  40441. _this._tmpQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  40442. _this._tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  40443. _this._tmpRotationMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  40444. /**
  40445. * 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)
  40446. */
  40447. _this.ignoreChildren = false;
  40448. /**
  40449. * 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)
  40450. */
  40451. _this.includeChildPredicate = null;
  40452. /**
  40453. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  40454. */
  40455. _this.rotationSphereSize = 0.1;
  40456. /**
  40457. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  40458. */
  40459. _this.scaleBoxSize = 0.1;
  40460. /**
  40461. * 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)
  40462. */
  40463. _this.fixedDragMeshScreenSize = false;
  40464. /**
  40465. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  40466. */
  40467. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  40468. /**
  40469. * Fired when a rotation sphere or scale box is dragged
  40470. */
  40471. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40472. /**
  40473. * Fired when a scale box is dragged
  40474. */
  40475. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40476. /**
  40477. * Fired when a scale box drag is ended
  40478. */
  40479. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40480. /**
  40481. * Fired when a rotation sphere is dragged
  40482. */
  40483. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40484. /**
  40485. * Fired when a rotation sphere drag is ended
  40486. */
  40487. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40488. /**
  40489. * 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)
  40490. */
  40491. _this.scalePivot = null;
  40492. _this._existingMeshScale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  40493. // Dragging
  40494. _this._dragMesh = null;
  40495. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  40496. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  40497. _this.updateScale = false;
  40498. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  40499. // Create Materials
  40500. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  40501. _this.coloredMaterial.disableLighting = true;
  40502. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  40503. _this.hoverColoredMaterial.disableLighting = true;
  40504. // Build bounding box out of lines
  40505. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  40506. _this._lineBoundingBox.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  40507. var lines = [];
  40508. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));
  40509. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  40510. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40511. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  40512. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40513. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  40514. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40515. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40516. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40517. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40518. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  40519. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  40520. lines.forEach(function (l) {
  40521. l.color = color;
  40522. l.position.addInPlace(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  40523. l.isPickable = false;
  40524. _this._lineBoundingBox.addChild(l);
  40525. });
  40526. _this._rootMesh.addChild(_this._lineBoundingBox);
  40527. _this.setColor(color);
  40528. // Create rotation spheres
  40529. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  40530. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  40531. var _loop_1 = function (i_1) {
  40532. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  40533. sphere.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  40534. sphere.material = this_1.coloredMaterial;
  40535. // Drag behavior
  40536. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  40537. _dragBehavior.moveAttached = false;
  40538. _dragBehavior.updateDragPlane = false;
  40539. sphere.addBehavior(_dragBehavior);
  40540. var startingTurnDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  40541. var totalTurnAmountOfDrag = 0;
  40542. _dragBehavior.onDragStartObservable.add(function () {
  40543. startingTurnDirection.copyFrom(sphere.forward);
  40544. totalTurnAmountOfDrag = 0;
  40545. });
  40546. _dragBehavior.onDragObservable.add(function (event) {
  40547. _this.onRotationSphereDragObservable.notifyObservers({});
  40548. if (_this.attachedMesh) {
  40549. var originalParent = _this.attachedMesh.parent;
  40550. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  40551. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  40552. return;
  40553. }
  40554. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  40555. var worldDragDirection = startingTurnDirection;
  40556. // Project the world right on to the drag plane
  40557. var toSub = event.dragPlaneNormal.scale(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  40558. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  40559. // project drag delta on to the resulting drag axis and rotate based on that
  40560. var projectDist = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  40561. // Make rotation relative to size of mesh.
  40562. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  40563. // Rotate based on axis
  40564. if (!_this.attachedMesh.rotationQuaternion) {
  40565. _this.attachedMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  40566. }
  40567. if (!_this._anchorMesh.rotationQuaternion) {
  40568. _this._anchorMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  40569. }
  40570. // Do not allow the object to turn more than a full circle
  40571. totalTurnAmountOfDrag += projectDist;
  40572. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  40573. if (i_1 >= 8) {
  40574. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  40575. }
  40576. else if (i_1 >= 4) {
  40577. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  40578. }
  40579. else {
  40580. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  40581. }
  40582. // Rotate around center of bounding box
  40583. _this._anchorMesh.addChild(_this.attachedMesh);
  40584. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  40585. _this._anchorMesh.removeChild(_this.attachedMesh);
  40586. _this.attachedMesh.setParent(originalParent);
  40587. }
  40588. _this.updateBoundingBox();
  40589. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  40590. }
  40591. _this._updateDummy();
  40592. });
  40593. // Selection/deselection
  40594. _dragBehavior.onDragStartObservable.add(function () {
  40595. _this.onDragStartObservable.notifyObservers({});
  40596. _this._selectNode(sphere);
  40597. });
  40598. _dragBehavior.onDragEndObservable.add(function () {
  40599. _this.onRotationSphereDragEndObservable.notifyObservers({});
  40600. _this._selectNode(null);
  40601. _this._updateDummy();
  40602. });
  40603. this_1._rotateSpheresParent.addChild(sphere);
  40604. };
  40605. var this_1 = this, _dragBehavior;
  40606. for (var i_1 = 0; i_1 < 12; i_1++) {
  40607. _loop_1(i_1);
  40608. }
  40609. _this._rootMesh.addChild(_this._rotateSpheresParent);
  40610. // Create scale cubes
  40611. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  40612. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  40613. for (var i = 0; i < 2; i++) {
  40614. for (var j = 0; j < 2; j++) {
  40615. var _loop_2 = function () {
  40616. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  40617. box.material = this_2.coloredMaterial;
  40618. // Dragging logic
  40619. var dragAxis = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  40620. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  40621. _dragBehavior.moveAttached = false;
  40622. box.addBehavior(_dragBehavior);
  40623. _dragBehavior.onDragObservable.add(function (event) {
  40624. _this.onScaleBoxDragObservable.notifyObservers({});
  40625. if (_this.attachedMesh) {
  40626. var originalParent = _this.attachedMesh.parent;
  40627. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  40628. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  40629. return;
  40630. }
  40631. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  40632. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  40633. var deltaScale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  40634. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  40635. _this.updateBoundingBox();
  40636. if (_this.scalePivot) {
  40637. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  40638. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  40639. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  40640. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  40641. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  40642. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  40643. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  40644. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  40645. }
  40646. else {
  40647. // Scale from the position of the opposite corner
  40648. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  40649. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  40650. }
  40651. _this._anchorMesh.addChild(_this.attachedMesh);
  40652. _this._anchorMesh.scaling.addInPlace(deltaScale);
  40653. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  40654. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  40655. }
  40656. _this._anchorMesh.removeChild(_this.attachedMesh);
  40657. _this.attachedMesh.setParent(originalParent);
  40658. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  40659. }
  40660. _this._updateDummy();
  40661. });
  40662. // Selection/deselection
  40663. _dragBehavior.onDragStartObservable.add(function () {
  40664. _this.onDragStartObservable.notifyObservers({});
  40665. _this._selectNode(box);
  40666. });
  40667. _dragBehavior.onDragEndObservable.add(function () {
  40668. _this.onScaleBoxDragEndObservable.notifyObservers({});
  40669. _this._selectNode(null);
  40670. _this._updateDummy();
  40671. });
  40672. this_2._scaleBoxesParent.addChild(box);
  40673. };
  40674. var this_2 = this, _dragBehavior;
  40675. for (var k = 0; k < 2; k++) {
  40676. _loop_2();
  40677. }
  40678. }
  40679. }
  40680. _this._rootMesh.addChild(_this._scaleBoxesParent);
  40681. // Hover color change
  40682. var pointerIds = new Array();
  40683. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  40684. if (!pointerIds[pointerInfo.event.pointerId]) {
  40685. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  40686. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  40687. pointerIds[pointerInfo.event.pointerId] = mesh;
  40688. mesh.material = _this.hoverColoredMaterial;
  40689. }
  40690. });
  40691. }
  40692. else {
  40693. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  40694. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  40695. delete pointerIds[pointerInfo.event.pointerId];
  40696. }
  40697. }
  40698. });
  40699. // Update bounding box positions
  40700. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  40701. // Only update the bouding box if scaling has changed
  40702. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  40703. _this.updateBoundingBox();
  40704. }
  40705. else if (_this.fixedDragMeshScreenSize) {
  40706. _this._updateRotationSpheres();
  40707. _this._updateScaleBoxes();
  40708. }
  40709. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  40710. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  40711. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  40712. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  40713. }
  40714. });
  40715. _this.updateBoundingBox();
  40716. return _this;
  40717. }
  40718. /**
  40719. * Sets the color of the bounding box gizmo
  40720. * @param color the color to set
  40721. */
  40722. BoundingBoxGizmo.prototype.setColor = function (color) {
  40723. this.coloredMaterial.emissiveColor = color;
  40724. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__["Color3"](0.3, 0.3, 0.3));
  40725. this._lineBoundingBox.getChildren().forEach(function (l) {
  40726. if (l.color) {
  40727. l.color = color;
  40728. }
  40729. });
  40730. };
  40731. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  40732. var _this = this;
  40733. if (value) {
  40734. // Reset anchor mesh to match attached mesh's scale
  40735. // This is needed to avoid invalid box/sphere position on first drag
  40736. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  40737. var originalParent = value.parent;
  40738. this._anchorMesh.addChild(value);
  40739. this._anchorMesh.removeChild(value);
  40740. value.setParent(originalParent);
  40741. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  40742. this.updateBoundingBox();
  40743. value.getChildMeshes(false).forEach(function (m) {
  40744. m.markAsDirty("scaling");
  40745. });
  40746. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  40747. _this._updateDummy();
  40748. });
  40749. }
  40750. };
  40751. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  40752. this._rotateSpheresParent.getChildMeshes()
  40753. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  40754. m.isVisible = (!selectedMesh || m == selectedMesh);
  40755. });
  40756. };
  40757. /**
  40758. * Updates the bounding box information for the Gizmo
  40759. */
  40760. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  40761. if (this.attachedMesh) {
  40762. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  40763. // Store original parent
  40764. var originalParent = this.attachedMesh.parent;
  40765. this.attachedMesh.setParent(null);
  40766. // Store original skelton override mesh
  40767. var originalSkeletonOverrideMesh = null;
  40768. if (this.attachedMesh.skeleton) {
  40769. originalSkeletonOverrideMesh = this.attachedMesh.skeleton.overrideMesh;
  40770. this.attachedMesh.skeleton.overrideMesh = null;
  40771. }
  40772. this._update();
  40773. // Rotate based on axis
  40774. if (!this.attachedMesh.rotationQuaternion) {
  40775. this.attachedMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  40776. }
  40777. if (!this._anchorMesh.rotationQuaternion) {
  40778. this._anchorMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  40779. }
  40780. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  40781. // Store original position and reset mesh to origin before computing the bounding box
  40782. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  40783. this._tmpVector.copyFrom(this.attachedMesh.position);
  40784. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  40785. this.attachedMesh.position.set(0, 0, 0);
  40786. // Update bounding dimensions/positions
  40787. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  40788. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  40789. // Update gizmo to match bounding box scaling and rotation
  40790. // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin
  40791. // The position of the gizmo is then set to the attachedMesh in gizmo._update
  40792. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  40793. 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);
  40794. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  40795. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  40796. this._lineBoundingBox.computeWorldMatrix();
  40797. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  40798. // Restore position/rotation values
  40799. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  40800. this.attachedMesh.position.copyFrom(this._tmpVector);
  40801. // Restore original parent
  40802. this.attachedMesh.setParent(originalParent);
  40803. // Restore original skeleton override mesh
  40804. if (this.attachedMesh.skeleton) {
  40805. this.attachedMesh.skeleton.overrideMesh = originalSkeletonOverrideMesh;
  40806. }
  40807. }
  40808. this._updateRotationSpheres();
  40809. this._updateScaleBoxes();
  40810. if (this.attachedMesh) {
  40811. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  40812. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  40813. }
  40814. };
  40815. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  40816. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  40817. for (var i = 0; i < 3; i++) {
  40818. for (var j = 0; j < 2; j++) {
  40819. for (var k = 0; k < 2; k++) {
  40820. var index = ((i * 4) + (j * 2)) + k;
  40821. if (i == 0) {
  40822. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  40823. rotateSpheres[index].position.addInPlace(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  40824. rotateSpheres[index].lookAt(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Right()).normalizeToNew().add(rotateSpheres[index].position));
  40825. }
  40826. if (i == 1) {
  40827. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  40828. rotateSpheres[index].position.addInPlace(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  40829. rotateSpheres[index].lookAt(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up()).normalizeToNew().add(rotateSpheres[index].position));
  40830. }
  40831. if (i == 2) {
  40832. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  40833. rotateSpheres[index].position.addInPlace(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  40834. rotateSpheres[index].lookAt(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Forward()).normalizeToNew().add(rotateSpheres[index].position));
  40835. }
  40836. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  40837. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  40838. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  40839. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  40840. }
  40841. else {
  40842. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  40843. }
  40844. }
  40845. }
  40846. }
  40847. };
  40848. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  40849. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  40850. for (var i = 0; i < 2; i++) {
  40851. for (var j = 0; j < 2; j++) {
  40852. for (var k = 0; k < 2; k++) {
  40853. var index = ((i * 4) + (j * 2)) + k;
  40854. if (scaleBoxes[index]) {
  40855. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  40856. scaleBoxes[index].position.addInPlace(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  40857. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  40858. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  40859. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  40860. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  40861. }
  40862. else {
  40863. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  40864. }
  40865. }
  40866. }
  40867. }
  40868. }
  40869. };
  40870. /**
  40871. * Enables rotation on the specified axis and disables rotation on the others
  40872. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  40873. */
  40874. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  40875. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  40876. if (i < 4) {
  40877. m.setEnabled(axis.indexOf("x") != -1);
  40878. }
  40879. else if (i < 8) {
  40880. m.setEnabled(axis.indexOf("y") != -1);
  40881. }
  40882. else {
  40883. m.setEnabled(axis.indexOf("z") != -1);
  40884. }
  40885. });
  40886. };
  40887. /**
  40888. * Enables/disables scaling
  40889. * @param enable if scaling should be enabled
  40890. */
  40891. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  40892. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  40893. m.setEnabled(enable);
  40894. });
  40895. };
  40896. BoundingBoxGizmo.prototype._updateDummy = function () {
  40897. if (this._dragMesh) {
  40898. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  40899. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  40900. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  40901. }
  40902. };
  40903. /**
  40904. * Enables a pointer drag behavior on the bounding box of the gizmo
  40905. */
  40906. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  40907. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  40908. this._dragMesh.visibility = 0;
  40909. this._dragMesh.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  40910. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  40911. this._dragMesh.addBehavior(this.pointerDragBehavior);
  40912. };
  40913. /**
  40914. * Disposes of the gizmo
  40915. */
  40916. BoundingBoxGizmo.prototype.dispose = function () {
  40917. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  40918. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  40919. this._lineBoundingBox.dispose();
  40920. this._rotateSpheresParent.dispose();
  40921. this._scaleBoxesParent.dispose();
  40922. if (this._dragMesh) {
  40923. this._dragMesh.dispose();
  40924. }
  40925. _super.prototype.dispose.call(this);
  40926. };
  40927. /**
  40928. * 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)
  40929. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  40930. * @returns the bounding box mesh with the passed in mesh as a child
  40931. */
  40932. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  40933. var makeNotPickable = function (root) {
  40934. root.isPickable = false;
  40935. root.getChildMeshes().forEach(function (c) {
  40936. makeNotPickable(c);
  40937. });
  40938. };
  40939. makeNotPickable(mesh);
  40940. // Reset position to get boudning box from origin with no rotation
  40941. if (!mesh.rotationQuaternion) {
  40942. mesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  40943. }
  40944. var oldPos = mesh.position.clone();
  40945. var oldRot = mesh.rotationQuaternion.clone();
  40946. mesh.rotationQuaternion.set(0, 0, 0, 1);
  40947. mesh.position.set(0, 0, 0);
  40948. // Update bounding dimensions/positions
  40949. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  40950. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  40951. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  40952. // Adjust scale to avoid undefined behavior when adding child
  40953. if (box.scaling.y === 0) {
  40954. box.scaling.y = _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"];
  40955. }
  40956. if (box.scaling.x === 0) {
  40957. box.scaling.x = _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"];
  40958. }
  40959. if (box.scaling.z === 0) {
  40960. box.scaling.z = _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"];
  40961. }
  40962. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  40963. // Restore original positions
  40964. mesh.addChild(box);
  40965. mesh.rotationQuaternion.copyFrom(oldRot);
  40966. mesh.position.copyFrom(oldPos);
  40967. // Reverse parenting
  40968. mesh.removeChild(box);
  40969. box.addChild(mesh);
  40970. box.visibility = 0;
  40971. return box;
  40972. };
  40973. /**
  40974. * CustomMeshes are not supported by this gizmo
  40975. * @param mesh The mesh to replace the default mesh of the gizmo
  40976. */
  40977. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  40978. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  40979. };
  40980. return BoundingBoxGizmo;
  40981. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  40982. /***/ }),
  40983. /***/ "./Gizmos/gizmo.ts":
  40984. /*!*************************!*\
  40985. !*** ./Gizmos/gizmo.ts ***!
  40986. \*************************/
  40987. /*! exports provided: Gizmo */
  40988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40989. "use strict";
  40990. __webpack_require__.r(__webpack_exports__);
  40991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  40992. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  40993. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40994. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40995. /**
  40996. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40997. */
  40998. var Gizmo = /** @class */ (function () {
  40999. /**
  41000. * Creates a gizmo
  41001. * @param gizmoLayer The utility layer the gizmo will be added to
  41002. */
  41003. function Gizmo(
  41004. /** The utility layer the gizmo will be added to */
  41005. gizmoLayer) {
  41006. var _this = this;
  41007. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  41008. this.gizmoLayer = gizmoLayer;
  41009. this._attachedMesh = null;
  41010. /**
  41011. * Ratio for the scale of the gizmo (Default: 1)
  41012. */
  41013. this.scaleRatio = 1;
  41014. /**
  41015. * If a custom mesh has been set (Default: false)
  41016. */
  41017. this._customMeshSet = false;
  41018. /**
  41019. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41020. */
  41021. this.updateGizmoRotationToMatchAttachedMesh = true;
  41022. /**
  41023. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41024. */
  41025. this.updateGizmoPositionToMatchAttachedMesh = true;
  41026. /**
  41027. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41028. */
  41029. this.updateScale = true;
  41030. this._interactionsEnabled = true;
  41031. this._tempVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  41032. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  41033. this._rootMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  41034. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  41035. _this._update();
  41036. });
  41037. }
  41038. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  41039. /**
  41040. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41041. * * When set, interactions will be enabled
  41042. */
  41043. get: function () {
  41044. return this._attachedMesh;
  41045. },
  41046. set: function (value) {
  41047. this._attachedMesh = value;
  41048. this._rootMesh.setEnabled(value ? true : false);
  41049. this._attachedMeshChanged(value);
  41050. },
  41051. enumerable: true,
  41052. configurable: true
  41053. });
  41054. /**
  41055. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41056. * @param mesh The mesh to replace the default mesh of the gizmo
  41057. */
  41058. Gizmo.prototype.setCustomMesh = function (mesh) {
  41059. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  41060. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  41061. }
  41062. this._rootMesh.getChildMeshes().forEach(function (c) {
  41063. c.dispose();
  41064. });
  41065. mesh.parent = this._rootMesh;
  41066. this._customMeshSet = true;
  41067. };
  41068. Gizmo.prototype._attachedMeshChanged = function (value) {
  41069. };
  41070. /**
  41071. * Updates the gizmo to match the attached mesh's position/rotation
  41072. */
  41073. Gizmo.prototype._update = function () {
  41074. if (this.attachedMesh) {
  41075. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  41076. // Position
  41077. if (this.updateGizmoPositionToMatchAttachedMesh) {
  41078. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  41079. }
  41080. // Rotation
  41081. if (this.updateGizmoRotationToMatchAttachedMesh) {
  41082. effectiveMesh.getWorldMatrix().decompose(undefined, this._rootMesh.rotationQuaternion);
  41083. }
  41084. else {
  41085. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  41086. }
  41087. // Scale
  41088. if (this.updateScale) {
  41089. var activeCamera = this.gizmoLayer.utilityLayerScene.activeCamera;
  41090. var cameraPosition = activeCamera.globalPosition;
  41091. if (activeCamera.devicePosition) {
  41092. cameraPosition = activeCamera.devicePosition;
  41093. }
  41094. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  41095. var dist = this._tempVector.length() * this.scaleRatio;
  41096. this._rootMesh.scaling.set(dist, dist, dist);
  41097. // Account for handedness, similar to Matrix.decompose
  41098. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  41099. this._rootMesh.scaling.y *= -1;
  41100. }
  41101. }
  41102. else {
  41103. this._rootMesh.scaling.setAll(this.scaleRatio);
  41104. }
  41105. }
  41106. };
  41107. /**
  41108. * Disposes of the gizmo
  41109. */
  41110. Gizmo.prototype.dispose = function () {
  41111. this._rootMesh.dispose();
  41112. if (this._beforeRenderObserver) {
  41113. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  41114. }
  41115. };
  41116. return Gizmo;
  41117. }());
  41118. /***/ }),
  41119. /***/ "./Gizmos/gizmoManager.ts":
  41120. /*!********************************!*\
  41121. !*** ./Gizmos/gizmoManager.ts ***!
  41122. \********************************/
  41123. /*! exports provided: GizmoManager */
  41124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41125. "use strict";
  41126. __webpack_require__.r(__webpack_exports__);
  41127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  41128. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41129. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  41130. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  41131. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  41132. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  41133. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  41134. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  41135. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  41136. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  41137. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  41138. /**
  41139. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41140. */
  41141. var GizmoManager = /** @class */ (function () {
  41142. /**
  41143. * Instatiates a gizmo manager
  41144. * @param scene the scene to overlay the gizmos on top of
  41145. */
  41146. function GizmoManager(scene) {
  41147. var _this = this;
  41148. this.scene = scene;
  41149. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41150. this.clearGizmoOnEmptyPointerEvent = false;
  41151. /** Fires an event when the manager is attached to a mesh */
  41152. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41153. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  41154. this._pointerObserver = null;
  41155. this._attachedMesh = null;
  41156. this._boundingBoxColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  41157. /**
  41158. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41159. */
  41160. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  41161. /**
  41162. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41163. */
  41164. this.attachableMeshes = null;
  41165. /**
  41166. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41167. */
  41168. this.usePointerToAttachGizmos = true;
  41169. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  41170. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  41171. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  41172. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  41173. // Instatiate/dispose gizmos based on pointer actions
  41174. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  41175. if (!_this.usePointerToAttachGizmos) {
  41176. return;
  41177. }
  41178. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  41179. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  41180. var node = pointerInfo.pickInfo.pickedMesh;
  41181. if (_this.attachableMeshes == null) {
  41182. // Attach to the most parent node
  41183. while (node && node.parent != null) {
  41184. node = node.parent;
  41185. }
  41186. }
  41187. else {
  41188. // Attach to the parent node that is an attachableMesh
  41189. var found = false;
  41190. _this.attachableMeshes.forEach(function (mesh) {
  41191. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  41192. node = mesh;
  41193. found = true;
  41194. }
  41195. });
  41196. if (!found) {
  41197. node = null;
  41198. }
  41199. }
  41200. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  41201. if (_this._attachedMesh != node) {
  41202. _this.attachToMesh(node);
  41203. }
  41204. }
  41205. else {
  41206. if (_this.clearGizmoOnEmptyPointerEvent) {
  41207. _this.attachToMesh(null);
  41208. }
  41209. }
  41210. }
  41211. else {
  41212. if (_this.clearGizmoOnEmptyPointerEvent) {
  41213. _this.attachToMesh(null);
  41214. }
  41215. }
  41216. }
  41217. });
  41218. }
  41219. Object.defineProperty(GizmoManager.prototype, "keepDepthUtilityLayer", {
  41220. /**
  41221. * Utility layer that the bounding box gizmo belongs to
  41222. */
  41223. get: function () {
  41224. return this._defaultKeepDepthUtilityLayer;
  41225. },
  41226. enumerable: true,
  41227. configurable: true
  41228. });
  41229. Object.defineProperty(GizmoManager.prototype, "utilityLayer", {
  41230. /**
  41231. * Utility layer that all gizmos besides bounding box belong to
  41232. */
  41233. get: function () {
  41234. return this._defaultUtilityLayer;
  41235. },
  41236. enumerable: true,
  41237. configurable: true
  41238. });
  41239. /**
  41240. * Attaches a set of gizmos to the specified mesh
  41241. * @param mesh The mesh the gizmo's should be attached to
  41242. */
  41243. GizmoManager.prototype.attachToMesh = function (mesh) {
  41244. if (this._attachedMesh) {
  41245. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  41246. }
  41247. this._attachedMesh = mesh;
  41248. for (var key in this.gizmos) {
  41249. var gizmo = (this.gizmos[key]);
  41250. if (gizmo && this._gizmosEnabled[key]) {
  41251. gizmo.attachedMesh = mesh;
  41252. }
  41253. }
  41254. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  41255. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  41256. }
  41257. this.onAttachedToMeshObservable.notifyObservers(mesh);
  41258. };
  41259. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  41260. get: function () {
  41261. return this._gizmosEnabled.positionGizmo;
  41262. },
  41263. /**
  41264. * If the position gizmo is enabled
  41265. */
  41266. set: function (value) {
  41267. if (value) {
  41268. if (!this.gizmos.positionGizmo) {
  41269. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  41270. }
  41271. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  41272. }
  41273. else if (this.gizmos.positionGizmo) {
  41274. this.gizmos.positionGizmo.attachedMesh = null;
  41275. }
  41276. this._gizmosEnabled.positionGizmo = value;
  41277. },
  41278. enumerable: true,
  41279. configurable: true
  41280. });
  41281. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  41282. get: function () {
  41283. return this._gizmosEnabled.rotationGizmo;
  41284. },
  41285. /**
  41286. * If the rotation gizmo is enabled
  41287. */
  41288. set: function (value) {
  41289. if (value) {
  41290. if (!this.gizmos.rotationGizmo) {
  41291. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  41292. }
  41293. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  41294. }
  41295. else if (this.gizmos.rotationGizmo) {
  41296. this.gizmos.rotationGizmo.attachedMesh = null;
  41297. }
  41298. this._gizmosEnabled.rotationGizmo = value;
  41299. },
  41300. enumerable: true,
  41301. configurable: true
  41302. });
  41303. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  41304. get: function () {
  41305. return this._gizmosEnabled.scaleGizmo;
  41306. },
  41307. /**
  41308. * If the scale gizmo is enabled
  41309. */
  41310. set: function (value) {
  41311. if (value) {
  41312. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  41313. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  41314. }
  41315. else if (this.gizmos.scaleGizmo) {
  41316. this.gizmos.scaleGizmo.attachedMesh = null;
  41317. }
  41318. this._gizmosEnabled.scaleGizmo = value;
  41319. },
  41320. enumerable: true,
  41321. configurable: true
  41322. });
  41323. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  41324. get: function () {
  41325. return this._gizmosEnabled.boundingBoxGizmo;
  41326. },
  41327. /**
  41328. * If the boundingBox gizmo is enabled
  41329. */
  41330. set: function (value) {
  41331. if (value) {
  41332. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  41333. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  41334. if (this._attachedMesh) {
  41335. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  41336. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  41337. }
  41338. }
  41339. else if (this.gizmos.boundingBoxGizmo) {
  41340. if (this._attachedMesh) {
  41341. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  41342. }
  41343. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  41344. }
  41345. this._gizmosEnabled.boundingBoxGizmo = value;
  41346. },
  41347. enumerable: true,
  41348. configurable: true
  41349. });
  41350. /**
  41351. * Disposes of the gizmo manager
  41352. */
  41353. GizmoManager.prototype.dispose = function () {
  41354. this.scene.onPointerObservable.remove(this._pointerObserver);
  41355. for (var key in this.gizmos) {
  41356. var gizmo = (this.gizmos[key]);
  41357. if (gizmo) {
  41358. gizmo.dispose();
  41359. }
  41360. }
  41361. this._defaultKeepDepthUtilityLayer.dispose();
  41362. this._defaultUtilityLayer.dispose();
  41363. this.boundingBoxDragBehavior.detach();
  41364. this.onAttachedToMeshObservable.clear();
  41365. };
  41366. return GizmoManager;
  41367. }());
  41368. /***/ }),
  41369. /***/ "./Gizmos/index.ts":
  41370. /*!*************************!*\
  41371. !*** ./Gizmos/index.ts ***!
  41372. \*************************/
  41373. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, PlaneDragGizmo */
  41374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41375. "use strict";
  41376. __webpack_require__.r(__webpack_exports__);
  41377. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  41378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  41379. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  41380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  41381. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  41382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  41383. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  41384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  41385. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  41386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  41387. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  41388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  41389. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  41390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  41391. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  41392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  41393. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  41394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  41395. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  41396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  41397. /* harmony import */ var _planeDragGizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./planeDragGizmo */ "./Gizmos/planeDragGizmo.ts");
  41398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneDragGizmo", function() { return _planeDragGizmo__WEBPACK_IMPORTED_MODULE_10__["PlaneDragGizmo"]; });
  41399. /***/ }),
  41400. /***/ "./Gizmos/lightGizmo.ts":
  41401. /*!******************************!*\
  41402. !*** ./Gizmos/lightGizmo.ts ***!
  41403. \******************************/
  41404. /*! exports provided: LightGizmo */
  41405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41406. "use strict";
  41407. __webpack_require__.r(__webpack_exports__);
  41408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  41409. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41410. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  41411. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  41412. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  41413. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41414. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  41415. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  41416. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  41417. /* harmony import */ var _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Lights/directionalLight */ "./Lights/directionalLight.ts");
  41418. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41419. /* harmony import */ var _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Meshes/Builders/hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  41420. /* harmony import */ var _Lights_spotLight__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Lights/spotLight */ "./Lights/spotLight.ts");
  41421. /**
  41422. * Gizmo that enables viewing a light
  41423. */
  41424. var LightGizmo = /** @class */ (function (_super) {
  41425. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  41426. /**
  41427. * Creates a LightGizmo
  41428. * @param gizmoLayer The utility layer the gizmo will be added to
  41429. */
  41430. function LightGizmo(gizmoLayer) {
  41431. var _this = _super.call(this, gizmoLayer) || this;
  41432. _this.cachedPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  41433. _this.cachedForward = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  41434. _this._light = null;
  41435. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  41436. _this._material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("light", _this.gizmoLayer.originalScene);
  41437. _this._material.diffuseColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.5, 0.5, 0.5);
  41438. _this._material.specularColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1);
  41439. return _this;
  41440. }
  41441. Object.defineProperty(LightGizmo.prototype, "light", {
  41442. get: function () {
  41443. return this._light;
  41444. },
  41445. /**
  41446. * The light that the gizmo is attached to
  41447. */
  41448. set: function (light) {
  41449. var _this = this;
  41450. this._light = light;
  41451. if (light) {
  41452. // Create the mesh for the given light type
  41453. if (this._lightMesh) {
  41454. this._lightMesh.dispose();
  41455. }
  41456. if (light instanceof _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]) {
  41457. this._lightMesh = LightGizmo._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene);
  41458. }
  41459. else if (light instanceof _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_8__["DirectionalLight"]) {
  41460. this._lightMesh = LightGizmo._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene);
  41461. }
  41462. else if (light instanceof _Lights_spotLight__WEBPACK_IMPORTED_MODULE_11__["SpotLight"]) {
  41463. this._lightMesh = LightGizmo._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene);
  41464. }
  41465. else {
  41466. this._lightMesh = LightGizmo._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene);
  41467. }
  41468. this._lightMesh.getChildMeshes(false).forEach(function (m) {
  41469. m.material = _this._material;
  41470. });
  41471. this._lightMesh.parent = this._rootMesh;
  41472. // Add lighting to the light gizmo
  41473. var gizmoLight = this.gizmoLayer._getSharedGizmoLight();
  41474. gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(false));
  41475. this._lightMesh.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  41476. if (!this.attachedMesh.reservedDataStore) {
  41477. this.attachedMesh.reservedDataStore = {};
  41478. }
  41479. this.attachedMesh.reservedDataStore.lightGizmo = this;
  41480. // Get update position and direction if the light has it
  41481. if (light.position) {
  41482. this.attachedMesh.position.copyFrom(light.position);
  41483. }
  41484. if (light.direction) {
  41485. this.attachedMesh.setDirection(light.direction);
  41486. }
  41487. this._update();
  41488. }
  41489. },
  41490. enumerable: true,
  41491. configurable: true
  41492. });
  41493. /**
  41494. * @hidden
  41495. * Updates the gizmo to match the attached mesh's position/rotation
  41496. */
  41497. LightGizmo.prototype._update = function () {
  41498. _super.prototype._update.call(this);
  41499. if (!this._light) {
  41500. return;
  41501. }
  41502. if (this._light.position) {
  41503. // If the gizmo is moved update the light otherwise update the gizmo to match the light
  41504. if (!this.attachedMesh.position.equals(this.cachedPosition)) {
  41505. // update light to match gizmo
  41506. this._light.position.copyFrom(this.attachedMesh.position);
  41507. this.cachedPosition.copyFrom(this.attachedMesh.position);
  41508. }
  41509. else {
  41510. // update gizmo to match light
  41511. this.attachedMesh.position.copyFrom(this._light.position);
  41512. }
  41513. }
  41514. if (this._light.direction) {
  41515. // If the gizmo is moved update the light otherwise update the gizmo to match the light
  41516. if (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.attachedMesh.forward, this.cachedForward) > 0.0001) {
  41517. // update light to match gizmo
  41518. this._light.direction.copyFrom(this.attachedMesh.forward);
  41519. this.cachedForward.copyFrom(this.attachedMesh.forward);
  41520. }
  41521. else if (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.attachedMesh.forward, this._light.direction) > 0.0001) {
  41522. // update gizmo to match light
  41523. this.attachedMesh.setDirection(this._light.direction);
  41524. this.cachedForward.copyFrom(this._lightMesh.forward);
  41525. }
  41526. }
  41527. if (!this._light.isEnabled()) {
  41528. this._material.diffuseColor.set(0, 0, 0);
  41529. }
  41530. else {
  41531. this._material.diffuseColor.set(this._light.diffuse.r / 3, this._light.diffuse.g / 3, this._light.diffuse.b / 3);
  41532. }
  41533. };
  41534. /**
  41535. * Disposes of the light gizmo
  41536. */
  41537. LightGizmo.prototype.dispose = function () {
  41538. this._material.dispose();
  41539. _super.prototype.dispose.call(this);
  41540. };
  41541. LightGizmo._CreateHemisphericLightMesh = function (scene) {
  41542. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("hemisphereLight", scene);
  41543. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_10__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 1 }, scene);
  41544. hemisphere.position.z = -0.15;
  41545. hemisphere.rotation.x = Math.PI / 2;
  41546. hemisphere.parent = root;
  41547. var lines = this._createLightLines(3, scene);
  41548. lines.parent = root;
  41549. lines.position.z - 0.15;
  41550. root.scaling.scaleInPlace(LightGizmo._Scale);
  41551. root.rotation.x = Math.PI / 2;
  41552. return root;
  41553. };
  41554. LightGizmo._CreatePointLightMesh = function (scene) {
  41555. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("pointLight", scene);
  41556. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_9__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  41557. sphere.rotation.x = Math.PI / 2;
  41558. sphere.parent = root;
  41559. var lines = this._createLightLines(5, scene);
  41560. lines.parent = root;
  41561. root.scaling.scaleInPlace(LightGizmo._Scale);
  41562. root.rotation.x = Math.PI / 2;
  41563. return root;
  41564. };
  41565. LightGizmo._CreateSpotLightMesh = function (scene) {
  41566. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("spotLight", scene);
  41567. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_9__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  41568. sphere.parent = root;
  41569. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_10__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 2 }, scene);
  41570. hemisphere.parent = root;
  41571. hemisphere.rotation.x = -Math.PI / 2;
  41572. var lines = this._createLightLines(2, scene);
  41573. lines.parent = root;
  41574. root.scaling.scaleInPlace(LightGizmo._Scale);
  41575. root.rotation.x = Math.PI / 2;
  41576. return root;
  41577. };
  41578. LightGizmo._CreateDirectionalLightMesh = function (scene) {
  41579. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("directionalLight", scene);
  41580. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](root.name, scene);
  41581. mesh.parent = root;
  41582. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_9__["SphereBuilder"].CreateSphere(root.name, { diameter: 1.2, segments: 10 }, scene);
  41583. sphere.parent = mesh;
  41584. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateCylinder(root.name, 6, 0.3, 0.3, 6, 1, scene);
  41585. line.parent = mesh;
  41586. var left = line.clone(root.name);
  41587. left.scaling.y = 0.5;
  41588. left.position.x += 1.25;
  41589. var right = line.clone(root.name);
  41590. right.scaling.y = 0.5;
  41591. right.position.x += -1.25;
  41592. var arrowHead = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateCylinder(root.name, 1, 0, 0.6, 6, 1, scene);
  41593. arrowHead.position.y += 3;
  41594. arrowHead.parent = mesh;
  41595. var left = arrowHead.clone(root.name);
  41596. left.position.y = 1.5;
  41597. left.position.x += 1.25;
  41598. var right = arrowHead.clone(root.name);
  41599. right.position.y = 1.5;
  41600. right.position.x += -1.25;
  41601. mesh.scaling.scaleInPlace(LightGizmo._Scale);
  41602. mesh.rotation.z = Math.PI / 2;
  41603. mesh.rotation.y = Math.PI / 2;
  41604. return root;
  41605. };
  41606. // Static helper methods
  41607. LightGizmo._Scale = 0.007;
  41608. /**
  41609. * Creates the lines for a light mesh
  41610. */
  41611. LightGizmo._createLightLines = function (levels, scene) {
  41612. var distFromSphere = 1.2;
  41613. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("root", scene);
  41614. root.rotation.x = Math.PI / 2;
  41615. // Create the top line, this will be cloned for all other lines
  41616. var linePivot = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("linePivot", scene);
  41617. linePivot.parent = root;
  41618. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateCylinder("line", 2, 0.2, 0.3, 6, 1, scene);
  41619. line.position.y = line.scaling.y / 2 + distFromSphere;
  41620. line.parent = linePivot;
  41621. if (levels < 2) {
  41622. return linePivot;
  41623. }
  41624. for (var i = 0; i < 4; i++) {
  41625. var l = linePivot.clone("lineParentClone");
  41626. l.rotation.z = Math.PI / 4;
  41627. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  41628. l.getChildMeshes()[0].scaling.y = 0.5;
  41629. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  41630. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  41631. }
  41632. if (levels < 3) {
  41633. return root;
  41634. }
  41635. for (var i = 0; i < 4; i++) {
  41636. var l = linePivot.clone("linePivotClone");
  41637. l.rotation.z = Math.PI / 2;
  41638. l.rotation.y = (Math.PI / 2 * i);
  41639. }
  41640. if (levels < 4) {
  41641. return root;
  41642. }
  41643. for (var i = 0; i < 4; i++) {
  41644. var l = linePivot.clone("linePivotClone");
  41645. l.rotation.z = Math.PI + (Math.PI / 4);
  41646. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  41647. l.getChildMeshes()[0].scaling.y = 0.5;
  41648. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  41649. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  41650. }
  41651. if (levels < 5) {
  41652. return root;
  41653. }
  41654. var l = linePivot.clone("linePivotClone");
  41655. l.rotation.z = Math.PI;
  41656. return root;
  41657. };
  41658. return LightGizmo;
  41659. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  41660. /***/ }),
  41661. /***/ "./Gizmos/planeDragGizmo.ts":
  41662. /*!**********************************!*\
  41663. !*** ./Gizmos/planeDragGizmo.ts ***!
  41664. \**********************************/
  41665. /*! exports provided: PlaneDragGizmo */
  41666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41667. "use strict";
  41668. __webpack_require__.r(__webpack_exports__);
  41669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneDragGizmo", function() { return PlaneDragGizmo; });
  41670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41671. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41672. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  41673. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  41674. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41675. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  41676. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  41677. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  41678. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  41679. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  41680. /**
  41681. * Single plane drag gizmo
  41682. */
  41683. var PlaneDragGizmo = /** @class */ (function (_super) {
  41684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneDragGizmo, _super);
  41685. /**
  41686. * Creates a PlaneDragGizmo
  41687. * @param gizmoLayer The utility layer the gizmo will be added to
  41688. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41689. * @param color The color of the gizmo
  41690. */
  41691. function PlaneDragGizmo(dragPlaneNormal, color, gizmoLayer, parent) {
  41692. if (color === void 0) { color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  41693. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  41694. if (parent === void 0) { parent = null; }
  41695. var _this = _super.call(this, gizmoLayer) || this;
  41696. _this._pointerObserver = null;
  41697. /**
  41698. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41699. */
  41700. _this.snapDistance = 0;
  41701. /**
  41702. * Event that fires each time the gizmo snaps to a new location.
  41703. * * snapDistance is the the change in distance
  41704. */
  41705. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  41706. _this._isEnabled = false;
  41707. _this._parent = null;
  41708. _this._parent = parent;
  41709. // Create Material
  41710. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  41711. _this._coloredMaterial.diffuseColor = color;
  41712. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.1, 0.1, 0.1));
  41713. _this._hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  41714. _this._hoverMaterial.diffuseColor = color.add(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  41715. // Build plane mesh on root node
  41716. _this._plane = PlaneDragGizmo._CreatePlane(gizmoLayer.utilityLayerScene, _this._coloredMaterial);
  41717. _this._plane.lookAt(_this._rootMesh.position.add(dragPlaneNormal));
  41718. _this._plane.scaling.scaleInPlace(1 / 3);
  41719. _this._plane.parent = _this._rootMesh;
  41720. var currentSnapDragDistance = 0;
  41721. var tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  41722. var tmpSnapEvent = { snapDistance: 0 };
  41723. // Add dragPlaneNormal drag behavior to handle events when the gizmo is dragged
  41724. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragPlaneNormal: dragPlaneNormal });
  41725. _this.dragBehavior.moveAttached = false;
  41726. _this._rootMesh.addBehavior(_this.dragBehavior);
  41727. var localDelta = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  41728. var tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  41729. _this.dragBehavior.onDragObservable.add(function (event) {
  41730. if (_this.attachedMesh) {
  41731. // Convert delta to local translation if it has a parent
  41732. if (_this.attachedMesh.parent) {
  41733. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  41734. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  41735. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  41736. }
  41737. else {
  41738. localDelta.copyFrom(event.delta);
  41739. }
  41740. // Snapping logic
  41741. if (_this.snapDistance == 0) {
  41742. _this.attachedMesh.position.addInPlace(localDelta);
  41743. }
  41744. else {
  41745. currentSnapDragDistance += event.dragDistance;
  41746. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  41747. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  41748. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  41749. localDelta.normalizeToRef(tmpVector);
  41750. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  41751. _this.attachedMesh.position.addInPlace(tmpVector);
  41752. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  41753. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  41754. }
  41755. }
  41756. }
  41757. });
  41758. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  41759. if (_this._customMeshSet) {
  41760. return;
  41761. }
  41762. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  41763. var material = isHovered ? _this._hoverMaterial : _this._coloredMaterial;
  41764. _this._rootMesh.getChildMeshes().forEach(function (m) {
  41765. m.material = material;
  41766. });
  41767. });
  41768. var light = gizmoLayer._getSharedGizmoLight();
  41769. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  41770. return _this;
  41771. }
  41772. /** @hidden */
  41773. PlaneDragGizmo._CreatePlane = function (scene, material) {
  41774. var plane = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_4__["TransformNode"]("plane", scene);
  41775. //make sure plane is double sided
  41776. var dragPlane = _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_5__["PlaneBuilder"].CreatePlane("dragPlane", { width: .1375, height: .1375, sideOrientation: 2 }, scene);
  41777. dragPlane.material = material;
  41778. dragPlane.parent = plane;
  41779. // Position plane pointing normal to dragPlane normal
  41780. dragPlane.material = material;
  41781. return plane;
  41782. };
  41783. /** @hidden */
  41784. PlaneDragGizmo._CreateArrowInstance = function (scene, arrow) {
  41785. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_4__["TransformNode"]("arrow", scene);
  41786. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  41787. var mesh = _a[_i];
  41788. var childInstance = mesh.createInstance(mesh.name);
  41789. childInstance.parent = instance;
  41790. }
  41791. return instance;
  41792. };
  41793. PlaneDragGizmo.prototype._attachedMeshChanged = function (value) {
  41794. if (this.dragBehavior) {
  41795. this.dragBehavior.enabled = value ? true : false;
  41796. }
  41797. };
  41798. Object.defineProperty(PlaneDragGizmo.prototype, "isEnabled", {
  41799. get: function () {
  41800. return this._isEnabled;
  41801. },
  41802. /**
  41803. * If the gizmo is enabled
  41804. */
  41805. set: function (value) {
  41806. this._isEnabled = value;
  41807. if (!value) {
  41808. this.attachedMesh = null;
  41809. }
  41810. else {
  41811. if (this._parent) {
  41812. this.attachedMesh = this._parent.attachedMesh;
  41813. }
  41814. }
  41815. },
  41816. enumerable: true,
  41817. configurable: true
  41818. });
  41819. /**
  41820. * Disposes of the gizmo
  41821. */
  41822. PlaneDragGizmo.prototype.dispose = function () {
  41823. this.onSnapObservable.clear();
  41824. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  41825. this.dragBehavior.detach();
  41826. _super.prototype.dispose.call(this);
  41827. if (this._plane) {
  41828. this._plane.dispose();
  41829. }
  41830. [this._coloredMaterial, this._hoverMaterial].forEach(function (matl) {
  41831. if (matl) {
  41832. matl.dispose();
  41833. }
  41834. });
  41835. };
  41836. return PlaneDragGizmo;
  41837. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  41838. /***/ }),
  41839. /***/ "./Gizmos/planeRotationGizmo.ts":
  41840. /*!**************************************!*\
  41841. !*** ./Gizmos/planeRotationGizmo.ts ***!
  41842. \**************************************/
  41843. /*! exports provided: PlaneRotationGizmo */
  41844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41845. "use strict";
  41846. __webpack_require__.r(__webpack_exports__);
  41847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  41848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41849. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41850. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  41851. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  41852. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  41853. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41854. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  41855. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  41856. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  41857. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  41858. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  41859. /**
  41860. * Single plane rotation gizmo
  41861. */
  41862. var PlaneRotationGizmo = /** @class */ (function (_super) {
  41863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  41864. /**
  41865. * Creates a PlaneRotationGizmo
  41866. * @param gizmoLayer The utility layer the gizmo will be added to
  41867. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41868. * @param color The color of the gizmo
  41869. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41870. */
  41871. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation, parent) {
  41872. if (color === void 0) { color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  41873. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  41874. if (tessellation === void 0) { tessellation = 32; }
  41875. if (parent === void 0) { parent = null; }
  41876. var _this = _super.call(this, gizmoLayer) || this;
  41877. _this._pointerObserver = null;
  41878. /**
  41879. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41880. */
  41881. _this.snapDistance = 0;
  41882. /**
  41883. * Event that fires each time the gizmo snaps to a new location.
  41884. * * snapDistance is the the change in distance
  41885. */
  41886. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  41887. _this._isEnabled = true;
  41888. _this._parent = null;
  41889. _this._parent = parent;
  41890. // Create Material
  41891. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  41892. coloredMaterial.diffuseColor = color;
  41893. coloredMaterial.specularColor = color.subtract(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.1, 0.1, 0.1));
  41894. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  41895. hoverMaterial.diffuseColor = color.add(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  41896. // Build mesh on root node
  41897. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  41898. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  41899. drag.visibility = 0;
  41900. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  41901. rotationMesh.material = coloredMaterial;
  41902. // Position arrow pointing in its drag axis
  41903. rotationMesh.rotation.x = Math.PI / 2;
  41904. drag.rotation.x = Math.PI / 2;
  41905. parentMesh.addChild(rotationMesh);
  41906. parentMesh.addChild(drag);
  41907. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  41908. _this._rootMesh.addChild(parentMesh);
  41909. parentMesh.scaling.scaleInPlace(1 / 3);
  41910. // Add drag behavior to handle events when the gizmo is dragged
  41911. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  41912. _this.dragBehavior.moveAttached = false;
  41913. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  41914. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  41915. _this._rootMesh.addBehavior(_this.dragBehavior);
  41916. var lastDragPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  41917. _this.dragBehavior.onDragStartObservable.add(function (e) {
  41918. if (_this.attachedMesh) {
  41919. lastDragPosition.copyFrom(e.dragPlanePoint);
  41920. }
  41921. });
  41922. var rotationMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  41923. var planeNormalTowardsCamera = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  41924. var localPlaneNormalTowardsCamera = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  41925. var tmpSnapEvent = { snapDistance: 0 };
  41926. var currentSnapDragDistance = 0;
  41927. var tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  41928. var tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  41929. var amountToRotate = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  41930. _this.dragBehavior.onDragObservable.add(function (event) {
  41931. if (_this.attachedMesh) {
  41932. if (!_this.attachedMesh.rotationQuaternion) {
  41933. _this.attachedMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  41934. }
  41935. // Remove parent priort to rotating
  41936. var attachedMeshParent = _this.attachedMesh.parent;
  41937. if (attachedMeshParent) {
  41938. _this.attachedMesh.setParent(null);
  41939. }
  41940. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  41941. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  41942. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  41943. var cross = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  41944. var dot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  41945. var angle = Math.atan2(cross.length(), dot);
  41946. planeNormalTowardsCamera.copyFrom(planeNormal);
  41947. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  41948. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  41949. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  41950. localPlaneNormalTowardsCamera = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  41951. }
  41952. // Flip up vector depending on which side the camera is on
  41953. if (gizmoLayer.utilityLayerScene.activeCamera) {
  41954. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  41955. if (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  41956. planeNormalTowardsCamera.scaleInPlace(-1);
  41957. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  41958. }
  41959. }
  41960. var halfCircleSide = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  41961. if (halfCircleSide) {
  41962. angle = -angle;
  41963. }
  41964. // Snapping logic
  41965. var snapped = false;
  41966. if (_this.snapDistance != 0) {
  41967. currentSnapDragDistance += angle;
  41968. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  41969. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  41970. if (currentSnapDragDistance < 0) {
  41971. dragSteps *= -1;
  41972. }
  41973. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  41974. angle = _this.snapDistance * dragSteps;
  41975. snapped = true;
  41976. }
  41977. else {
  41978. angle = 0;
  41979. }
  41980. }
  41981. // If the mesh has a parent, convert needed world rotation to local rotation
  41982. tmpMatrix.reset();
  41983. if (_this.attachedMesh.parent) {
  41984. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  41985. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  41986. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  41987. }
  41988. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  41989. var quaternionCoefficient = Math.sin(angle / 2);
  41990. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  41991. // 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
  41992. if (tmpMatrix.determinant() > 0) {
  41993. amountToRotate.toEulerAnglesToRef(tmpVector);
  41994. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  41995. }
  41996. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  41997. // Rotate selected mesh quaternion over fixed axis
  41998. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  41999. }
  42000. else {
  42001. // Rotate selected mesh quaternion over rotated axis
  42002. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  42003. }
  42004. lastDragPosition.copyFrom(event.dragPlanePoint);
  42005. if (snapped) {
  42006. tmpSnapEvent.snapDistance = angle;
  42007. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  42008. }
  42009. // Restore parent
  42010. if (attachedMeshParent) {
  42011. _this.attachedMesh.setParent(attachedMeshParent);
  42012. }
  42013. }
  42014. });
  42015. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  42016. if (_this._customMeshSet) {
  42017. return;
  42018. }
  42019. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  42020. var material = isHovered ? hoverMaterial : coloredMaterial;
  42021. _this._rootMesh.getChildMeshes().forEach(function (m) {
  42022. m.material = material;
  42023. if (m.color) {
  42024. m.color = material.diffuseColor;
  42025. }
  42026. });
  42027. });
  42028. var light = gizmoLayer._getSharedGizmoLight();
  42029. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  42030. return _this;
  42031. }
  42032. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  42033. if (this.dragBehavior) {
  42034. this.dragBehavior.enabled = value ? true : false;
  42035. }
  42036. };
  42037. Object.defineProperty(PlaneRotationGizmo.prototype, "isEnabled", {
  42038. get: function () {
  42039. return this._isEnabled;
  42040. },
  42041. /**
  42042. * If the gizmo is enabled
  42043. */
  42044. set: function (value) {
  42045. this._isEnabled = value;
  42046. if (!value) {
  42047. this.attachedMesh = null;
  42048. }
  42049. else {
  42050. if (this._parent) {
  42051. this.attachedMesh = this._parent.attachedMesh;
  42052. }
  42053. }
  42054. },
  42055. enumerable: true,
  42056. configurable: true
  42057. });
  42058. /**
  42059. * Disposes of the gizmo
  42060. */
  42061. PlaneRotationGizmo.prototype.dispose = function () {
  42062. this.onSnapObservable.clear();
  42063. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  42064. this.dragBehavior.detach();
  42065. _super.prototype.dispose.call(this);
  42066. };
  42067. return PlaneRotationGizmo;
  42068. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  42069. /***/ }),
  42070. /***/ "./Gizmos/positionGizmo.ts":
  42071. /*!*********************************!*\
  42072. !*** ./Gizmos/positionGizmo.ts ***!
  42073. \*********************************/
  42074. /*! exports provided: PositionGizmo */
  42075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42076. "use strict";
  42077. __webpack_require__.r(__webpack_exports__);
  42078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  42079. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42080. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42081. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42082. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  42083. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  42084. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  42085. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  42086. /* harmony import */ var _planeDragGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planeDragGizmo */ "./Gizmos/planeDragGizmo.ts");
  42087. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  42088. /**
  42089. * Gizmo that enables dragging a mesh along 3 axis
  42090. */
  42091. var PositionGizmo = /** @class */ (function (_super) {
  42092. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  42093. /**
  42094. * Creates a PositionGizmo
  42095. * @param gizmoLayer The utility layer the gizmo will be added to
  42096. */
  42097. function PositionGizmo(gizmoLayer) {
  42098. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  42099. var _this = _super.call(this, gizmoLayer) || this;
  42100. /**
  42101. * private variables
  42102. */
  42103. _this._meshAttached = null;
  42104. /** Fires an event when any of it's sub gizmos are dragged */
  42105. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42106. /** Fires an event when any of it's sub gizmos are released from dragging */
  42107. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42108. /**
  42109. * If set to true, planar drag is enabled
  42110. */
  42111. _this._planarGizmoEnabled = false;
  42112. _this.xGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisDragGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Red().scale(0.5), gizmoLayer, _this);
  42113. _this.yGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisDragGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Green().scale(0.5), gizmoLayer, _this);
  42114. _this.zGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisDragGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Blue().scale(0.5), gizmoLayer, _this);
  42115. _this.xPlaneGizmo = new _planeDragGizmo__WEBPACK_IMPORTED_MODULE_7__["PlaneDragGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Red().scale(0.5), _this.gizmoLayer, _this);
  42116. _this.yPlaneGizmo = new _planeDragGizmo__WEBPACK_IMPORTED_MODULE_7__["PlaneDragGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Green().scale(0.5), _this.gizmoLayer, _this);
  42117. _this.zPlaneGizmo = new _planeDragGizmo__WEBPACK_IMPORTED_MODULE_7__["PlaneDragGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Blue().scale(0.5), _this.gizmoLayer, _this);
  42118. // Relay drag events
  42119. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.xPlaneGizmo, _this.yPlaneGizmo, _this.zPlaneGizmo].forEach(function (gizmo) {
  42120. gizmo.dragBehavior.onDragStartObservable.add(function () {
  42121. _this.onDragStartObservable.notifyObservers({});
  42122. });
  42123. gizmo.dragBehavior.onDragEndObservable.add(function () {
  42124. _this.onDragEndObservable.notifyObservers({});
  42125. });
  42126. });
  42127. _this.attachedMesh = null;
  42128. return _this;
  42129. }
  42130. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  42131. get: function () {
  42132. return this._meshAttached;
  42133. },
  42134. set: function (mesh) {
  42135. this._meshAttached = mesh;
  42136. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function (gizmo) {
  42137. if (gizmo.isEnabled) {
  42138. gizmo.attachedMesh = mesh;
  42139. }
  42140. else {
  42141. gizmo.attachedMesh = null;
  42142. }
  42143. });
  42144. },
  42145. enumerable: true,
  42146. configurable: true
  42147. });
  42148. Object.defineProperty(PositionGizmo.prototype, "planarGizmoEnabled", {
  42149. get: function () {
  42150. return this._planarGizmoEnabled;
  42151. },
  42152. /**
  42153. * If the planar drag gizmo is enabled
  42154. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42155. */
  42156. set: function (value) {
  42157. var _this = this;
  42158. this._planarGizmoEnabled = value;
  42159. [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function (gizmo) {
  42160. if (gizmo) {
  42161. gizmo.isEnabled = value;
  42162. if (value) {
  42163. gizmo.attachedMesh = _this.attachedMesh;
  42164. }
  42165. }
  42166. }, this);
  42167. },
  42168. enumerable: true,
  42169. configurable: true
  42170. });
  42171. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  42172. get: function () {
  42173. return this._updateGizmoRotationToMatchAttachedMesh;
  42174. },
  42175. set: function (value) {
  42176. this._updateGizmoRotationToMatchAttachedMesh = value;
  42177. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function (gizmo) {
  42178. if (gizmo) {
  42179. gizmo.updateGizmoRotationToMatchAttachedMesh = value;
  42180. }
  42181. });
  42182. },
  42183. enumerable: true,
  42184. configurable: true
  42185. });
  42186. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  42187. get: function () {
  42188. return this._snapDistance;
  42189. },
  42190. /**
  42191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42192. */
  42193. set: function (value) {
  42194. this._snapDistance = value;
  42195. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function (gizmo) {
  42196. if (gizmo) {
  42197. gizmo.snapDistance = value;
  42198. }
  42199. });
  42200. },
  42201. enumerable: true,
  42202. configurable: true
  42203. });
  42204. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  42205. get: function () {
  42206. return this._scaleRatio;
  42207. },
  42208. /**
  42209. * Ratio for the scale of the gizmo (Default: 1)
  42210. */
  42211. set: function (value) {
  42212. this._scaleRatio = value;
  42213. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function (gizmo) {
  42214. if (gizmo) {
  42215. gizmo.scaleRatio = value;
  42216. }
  42217. });
  42218. },
  42219. enumerable: true,
  42220. configurable: true
  42221. });
  42222. /**
  42223. * Disposes of the gizmo
  42224. */
  42225. PositionGizmo.prototype.dispose = function () {
  42226. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function (gizmo) {
  42227. if (gizmo) {
  42228. gizmo.dispose();
  42229. }
  42230. });
  42231. this.onDragStartObservable.clear();
  42232. this.onDragEndObservable.clear();
  42233. };
  42234. /**
  42235. * CustomMeshes are not supported by this gizmo
  42236. * @param mesh The mesh to replace the default mesh of the gizmo
  42237. */
  42238. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  42239. _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,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)");
  42240. };
  42241. return PositionGizmo;
  42242. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  42243. /***/ }),
  42244. /***/ "./Gizmos/rotationGizmo.ts":
  42245. /*!*********************************!*\
  42246. !*** ./Gizmos/rotationGizmo.ts ***!
  42247. \*********************************/
  42248. /*! exports provided: RotationGizmo */
  42249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42250. "use strict";
  42251. __webpack_require__.r(__webpack_exports__);
  42252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  42253. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42254. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42255. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42256. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  42257. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  42258. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  42259. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  42260. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  42261. /**
  42262. * Gizmo that enables rotating a mesh along 3 axis
  42263. */
  42264. var RotationGizmo = /** @class */ (function (_super) {
  42265. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  42266. /**
  42267. * Creates a RotationGizmo
  42268. * @param gizmoLayer The utility layer the gizmo will be added to
  42269. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42270. */
  42271. function RotationGizmo(gizmoLayer, tessellation) {
  42272. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  42273. if (tessellation === void 0) { tessellation = 32; }
  42274. var _this = _super.call(this, gizmoLayer) || this;
  42275. /** Fires an event when any of it's sub gizmos are dragged */
  42276. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42277. /** Fires an event when any of it's sub gizmos are released from dragging */
  42278. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42279. _this.xGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_6__["PlaneRotationGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Red().scale(0.5), gizmoLayer, tessellation, _this);
  42280. _this.yGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_6__["PlaneRotationGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Green().scale(0.5), gizmoLayer, tessellation, _this);
  42281. _this.zGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_6__["PlaneRotationGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Blue().scale(0.5), gizmoLayer, tessellation, _this);
  42282. // Relay drag events
  42283. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  42284. gizmo.dragBehavior.onDragStartObservable.add(function () {
  42285. _this.onDragStartObservable.notifyObservers({});
  42286. });
  42287. gizmo.dragBehavior.onDragEndObservable.add(function () {
  42288. _this.onDragEndObservable.notifyObservers({});
  42289. });
  42290. });
  42291. _this.attachedMesh = null;
  42292. return _this;
  42293. }
  42294. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  42295. get: function () {
  42296. return this._meshAttached;
  42297. },
  42298. set: function (mesh) {
  42299. this._meshAttached = mesh;
  42300. [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function (gizmo) {
  42301. if (gizmo.isEnabled) {
  42302. gizmo.attachedMesh = mesh;
  42303. }
  42304. else {
  42305. gizmo.attachedMesh = null;
  42306. }
  42307. });
  42308. },
  42309. enumerable: true,
  42310. configurable: true
  42311. });
  42312. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  42313. get: function () {
  42314. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  42315. },
  42316. set: function (value) {
  42317. if (this.xGizmo) {
  42318. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  42319. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  42320. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  42321. }
  42322. },
  42323. enumerable: true,
  42324. configurable: true
  42325. });
  42326. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  42327. get: function () {
  42328. return this.xGizmo.snapDistance;
  42329. },
  42330. /**
  42331. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42332. */
  42333. set: function (value) {
  42334. if (this.xGizmo) {
  42335. this.xGizmo.snapDistance = value;
  42336. this.yGizmo.snapDistance = value;
  42337. this.zGizmo.snapDistance = value;
  42338. }
  42339. },
  42340. enumerable: true,
  42341. configurable: true
  42342. });
  42343. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  42344. get: function () {
  42345. return this.xGizmo.scaleRatio;
  42346. },
  42347. /**
  42348. * Ratio for the scale of the gizmo (Default: 1)
  42349. */
  42350. set: function (value) {
  42351. if (this.xGizmo) {
  42352. this.xGizmo.scaleRatio = value;
  42353. this.yGizmo.scaleRatio = value;
  42354. this.zGizmo.scaleRatio = value;
  42355. }
  42356. },
  42357. enumerable: true,
  42358. configurable: true
  42359. });
  42360. /**
  42361. * Disposes of the gizmo
  42362. */
  42363. RotationGizmo.prototype.dispose = function () {
  42364. this.xGizmo.dispose();
  42365. this.yGizmo.dispose();
  42366. this.zGizmo.dispose();
  42367. this.onDragStartObservable.clear();
  42368. this.onDragEndObservable.clear();
  42369. };
  42370. /**
  42371. * CustomMeshes are not supported by this gizmo
  42372. * @param mesh The mesh to replace the default mesh of the gizmo
  42373. */
  42374. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  42375. _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)");
  42376. };
  42377. return RotationGizmo;
  42378. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  42379. /***/ }),
  42380. /***/ "./Gizmos/scaleGizmo.ts":
  42381. /*!******************************!*\
  42382. !*** ./Gizmos/scaleGizmo.ts ***!
  42383. \******************************/
  42384. /*! exports provided: ScaleGizmo */
  42385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42386. "use strict";
  42387. __webpack_require__.r(__webpack_exports__);
  42388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  42389. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42390. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42391. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42392. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  42393. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  42394. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  42395. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  42396. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  42397. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  42398. /**
  42399. * Gizmo that enables scaling a mesh along 3 axis
  42400. */
  42401. var ScaleGizmo = /** @class */ (function (_super) {
  42402. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  42403. /**
  42404. * Creates a ScaleGizmo
  42405. * @param gizmoLayer The utility layer the gizmo will be added to
  42406. */
  42407. function ScaleGizmo(gizmoLayer) {
  42408. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  42409. var _this = _super.call(this, gizmoLayer) || this;
  42410. _this._meshAttached = null;
  42411. /** Fires an event when any of it's sub gizmos are dragged */
  42412. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42413. /** Fires an event when any of it's sub gizmos are released from dragging */
  42414. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42415. _this.xGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_7__["AxisScaleGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Red().scale(0.5), gizmoLayer, _this);
  42416. _this.yGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_7__["AxisScaleGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Green().scale(0.5), gizmoLayer, _this);
  42417. _this.zGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_7__["AxisScaleGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Blue().scale(0.5), gizmoLayer, _this);
  42418. // Create uniform scale gizmo
  42419. _this.uniformScaleGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_7__["AxisScaleGizmo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"].Yellow().scale(0.5), gizmoLayer, _this);
  42420. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  42421. _this.uniformScaleGizmo.uniformScaling = true;
  42422. _this._uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_5__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  42423. _this._uniformScalingMesh.scaling.scaleInPlace(0.02);
  42424. _this._uniformScalingMesh.visibility = 0;
  42425. _this._octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_5__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  42426. _this._octahedron.scaling.scaleInPlace(0.007);
  42427. _this._uniformScalingMesh.addChild(_this._octahedron);
  42428. _this.uniformScaleGizmo.setCustomMesh(_this._uniformScalingMesh, true);
  42429. var light = gizmoLayer._getSharedGizmoLight();
  42430. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._octahedron);
  42431. // Relay drag events
  42432. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  42433. gizmo.dragBehavior.onDragStartObservable.add(function () {
  42434. _this.onDragStartObservable.notifyObservers({});
  42435. });
  42436. gizmo.dragBehavior.onDragEndObservable.add(function () {
  42437. _this.onDragEndObservable.notifyObservers({});
  42438. });
  42439. });
  42440. _this.attachedMesh = null;
  42441. return _this;
  42442. }
  42443. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  42444. get: function () {
  42445. return this._meshAttached;
  42446. },
  42447. set: function (mesh) {
  42448. this._meshAttached = mesh;
  42449. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function (gizmo) {
  42450. if (gizmo.isEnabled) {
  42451. gizmo.attachedMesh = mesh;
  42452. }
  42453. else {
  42454. gizmo.attachedMesh = null;
  42455. }
  42456. });
  42457. },
  42458. enumerable: true,
  42459. configurable: true
  42460. });
  42461. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  42462. get: function () {
  42463. return this._updateGizmoRotationToMatchAttachedMesh;
  42464. },
  42465. set: function (value) {
  42466. if (!value) {
  42467. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  42468. }
  42469. else {
  42470. this._updateGizmoRotationToMatchAttachedMesh = value;
  42471. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function (gizmo) {
  42472. if (gizmo) {
  42473. gizmo.updateGizmoRotationToMatchAttachedMesh = value;
  42474. }
  42475. });
  42476. }
  42477. },
  42478. enumerable: true,
  42479. configurable: true
  42480. });
  42481. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  42482. get: function () {
  42483. return this._snapDistance;
  42484. },
  42485. /**
  42486. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42487. */
  42488. set: function (value) {
  42489. this._snapDistance = value;
  42490. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function (gizmo) {
  42491. if (gizmo) {
  42492. gizmo.snapDistance = value;
  42493. }
  42494. });
  42495. },
  42496. enumerable: true,
  42497. configurable: true
  42498. });
  42499. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  42500. get: function () {
  42501. return this._scaleRatio;
  42502. },
  42503. /**
  42504. * Ratio for the scale of the gizmo (Default: 1)
  42505. */
  42506. set: function (value) {
  42507. this._scaleRatio = value;
  42508. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function (gizmo) {
  42509. if (gizmo) {
  42510. gizmo.scaleRatio = value;
  42511. }
  42512. });
  42513. },
  42514. enumerable: true,
  42515. configurable: true
  42516. });
  42517. /**
  42518. * Disposes of the gizmo
  42519. */
  42520. ScaleGizmo.prototype.dispose = function () {
  42521. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function (gizmo) {
  42522. if (gizmo) {
  42523. gizmo.dispose();
  42524. }
  42525. });
  42526. this.onDragStartObservable.clear();
  42527. this.onDragEndObservable.clear();
  42528. [this._uniformScalingMesh, this._octahedron].forEach(function (msh) {
  42529. if (msh) {
  42530. msh.dispose();
  42531. }
  42532. });
  42533. };
  42534. return ScaleGizmo;
  42535. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  42536. /***/ }),
  42537. /***/ "./Helpers/environmentHelper.ts":
  42538. /*!**************************************!*\
  42539. !*** ./Helpers/environmentHelper.ts ***!
  42540. \**************************************/
  42541. /*! exports provided: EnvironmentHelper */
  42542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42543. "use strict";
  42544. __webpack_require__.r(__webpack_exports__);
  42545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  42546. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42547. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42548. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  42549. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  42550. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  42551. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  42552. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  42553. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42554. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  42555. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  42556. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  42557. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42558. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  42559. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  42560. /* harmony import */ var _Maths_math_plane__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Maths/math.plane */ "./Maths/math.plane.ts");
  42561. /**
  42562. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42563. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42564. * It also helps with the default setup of your imageProcessing configuration.
  42565. */
  42566. var EnvironmentHelper = /** @class */ (function () {
  42567. /**
  42568. * constructor
  42569. * @param options Defines the options we want to customize the helper
  42570. * @param scene The scene to add the material to
  42571. */
  42572. function EnvironmentHelper(options, scene) {
  42573. var _this = this;
  42574. this._errorHandler = function (message, exception) {
  42575. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  42576. };
  42577. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  42578. this._scene = scene;
  42579. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  42580. this._setupBackground();
  42581. this._setupImageProcessing();
  42582. }
  42583. /**
  42584. * Creates the default options for the helper.
  42585. */
  42586. EnvironmentHelper._getDefaultOptions = function () {
  42587. return {
  42588. createGround: true,
  42589. groundSize: 15,
  42590. groundTexture: this._groundTextureCDNUrl,
  42591. groundColor: new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  42592. groundOpacity: 0.9,
  42593. enableGroundShadow: true,
  42594. groundShadowLevel: 0.5,
  42595. enableGroundMirror: false,
  42596. groundMirrorSizeRatio: 0.3,
  42597. groundMirrorBlurKernel: 64,
  42598. groundMirrorAmount: 1,
  42599. groundMirrorFresnelWeight: 1,
  42600. groundMirrorFallOffDistance: 0,
  42601. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  42602. groundYBias: 0.00001,
  42603. createSkybox: true,
  42604. skyboxSize: 20,
  42605. skyboxTexture: this._skyboxTextureCDNUrl,
  42606. skyboxColor: new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  42607. backgroundYRotation: 0,
  42608. sizeAuto: true,
  42609. rootPosition: _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  42610. setupImageProcessing: true,
  42611. environmentTexture: this._environmentTextureCDNUrl,
  42612. cameraExposure: 0.8,
  42613. cameraContrast: 1.2,
  42614. toneMappingEnabled: true,
  42615. };
  42616. };
  42617. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  42618. /**
  42619. * Gets the root mesh created by the helper.
  42620. */
  42621. get: function () {
  42622. return this._rootMesh;
  42623. },
  42624. enumerable: true,
  42625. configurable: true
  42626. });
  42627. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  42628. /**
  42629. * Gets the skybox created by the helper.
  42630. */
  42631. get: function () {
  42632. return this._skybox;
  42633. },
  42634. enumerable: true,
  42635. configurable: true
  42636. });
  42637. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  42638. /**
  42639. * Gets the skybox texture created by the helper.
  42640. */
  42641. get: function () {
  42642. return this._skyboxTexture;
  42643. },
  42644. enumerable: true,
  42645. configurable: true
  42646. });
  42647. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  42648. /**
  42649. * Gets the skybox material created by the helper.
  42650. */
  42651. get: function () {
  42652. return this._skyboxMaterial;
  42653. },
  42654. enumerable: true,
  42655. configurable: true
  42656. });
  42657. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  42658. /**
  42659. * Gets the ground mesh created by the helper.
  42660. */
  42661. get: function () {
  42662. return this._ground;
  42663. },
  42664. enumerable: true,
  42665. configurable: true
  42666. });
  42667. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  42668. /**
  42669. * Gets the ground texture created by the helper.
  42670. */
  42671. get: function () {
  42672. return this._groundTexture;
  42673. },
  42674. enumerable: true,
  42675. configurable: true
  42676. });
  42677. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  42678. /**
  42679. * Gets the ground mirror created by the helper.
  42680. */
  42681. get: function () {
  42682. return this._groundMirror;
  42683. },
  42684. enumerable: true,
  42685. configurable: true
  42686. });
  42687. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  42688. /**
  42689. * Gets the ground mirror render list to helps pushing the meshes
  42690. * you wish in the ground reflection.
  42691. */
  42692. get: function () {
  42693. if (this._groundMirror) {
  42694. return this._groundMirror.renderList;
  42695. }
  42696. return null;
  42697. },
  42698. enumerable: true,
  42699. configurable: true
  42700. });
  42701. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  42702. /**
  42703. * Gets the ground material created by the helper.
  42704. */
  42705. get: function () {
  42706. return this._groundMaterial;
  42707. },
  42708. enumerable: true,
  42709. configurable: true
  42710. });
  42711. /**
  42712. * Updates the background according to the new options
  42713. * @param options
  42714. */
  42715. EnvironmentHelper.prototype.updateOptions = function (options) {
  42716. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  42717. if (this._ground && !newOptions.createGround) {
  42718. this._ground.dispose();
  42719. this._ground = null;
  42720. }
  42721. if (this._groundMaterial && !newOptions.createGround) {
  42722. this._groundMaterial.dispose();
  42723. this._groundMaterial = null;
  42724. }
  42725. if (this._groundTexture) {
  42726. if (this._options.groundTexture != newOptions.groundTexture) {
  42727. this._groundTexture.dispose();
  42728. this._groundTexture = null;
  42729. }
  42730. }
  42731. if (this._skybox && !newOptions.createSkybox) {
  42732. this._skybox.dispose();
  42733. this._skybox = null;
  42734. }
  42735. if (this._skyboxMaterial && !newOptions.createSkybox) {
  42736. this._skyboxMaterial.dispose();
  42737. this._skyboxMaterial = null;
  42738. }
  42739. if (this._skyboxTexture) {
  42740. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  42741. this._skyboxTexture.dispose();
  42742. this._skyboxTexture = null;
  42743. }
  42744. }
  42745. if (this._groundMirror && !newOptions.enableGroundMirror) {
  42746. this._groundMirror.dispose();
  42747. this._groundMirror = null;
  42748. }
  42749. if (this._scene.environmentTexture) {
  42750. if (this._options.environmentTexture != newOptions.environmentTexture) {
  42751. this._scene.environmentTexture.dispose();
  42752. }
  42753. }
  42754. this._options = newOptions;
  42755. this._setupBackground();
  42756. this._setupImageProcessing();
  42757. };
  42758. /**
  42759. * Sets the primary color of all the available elements.
  42760. * @param color the main color to affect to the ground and the background
  42761. */
  42762. EnvironmentHelper.prototype.setMainColor = function (color) {
  42763. if (this.groundMaterial) {
  42764. this.groundMaterial.primaryColor = color;
  42765. }
  42766. if (this.skyboxMaterial) {
  42767. this.skyboxMaterial.primaryColor = color;
  42768. }
  42769. if (this.groundMirror) {
  42770. this.groundMirror.clearColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](color.r, color.g, color.b, 1.0);
  42771. }
  42772. };
  42773. /**
  42774. * Setup the image processing according to the specified options.
  42775. */
  42776. EnvironmentHelper.prototype._setupImageProcessing = function () {
  42777. if (this._options.setupImageProcessing) {
  42778. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  42779. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  42780. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  42781. this._setupEnvironmentTexture();
  42782. }
  42783. };
  42784. /**
  42785. * Setup the environment texture according to the specified options.
  42786. */
  42787. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  42788. if (this._scene.environmentTexture) {
  42789. return;
  42790. }
  42791. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_6__["BaseTexture"]) {
  42792. this._scene.environmentTexture = this._options.environmentTexture;
  42793. return;
  42794. }
  42795. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  42796. this._scene.environmentTexture = environmentTexture;
  42797. };
  42798. /**
  42799. * Setup the background according to the specified options.
  42800. */
  42801. EnvironmentHelper.prototype._setupBackground = function () {
  42802. if (!this._rootMesh) {
  42803. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"]("BackgroundHelper", this._scene);
  42804. }
  42805. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  42806. var sceneSize = this._getSceneSize();
  42807. if (this._options.createGround) {
  42808. this._setupGround(sceneSize);
  42809. this._setupGroundMaterial();
  42810. this._setupGroundDiffuseTexture();
  42811. if (this._options.enableGroundMirror) {
  42812. this._setupGroundMirrorTexture(sceneSize);
  42813. }
  42814. this._setupMirrorInGroundMaterial();
  42815. }
  42816. if (this._options.createSkybox) {
  42817. this._setupSkybox(sceneSize);
  42818. this._setupSkyboxMaterial();
  42819. this._setupSkyboxReflectionTexture();
  42820. }
  42821. this._rootMesh.position.x = sceneSize.rootPosition.x;
  42822. this._rootMesh.position.z = sceneSize.rootPosition.z;
  42823. this._rootMesh.position.y = sceneSize.rootPosition.y;
  42824. };
  42825. /**
  42826. * Get the scene sizes according to the setup.
  42827. */
  42828. EnvironmentHelper.prototype._getSceneSize = function () {
  42829. var _this = this;
  42830. var groundSize = this._options.groundSize;
  42831. var skyboxSize = this._options.skyboxSize;
  42832. var rootPosition = this._options.rootPosition;
  42833. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  42834. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  42835. }
  42836. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  42837. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  42838. });
  42839. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  42840. if (this._options.sizeAuto) {
  42841. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  42842. this._scene.activeCamera.upperRadiusLimit) {
  42843. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  42844. skyboxSize = groundSize;
  42845. }
  42846. var sceneDiagonalLenght = sceneDiagonal.length();
  42847. if (sceneDiagonalLenght > groundSize) {
  42848. groundSize = sceneDiagonalLenght * 2;
  42849. skyboxSize = groundSize;
  42850. }
  42851. // 10 % bigger.
  42852. groundSize *= 1.1;
  42853. skyboxSize *= 1.5;
  42854. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  42855. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  42856. }
  42857. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  42858. };
  42859. /**
  42860. * Setup the ground according to the specified options.
  42861. */
  42862. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  42863. var _this = this;
  42864. if (!this._ground || this._ground.isDisposed()) {
  42865. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  42866. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  42867. this._ground.parent = this._rootMesh;
  42868. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  42869. }
  42870. this._ground.receiveShadows = this._options.enableGroundShadow;
  42871. };
  42872. /**
  42873. * Setup the ground material according to the specified options.
  42874. */
  42875. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  42876. if (!this._groundMaterial) {
  42877. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_10__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  42878. }
  42879. this._groundMaterial.alpha = this._options.groundOpacity;
  42880. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  42881. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  42882. this._groundMaterial.primaryColor = this._options.groundColor;
  42883. this._groundMaterial.useRGBColor = false;
  42884. this._groundMaterial.enableNoise = true;
  42885. if (this._ground) {
  42886. this._ground.material = this._groundMaterial;
  42887. }
  42888. };
  42889. /**
  42890. * Setup the ground diffuse texture according to the specified options.
  42891. */
  42892. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  42893. if (!this._groundMaterial) {
  42894. return;
  42895. }
  42896. if (this._groundTexture) {
  42897. return;
  42898. }
  42899. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_6__["BaseTexture"]) {
  42900. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  42901. return;
  42902. }
  42903. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  42904. diffuseTexture.gammaSpace = false;
  42905. diffuseTexture.hasAlpha = true;
  42906. this._groundMaterial.diffuseTexture = diffuseTexture;
  42907. };
  42908. /**
  42909. * Setup the ground mirror texture according to the specified options.
  42910. */
  42911. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  42912. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42913. if (!this._groundMirror) {
  42914. this._groundMirror = new _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]("BackgroundPlaneMirrorTexture", { ratio: this._options.groundMirrorSizeRatio }, this._scene, false, this._options.groundMirrorTextureType, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, true);
  42915. this._groundMirror.mirrorPlane = new _Maths_math_plane__WEBPACK_IMPORTED_MODULE_14__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  42916. this._groundMirror.anisotropicFilteringLevel = 1;
  42917. this._groundMirror.wrapU = wrapping;
  42918. this._groundMirror.wrapV = wrapping;
  42919. this._groundMirror.gammaSpace = false;
  42920. if (this._groundMirror.renderList) {
  42921. for (var i = 0; i < this._scene.meshes.length; i++) {
  42922. var mesh = this._scene.meshes[i];
  42923. if (mesh !== this._ground &&
  42924. mesh !== this._skybox &&
  42925. mesh !== this._rootMesh) {
  42926. this._groundMirror.renderList.push(mesh);
  42927. }
  42928. }
  42929. }
  42930. }
  42931. this._groundMirror.clearColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  42932. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  42933. };
  42934. /**
  42935. * Setup the ground to receive the mirror texture.
  42936. */
  42937. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  42938. if (this._groundMaterial) {
  42939. this._groundMaterial.reflectionTexture = this._groundMirror;
  42940. this._groundMaterial.reflectionFresnel = true;
  42941. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  42942. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  42943. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  42944. }
  42945. };
  42946. /**
  42947. * Setup the skybox according to the specified options.
  42948. */
  42949. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  42950. var _this = this;
  42951. if (!this._skybox || this._skybox.isDisposed()) {
  42952. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].BACKSIDE);
  42953. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  42954. }
  42955. this._skybox.parent = this._rootMesh;
  42956. };
  42957. /**
  42958. * Setup the skybox material according to the specified options.
  42959. */
  42960. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  42961. if (!this._skybox) {
  42962. return;
  42963. }
  42964. if (!this._skyboxMaterial) {
  42965. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_10__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  42966. }
  42967. this._skyboxMaterial.useRGBColor = false;
  42968. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  42969. this._skyboxMaterial.enableNoise = true;
  42970. this._skybox.material = this._skyboxMaterial;
  42971. };
  42972. /**
  42973. * Setup the skybox reflection texture according to the specified options.
  42974. */
  42975. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  42976. if (!this._skyboxMaterial) {
  42977. return;
  42978. }
  42979. if (this._skyboxTexture) {
  42980. return;
  42981. }
  42982. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_6__["BaseTexture"]) {
  42983. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  42984. return;
  42985. }
  42986. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  42987. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].SKYBOX_MODE;
  42988. this._skyboxTexture.gammaSpace = false;
  42989. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  42990. };
  42991. /**
  42992. * Dispose all the elements created by the Helper.
  42993. */
  42994. EnvironmentHelper.prototype.dispose = function () {
  42995. if (this._groundMaterial) {
  42996. this._groundMaterial.dispose(true, true);
  42997. }
  42998. if (this._skyboxMaterial) {
  42999. this._skyboxMaterial.dispose(true, true);
  43000. }
  43001. this._rootMesh.dispose(false);
  43002. };
  43003. /**
  43004. * Default ground texture URL.
  43005. */
  43006. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  43007. /**
  43008. * Default skybox texture URL.
  43009. */
  43010. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  43011. /**
  43012. * Default environment texture URL.
  43013. */
  43014. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  43015. return EnvironmentHelper;
  43016. }());
  43017. /***/ }),
  43018. /***/ "./Helpers/index.ts":
  43019. /*!**************************!*\
  43020. !*** ./Helpers/index.ts ***!
  43021. \**************************/
  43022. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  43023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43024. "use strict";
  43025. __webpack_require__.r(__webpack_exports__);
  43026. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  43027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43028. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  43029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  43030. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  43031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  43032. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  43033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  43034. /***/ }),
  43035. /***/ "./Helpers/photoDome.ts":
  43036. /*!******************************!*\
  43037. !*** ./Helpers/photoDome.ts ***!
  43038. \******************************/
  43039. /*! exports provided: PhotoDome */
  43040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43041. "use strict";
  43042. __webpack_require__.r(__webpack_exports__);
  43043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  43044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43045. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43046. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  43047. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  43048. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43049. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  43050. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  43051. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  43052. /**
  43053. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43054. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43055. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43056. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43057. */
  43058. var PhotoDome = /** @class */ (function (_super) {
  43059. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  43060. /**
  43061. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43062. * @param name Element's name, child elements will append suffixes for their own names.
  43063. * @param urlsOfPhoto defines the url of the photo to display
  43064. * @param options defines an object containing optional or exposed sub element properties
  43065. * @param onError defines a callback called when an error occured while loading the texture
  43066. */
  43067. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  43068. if (onError === void 0) { onError = null; }
  43069. var _this = _super.call(this, name, scene) || this;
  43070. _this._useDirectMapping = false;
  43071. /**
  43072. * Observable raised when an error occured while loading the 360 image
  43073. */
  43074. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  43075. _this._imageMode = PhotoDome.MODE_MONOSCOPIC;
  43076. _this._onBeforeCameraRenderObserver = null;
  43077. // set defaults and manage values
  43078. name = name || "photoDome";
  43079. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  43080. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  43081. if (options.useDirectMapping === undefined) {
  43082. _this._useDirectMapping = true;
  43083. }
  43084. else {
  43085. _this._useDirectMapping = options.useDirectMapping;
  43086. }
  43087. if (options.faceForward === undefined) {
  43088. options.faceForward = true;
  43089. }
  43090. _this._setReady(false);
  43091. // create
  43092. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  43093. _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);
  43094. // configure material
  43095. material.opacityFresnel = false;
  43096. material.useEquirectangularFOV = true;
  43097. material.fovMultiplier = 1.0;
  43098. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  43099. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  43100. if (onError) {
  43101. onError(message, exception);
  43102. }
  43103. });
  43104. _this.photoTexture.onLoadObservable.addOnce(function () {
  43105. _this._setReady(true);
  43106. });
  43107. // configure mesh
  43108. _this._mesh.material = material;
  43109. _this._mesh.parent = _this;
  43110. // Initial rotation
  43111. if (options.faceForward && scene.activeCamera) {
  43112. var camera = scene.activeCamera;
  43113. var forward = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  43114. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  43115. direction.normalize();
  43116. _this.rotation.y = Math.acos(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  43117. }
  43118. return _this;
  43119. }
  43120. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  43121. /**
  43122. * Gets or sets the texture being displayed on the sphere
  43123. */
  43124. get: function () {
  43125. return this._photoTexture;
  43126. },
  43127. set: function (value) {
  43128. if (this._photoTexture === value) {
  43129. return;
  43130. }
  43131. this._photoTexture = value;
  43132. if (this._useDirectMapping) {
  43133. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  43134. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  43135. this._material.diffuseTexture = this._photoTexture;
  43136. }
  43137. else {
  43138. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  43139. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  43140. this._material.reflectionTexture = this._photoTexture;
  43141. }
  43142. },
  43143. enumerable: true,
  43144. configurable: true
  43145. });
  43146. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  43147. /**
  43148. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43149. * Also see the options.resolution property.
  43150. */
  43151. get: function () {
  43152. return this._material.fovMultiplier;
  43153. },
  43154. set: function (value) {
  43155. this._material.fovMultiplier = value;
  43156. },
  43157. enumerable: true,
  43158. configurable: true
  43159. });
  43160. Object.defineProperty(PhotoDome.prototype, "imageMode", {
  43161. /**
  43162. * Gets or set the current video mode for the video. It can be:
  43163. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  43164. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43165. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43166. */
  43167. get: function () {
  43168. return this._imageMode;
  43169. },
  43170. set: function (value) {
  43171. if (this._imageMode === value) {
  43172. return;
  43173. }
  43174. this._changeImageMode(value);
  43175. },
  43176. enumerable: true,
  43177. configurable: true
  43178. });
  43179. PhotoDome.prototype._changeImageMode = function (value) {
  43180. var _this = this;
  43181. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  43182. this._imageMode = value;
  43183. // Default Setup and Reset.
  43184. this._photoTexture.uScale = 1;
  43185. this._photoTexture.vScale = 1;
  43186. this._photoTexture.uOffset = 0;
  43187. this._photoTexture.vOffset = 0;
  43188. switch (value) {
  43189. case PhotoDome.MODE_SIDEBYSIDE:
  43190. this._photoTexture.uScale = 0.5;
  43191. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  43192. _this._photoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  43193. });
  43194. break;
  43195. case PhotoDome.MODE_TOPBOTTOM:
  43196. this._photoTexture.vScale = 0.5;
  43197. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  43198. _this._photoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  43199. });
  43200. break;
  43201. }
  43202. };
  43203. /**
  43204. * Releases resources associated with this node.
  43205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43207. */
  43208. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  43209. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  43210. this._photoTexture.dispose();
  43211. this._mesh.dispose();
  43212. this._material.dispose();
  43213. this.onLoadErrorObservable.clear();
  43214. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  43215. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  43216. };
  43217. /**
  43218. * Define the image as a Monoscopic panoramic 360 image.
  43219. */
  43220. PhotoDome.MODE_MONOSCOPIC = 0;
  43221. /**
  43222. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43223. */
  43224. PhotoDome.MODE_TOPBOTTOM = 1;
  43225. /**
  43226. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43227. */
  43228. PhotoDome.MODE_SIDEBYSIDE = 2;
  43229. return PhotoDome;
  43230. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  43231. /***/ }),
  43232. /***/ "./Helpers/sceneHelpers.ts":
  43233. /*!*********************************!*\
  43234. !*** ./Helpers/sceneHelpers.ts ***!
  43235. \*********************************/
  43236. /*! exports provided: _forceSceneHelpersToBundle */
  43237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43238. "use strict";
  43239. __webpack_require__.r(__webpack_exports__);
  43240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  43241. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  43242. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  43243. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  43244. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  43245. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43246. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  43247. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  43248. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  43249. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  43250. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  43251. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  43252. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  43253. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  43254. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  43255. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  43256. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  43257. /* harmony import */ var _Cameras_XR_webXRDefaultExperience__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Cameras/XR/webXRDefaultExperience */ "./Cameras/XR/webXRDefaultExperience.ts");
  43258. /** @hidden */
  43259. var _forceSceneHelpersToBundle = true;
  43260. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  43261. if (replace === void 0) { replace = false; }
  43262. // Dispose existing light in replace mode.
  43263. if (replace) {
  43264. if (this.lights) {
  43265. for (var i = 0; i < this.lights.length; i++) {
  43266. this.lights[i].dispose();
  43267. }
  43268. }
  43269. }
  43270. // Light
  43271. if (this.lights.length === 0) {
  43272. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  43273. }
  43274. };
  43275. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  43276. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  43277. if (replace === void 0) { replace = false; }
  43278. if (attachCameraControls === void 0) { attachCameraControls = false; }
  43279. // Dispose existing camera in replace mode.
  43280. if (replace) {
  43281. if (this.activeCamera) {
  43282. this.activeCamera.dispose();
  43283. this.activeCamera = null;
  43284. }
  43285. }
  43286. // Camera
  43287. if (!this.activeCamera) {
  43288. var worldExtends = this.getWorldExtends();
  43289. var worldSize = worldExtends.max.subtract(worldExtends.min);
  43290. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  43291. var camera;
  43292. var radius = worldSize.length() * 1.5;
  43293. // empty scene scenario!
  43294. if (!isFinite(radius)) {
  43295. radius = 1;
  43296. worldCenter.copyFromFloats(0, 0, 0);
  43297. }
  43298. if (createArcRotateCamera) {
  43299. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  43300. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  43301. arcRotateCamera.wheelPrecision = 100 / radius;
  43302. camera = arcRotateCamera;
  43303. }
  43304. else {
  43305. var freeCamera = new _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__["FreeCamera"]("default camera", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](worldCenter.x, worldCenter.y, -radius), this);
  43306. freeCamera.setTarget(worldCenter);
  43307. camera = freeCamera;
  43308. }
  43309. camera.minZ = radius * 0.01;
  43310. camera.maxZ = radius * 1000;
  43311. camera.speed = radius * 0.2;
  43312. this.activeCamera = camera;
  43313. var canvas = this.getEngine().getRenderingCanvas();
  43314. if (attachCameraControls && canvas) {
  43315. camera.attachControl(canvas);
  43316. }
  43317. }
  43318. };
  43319. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  43320. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  43321. if (replace === void 0) { replace = false; }
  43322. if (attachCameraControls === void 0) { attachCameraControls = false; }
  43323. this.createDefaultLight(replace);
  43324. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  43325. };
  43326. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  43327. if (pbr === void 0) { pbr = false; }
  43328. if (scale === void 0) { scale = 1000; }
  43329. if (blur === void 0) { blur = 0; }
  43330. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  43331. if (!environmentTexture) {
  43332. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  43333. return null;
  43334. }
  43335. if (setGlobalEnvTexture) {
  43336. if (environmentTexture) {
  43337. this.environmentTexture = environmentTexture;
  43338. }
  43339. }
  43340. // Skybox
  43341. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  43342. if (pbr) {
  43343. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  43344. hdrSkyboxMaterial.backFaceCulling = false;
  43345. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  43346. if (hdrSkyboxMaterial.reflectionTexture) {
  43347. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  43348. }
  43349. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  43350. hdrSkyboxMaterial.disableLighting = true;
  43351. hdrSkyboxMaterial.twoSidedLighting = true;
  43352. hdrSkybox.infiniteDistance = true;
  43353. hdrSkybox.material = hdrSkyboxMaterial;
  43354. }
  43355. else {
  43356. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  43357. skyboxMaterial.backFaceCulling = false;
  43358. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  43359. if (skyboxMaterial.reflectionTexture) {
  43360. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  43361. }
  43362. skyboxMaterial.disableLighting = true;
  43363. hdrSkybox.infiniteDistance = true;
  43364. hdrSkybox.material = skyboxMaterial;
  43365. }
  43366. hdrSkybox.isPickable = false;
  43367. return hdrSkybox;
  43368. };
  43369. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  43370. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  43371. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  43372. }
  43373. return null;
  43374. };
  43375. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  43376. if (webVROptions === void 0) { webVROptions = {}; }
  43377. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_11__["VRExperienceHelper"](this, webVROptions);
  43378. };
  43379. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function (options) {
  43380. return _Cameras_XR_webXRDefaultExperience__WEBPACK_IMPORTED_MODULE_16__["WebXRDefaultExperience"].CreateAsync(this, options).then(function (helper) {
  43381. return helper;
  43382. });
  43383. };
  43384. /***/ }),
  43385. /***/ "./Helpers/videoDome.ts":
  43386. /*!******************************!*\
  43387. !*** ./Helpers/videoDome.ts ***!
  43388. \******************************/
  43389. /*! exports provided: VideoDome */
  43390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43391. "use strict";
  43392. __webpack_require__.r(__webpack_exports__);
  43393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  43394. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43395. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  43396. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  43397. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43398. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  43399. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  43400. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  43401. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  43402. /**
  43403. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43404. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43405. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43406. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43407. */
  43408. var VideoDome = /** @class */ (function (_super) {
  43409. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  43410. /**
  43411. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43412. * @param name Element's name, child elements will append suffixes for their own names.
  43413. * @param urlsOrVideo defines the url(s) or the video element to use
  43414. * @param options An object containing optional or exposed sub element properties
  43415. */
  43416. function VideoDome(name, urlsOrVideo, options, scene) {
  43417. var _this = _super.call(this, name, scene) || this;
  43418. _this._useDirectMapping = false;
  43419. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  43420. /**
  43421. * Oberserver used in Stereoscopic VR Mode.
  43422. */
  43423. _this._onBeforeCameraRenderObserver = null;
  43424. scene = _this.getScene();
  43425. // set defaults and manage values
  43426. name = name || "videoDome";
  43427. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  43428. options.clickToPlay = Boolean(options.clickToPlay);
  43429. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  43430. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  43431. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  43432. if (options.useDirectMapping === undefined) {
  43433. _this._useDirectMapping = true;
  43434. }
  43435. else {
  43436. _this._useDirectMapping = options.useDirectMapping;
  43437. }
  43438. if (options.faceForward === undefined) {
  43439. options.faceForward = true;
  43440. }
  43441. _this._setReady(false);
  43442. // create
  43443. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  43444. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  43445. 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);
  43446. _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);
  43447. texture.onLoadObservable.addOnce(function () {
  43448. _this._setReady(true);
  43449. });
  43450. // configure material
  43451. material.useEquirectangularFOV = true;
  43452. material.fovMultiplier = 1.0;
  43453. material.opacityFresnel = false;
  43454. if (_this._useDirectMapping) {
  43455. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  43456. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  43457. material.diffuseTexture = texture;
  43458. }
  43459. else {
  43460. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  43461. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  43462. material.reflectionTexture = texture;
  43463. }
  43464. // configure mesh
  43465. _this._mesh.material = material;
  43466. _this._mesh.parent = _this;
  43467. // optional configuration
  43468. if (options.clickToPlay) {
  43469. scene.onPointerUp = function () {
  43470. _this._videoTexture.video.play();
  43471. };
  43472. }
  43473. // Initial rotation
  43474. if (options.faceForward && scene.activeCamera) {
  43475. var camera = scene.activeCamera;
  43476. var forward = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  43477. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  43478. direction.normalize();
  43479. _this.rotation.y = Math.acos(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  43480. }
  43481. return _this;
  43482. }
  43483. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  43484. /**
  43485. * Gets the video texture being displayed on the sphere
  43486. */
  43487. get: function () {
  43488. return this._videoTexture;
  43489. },
  43490. enumerable: true,
  43491. configurable: true
  43492. });
  43493. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  43494. /**
  43495. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43496. * Also see the options.resolution property.
  43497. */
  43498. get: function () {
  43499. return this._material.fovMultiplier;
  43500. },
  43501. set: function (value) {
  43502. this._material.fovMultiplier = value;
  43503. },
  43504. enumerable: true,
  43505. configurable: true
  43506. });
  43507. Object.defineProperty(VideoDome.prototype, "videoMode", {
  43508. /**
  43509. * Gets or set the current video mode for the video. It can be:
  43510. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  43511. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  43512. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  43513. */
  43514. get: function () {
  43515. return this._videoMode;
  43516. },
  43517. set: function (value) {
  43518. if (this._videoMode === value) {
  43519. return;
  43520. }
  43521. this._changeVideoMode(value);
  43522. },
  43523. enumerable: true,
  43524. configurable: true
  43525. });
  43526. VideoDome.prototype._changeVideoMode = function (value) {
  43527. var _this = this;
  43528. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  43529. this._videoMode = value;
  43530. // Default Setup and Reset.
  43531. this._videoTexture.uScale = 1;
  43532. this._videoTexture.vScale = 1;
  43533. this._videoTexture.uOffset = 0;
  43534. this._videoTexture.vOffset = 0;
  43535. switch (value) {
  43536. case VideoDome.MODE_SIDEBYSIDE:
  43537. this._videoTexture.uScale = 0.5;
  43538. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  43539. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  43540. });
  43541. break;
  43542. case VideoDome.MODE_TOPBOTTOM:
  43543. this._videoTexture.vScale = 0.5;
  43544. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  43545. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  43546. });
  43547. break;
  43548. }
  43549. };
  43550. /**
  43551. * Releases resources associated with this node.
  43552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43554. */
  43555. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  43556. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  43557. this._videoTexture.dispose();
  43558. this._mesh.dispose();
  43559. this._material.dispose();
  43560. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  43561. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  43562. };
  43563. /**
  43564. * Define the video source as a Monoscopic panoramic 360 video.
  43565. */
  43566. VideoDome.MODE_MONOSCOPIC = 0;
  43567. /**
  43568. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  43569. */
  43570. VideoDome.MODE_TOPBOTTOM = 1;
  43571. /**
  43572. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  43573. */
  43574. VideoDome.MODE_SIDEBYSIDE = 2;
  43575. return VideoDome;
  43576. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  43577. /***/ }),
  43578. /***/ "./Inputs/scene.inputManager.ts":
  43579. /*!**************************************!*\
  43580. !*** ./Inputs/scene.inputManager.ts ***!
  43581. \**************************************/
  43582. /*! exports provided: InputManager */
  43583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43584. "use strict";
  43585. __webpack_require__.r(__webpack_exports__);
  43586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputManager", function() { return InputManager; });
  43587. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  43588. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  43589. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  43590. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43591. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  43592. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43593. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  43594. /** @hidden */
  43595. var _ClickInfo = /** @class */ (function () {
  43596. function _ClickInfo() {
  43597. this._singleClick = false;
  43598. this._doubleClick = false;
  43599. this._hasSwiped = false;
  43600. this._ignore = false;
  43601. }
  43602. Object.defineProperty(_ClickInfo.prototype, "singleClick", {
  43603. get: function () {
  43604. return this._singleClick;
  43605. },
  43606. set: function (b) {
  43607. this._singleClick = b;
  43608. },
  43609. enumerable: true,
  43610. configurable: true
  43611. });
  43612. Object.defineProperty(_ClickInfo.prototype, "doubleClick", {
  43613. get: function () {
  43614. return this._doubleClick;
  43615. },
  43616. set: function (b) {
  43617. this._doubleClick = b;
  43618. },
  43619. enumerable: true,
  43620. configurable: true
  43621. });
  43622. Object.defineProperty(_ClickInfo.prototype, "hasSwiped", {
  43623. get: function () {
  43624. return this._hasSwiped;
  43625. },
  43626. set: function (b) {
  43627. this._hasSwiped = b;
  43628. },
  43629. enumerable: true,
  43630. configurable: true
  43631. });
  43632. Object.defineProperty(_ClickInfo.prototype, "ignore", {
  43633. get: function () {
  43634. return this._ignore;
  43635. },
  43636. set: function (b) {
  43637. this._ignore = b;
  43638. },
  43639. enumerable: true,
  43640. configurable: true
  43641. });
  43642. return _ClickInfo;
  43643. }());
  43644. /**
  43645. * Class used to manage all inputs for the scene.
  43646. */
  43647. var InputManager = /** @class */ (function () {
  43648. /**
  43649. * Creates a new InputManager
  43650. * @param scene defines the hosting scene
  43651. */
  43652. function InputManager(scene) {
  43653. // Pointers
  43654. this._wheelEventName = "";
  43655. this._meshPickProceed = false;
  43656. this._currentPickResult = null;
  43657. this._previousPickResult = null;
  43658. this._totalPointersPressed = 0;
  43659. this._doubleClickOccured = false;
  43660. this._pointerX = 0;
  43661. this._pointerY = 0;
  43662. this._startingPointerPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  43663. this._previousStartingPointerPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  43664. this._startingPointerTime = 0;
  43665. this._previousStartingPointerTime = 0;
  43666. this._pointerCaptures = {};
  43667. this._scene = scene;
  43668. }
  43669. Object.defineProperty(InputManager.prototype, "meshUnderPointer", {
  43670. /**
  43671. * Gets the mesh that is currently under the pointer
  43672. */
  43673. get: function () {
  43674. return this._pointerOverMesh;
  43675. },
  43676. enumerable: true,
  43677. configurable: true
  43678. });
  43679. Object.defineProperty(InputManager.prototype, "unTranslatedPointer", {
  43680. /**
  43681. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43682. */
  43683. get: function () {
  43684. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  43685. },
  43686. enumerable: true,
  43687. configurable: true
  43688. });
  43689. Object.defineProperty(InputManager.prototype, "pointerX", {
  43690. /**
  43691. * Gets or sets the current on-screen X position of the pointer
  43692. */
  43693. get: function () {
  43694. return this._pointerX;
  43695. },
  43696. set: function (value) {
  43697. this._pointerX = value;
  43698. },
  43699. enumerable: true,
  43700. configurable: true
  43701. });
  43702. Object.defineProperty(InputManager.prototype, "pointerY", {
  43703. /**
  43704. * Gets or sets the current on-screen Y position of the pointer
  43705. */
  43706. get: function () {
  43707. return this._pointerY;
  43708. },
  43709. set: function (value) {
  43710. this._pointerY = value;
  43711. },
  43712. enumerable: true,
  43713. configurable: true
  43714. });
  43715. InputManager.prototype._updatePointerPosition = function (evt) {
  43716. var canvasRect = this._scene.getEngine().getRenderingCanvasClientRect();
  43717. if (!canvasRect) {
  43718. return;
  43719. }
  43720. this._pointerX = evt.clientX - canvasRect.left;
  43721. this._pointerY = evt.clientY - canvasRect.top;
  43722. this._unTranslatedPointerX = this._pointerX;
  43723. this._unTranslatedPointerY = this._pointerY;
  43724. };
  43725. InputManager.prototype._processPointerMove = function (pickResult, evt) {
  43726. var scene = this._scene;
  43727. var canvas = scene.getEngine().getRenderingCanvas();
  43728. if (!canvas) {
  43729. return;
  43730. }
  43731. canvas.tabIndex = 1;
  43732. // Restore pointer
  43733. canvas.style.cursor = scene.defaultCursor;
  43734. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  43735. if (isMeshPicked) {
  43736. scene.setPointerOverMesh(pickResult.pickedMesh);
  43737. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  43738. if (this._pointerOverMesh.actionManager.hoverCursor) {
  43739. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  43740. }
  43741. else {
  43742. canvas.style.cursor = scene.hoverCursor;
  43743. }
  43744. }
  43745. }
  43746. else {
  43747. scene.setPointerOverMesh(null);
  43748. }
  43749. for (var _i = 0, _a = scene._pointerMoveStage; _i < _a.length; _i++) {
  43750. var step = _a[_i];
  43751. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  43752. }
  43753. if (pickResult) {
  43754. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE;
  43755. if (scene.onPointerMove) {
  43756. scene.onPointerMove(evt, pickResult, type);
  43757. }
  43758. if (scene.onPointerObservable.hasObservers()) {
  43759. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  43760. this._setRayOnPointerInfo(pi);
  43761. scene.onPointerObservable.notifyObservers(pi, type);
  43762. }
  43763. }
  43764. };
  43765. // Pointers handling
  43766. InputManager.prototype._setRayOnPointerInfo = function (pointerInfo) {
  43767. var scene = this._scene;
  43768. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  43769. if (!pointerInfo.pickInfo.ray) {
  43770. pointerInfo.pickInfo.ray = scene.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity(), scene.activeCamera);
  43771. }
  43772. }
  43773. };
  43774. InputManager.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  43775. var scene = this._scene;
  43776. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  43777. if (pickResult) {
  43778. pi.ray = pickResult.ray;
  43779. }
  43780. scene.onPrePointerObservable.notifyObservers(pi, type);
  43781. if (pi.skipOnPointerObservable) {
  43782. return true;
  43783. }
  43784. else {
  43785. return false;
  43786. }
  43787. };
  43788. /**
  43789. * Use this method to simulate a pointer move on a mesh
  43790. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43791. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43792. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43793. */
  43794. InputManager.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  43795. var evt = new PointerEvent("pointermove", pointerEventInit);
  43796. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE)) {
  43797. return;
  43798. }
  43799. this._processPointerMove(pickResult, evt);
  43800. };
  43801. /**
  43802. * Use this method to simulate a pointer down on a mesh
  43803. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43804. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43805. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43806. */
  43807. InputManager.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  43808. var evt = new PointerEvent("pointerdown", pointerEventInit);
  43809. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN)) {
  43810. return;
  43811. }
  43812. this._processPointerDown(pickResult, evt);
  43813. };
  43814. InputManager.prototype._processPointerDown = function (pickResult, evt) {
  43815. var _this = this;
  43816. var scene = this._scene;
  43817. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  43818. this._pickedDownMesh = pickResult.pickedMesh;
  43819. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  43820. if (actionManager) {
  43821. if (actionManager.hasPickTriggers) {
  43822. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43823. switch (evt.button) {
  43824. case 0:
  43825. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43826. break;
  43827. case 1:
  43828. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43829. break;
  43830. case 2:
  43831. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43832. break;
  43833. }
  43834. }
  43835. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLongPressTrigger)) {
  43836. window.setTimeout(function () {
  43837. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, scene.cameraToUseForPointers);
  43838. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  43839. if (_this._totalPointersPressed !== 0 &&
  43840. ((Date.now() - _this._startingPointerTime) > InputManager.LongPressDelay) &&
  43841. !_this._isPointerSwiping()) {
  43842. _this._startingPointerTime = 0;
  43843. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43844. }
  43845. }
  43846. }, InputManager.LongPressDelay);
  43847. }
  43848. }
  43849. }
  43850. else {
  43851. for (var _i = 0, _a = scene._pointerDownStage; _i < _a.length; _i++) {
  43852. var step = _a[_i];
  43853. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  43854. }
  43855. }
  43856. if (pickResult) {
  43857. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN;
  43858. if (scene.onPointerDown) {
  43859. scene.onPointerDown(evt, pickResult, type);
  43860. }
  43861. if (scene.onPointerObservable.hasObservers()) {
  43862. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  43863. this._setRayOnPointerInfo(pi);
  43864. scene.onPointerObservable.notifyObservers(pi, type);
  43865. }
  43866. }
  43867. };
  43868. /** @hidden */
  43869. InputManager.prototype._isPointerSwiping = function () {
  43870. return Math.abs(this._startingPointerPosition.x - this._pointerX) > InputManager.DragMovementThreshold ||
  43871. Math.abs(this._startingPointerPosition.y - this._pointerY) > InputManager.DragMovementThreshold;
  43872. };
  43873. /**
  43874. * Use this method to simulate a pointer up on a mesh
  43875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43878. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43879. */
  43880. InputManager.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  43881. var evt = new PointerEvent("pointerup", pointerEventInit);
  43882. var clickInfo = new _ClickInfo();
  43883. if (doubleTap) {
  43884. clickInfo.doubleClick = true;
  43885. }
  43886. else {
  43887. clickInfo.singleClick = true;
  43888. }
  43889. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP)) {
  43890. return;
  43891. }
  43892. this._processPointerUp(pickResult, evt, clickInfo);
  43893. };
  43894. InputManager.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  43895. var scene = this._scene;
  43896. if (pickResult && pickResult && pickResult.pickedMesh) {
  43897. this._pickedUpMesh = pickResult.pickedMesh;
  43898. if (this._pickedDownMesh === this._pickedUpMesh) {
  43899. if (scene.onPointerPick) {
  43900. scene.onPointerPick(evt, pickResult);
  43901. }
  43902. if (clickInfo.singleClick && !clickInfo.ignore && scene.onPointerObservable.hasObservers()) {
  43903. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERPICK;
  43904. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type_1, evt, pickResult);
  43905. this._setRayOnPointerInfo(pi);
  43906. scene.onPointerObservable.notifyObservers(pi, type_1);
  43907. }
  43908. }
  43909. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  43910. if (actionManager && !clickInfo.ignore) {
  43911. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43912. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  43913. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43914. }
  43915. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger);
  43916. if (clickInfo.doubleClick && doubleClickActionManager) {
  43917. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  43918. }
  43919. }
  43920. }
  43921. else {
  43922. if (!clickInfo.ignore) {
  43923. for (var _i = 0, _a = scene._pointerUpStage; _i < _a.length; _i++) {
  43924. var step = _a[_i];
  43925. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  43926. }
  43927. }
  43928. }
  43929. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  43930. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickOutTrigger);
  43931. if (pickedDownActionManager) {
  43932. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  43933. }
  43934. }
  43935. var type = 0;
  43936. if (scene.onPointerObservable.hasObservers()) {
  43937. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  43938. if (clickInfo.singleClick && scene.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)) {
  43939. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP;
  43940. }
  43941. else if (clickInfo.doubleClick && scene.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP)) {
  43942. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP;
  43943. }
  43944. if (type) {
  43945. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  43946. this._setRayOnPointerInfo(pi);
  43947. scene.onPointerObservable.notifyObservers(pi, type);
  43948. }
  43949. }
  43950. if (!clickInfo.ignore) {
  43951. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP;
  43952. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  43953. this._setRayOnPointerInfo(pi);
  43954. scene.onPointerObservable.notifyObservers(pi, type);
  43955. }
  43956. }
  43957. if (scene.onPointerUp && !clickInfo.ignore) {
  43958. scene.onPointerUp(evt, pickResult, type);
  43959. }
  43960. };
  43961. /**
  43962. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43963. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43964. * @returns true if the pointer was captured
  43965. */
  43966. InputManager.prototype.isPointerCaptured = function (pointerId) {
  43967. if (pointerId === void 0) { pointerId = 0; }
  43968. return this._pointerCaptures[pointerId];
  43969. };
  43970. /**
  43971. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43972. * @param attachUp defines if you want to attach events to pointerup
  43973. * @param attachDown defines if you want to attach events to pointerdown
  43974. * @param attachMove defines if you want to attach events to pointermove
  43975. */
  43976. InputManager.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  43977. var _this = this;
  43978. if (attachUp === void 0) { attachUp = true; }
  43979. if (attachDown === void 0) { attachDown = true; }
  43980. if (attachMove === void 0) { attachMove = true; }
  43981. var scene = this._scene;
  43982. var canvas = scene.getEngine().getRenderingCanvas();
  43983. if (!canvas) {
  43984. return;
  43985. }
  43986. var engine = scene.getEngine();
  43987. this._initActionManager = function (act, clickInfo) {
  43988. if (!_this._meshPickProceed) {
  43989. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, scene.pointerDownPredicate, false, scene.cameraToUseForPointers);
  43990. _this._currentPickResult = pickResult;
  43991. if (pickResult) {
  43992. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh._getActionManagerForTrigger() : null;
  43993. }
  43994. _this._meshPickProceed = true;
  43995. }
  43996. return act;
  43997. };
  43998. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  43999. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  44000. if ((Date.now() - _this._previousStartingPointerTime > InputManager.DoubleClickDelay && !_this._doubleClickOccured) ||
  44001. btn !== _this._previousButtonPressed) {
  44002. _this._doubleClickOccured = false;
  44003. clickInfo.singleClick = true;
  44004. clickInfo.ignore = false;
  44005. cb(clickInfo, _this._currentPickResult);
  44006. }
  44007. };
  44008. this._initClickEvent = function (obs1, obs2, evt, cb) {
  44009. var clickInfo = new _ClickInfo();
  44010. _this._currentPickResult = null;
  44011. var act = null;
  44012. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERPICK)
  44013. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)
  44014. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP);
  44015. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"]) {
  44016. act = _this._initActionManager(act, clickInfo);
  44017. if (act) {
  44018. checkPicking = act.hasPickTriggers;
  44019. }
  44020. }
  44021. var needToIgnoreNext = false;
  44022. if (checkPicking) {
  44023. var btn = evt.button;
  44024. clickInfo.hasSwiped = _this._isPointerSwiping();
  44025. if (!clickInfo.hasSwiped) {
  44026. var checkSingleClickImmediately = !InputManager.ExclusiveDoubleClickMode;
  44027. if (!checkSingleClickImmediately) {
  44028. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) &&
  44029. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP);
  44030. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger)) {
  44031. act = _this._initActionManager(act, clickInfo);
  44032. if (act) {
  44033. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger);
  44034. }
  44035. }
  44036. }
  44037. if (checkSingleClickImmediately) {
  44038. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  44039. if (Date.now() - _this._previousStartingPointerTime > InputManager.DoubleClickDelay ||
  44040. btn !== _this._previousButtonPressed) {
  44041. clickInfo.singleClick = true;
  44042. cb(clickInfo, _this._currentPickResult);
  44043. needToIgnoreNext = true;
  44044. }
  44045. }
  44046. // at least one double click is required to be check and exclusive double click is enabled
  44047. else {
  44048. // wait that no double click has been raised during the double click delay
  44049. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  44050. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), InputManager.DoubleClickDelay);
  44051. }
  44052. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) ||
  44053. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP);
  44054. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger)) {
  44055. act = _this._initActionManager(act, clickInfo);
  44056. if (act) {
  44057. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger);
  44058. }
  44059. }
  44060. if (checkDoubleClick) {
  44061. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  44062. if (btn === _this._previousButtonPressed &&
  44063. Date.now() - _this._previousStartingPointerTime < InputManager.DoubleClickDelay &&
  44064. !_this._doubleClickOccured) {
  44065. // pointer has not moved for 2 clicks, it's a double click
  44066. if (!clickInfo.hasSwiped &&
  44067. !_this._isPointerSwiping()) {
  44068. _this._previousStartingPointerTime = 0;
  44069. _this._doubleClickOccured = true;
  44070. clickInfo.doubleClick = true;
  44071. clickInfo.ignore = false;
  44072. if (InputManager.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  44073. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  44074. }
  44075. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  44076. cb(clickInfo, _this._currentPickResult);
  44077. }
  44078. // if the two successive clicks are too far, it's just two simple clicks
  44079. else {
  44080. _this._doubleClickOccured = false;
  44081. _this._previousStartingPointerTime = _this._startingPointerTime;
  44082. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  44083. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  44084. _this._previousButtonPressed = btn;
  44085. if (InputManager.ExclusiveDoubleClickMode) {
  44086. if (_this._previousDelayedSimpleClickTimeout) {
  44087. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  44088. }
  44089. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  44090. cb(clickInfo, _this._previousPickResult);
  44091. }
  44092. else {
  44093. cb(clickInfo, _this._currentPickResult);
  44094. }
  44095. }
  44096. needToIgnoreNext = true;
  44097. }
  44098. // just the first click of the double has been raised
  44099. else {
  44100. _this._doubleClickOccured = false;
  44101. _this._previousStartingPointerTime = _this._startingPointerTime;
  44102. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  44103. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  44104. _this._previousButtonPressed = btn;
  44105. }
  44106. }
  44107. }
  44108. }
  44109. if (!needToIgnoreNext) {
  44110. cb(clickInfo, _this._currentPickResult);
  44111. }
  44112. };
  44113. this._onPointerMove = function (evt) {
  44114. _this._updatePointerPosition(evt);
  44115. // PreObservable support
  44116. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE)) {
  44117. return;
  44118. }
  44119. if (!scene.cameraToUseForPointers && !scene.activeCamera) {
  44120. return;
  44121. }
  44122. if (!scene.pointerMovePredicate) {
  44123. scene.pointerMovePredicate = function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || scene.constantlyUpdateMeshUnderPointer || (mesh._getActionManagerForTrigger() != null)) && (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0)); };
  44124. }
  44125. // Meshes
  44126. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, scene.pointerMovePredicate, false, scene.cameraToUseForPointers);
  44127. _this._processPointerMove(pickResult, evt);
  44128. };
  44129. this._onPointerDown = function (evt) {
  44130. _this._totalPointersPressed++;
  44131. _this._pickedDownMesh = null;
  44132. _this._meshPickProceed = false;
  44133. _this._updatePointerPosition(evt);
  44134. if (scene.preventDefaultOnPointerDown && canvas) {
  44135. evt.preventDefault();
  44136. canvas.focus();
  44137. }
  44138. _this._startingPointerPosition.x = _this._pointerX;
  44139. _this._startingPointerPosition.y = _this._pointerY;
  44140. _this._startingPointerTime = Date.now();
  44141. // PreObservable support
  44142. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN)) {
  44143. return;
  44144. }
  44145. if (!scene.cameraToUseForPointers && !scene.activeCamera) {
  44146. return;
  44147. }
  44148. _this._pointerCaptures[evt.pointerId] = true;
  44149. if (!scene.pointerDownPredicate) {
  44150. scene.pointerDownPredicate = function (mesh) {
  44151. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  44152. };
  44153. }
  44154. // Meshes
  44155. _this._pickedDownMesh = null;
  44156. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, scene.pointerDownPredicate, false, scene.cameraToUseForPointers);
  44157. _this._processPointerDown(pickResult, evt);
  44158. };
  44159. this._onPointerUp = function (evt) {
  44160. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  44161. return; // So we need to test it the pointer down was pressed before.
  44162. }
  44163. _this._totalPointersPressed--;
  44164. _this._pickedUpMesh = null;
  44165. _this._meshPickProceed = false;
  44166. _this._updatePointerPosition(evt);
  44167. if (scene.preventDefaultOnPointerUp && canvas) {
  44168. evt.preventDefault();
  44169. canvas.focus();
  44170. }
  44171. _this._initClickEvent(scene.onPrePointerObservable, scene.onPointerObservable, evt, function (clickInfo, pickResult) {
  44172. // PreObservable support
  44173. if (scene.onPrePointerObservable.hasObservers()) {
  44174. if (!clickInfo.ignore) {
  44175. if (!clickInfo.hasSwiped) {
  44176. if (clickInfo.singleClick && scene.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)) {
  44177. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)) {
  44178. return;
  44179. }
  44180. }
  44181. if (clickInfo.doubleClick && scene.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP)) {
  44182. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP)) {
  44183. return;
  44184. }
  44185. }
  44186. }
  44187. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP)) {
  44188. return;
  44189. }
  44190. }
  44191. }
  44192. if (!_this._pointerCaptures[evt.pointerId]) {
  44193. return;
  44194. }
  44195. _this._pointerCaptures[evt.pointerId] = false;
  44196. if (!scene.cameraToUseForPointers && !scene.activeCamera) {
  44197. return;
  44198. }
  44199. if (!scene.pointerUpPredicate) {
  44200. scene.pointerUpPredicate = function (mesh) {
  44201. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  44202. };
  44203. }
  44204. // Meshes
  44205. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"].HasTriggers || scene.onPointerObservable.hasObservers())) {
  44206. _this._initActionManager(null, clickInfo);
  44207. }
  44208. if (!pickResult) {
  44209. pickResult = _this._currentPickResult;
  44210. }
  44211. _this._processPointerUp(pickResult, evt, clickInfo);
  44212. _this._previousPickResult = _this._currentPickResult;
  44213. });
  44214. };
  44215. this._onKeyDown = function (evt) {
  44216. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardEventTypes"].KEYDOWN;
  44217. if (scene.onPreKeyboardObservable.hasObservers()) {
  44218. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfoPre"](type, evt);
  44219. scene.onPreKeyboardObservable.notifyObservers(pi, type);
  44220. if (pi.skipOnPointerObservable) {
  44221. return;
  44222. }
  44223. }
  44224. if (scene.onKeyboardObservable.hasObservers()) {
  44225. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfo"](type, evt);
  44226. scene.onKeyboardObservable.notifyObservers(pi, type);
  44227. }
  44228. if (scene.actionManager) {
  44229. scene.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNewFromScene(scene, evt));
  44230. }
  44231. };
  44232. this._onKeyUp = function (evt) {
  44233. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardEventTypes"].KEYUP;
  44234. if (scene.onPreKeyboardObservable.hasObservers()) {
  44235. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfoPre"](type, evt);
  44236. scene.onPreKeyboardObservable.notifyObservers(pi, type);
  44237. if (pi.skipOnPointerObservable) {
  44238. return;
  44239. }
  44240. }
  44241. if (scene.onKeyboardObservable.hasObservers()) {
  44242. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfo"](type, evt);
  44243. scene.onKeyboardObservable.notifyObservers(pi, type);
  44244. }
  44245. if (scene.actionManager) {
  44246. scene.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNewFromScene(scene, evt));
  44247. }
  44248. };
  44249. // Keyboard events
  44250. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add((function () {
  44251. var fn = function () {
  44252. if (!canvas) {
  44253. return;
  44254. }
  44255. canvas.addEventListener("keydown", _this._onKeyDown, false);
  44256. canvas.addEventListener("keyup", _this._onKeyUp, false);
  44257. };
  44258. if (document.activeElement === canvas) {
  44259. fn();
  44260. }
  44261. return fn;
  44262. })());
  44263. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  44264. if (!canvas) {
  44265. return;
  44266. }
  44267. canvas.removeEventListener("keydown", _this._onKeyDown);
  44268. canvas.removeEventListener("keyup", _this._onKeyUp);
  44269. });
  44270. // Pointer events
  44271. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetPointerPrefix();
  44272. if (attachMove) {
  44273. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  44274. // Wheel
  44275. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  44276. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  44277. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  44278. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  44279. }
  44280. if (attachDown) {
  44281. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  44282. }
  44283. if (attachUp) {
  44284. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  44285. }
  44286. };
  44287. /**
  44288. * Detaches all event handlers
  44289. */
  44290. InputManager.prototype.detachControl = function () {
  44291. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetPointerPrefix();
  44292. var canvas = this._scene.getEngine().getRenderingCanvas();
  44293. var engine = this._scene.getEngine();
  44294. if (!canvas) {
  44295. return;
  44296. }
  44297. // Pointer
  44298. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  44299. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  44300. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  44301. // Blur / Focus
  44302. if (this._onCanvasBlurObserver) {
  44303. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  44304. }
  44305. if (this._onCanvasFocusObserver) {
  44306. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  44307. }
  44308. // Keyboard
  44309. canvas.removeEventListener("keydown", this._onKeyDown);
  44310. canvas.removeEventListener("keyup", this._onKeyUp);
  44311. // Cursor
  44312. canvas.style.cursor = this._scene.defaultCursor;
  44313. };
  44314. /**
  44315. * Force the value of meshUnderPointer
  44316. * @param mesh defines the mesh to use
  44317. */
  44318. InputManager.prototype.setPointerOverMesh = function (mesh) {
  44319. if (this._pointerOverMesh === mesh) {
  44320. return;
  44321. }
  44322. var actionManager;
  44323. if (this._pointerOverMesh) {
  44324. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOutTrigger);
  44325. if (actionManager) {
  44326. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(this._pointerOverMesh));
  44327. }
  44328. }
  44329. this._pointerOverMesh = mesh;
  44330. if (this._pointerOverMesh) {
  44331. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOverTrigger);
  44332. if (actionManager) {
  44333. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(this._pointerOverMesh));
  44334. }
  44335. }
  44336. };
  44337. /**
  44338. * Gets the mesh under the pointer
  44339. * @returns a Mesh or null if no mesh is under the pointer
  44340. */
  44341. InputManager.prototype.getPointerOverMesh = function () {
  44342. return this._pointerOverMesh;
  44343. };
  44344. /** The distance in pixel that you have to move to prevent some events */
  44345. InputManager.DragMovementThreshold = 10; // in pixels
  44346. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44347. InputManager.LongPressDelay = 500; // in milliseconds
  44348. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44349. InputManager.DoubleClickDelay = 300; // in milliseconds
  44350. /** If you need to check double click without raising a single click at first click, enable this flag */
  44351. InputManager.ExclusiveDoubleClickMode = false;
  44352. return InputManager;
  44353. }());
  44354. /***/ }),
  44355. /***/ "./Instrumentation/engineInstrumentation.ts":
  44356. /*!**************************************************!*\
  44357. !*** ./Instrumentation/engineInstrumentation.ts ***!
  44358. \**************************************************/
  44359. /*! exports provided: EngineInstrumentation */
  44360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44361. "use strict";
  44362. __webpack_require__.r(__webpack_exports__);
  44363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  44364. /* harmony import */ var _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/perfCounter */ "./Misc/perfCounter.ts");
  44365. /**
  44366. * This class can be used to get instrumentation data from a Babylon engine
  44367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44368. */
  44369. var EngineInstrumentation = /** @class */ (function () {
  44370. /**
  44371. * Instantiates a new engine instrumentation.
  44372. * This class can be used to get instrumentation data from a Babylon engine
  44373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44374. * @param engine Defines the engine to instrument
  44375. */
  44376. function EngineInstrumentation(
  44377. /**
  44378. * Define the instrumented engine.
  44379. */
  44380. engine) {
  44381. this.engine = engine;
  44382. this._captureGPUFrameTime = false;
  44383. this._gpuFrameTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  44384. this._captureShaderCompilationTime = false;
  44385. this._shaderCompilationTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  44386. // Observers
  44387. this._onBeginFrameObserver = null;
  44388. this._onEndFrameObserver = null;
  44389. this._onBeforeShaderCompilationObserver = null;
  44390. this._onAfterShaderCompilationObserver = null;
  44391. }
  44392. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  44393. // Properties
  44394. /**
  44395. * Gets the perf counter used for GPU frame time
  44396. */
  44397. get: function () {
  44398. return this._gpuFrameTime;
  44399. },
  44400. enumerable: true,
  44401. configurable: true
  44402. });
  44403. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  44404. /**
  44405. * Gets the GPU frame time capture status
  44406. */
  44407. get: function () {
  44408. return this._captureGPUFrameTime;
  44409. },
  44410. /**
  44411. * Enable or disable the GPU frame time capture
  44412. */
  44413. set: function (value) {
  44414. var _this = this;
  44415. if (value === this._captureGPUFrameTime) {
  44416. return;
  44417. }
  44418. this._captureGPUFrameTime = value;
  44419. if (value) {
  44420. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  44421. if (!_this._gpuFrameTimeToken) {
  44422. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  44423. }
  44424. });
  44425. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  44426. if (!_this._gpuFrameTimeToken) {
  44427. return;
  44428. }
  44429. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  44430. if (time > -1) {
  44431. _this._gpuFrameTimeToken = null;
  44432. _this._gpuFrameTime.fetchNewFrame();
  44433. _this._gpuFrameTime.addCount(time, true);
  44434. }
  44435. });
  44436. }
  44437. else {
  44438. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  44439. this._onBeginFrameObserver = null;
  44440. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  44441. this._onEndFrameObserver = null;
  44442. }
  44443. },
  44444. enumerable: true,
  44445. configurable: true
  44446. });
  44447. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  44448. /**
  44449. * Gets the perf counter used for shader compilation time
  44450. */
  44451. get: function () {
  44452. return this._shaderCompilationTime;
  44453. },
  44454. enumerable: true,
  44455. configurable: true
  44456. });
  44457. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  44458. /**
  44459. * Gets the shader compilation time capture status
  44460. */
  44461. get: function () {
  44462. return this._captureShaderCompilationTime;
  44463. },
  44464. /**
  44465. * Enable or disable the shader compilation time capture
  44466. */
  44467. set: function (value) {
  44468. var _this = this;
  44469. if (value === this._captureShaderCompilationTime) {
  44470. return;
  44471. }
  44472. this._captureShaderCompilationTime = value;
  44473. if (value) {
  44474. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  44475. _this._shaderCompilationTime.fetchNewFrame();
  44476. _this._shaderCompilationTime.beginMonitoring();
  44477. });
  44478. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  44479. _this._shaderCompilationTime.endMonitoring();
  44480. });
  44481. }
  44482. else {
  44483. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  44484. this._onBeforeShaderCompilationObserver = null;
  44485. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  44486. this._onAfterShaderCompilationObserver = null;
  44487. }
  44488. },
  44489. enumerable: true,
  44490. configurable: true
  44491. });
  44492. /**
  44493. * Dispose and release associated resources.
  44494. */
  44495. EngineInstrumentation.prototype.dispose = function () {
  44496. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  44497. this._onBeginFrameObserver = null;
  44498. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  44499. this._onEndFrameObserver = null;
  44500. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  44501. this._onBeforeShaderCompilationObserver = null;
  44502. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  44503. this._onAfterShaderCompilationObserver = null;
  44504. this.engine = null;
  44505. };
  44506. return EngineInstrumentation;
  44507. }());
  44508. /***/ }),
  44509. /***/ "./Instrumentation/index.ts":
  44510. /*!**********************************!*\
  44511. !*** ./Instrumentation/index.ts ***!
  44512. \**********************************/
  44513. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  44514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44515. "use strict";
  44516. __webpack_require__.r(__webpack_exports__);
  44517. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  44518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  44519. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  44520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  44521. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  44522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  44523. /***/ }),
  44524. /***/ "./Instrumentation/sceneInstrumentation.ts":
  44525. /*!*************************************************!*\
  44526. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  44527. \*************************************************/
  44528. /*! exports provided: SceneInstrumentation */
  44529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44530. "use strict";
  44531. __webpack_require__.r(__webpack_exports__);
  44532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  44533. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44534. /* harmony import */ var _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/perfCounter */ "./Misc/perfCounter.ts");
  44535. /**
  44536. * This class can be used to get instrumentation data from a Babylon engine
  44537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44538. */
  44539. var SceneInstrumentation = /** @class */ (function () {
  44540. /**
  44541. * Instantiates a new scene instrumentation.
  44542. * This class can be used to get instrumentation data from a Babylon engine
  44543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44544. * @param scene Defines the scene to instrument
  44545. */
  44546. function SceneInstrumentation(
  44547. /**
  44548. * Defines the scene to instrument
  44549. */
  44550. scene) {
  44551. var _this = this;
  44552. this.scene = scene;
  44553. this._captureActiveMeshesEvaluationTime = false;
  44554. this._activeMeshesEvaluationTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44555. this._captureRenderTargetsRenderTime = false;
  44556. this._renderTargetsRenderTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44557. this._captureFrameTime = false;
  44558. this._frameTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44559. this._captureRenderTime = false;
  44560. this._renderTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44561. this._captureInterFrameTime = false;
  44562. this._interFrameTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44563. this._captureParticlesRenderTime = false;
  44564. this._particlesRenderTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44565. this._captureSpritesRenderTime = false;
  44566. this._spritesRenderTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44567. this._capturePhysicsTime = false;
  44568. this._physicsTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44569. this._captureAnimationsTime = false;
  44570. this._animationsTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44571. this._captureCameraRenderTime = false;
  44572. this._cameraRenderTime = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  44573. // Observers
  44574. this._onBeforeActiveMeshesEvaluationObserver = null;
  44575. this._onAfterActiveMeshesEvaluationObserver = null;
  44576. this._onBeforeRenderTargetsRenderObserver = null;
  44577. this._onAfterRenderTargetsRenderObserver = null;
  44578. this._onAfterRenderObserver = null;
  44579. this._onBeforeDrawPhaseObserver = null;
  44580. this._onAfterDrawPhaseObserver = null;
  44581. this._onBeforeAnimationsObserver = null;
  44582. this._onBeforeParticlesRenderingObserver = null;
  44583. this._onAfterParticlesRenderingObserver = null;
  44584. this._onBeforeSpritesRenderingObserver = null;
  44585. this._onAfterSpritesRenderingObserver = null;
  44586. this._onBeforePhysicsObserver = null;
  44587. this._onAfterPhysicsObserver = null;
  44588. this._onAfterAnimationsObserver = null;
  44589. this._onBeforeCameraRenderObserver = null;
  44590. this._onAfterCameraRenderObserver = null;
  44591. // Before render
  44592. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  44593. if (_this._captureActiveMeshesEvaluationTime) {
  44594. _this._activeMeshesEvaluationTime.fetchNewFrame();
  44595. }
  44596. if (_this._captureRenderTargetsRenderTime) {
  44597. _this._renderTargetsRenderTime.fetchNewFrame();
  44598. }
  44599. if (_this._captureFrameTime) {
  44600. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  44601. _this._frameTime.beginMonitoring();
  44602. }
  44603. if (_this._captureInterFrameTime) {
  44604. _this._interFrameTime.endMonitoring();
  44605. }
  44606. if (_this._captureParticlesRenderTime) {
  44607. _this._particlesRenderTime.fetchNewFrame();
  44608. }
  44609. if (_this._captureSpritesRenderTime) {
  44610. _this._spritesRenderTime.fetchNewFrame();
  44611. }
  44612. if (_this._captureAnimationsTime) {
  44613. _this._animationsTime.beginMonitoring();
  44614. }
  44615. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  44616. });
  44617. // After render
  44618. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  44619. if (_this._captureFrameTime) {
  44620. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  44621. _this._frameTime.endMonitoring();
  44622. }
  44623. if (_this._captureRenderTime) {
  44624. _this._renderTime.endMonitoring(false);
  44625. }
  44626. if (_this._captureInterFrameTime) {
  44627. _this._interFrameTime.beginMonitoring();
  44628. }
  44629. });
  44630. }
  44631. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  44632. // Properties
  44633. /**
  44634. * Gets the perf counter used for active meshes evaluation time
  44635. */
  44636. get: function () {
  44637. return this._activeMeshesEvaluationTime;
  44638. },
  44639. enumerable: true,
  44640. configurable: true
  44641. });
  44642. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  44643. /**
  44644. * Gets the active meshes evaluation time capture status
  44645. */
  44646. get: function () {
  44647. return this._captureActiveMeshesEvaluationTime;
  44648. },
  44649. /**
  44650. * Enable or disable the active meshes evaluation time capture
  44651. */
  44652. set: function (value) {
  44653. var _this = this;
  44654. if (value === this._captureActiveMeshesEvaluationTime) {
  44655. return;
  44656. }
  44657. this._captureActiveMeshesEvaluationTime = value;
  44658. if (value) {
  44659. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  44660. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  44661. _this._activeMeshesEvaluationTime.beginMonitoring();
  44662. });
  44663. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  44664. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  44665. _this._activeMeshesEvaluationTime.endMonitoring();
  44666. });
  44667. }
  44668. else {
  44669. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  44670. this._onBeforeActiveMeshesEvaluationObserver = null;
  44671. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  44672. this._onAfterActiveMeshesEvaluationObserver = null;
  44673. }
  44674. },
  44675. enumerable: true,
  44676. configurable: true
  44677. });
  44678. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  44679. /**
  44680. * Gets the perf counter used for render targets render time
  44681. */
  44682. get: function () {
  44683. return this._renderTargetsRenderTime;
  44684. },
  44685. enumerable: true,
  44686. configurable: true
  44687. });
  44688. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  44689. /**
  44690. * Gets the render targets render time capture status
  44691. */
  44692. get: function () {
  44693. return this._captureRenderTargetsRenderTime;
  44694. },
  44695. /**
  44696. * Enable or disable the render targets render time capture
  44697. */
  44698. set: function (value) {
  44699. var _this = this;
  44700. if (value === this._captureRenderTargetsRenderTime) {
  44701. return;
  44702. }
  44703. this._captureRenderTargetsRenderTime = value;
  44704. if (value) {
  44705. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  44706. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  44707. _this._renderTargetsRenderTime.beginMonitoring();
  44708. });
  44709. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  44710. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  44711. _this._renderTargetsRenderTime.endMonitoring(false);
  44712. });
  44713. }
  44714. else {
  44715. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  44716. this._onBeforeRenderTargetsRenderObserver = null;
  44717. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  44718. this._onAfterRenderTargetsRenderObserver = null;
  44719. }
  44720. },
  44721. enumerable: true,
  44722. configurable: true
  44723. });
  44724. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  44725. /**
  44726. * Gets the perf counter used for particles render time
  44727. */
  44728. get: function () {
  44729. return this._particlesRenderTime;
  44730. },
  44731. enumerable: true,
  44732. configurable: true
  44733. });
  44734. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  44735. /**
  44736. * Gets the particles render time capture status
  44737. */
  44738. get: function () {
  44739. return this._captureParticlesRenderTime;
  44740. },
  44741. /**
  44742. * Enable or disable the particles render time capture
  44743. */
  44744. set: function (value) {
  44745. var _this = this;
  44746. if (value === this._captureParticlesRenderTime) {
  44747. return;
  44748. }
  44749. this._captureParticlesRenderTime = value;
  44750. if (value) {
  44751. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  44752. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  44753. _this._particlesRenderTime.beginMonitoring();
  44754. });
  44755. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  44756. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  44757. _this._particlesRenderTime.endMonitoring(false);
  44758. });
  44759. }
  44760. else {
  44761. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  44762. this._onBeforeParticlesRenderingObserver = null;
  44763. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  44764. this._onAfterParticlesRenderingObserver = null;
  44765. }
  44766. },
  44767. enumerable: true,
  44768. configurable: true
  44769. });
  44770. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  44771. /**
  44772. * Gets the perf counter used for sprites render time
  44773. */
  44774. get: function () {
  44775. return this._spritesRenderTime;
  44776. },
  44777. enumerable: true,
  44778. configurable: true
  44779. });
  44780. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  44781. /**
  44782. * Gets the sprites render time capture status
  44783. */
  44784. get: function () {
  44785. return this._captureSpritesRenderTime;
  44786. },
  44787. /**
  44788. * Enable or disable the sprites render time capture
  44789. */
  44790. set: function (value) {
  44791. var _this = this;
  44792. if (value === this._captureSpritesRenderTime) {
  44793. return;
  44794. }
  44795. this._captureSpritesRenderTime = value;
  44796. if (!this.scene.spriteManagers) {
  44797. return;
  44798. }
  44799. if (value) {
  44800. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  44801. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  44802. _this._spritesRenderTime.beginMonitoring();
  44803. });
  44804. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  44805. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  44806. _this._spritesRenderTime.endMonitoring(false);
  44807. });
  44808. }
  44809. else {
  44810. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  44811. this._onBeforeSpritesRenderingObserver = null;
  44812. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  44813. this._onAfterSpritesRenderingObserver = null;
  44814. }
  44815. },
  44816. enumerable: true,
  44817. configurable: true
  44818. });
  44819. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  44820. /**
  44821. * Gets the perf counter used for physics time
  44822. */
  44823. get: function () {
  44824. return this._physicsTime;
  44825. },
  44826. enumerable: true,
  44827. configurable: true
  44828. });
  44829. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  44830. /**
  44831. * Gets the physics time capture status
  44832. */
  44833. get: function () {
  44834. return this._capturePhysicsTime;
  44835. },
  44836. /**
  44837. * Enable or disable the physics time capture
  44838. */
  44839. set: function (value) {
  44840. var _this = this;
  44841. if (value === this._capturePhysicsTime) {
  44842. return;
  44843. }
  44844. if (!this.scene.onBeforePhysicsObservable) {
  44845. return;
  44846. }
  44847. this._capturePhysicsTime = value;
  44848. if (value) {
  44849. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  44850. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  44851. _this._physicsTime.beginMonitoring();
  44852. });
  44853. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  44854. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  44855. _this._physicsTime.endMonitoring();
  44856. });
  44857. }
  44858. else {
  44859. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  44860. this._onBeforePhysicsObserver = null;
  44861. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  44862. this._onAfterPhysicsObserver = null;
  44863. }
  44864. },
  44865. enumerable: true,
  44866. configurable: true
  44867. });
  44868. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  44869. /**
  44870. * Gets the perf counter used for animations time
  44871. */
  44872. get: function () {
  44873. return this._animationsTime;
  44874. },
  44875. enumerable: true,
  44876. configurable: true
  44877. });
  44878. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  44879. /**
  44880. * Gets the animations time capture status
  44881. */
  44882. get: function () {
  44883. return this._captureAnimationsTime;
  44884. },
  44885. /**
  44886. * Enable or disable the animations time capture
  44887. */
  44888. set: function (value) {
  44889. var _this = this;
  44890. if (value === this._captureAnimationsTime) {
  44891. return;
  44892. }
  44893. this._captureAnimationsTime = value;
  44894. if (value) {
  44895. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  44896. _this._animationsTime.endMonitoring();
  44897. });
  44898. }
  44899. else {
  44900. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  44901. this._onAfterAnimationsObserver = null;
  44902. }
  44903. },
  44904. enumerable: true,
  44905. configurable: true
  44906. });
  44907. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  44908. /**
  44909. * Gets the perf counter used for frame time capture
  44910. */
  44911. get: function () {
  44912. return this._frameTime;
  44913. },
  44914. enumerable: true,
  44915. configurable: true
  44916. });
  44917. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  44918. /**
  44919. * Gets the frame time capture status
  44920. */
  44921. get: function () {
  44922. return this._captureFrameTime;
  44923. },
  44924. /**
  44925. * Enable or disable the frame time capture
  44926. */
  44927. set: function (value) {
  44928. this._captureFrameTime = value;
  44929. },
  44930. enumerable: true,
  44931. configurable: true
  44932. });
  44933. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  44934. /**
  44935. * Gets the perf counter used for inter-frames time capture
  44936. */
  44937. get: function () {
  44938. return this._interFrameTime;
  44939. },
  44940. enumerable: true,
  44941. configurable: true
  44942. });
  44943. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  44944. /**
  44945. * Gets the inter-frames time capture status
  44946. */
  44947. get: function () {
  44948. return this._captureInterFrameTime;
  44949. },
  44950. /**
  44951. * Enable or disable the inter-frames time capture
  44952. */
  44953. set: function (value) {
  44954. this._captureInterFrameTime = value;
  44955. },
  44956. enumerable: true,
  44957. configurable: true
  44958. });
  44959. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  44960. /**
  44961. * Gets the perf counter used for render time capture
  44962. */
  44963. get: function () {
  44964. return this._renderTime;
  44965. },
  44966. enumerable: true,
  44967. configurable: true
  44968. });
  44969. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  44970. /**
  44971. * Gets the render time capture status
  44972. */
  44973. get: function () {
  44974. return this._captureRenderTime;
  44975. },
  44976. /**
  44977. * Enable or disable the render time capture
  44978. */
  44979. set: function (value) {
  44980. var _this = this;
  44981. if (value === this._captureRenderTime) {
  44982. return;
  44983. }
  44984. this._captureRenderTime = value;
  44985. if (value) {
  44986. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  44987. _this._renderTime.beginMonitoring();
  44988. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  44989. });
  44990. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  44991. _this._renderTime.endMonitoring(false);
  44992. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  44993. });
  44994. }
  44995. else {
  44996. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  44997. this._onBeforeDrawPhaseObserver = null;
  44998. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  44999. this._onAfterDrawPhaseObserver = null;
  45000. }
  45001. },
  45002. enumerable: true,
  45003. configurable: true
  45004. });
  45005. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  45006. /**
  45007. * Gets the perf counter used for camera render time capture
  45008. */
  45009. get: function () {
  45010. return this._cameraRenderTime;
  45011. },
  45012. enumerable: true,
  45013. configurable: true
  45014. });
  45015. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  45016. /**
  45017. * Gets the camera render time capture status
  45018. */
  45019. get: function () {
  45020. return this._captureCameraRenderTime;
  45021. },
  45022. /**
  45023. * Enable or disable the camera render time capture
  45024. */
  45025. set: function (value) {
  45026. var _this = this;
  45027. if (value === this._captureCameraRenderTime) {
  45028. return;
  45029. }
  45030. this._captureCameraRenderTime = value;
  45031. if (value) {
  45032. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  45033. _this._cameraRenderTime.beginMonitoring();
  45034. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  45035. });
  45036. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  45037. _this._cameraRenderTime.endMonitoring(false);
  45038. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  45039. });
  45040. }
  45041. else {
  45042. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  45043. this._onBeforeCameraRenderObserver = null;
  45044. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  45045. this._onAfterCameraRenderObserver = null;
  45046. }
  45047. },
  45048. enumerable: true,
  45049. configurable: true
  45050. });
  45051. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  45052. /**
  45053. * Gets the perf counter used for draw calls
  45054. */
  45055. get: function () {
  45056. return this.scene.getEngine()._drawCalls;
  45057. },
  45058. enumerable: true,
  45059. configurable: true
  45060. });
  45061. /**
  45062. * Dispose and release associated resources.
  45063. */
  45064. SceneInstrumentation.prototype.dispose = function () {
  45065. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  45066. this._onAfterRenderObserver = null;
  45067. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  45068. this._onBeforeActiveMeshesEvaluationObserver = null;
  45069. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  45070. this._onAfterActiveMeshesEvaluationObserver = null;
  45071. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  45072. this._onBeforeRenderTargetsRenderObserver = null;
  45073. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  45074. this._onAfterRenderTargetsRenderObserver = null;
  45075. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  45076. this._onBeforeAnimationsObserver = null;
  45077. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  45078. this._onBeforeParticlesRenderingObserver = null;
  45079. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  45080. this._onAfterParticlesRenderingObserver = null;
  45081. if (this._onBeforeSpritesRenderingObserver) {
  45082. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  45083. this._onBeforeSpritesRenderingObserver = null;
  45084. }
  45085. if (this._onAfterSpritesRenderingObserver) {
  45086. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  45087. this._onAfterSpritesRenderingObserver = null;
  45088. }
  45089. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  45090. this._onBeforeDrawPhaseObserver = null;
  45091. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  45092. this._onAfterDrawPhaseObserver = null;
  45093. if (this._onBeforePhysicsObserver) {
  45094. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  45095. this._onBeforePhysicsObserver = null;
  45096. }
  45097. if (this._onAfterPhysicsObserver) {
  45098. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  45099. this._onAfterPhysicsObserver = null;
  45100. }
  45101. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  45102. this._onAfterAnimationsObserver = null;
  45103. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  45104. this._onBeforeCameraRenderObserver = null;
  45105. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  45106. this._onAfterCameraRenderObserver = null;
  45107. this.scene = null;
  45108. };
  45109. return SceneInstrumentation;
  45110. }());
  45111. /***/ }),
  45112. /***/ "./Instrumentation/timeToken.ts":
  45113. /*!**************************************!*\
  45114. !*** ./Instrumentation/timeToken.ts ***!
  45115. \**************************************/
  45116. /*! exports provided: _TimeToken */
  45117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45118. "use strict";
  45119. __webpack_require__.r(__webpack_exports__);
  45120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  45121. /**
  45122. * @hidden
  45123. **/
  45124. var _TimeToken = /** @class */ (function () {
  45125. function _TimeToken() {
  45126. this._timeElapsedQueryEnded = false;
  45127. }
  45128. return _TimeToken;
  45129. }());
  45130. /***/ }),
  45131. /***/ "./Layers/effectLayer.ts":
  45132. /*!*******************************!*\
  45133. !*** ./Layers/effectLayer.ts ***!
  45134. \*******************************/
  45135. /*! exports provided: EffectLayer */
  45136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45137. "use strict";
  45138. __webpack_require__.r(__webpack_exports__);
  45139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  45140. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45141. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45142. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  45143. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  45144. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  45145. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  45146. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  45147. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  45148. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45149. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  45151. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  45152. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  45153. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  45154. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  45155. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  45156. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  45157. /**
  45158. * The effect layer Helps adding post process effect blended with the main pass.
  45159. *
  45160. * This can be for instance use to generate glow or higlight effects on the scene.
  45161. *
  45162. * The effect layer class can not be used directly and is intented to inherited from to be
  45163. * customized per effects.
  45164. */
  45165. var EffectLayer = /** @class */ (function () {
  45166. /**
  45167. * Instantiates a new effect Layer and references it in the scene.
  45168. * @param name The name of the layer
  45169. * @param scene The scene to use the layer in
  45170. */
  45171. function EffectLayer(
  45172. /** The Friendly of the effect in the scene */
  45173. name, scene) {
  45174. this._vertexBuffers = {};
  45175. this._maxSize = 0;
  45176. this._mainTextureDesiredSize = { width: 0, height: 0 };
  45177. this._shouldRender = true;
  45178. this._postProcesses = [];
  45179. this._textures = [];
  45180. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  45181. /**
  45182. * The clear color of the texture used to generate the glow map.
  45183. */
  45184. this.neutralColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  45185. /**
  45186. * Specifies wether the highlight layer is enabled or not.
  45187. */
  45188. this.isEnabled = true;
  45189. /**
  45190. * An event triggered when the effect layer has been disposed.
  45191. */
  45192. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  45193. /**
  45194. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45195. */
  45196. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  45197. /**
  45198. * An event triggered when the generated texture is being merged in the scene.
  45199. */
  45200. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  45201. /**
  45202. * An event triggered when the generated texture has been merged in the scene.
  45203. */
  45204. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  45205. /**
  45206. * An event triggered when the efffect layer changes its size.
  45207. */
  45208. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  45209. this.name = name;
  45210. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  45211. EffectLayer._SceneComponentInitialization(this._scene);
  45212. this._engine = this._scene.getEngine();
  45213. this._maxSize = this._engine.getCaps().maxTextureSize;
  45214. this._scene.effectLayers.push(this);
  45215. // Generate Buffers
  45216. this._generateIndexBuffer();
  45217. this._generateVertexBuffer();
  45218. }
  45219. Object.defineProperty(EffectLayer.prototype, "camera", {
  45220. /**
  45221. * Gets the camera attached to the layer.
  45222. */
  45223. get: function () {
  45224. return this._effectLayerOptions.camera;
  45225. },
  45226. enumerable: true,
  45227. configurable: true
  45228. });
  45229. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  45230. /**
  45231. * Gets the rendering group id the layer should render in.
  45232. */
  45233. get: function () {
  45234. return this._effectLayerOptions.renderingGroupId;
  45235. },
  45236. set: function (renderingGroupId) {
  45237. this._effectLayerOptions.renderingGroupId = renderingGroupId;
  45238. },
  45239. enumerable: true,
  45240. configurable: true
  45241. });
  45242. /**
  45243. * Initializes the effect layer with the required options.
  45244. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45245. */
  45246. EffectLayer.prototype._init = function (options) {
  45247. // Adapt options
  45248. this._effectLayerOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: 0.5, alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE, camera: null, renderingGroupId: -1 }, options);
  45249. this._setMainTextureSize();
  45250. this._createMainTexture();
  45251. this._createTextureAndPostProcesses();
  45252. this._mergeEffect = this._createMergeEffect();
  45253. };
  45254. /**
  45255. * Generates the index buffer of the full screen quad blending to the main canvas.
  45256. */
  45257. EffectLayer.prototype._generateIndexBuffer = function () {
  45258. // Indices
  45259. var indices = [];
  45260. indices.push(0);
  45261. indices.push(1);
  45262. indices.push(2);
  45263. indices.push(0);
  45264. indices.push(2);
  45265. indices.push(3);
  45266. this._indexBuffer = this._engine.createIndexBuffer(indices);
  45267. };
  45268. /**
  45269. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45270. */
  45271. EffectLayer.prototype._generateVertexBuffer = function () {
  45272. // VBO
  45273. var vertices = [];
  45274. vertices.push(1, 1);
  45275. vertices.push(-1, 1);
  45276. vertices.push(-1, -1);
  45277. vertices.push(1, -1);
  45278. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, false, false, 2);
  45279. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind] = vertexBuffer;
  45280. };
  45281. /**
  45282. * Sets the main texture desired size which is the closest power of two
  45283. * of the engine canvas size.
  45284. */
  45285. EffectLayer.prototype._setMainTextureSize = function () {
  45286. if (this._effectLayerOptions.mainTextureFixedSize) {
  45287. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  45288. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  45289. }
  45290. else {
  45291. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  45292. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  45293. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  45294. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  45295. }
  45296. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  45297. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  45298. };
  45299. /**
  45300. * Creates the main texture for the effect layer.
  45301. */
  45302. EffectLayer.prototype._createMainTexture = function () {
  45303. var _this = this;
  45304. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_9__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  45305. width: this._mainTextureDesiredSize.width,
  45306. height: this._mainTextureDesiredSize.height
  45307. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  45308. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  45309. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].CLAMP_ADDRESSMODE;
  45310. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].CLAMP_ADDRESSMODE;
  45311. this._mainTexture.anisotropicFilteringLevel = 1;
  45312. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE);
  45313. this._mainTexture.renderParticles = false;
  45314. this._mainTexture.renderList = null;
  45315. this._mainTexture.ignoreCameraViewport = true;
  45316. // Custom render function
  45317. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  45318. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  45319. var index;
  45320. var engine = _this._scene.getEngine();
  45321. if (depthOnlySubMeshes.length) {
  45322. engine.setColorWrite(false);
  45323. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  45324. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  45325. }
  45326. engine.setColorWrite(true);
  45327. }
  45328. for (index = 0; index < opaqueSubMeshes.length; index++) {
  45329. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  45330. }
  45331. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  45332. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  45333. }
  45334. var previousAlphaMode = engine.getAlphaMode();
  45335. for (index = 0; index < transparentSubMeshes.length; index++) {
  45336. _this._renderSubMesh(transparentSubMeshes.data[index], true);
  45337. }
  45338. engine.setAlphaMode(previousAlphaMode);
  45339. };
  45340. this._mainTexture.onClearObservable.add(function (engine) {
  45341. engine.clear(_this.neutralColor, true, true, true);
  45342. });
  45343. };
  45344. /**
  45345. * Adds specific effects defines.
  45346. * @param defines The defines to add specifics to.
  45347. */
  45348. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  45349. // Nothing to add by default.
  45350. };
  45351. /**
  45352. * Checks for the readiness of the element composing the layer.
  45353. * @param subMesh the mesh to check for
  45354. * @param useInstances specify wether or not to use instances to render the mesh
  45355. * @param emissiveTexture the associated emissive texture used to generate the glow
  45356. * @return true if ready otherwise, false
  45357. */
  45358. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  45359. var material = subMesh.getMaterial();
  45360. if (!material) {
  45361. return false;
  45362. }
  45363. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  45364. return false;
  45365. }
  45366. var defines = [];
  45367. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  45368. var mesh = subMesh.getMesh();
  45369. var uv1 = false;
  45370. var uv2 = false;
  45371. // Diffuse
  45372. if (material) {
  45373. var needAlphaTest = material.needAlphaTesting();
  45374. var diffuseTexture = material.getAlphaTestTexture();
  45375. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  45376. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  45377. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  45378. defines.push("#define DIFFUSE");
  45379. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind) &&
  45380. diffuseTexture.coordinatesIndex === 1) {
  45381. defines.push("#define DIFFUSEUV2");
  45382. uv2 = true;
  45383. }
  45384. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  45385. defines.push("#define DIFFUSEUV1");
  45386. uv1 = true;
  45387. }
  45388. if (needAlphaTest) {
  45389. defines.push("#define ALPHATEST");
  45390. defines.push("#define ALPHATESTVALUE 0.4");
  45391. }
  45392. }
  45393. var opacityTexture = material.opacityTexture;
  45394. if (opacityTexture) {
  45395. defines.push("#define OPACITY");
  45396. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind) &&
  45397. opacityTexture.coordinatesIndex === 1) {
  45398. defines.push("#define OPACITYUV2");
  45399. uv2 = true;
  45400. }
  45401. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  45402. defines.push("#define OPACITYUV1");
  45403. uv1 = true;
  45404. }
  45405. }
  45406. }
  45407. // Emissive
  45408. if (emissiveTexture) {
  45409. defines.push("#define EMISSIVE");
  45410. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind) &&
  45411. emissiveTexture.coordinatesIndex === 1) {
  45412. defines.push("#define EMISSIVEUV2");
  45413. uv2 = true;
  45414. }
  45415. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  45416. defines.push("#define EMISSIVEUV1");
  45417. uv1 = true;
  45418. }
  45419. }
  45420. // Vertex
  45421. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  45422. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  45423. defines.push("#define VERTEXALPHA");
  45424. }
  45425. if (uv1) {
  45426. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  45427. defines.push("#define UV1");
  45428. }
  45429. if (uv2) {
  45430. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  45431. defines.push("#define UV2");
  45432. }
  45433. // Bones
  45434. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_10__["EffectFallbacks"]();
  45435. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  45436. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  45437. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  45438. if (mesh.numBoneInfluencers > 4) {
  45439. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  45440. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  45441. }
  45442. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45443. var skeleton = mesh.skeleton;
  45444. if (skeleton && skeleton.isUsingTextureForMatrices) {
  45445. defines.push("#define BONETEXTURE");
  45446. }
  45447. else {
  45448. defines.push("#define BonesPerMesh " + (skeleton ? (skeleton.bones.length + 1) : 0));
  45449. }
  45450. if (mesh.numBoneInfluencers > 0) {
  45451. fallbacks.addCPUSkinningFallback(0, mesh);
  45452. }
  45453. }
  45454. else {
  45455. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45456. }
  45457. // Morph targets
  45458. var manager = mesh.morphTargetManager;
  45459. var morphInfluencers = 0;
  45460. if (manager) {
  45461. if (manager.numInfluencers > 0) {
  45462. defines.push("#define MORPHTARGETS");
  45463. morphInfluencers = manager.numInfluencers;
  45464. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45465. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, morphInfluencers);
  45466. }
  45467. }
  45468. // Instances
  45469. if (useInstances) {
  45470. defines.push("#define INSTANCES");
  45471. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PushAttributesForInstances(attribs);
  45472. }
  45473. this._addCustomEffectDefines(defines);
  45474. // Get correct effect
  45475. var join = defines.join("\n");
  45476. if (this._cachedDefines !== join) {
  45477. this._cachedDefines = join;
  45478. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  45479. "glowColor", "morphTargetInfluences", "boneTextureWidth",
  45480. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler"], join, fallbacks, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45481. }
  45482. return this._effectLayerMapGenerationEffect.isReady();
  45483. };
  45484. /**
  45485. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45486. */
  45487. EffectLayer.prototype.render = function () {
  45488. var currentEffect = this._mergeEffect;
  45489. // Check
  45490. if (!currentEffect.isReady()) {
  45491. return;
  45492. }
  45493. for (var i = 0; i < this._postProcesses.length; i++) {
  45494. if (!this._postProcesses[i].isReady()) {
  45495. return;
  45496. }
  45497. }
  45498. var engine = this._scene.getEngine();
  45499. this.onBeforeComposeObservable.notifyObservers(this);
  45500. // Render
  45501. engine.enableEffect(currentEffect);
  45502. engine.setState(false);
  45503. // VBOs
  45504. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  45505. // Cache
  45506. var previousAlphaMode = engine.getAlphaMode();
  45507. // Go Blend.
  45508. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  45509. // Blends the map on the main canvas.
  45510. this._internalRender(currentEffect);
  45511. // Restore Alpha
  45512. engine.setAlphaMode(previousAlphaMode);
  45513. this.onAfterComposeObservable.notifyObservers(this);
  45514. // Handle size changes.
  45515. var size = this._mainTexture.getSize();
  45516. this._setMainTextureSize();
  45517. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  45518. // Recreate RTT and post processes on size change.
  45519. this.onSizeChangedObservable.notifyObservers(this);
  45520. this._disposeTextureAndPostProcesses();
  45521. this._createMainTexture();
  45522. this._createTextureAndPostProcesses();
  45523. }
  45524. };
  45525. /**
  45526. * Determine if a given mesh will be used in the current effect.
  45527. * @param mesh mesh to test
  45528. * @returns true if the mesh will be used
  45529. */
  45530. EffectLayer.prototype.hasMesh = function (mesh) {
  45531. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  45532. return true;
  45533. }
  45534. return false;
  45535. };
  45536. /**
  45537. * Returns true if the layer contains information to display, otherwise false.
  45538. * @returns true if the glow layer should be rendered
  45539. */
  45540. EffectLayer.prototype.shouldRender = function () {
  45541. return this.isEnabled && this._shouldRender;
  45542. };
  45543. /**
  45544. * Returns true if the mesh should render, otherwise false.
  45545. * @param mesh The mesh to render
  45546. * @returns true if it should render otherwise false
  45547. */
  45548. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  45549. return true;
  45550. };
  45551. /**
  45552. * Returns true if the mesh can be rendered, otherwise false.
  45553. * @param mesh The mesh to render
  45554. * @param material The material used on the mesh
  45555. * @returns true if it can be rendered otherwise false
  45556. */
  45557. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  45558. return !material.needAlphaBlendingForMesh(mesh);
  45559. };
  45560. /**
  45561. * Returns true if the mesh should render, otherwise false.
  45562. * @param mesh The mesh to render
  45563. * @returns true if it should render otherwise false
  45564. */
  45565. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  45566. return true;
  45567. };
  45568. /**
  45569. * Renders the submesh passed in parameter to the generation map.
  45570. */
  45571. EffectLayer.prototype._renderSubMesh = function (subMesh, enableAlphaMode) {
  45572. var _this = this;
  45573. if (enableAlphaMode === void 0) { enableAlphaMode = false; }
  45574. if (!this.shouldRender()) {
  45575. return;
  45576. }
  45577. var material = subMesh.getMaterial();
  45578. var mesh = subMesh.getRenderingMesh();
  45579. var scene = this._scene;
  45580. var engine = scene.getEngine();
  45581. mesh._internalAbstractMeshDataInfo._isActiveIntermediate = false;
  45582. if (!material) {
  45583. return;
  45584. }
  45585. // Do not block in blend mode.
  45586. if (!this._canRenderMesh(mesh, material)) {
  45587. return;
  45588. }
  45589. // Culling
  45590. engine.setState(material.backFaceCulling);
  45591. // Managing instances
  45592. var batch = mesh._getInstancesRenderList(subMesh._id);
  45593. if (batch.mustReturn) {
  45594. return;
  45595. }
  45596. // Early Exit per mesh
  45597. if (!this._shouldRenderMesh(mesh)) {
  45598. return;
  45599. }
  45600. var hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id];
  45601. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  45602. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  45603. engine.enableEffect(this._effectLayerMapGenerationEffect);
  45604. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_11__["Material"].TriangleFillMode);
  45605. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  45606. this._effectLayerMapGenerationEffect.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  45607. var needAlphaTest = material.needAlphaTesting();
  45608. var diffuseTexture = material.getAlphaTestTexture();
  45609. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  45610. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  45611. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  45612. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  45613. var textureMatrix = diffuseTexture.getTextureMatrix();
  45614. if (textureMatrix) {
  45615. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  45616. }
  45617. }
  45618. var opacityTexture = material.opacityTexture;
  45619. if (opacityTexture) {
  45620. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  45621. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  45622. var textureMatrix = opacityTexture.getTextureMatrix();
  45623. if (textureMatrix) {
  45624. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  45625. }
  45626. }
  45627. // Glow emissive only
  45628. if (this._emissiveTextureAndColor.texture) {
  45629. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  45630. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  45631. }
  45632. // Bones
  45633. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45634. var skeleton = mesh.skeleton;
  45635. if (skeleton.isUsingTextureForMatrices) {
  45636. var boneTexture = skeleton.getTransformMatrixTexture(mesh);
  45637. if (!boneTexture) {
  45638. return;
  45639. }
  45640. this._effectLayerMapGenerationEffect.setTexture("boneSampler", boneTexture);
  45641. this._effectLayerMapGenerationEffect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  45642. }
  45643. else {
  45644. this._effectLayerMapGenerationEffect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  45645. }
  45646. }
  45647. // Morph targets
  45648. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  45649. // Alpha mode
  45650. if (enableAlphaMode) {
  45651. engine.setAlphaMode(material.alphaMode);
  45652. }
  45653. // Draw
  45654. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_11__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  45655. }
  45656. else {
  45657. // Need to reset refresh rate of the main map
  45658. this._mainTexture.resetRefreshCounter();
  45659. }
  45660. };
  45661. /**
  45662. * Rebuild the required buffers.
  45663. * @hidden Internal use only.
  45664. */
  45665. EffectLayer.prototype._rebuild = function () {
  45666. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  45667. if (vb) {
  45668. vb._rebuild();
  45669. }
  45670. this._generateIndexBuffer();
  45671. };
  45672. /**
  45673. * Dispose only the render target textures and post process.
  45674. */
  45675. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  45676. this._mainTexture.dispose();
  45677. for (var i = 0; i < this._postProcesses.length; i++) {
  45678. if (this._postProcesses[i]) {
  45679. this._postProcesses[i].dispose();
  45680. }
  45681. }
  45682. this._postProcesses = [];
  45683. for (var i = 0; i < this._textures.length; i++) {
  45684. if (this._textures[i]) {
  45685. this._textures[i].dispose();
  45686. }
  45687. }
  45688. this._textures = [];
  45689. };
  45690. /**
  45691. * Dispose the highlight layer and free resources.
  45692. */
  45693. EffectLayer.prototype.dispose = function () {
  45694. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  45695. if (vertexBuffer) {
  45696. vertexBuffer.dispose();
  45697. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind] = null;
  45698. }
  45699. if (this._indexBuffer) {
  45700. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  45701. this._indexBuffer = null;
  45702. }
  45703. // Clean textures and post processes
  45704. this._disposeTextureAndPostProcesses();
  45705. // Remove from scene
  45706. var index = this._scene.effectLayers.indexOf(this, 0);
  45707. if (index > -1) {
  45708. this._scene.effectLayers.splice(index, 1);
  45709. }
  45710. // Callback
  45711. this.onDisposeObservable.notifyObservers(this);
  45712. this.onDisposeObservable.clear();
  45713. this.onBeforeRenderMainTextureObservable.clear();
  45714. this.onBeforeComposeObservable.clear();
  45715. this.onAfterComposeObservable.clear();
  45716. this.onSizeChangedObservable.clear();
  45717. };
  45718. /**
  45719. * Gets the class name of the effect layer
  45720. * @returns the string with the class name of the effect layer
  45721. */
  45722. EffectLayer.prototype.getClassName = function () {
  45723. return "EffectLayer";
  45724. };
  45725. /**
  45726. * Creates an effect layer from parsed effect layer data
  45727. * @param parsedEffectLayer defines effect layer data
  45728. * @param scene defines the current scene
  45729. * @param rootUrl defines the root URL containing the effect layer information
  45730. * @returns a parsed effect Layer
  45731. */
  45732. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  45733. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  45734. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  45735. };
  45736. /** @hidden */
  45737. EffectLayer._SceneComponentInitialization = function (_) {
  45738. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_16__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  45739. };
  45740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45742. ], EffectLayer.prototype, "name", void 0);
  45743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  45745. ], EffectLayer.prototype, "neutralColor", void 0);
  45746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45748. ], EffectLayer.prototype, "isEnabled", void 0);
  45749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  45751. ], EffectLayer.prototype, "camera", null);
  45752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45754. ], EffectLayer.prototype, "renderingGroupId", null);
  45755. return EffectLayer;
  45756. }());
  45757. /***/ }),
  45758. /***/ "./Layers/effectLayerSceneComponent.ts":
  45759. /*!*********************************************!*\
  45760. !*** ./Layers/effectLayerSceneComponent.ts ***!
  45761. \*********************************************/
  45762. /*! exports provided: EffectLayerSceneComponent */
  45763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45764. "use strict";
  45765. __webpack_require__.r(__webpack_exports__);
  45766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  45767. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  45768. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  45769. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  45770. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  45771. // Adds the parser to the scene parsers.
  45772. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  45773. if (parsedData.effectLayers) {
  45774. if (!container.effectLayers) {
  45775. container.effectLayers = new Array();
  45776. }
  45777. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  45778. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  45779. container.effectLayers.push(effectLayer);
  45780. }
  45781. }
  45782. });
  45783. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  45784. var index = this.effectLayers.indexOf(toRemove);
  45785. if (index !== -1) {
  45786. this.effectLayers.splice(index, 1);
  45787. }
  45788. return index;
  45789. };
  45790. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  45791. this.effectLayers.push(newEffectLayer);
  45792. };
  45793. /**
  45794. * Defines the layer scene component responsible to manage any effect layers
  45795. * in a given scene.
  45796. */
  45797. var EffectLayerSceneComponent = /** @class */ (function () {
  45798. /**
  45799. * Creates a new instance of the component for the given scene
  45800. * @param scene Defines the scene to register the component in
  45801. */
  45802. function EffectLayerSceneComponent(scene) {
  45803. /**
  45804. * The component name helpfull to identify the component in the list of scene components.
  45805. */
  45806. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  45807. this._renderEffects = false;
  45808. this._needStencil = false;
  45809. this._previousStencilState = false;
  45810. this.scene = scene;
  45811. this._engine = scene.getEngine();
  45812. scene.effectLayers = new Array();
  45813. }
  45814. /**
  45815. * Registers the component in a given scene
  45816. */
  45817. EffectLayerSceneComponent.prototype.register = function () {
  45818. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  45819. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  45820. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  45821. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  45822. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  45823. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  45824. };
  45825. /**
  45826. * Rebuilds the elements related to this component in case of
  45827. * context lost for instance.
  45828. */
  45829. EffectLayerSceneComponent.prototype.rebuild = function () {
  45830. var layers = this.scene.effectLayers;
  45831. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  45832. var effectLayer = layers_1[_i];
  45833. effectLayer._rebuild();
  45834. }
  45835. };
  45836. /**
  45837. * Serializes the component data to the specified json object
  45838. * @param serializationObject The object to serialize to
  45839. */
  45840. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  45841. // Effect layers
  45842. serializationObject.effectLayers = [];
  45843. var layers = this.scene.effectLayers;
  45844. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  45845. var effectLayer = layers_2[_i];
  45846. if (effectLayer.serialize) {
  45847. serializationObject.effectLayers.push(effectLayer.serialize());
  45848. }
  45849. }
  45850. };
  45851. /**
  45852. * Adds all the elements from the container to the scene
  45853. * @param container the container holding the elements
  45854. */
  45855. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  45856. var _this = this;
  45857. if (!container.effectLayers) {
  45858. return;
  45859. }
  45860. container.effectLayers.forEach(function (o) {
  45861. _this.scene.addEffectLayer(o);
  45862. });
  45863. };
  45864. /**
  45865. * Removes all the elements in the container from the scene
  45866. * @param container contains the elements to remove
  45867. * @param dispose if the removed element should be disposed (default: false)
  45868. */
  45869. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  45870. var _this = this;
  45871. if (!container.effectLayers) {
  45872. return;
  45873. }
  45874. container.effectLayers.forEach(function (o) {
  45875. _this.scene.removeEffectLayer(o);
  45876. if (dispose) {
  45877. o.dispose();
  45878. }
  45879. });
  45880. };
  45881. /**
  45882. * Disposes the component and the associated ressources.
  45883. */
  45884. EffectLayerSceneComponent.prototype.dispose = function () {
  45885. var layers = this.scene.effectLayers;
  45886. while (layers.length) {
  45887. layers[0].dispose();
  45888. }
  45889. };
  45890. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  45891. var layers = this.scene.effectLayers;
  45892. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  45893. var layer = layers_3[_i];
  45894. if (!layer.hasMesh(mesh)) {
  45895. continue;
  45896. }
  45897. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  45898. var subMesh = _b[_a];
  45899. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  45900. return false;
  45901. }
  45902. }
  45903. }
  45904. return true;
  45905. };
  45906. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  45907. this._renderEffects = false;
  45908. this._needStencil = false;
  45909. var needRebind = false;
  45910. var layers = this.scene.effectLayers;
  45911. if (layers && layers.length > 0) {
  45912. this._previousStencilState = this._engine.getStencilBuffer();
  45913. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  45914. var effectLayer = layers_4[_i];
  45915. if (effectLayer.shouldRender() &&
  45916. (!effectLayer.camera ||
  45917. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  45918. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  45919. this._renderEffects = true;
  45920. this._needStencil = this._needStencil || effectLayer.needStencil();
  45921. var renderTarget = effectLayer._mainTexture;
  45922. if (renderTarget._shouldRender()) {
  45923. this.scene.incrementRenderId();
  45924. renderTarget.render(false, false);
  45925. needRebind = true;
  45926. }
  45927. }
  45928. }
  45929. this.scene.incrementRenderId();
  45930. }
  45931. return needRebind;
  45932. };
  45933. EffectLayerSceneComponent.prototype._setStencil = function () {
  45934. // Activate effect Layer stencil
  45935. if (this._needStencil) {
  45936. this._engine.setStencilBuffer(true);
  45937. }
  45938. };
  45939. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  45940. // Restore effect Layer stencil
  45941. if (this._needStencil) {
  45942. this._engine.setStencilBuffer(this._previousStencilState);
  45943. }
  45944. };
  45945. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  45946. if (this._renderEffects) {
  45947. this._engine.setDepthBuffer(false);
  45948. var layers = this.scene.effectLayers;
  45949. for (var i = 0; i < layers.length; i++) {
  45950. var effectLayer = layers[i];
  45951. if (effectLayer.renderingGroupId === renderingGroupId) {
  45952. if (effectLayer.shouldRender()) {
  45953. effectLayer.render();
  45954. }
  45955. }
  45956. }
  45957. this._engine.setDepthBuffer(true);
  45958. }
  45959. };
  45960. EffectLayerSceneComponent.prototype._drawCamera = function () {
  45961. if (this._renderEffects) {
  45962. this._draw(-1);
  45963. }
  45964. };
  45965. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  45966. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  45967. this._draw(index);
  45968. }
  45969. };
  45970. return EffectLayerSceneComponent;
  45971. }());
  45972. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  45973. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  45974. if (!component) {
  45975. component = new EffectLayerSceneComponent(scene);
  45976. scene._addComponent(component);
  45977. }
  45978. };
  45979. /***/ }),
  45980. /***/ "./Layers/glowLayer.ts":
  45981. /*!*****************************!*\
  45982. !*** ./Layers/glowLayer.ts ***!
  45983. \*****************************/
  45984. /*! exports provided: GlowLayer */
  45985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45986. "use strict";
  45987. __webpack_require__.r(__webpack_exports__);
  45988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  45989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45990. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45991. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  45992. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  45993. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45994. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45995. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  45996. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  45997. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  45998. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  45999. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  46000. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46001. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  46002. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  46003. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  46004. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  46005. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  46006. _abstractScene__WEBPACK_IMPORTED_MODULE_9__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  46007. for (var index = 0; index < this.effectLayers.length; index++) {
  46008. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  46009. return this.effectLayers[index];
  46010. }
  46011. }
  46012. return null;
  46013. };
  46014. /**
  46015. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46016. *
  46017. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46018. * glowy meshes to your scene.
  46019. *
  46020. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46021. */
  46022. var GlowLayer = /** @class */ (function (_super) {
  46023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  46024. /**
  46025. * Instantiates a new glow Layer and references it to the scene.
  46026. * @param name The name of the layer
  46027. * @param scene The scene to use the layer in
  46028. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46029. */
  46030. function GlowLayer(name, scene, options) {
  46031. var _this = _super.call(this, name, scene) || this;
  46032. _this._intensity = 1.0;
  46033. _this._includedOnlyMeshes = [];
  46034. _this._excludedMeshes = [];
  46035. _this.neutralColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color4"](0, 0, 0, 1);
  46036. // Adapt options
  46037. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  46038. // Initialize the layer
  46039. _this._init({
  46040. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_ADD,
  46041. camera: _this._options.camera,
  46042. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  46043. mainTextureRatio: _this._options.mainTextureRatio,
  46044. renderingGroupId: _this._options.renderingGroupId
  46045. });
  46046. return _this;
  46047. }
  46048. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  46049. /**
  46050. * Gets the kernel size of the blur.
  46051. */
  46052. get: function () {
  46053. return this._horizontalBlurPostprocess1.kernel;
  46054. },
  46055. /**
  46056. * Sets the kernel size of the blur.
  46057. */
  46058. set: function (value) {
  46059. this._horizontalBlurPostprocess1.kernel = value;
  46060. this._verticalBlurPostprocess1.kernel = value;
  46061. this._horizontalBlurPostprocess2.kernel = value;
  46062. this._verticalBlurPostprocess2.kernel = value;
  46063. },
  46064. enumerable: true,
  46065. configurable: true
  46066. });
  46067. Object.defineProperty(GlowLayer.prototype, "intensity", {
  46068. /**
  46069. * Gets the glow intensity.
  46070. */
  46071. get: function () {
  46072. return this._intensity;
  46073. },
  46074. /**
  46075. * Sets the glow intensity.
  46076. */
  46077. set: function (value) {
  46078. this._intensity = value;
  46079. },
  46080. enumerable: true,
  46081. configurable: true
  46082. });
  46083. /**
  46084. * Get the effect name of the layer.
  46085. * @return The effect name
  46086. */
  46087. GlowLayer.prototype.getEffectName = function () {
  46088. return GlowLayer.EffectName;
  46089. };
  46090. /**
  46091. * Create the merge effect. This is the shader use to blit the information back
  46092. * to the main canvas at the end of the scene rendering.
  46093. */
  46094. GlowLayer.prototype._createMergeEffect = function () {
  46095. // Effect
  46096. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  46097. };
  46098. /**
  46099. * Creates the render target textures and post processes used in the glow layer.
  46100. */
  46101. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  46102. var _this = this;
  46103. var blurTextureWidth = this._mainTextureDesiredSize.width;
  46104. var blurTextureHeight = this._mainTextureDesiredSize.height;
  46105. blurTextureWidth = this._engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_12__["Engine"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  46106. blurTextureHeight = this._engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_12__["Engine"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  46107. var textureType = 0;
  46108. if (this._engine.getCaps().textureHalfFloatRender) {
  46109. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  46110. }
  46111. else {
  46112. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  46113. }
  46114. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_5__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  46115. width: blurTextureWidth,
  46116. height: blurTextureHeight
  46117. }, this._scene, false, true, textureType);
  46118. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  46119. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  46120. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE);
  46121. this._blurTexture1.renderParticles = false;
  46122. this._blurTexture1.ignoreCameraViewport = true;
  46123. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  46124. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  46125. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_5__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  46126. width: blurTextureWidth2,
  46127. height: blurTextureHeight2
  46128. }, this._scene, false, true, textureType);
  46129. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  46130. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  46131. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE);
  46132. this._blurTexture2.renderParticles = false;
  46133. this._blurTexture2.ignoreCameraViewport = true;
  46134. this._textures = [this._blurTexture1, this._blurTexture2];
  46135. this._horizontalBlurPostprocess1 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_7__["BlurPostProcess"]("GlowLayerHBP1", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](1.0, 0), this._options.blurKernelSize / 2, {
  46136. width: blurTextureWidth,
  46137. height: blurTextureHeight
  46138. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  46139. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  46140. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  46141. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  46142. effect.setTexture("textureSampler", _this._mainTexture);
  46143. });
  46144. this._verticalBlurPostprocess1 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_7__["BlurPostProcess"]("GlowLayerVBP1", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 1.0), this._options.blurKernelSize / 2, {
  46145. width: blurTextureWidth,
  46146. height: blurTextureHeight
  46147. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  46148. this._horizontalBlurPostprocess2 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_7__["BlurPostProcess"]("GlowLayerHBP2", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](1.0, 0), this._options.blurKernelSize / 2, {
  46149. width: blurTextureWidth2,
  46150. height: blurTextureHeight2
  46151. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  46152. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  46153. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  46154. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  46155. effect.setTexture("textureSampler", _this._blurTexture1);
  46156. });
  46157. this._verticalBlurPostprocess2 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_7__["BlurPostProcess"]("GlowLayerVBP2", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 1.0), this._options.blurKernelSize / 2, {
  46158. width: blurTextureWidth2,
  46159. height: blurTextureHeight2
  46160. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  46161. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  46162. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  46163. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  46164. this._mainTexture.samples = this._options.mainTextureSamples;
  46165. this._mainTexture.onAfterUnbindObservable.add(function () {
  46166. var internalTexture = _this._blurTexture1.getInternalTexture();
  46167. if (internalTexture) {
  46168. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  46169. internalTexture = _this._blurTexture2.getInternalTexture();
  46170. if (internalTexture) {
  46171. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  46172. }
  46173. }
  46174. });
  46175. // Prevent autoClear.
  46176. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  46177. };
  46178. /**
  46179. * Checks for the readiness of the element composing the layer.
  46180. * @param subMesh the mesh to check for
  46181. * @param useInstances specify wether or not to use instances to render the mesh
  46182. * @param emissiveTexture the associated emissive texture used to generate the glow
  46183. * @return true if ready otherwise, false
  46184. */
  46185. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  46186. var material = subMesh.getMaterial();
  46187. var mesh = subMesh.getRenderingMesh();
  46188. if (!material || !mesh) {
  46189. return false;
  46190. }
  46191. var emissiveTexture = material.emissiveTexture;
  46192. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  46193. };
  46194. /**
  46195. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46196. */
  46197. GlowLayer.prototype.needStencil = function () {
  46198. return false;
  46199. };
  46200. /**
  46201. * Returns true if the mesh can be rendered, otherwise false.
  46202. * @param mesh The mesh to render
  46203. * @param material The material used on the mesh
  46204. * @returns true if it can be rendered otherwise false
  46205. */
  46206. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  46207. return true;
  46208. };
  46209. /**
  46210. * Implementation specific of rendering the generating effect on the main canvas.
  46211. * @param effect The effect used to render through
  46212. */
  46213. GlowLayer.prototype._internalRender = function (effect) {
  46214. // Texture
  46215. effect.setTexture("textureSampler", this._blurTexture1);
  46216. effect.setTexture("textureSampler2", this._blurTexture2);
  46217. effect.setFloat("offset", this._intensity);
  46218. // Cache
  46219. var engine = this._engine;
  46220. var previousStencilBuffer = engine.getStencilBuffer();
  46221. // Draw order
  46222. engine.setStencilBuffer(false);
  46223. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  46224. // Draw order
  46225. engine.setStencilBuffer(previousStencilBuffer);
  46226. };
  46227. /**
  46228. * Sets the required values for both the emissive texture and and the main color.
  46229. */
  46230. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  46231. var textureLevel = 1.0;
  46232. if (this.customEmissiveTextureSelector) {
  46233. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  46234. }
  46235. else {
  46236. if (material) {
  46237. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  46238. if (this._emissiveTextureAndColor.texture) {
  46239. textureLevel = this._emissiveTextureAndColor.texture.level;
  46240. }
  46241. }
  46242. else {
  46243. this._emissiveTextureAndColor.texture = null;
  46244. }
  46245. }
  46246. if (this.customEmissiveColorSelector) {
  46247. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  46248. }
  46249. else {
  46250. if (material.emissiveColor) {
  46251. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  46252. }
  46253. else {
  46254. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  46255. }
  46256. }
  46257. };
  46258. /**
  46259. * Returns true if the mesh should render, otherwise false.
  46260. * @param mesh The mesh to render
  46261. * @returns true if it should render otherwise false
  46262. */
  46263. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  46264. return this.hasMesh(mesh);
  46265. };
  46266. /**
  46267. * Adds specific effects defines.
  46268. * @param defines The defines to add specifics to.
  46269. */
  46270. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  46271. defines.push("#define GLOW");
  46272. };
  46273. /**
  46274. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46275. * @param mesh The mesh to exclude from the glow layer
  46276. */
  46277. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  46278. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  46279. this._excludedMeshes.push(mesh.uniqueId);
  46280. }
  46281. };
  46282. /**
  46283. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46284. * @param mesh The mesh to remove
  46285. */
  46286. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  46287. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  46288. if (index !== -1) {
  46289. this._excludedMeshes.splice(index, 1);
  46290. }
  46291. };
  46292. /**
  46293. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46294. * @param mesh The mesh to include in the glow layer
  46295. */
  46296. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  46297. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  46298. this._includedOnlyMeshes.push(mesh.uniqueId);
  46299. }
  46300. };
  46301. /**
  46302. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46303. * @param mesh The mesh to remove
  46304. */
  46305. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  46306. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  46307. if (index !== -1) {
  46308. this._includedOnlyMeshes.splice(index, 1);
  46309. }
  46310. };
  46311. /**
  46312. * Determine if a given mesh will be used in the glow layer
  46313. * @param mesh The mesh to test
  46314. * @returns true if the mesh will be highlighted by the current glow layer
  46315. */
  46316. GlowLayer.prototype.hasMesh = function (mesh) {
  46317. if (!_super.prototype.hasMesh.call(this, mesh)) {
  46318. return false;
  46319. }
  46320. // Included Mesh
  46321. if (this._includedOnlyMeshes.length) {
  46322. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  46323. }
  46324. // Excluded Mesh
  46325. if (this._excludedMeshes.length) {
  46326. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  46327. }
  46328. return true;
  46329. };
  46330. /**
  46331. * Free any resources and references associated to a mesh.
  46332. * Internal use
  46333. * @param mesh The mesh to free.
  46334. * @hidden
  46335. */
  46336. GlowLayer.prototype._disposeMesh = function (mesh) {
  46337. this.removeIncludedOnlyMesh(mesh);
  46338. this.removeExcludedMesh(mesh);
  46339. };
  46340. /**
  46341. * Gets the class name of the effect layer
  46342. * @returns the string with the class name of the effect layer
  46343. */
  46344. GlowLayer.prototype.getClassName = function () {
  46345. return "GlowLayer";
  46346. };
  46347. /**
  46348. * Serializes this glow layer
  46349. * @returns a serialized glow layer object
  46350. */
  46351. GlowLayer.prototype.serialize = function () {
  46352. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46353. serializationObject.customType = "BABYLON.GlowLayer";
  46354. var index;
  46355. // Included meshes
  46356. serializationObject.includedMeshes = [];
  46357. if (this._includedOnlyMeshes.length) {
  46358. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  46359. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  46360. if (mesh) {
  46361. serializationObject.includedMeshes.push(mesh.id);
  46362. }
  46363. }
  46364. }
  46365. // Excluded meshes
  46366. serializationObject.excludedMeshes = [];
  46367. if (this._excludedMeshes.length) {
  46368. for (index = 0; index < this._excludedMeshes.length; index++) {
  46369. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  46370. if (mesh) {
  46371. serializationObject.excludedMeshes.push(mesh.id);
  46372. }
  46373. }
  46374. }
  46375. return serializationObject;
  46376. };
  46377. /**
  46378. * Creates a Glow Layer from parsed glow layer data
  46379. * @param parsedGlowLayer defines glow layer data
  46380. * @param scene defines the current scene
  46381. * @param rootUrl defines the root URL containing the glow layer information
  46382. * @returns a parsed Glow Layer
  46383. */
  46384. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  46385. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  46386. var index;
  46387. // Excluded meshes
  46388. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  46389. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  46390. if (mesh) {
  46391. gl.addExcludedMesh(mesh);
  46392. }
  46393. }
  46394. // Included meshes
  46395. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  46396. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  46397. if (mesh) {
  46398. gl.addIncludedOnlyMesh(mesh);
  46399. }
  46400. }
  46401. return gl;
  46402. };
  46403. /**
  46404. * Effect Name of the layer.
  46405. */
  46406. GlowLayer.EffectName = "GlowLayer";
  46407. /**
  46408. * The default blur kernel size used for the glow.
  46409. */
  46410. GlowLayer.DefaultBlurKernelSize = 32;
  46411. /**
  46412. * The default texture size ratio used for the glow.
  46413. */
  46414. GlowLayer.DefaultTextureRatio = 0.5;
  46415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46417. ], GlowLayer.prototype, "blurKernelSize", null);
  46418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46420. ], GlowLayer.prototype, "intensity", null);
  46421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  46423. ], GlowLayer.prototype, "_options", void 0);
  46424. return GlowLayer;
  46425. }(_effectLayer__WEBPACK_IMPORTED_MODULE_8__["EffectLayer"]));
  46426. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_11__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  46427. /***/ }),
  46428. /***/ "./Layers/highlightLayer.ts":
  46429. /*!**********************************!*\
  46430. !*** ./Layers/highlightLayer.ts ***!
  46431. \**********************************/
  46432. /*! exports provided: HighlightLayer */
  46433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46434. "use strict";
  46435. __webpack_require__.r(__webpack_exports__);
  46436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  46437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46438. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46439. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  46440. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  46441. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  46442. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  46443. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  46444. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  46445. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  46446. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  46447. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  46448. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  46449. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  46450. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  46451. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  46452. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  46453. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46454. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  46455. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  46456. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  46457. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  46458. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  46459. for (var index = 0; index < this.effectLayers.length; index++) {
  46460. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  46461. return this.effectLayers[index];
  46462. }
  46463. }
  46464. return null;
  46465. };
  46466. /**
  46467. * Special Glow Blur post process only blurring the alpha channel
  46468. * It enforces keeping the most luminous color in the color channel.
  46469. */
  46470. var GlowBlurPostProcess = /** @class */ (function (_super) {
  46471. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  46472. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  46473. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  46474. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  46475. _this.direction = direction;
  46476. _this.kernel = kernel;
  46477. _this.onApplyObservable.add(function (effect) {
  46478. effect.setFloat2("screenSize", _this.width, _this.height);
  46479. effect.setVector2("direction", _this.direction);
  46480. effect.setFloat("blurWidth", _this.kernel);
  46481. });
  46482. return _this;
  46483. }
  46484. return GlowBlurPostProcess;
  46485. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  46486. /**
  46487. * The highlight layer Helps adding a glow effect around a mesh.
  46488. *
  46489. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46490. * glowy meshes to your scene.
  46491. *
  46492. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46493. */
  46494. var HighlightLayer = /** @class */ (function (_super) {
  46495. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  46496. /**
  46497. * Instantiates a new highlight Layer and references it to the scene..
  46498. * @param name The name of the layer
  46499. * @param scene The scene to use the layer in
  46500. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46501. */
  46502. function HighlightLayer(name, scene, options) {
  46503. var _this = _super.call(this, name, scene) || this;
  46504. _this.name = name;
  46505. /**
  46506. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46507. */
  46508. _this.innerGlow = true;
  46509. /**
  46510. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46511. */
  46512. _this.outerGlow = true;
  46513. /**
  46514. * An event triggered when the highlight layer is being blurred.
  46515. */
  46516. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  46517. /**
  46518. * An event triggered when the highlight layer has been blurred.
  46519. */
  46520. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  46521. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  46522. _this._meshes = {};
  46523. _this._excludedMeshes = {};
  46524. _this.neutralColor = HighlightLayer.NeutralColor;
  46525. // Warn on stencil
  46526. if (!_this._engine.isStencilEnable) {
  46527. _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 }");
  46528. }
  46529. // Adapt options
  46530. _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);
  46531. // Initialize the layer
  46532. _this._init({
  46533. alphaBlendingMode: _this._options.alphaBlendingMode,
  46534. camera: _this._options.camera,
  46535. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  46536. mainTextureRatio: _this._options.mainTextureRatio,
  46537. renderingGroupId: _this._options.renderingGroupId
  46538. });
  46539. // Do not render as long as no meshes have been added
  46540. _this._shouldRender = false;
  46541. return _this;
  46542. }
  46543. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  46544. /**
  46545. * Gets the horizontal size of the blur.
  46546. */
  46547. get: function () {
  46548. return this._horizontalBlurPostprocess.kernel;
  46549. },
  46550. /**
  46551. * Specifies the horizontal size of the blur.
  46552. */
  46553. set: function (value) {
  46554. this._horizontalBlurPostprocess.kernel = value;
  46555. },
  46556. enumerable: true,
  46557. configurable: true
  46558. });
  46559. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  46560. /**
  46561. * Gets the vertical size of the blur.
  46562. */
  46563. get: function () {
  46564. return this._verticalBlurPostprocess.kernel;
  46565. },
  46566. /**
  46567. * Specifies the vertical size of the blur.
  46568. */
  46569. set: function (value) {
  46570. this._verticalBlurPostprocess.kernel = value;
  46571. },
  46572. enumerable: true,
  46573. configurable: true
  46574. });
  46575. /**
  46576. * Get the effect name of the layer.
  46577. * @return The effect name
  46578. */
  46579. HighlightLayer.prototype.getEffectName = function () {
  46580. return HighlightLayer.EffectName;
  46581. };
  46582. /**
  46583. * Create the merge effect. This is the shader use to blit the information back
  46584. * to the main canvas at the end of the scene rendering.
  46585. */
  46586. HighlightLayer.prototype._createMergeEffect = function () {
  46587. // Effect
  46588. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  46589. };
  46590. /**
  46591. * Creates the render target textures and post processes used in the highlight layer.
  46592. */
  46593. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  46594. var _this = this;
  46595. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  46596. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  46597. blurTextureWidth = this._engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  46598. blurTextureHeight = this._engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  46599. var textureType = 0;
  46600. if (this._engine.getCaps().textureHalfFloatRender) {
  46601. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  46602. }
  46603. else {
  46604. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  46605. }
  46606. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  46607. width: blurTextureWidth,
  46608. height: blurTextureHeight
  46609. }, this._scene, false, true, textureType);
  46610. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  46611. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  46612. this._blurTexture.anisotropicFilteringLevel = 16;
  46613. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  46614. this._blurTexture.renderParticles = false;
  46615. this._blurTexture.ignoreCameraViewport = true;
  46616. this._textures = [this._blurTexture];
  46617. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  46618. 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());
  46619. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  46620. effect.setTexture("textureSampler", _this._mainTexture);
  46621. });
  46622. this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1.0, 0), this._options.blurHorizontalSize, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  46623. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  46624. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  46625. });
  46626. this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1.0), this._options.blurVerticalSize, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  46627. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  46628. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  46629. });
  46630. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  46631. }
  46632. else {
  46633. this._horizontalBlurPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"]("HighlightLayerHBP", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1.0, 0), this._options.blurHorizontalSize / 2, {
  46634. width: blurTextureWidth,
  46635. height: blurTextureHeight
  46636. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  46637. this._horizontalBlurPostprocess.width = blurTextureWidth;
  46638. this._horizontalBlurPostprocess.height = blurTextureHeight;
  46639. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  46640. effect.setTexture("textureSampler", _this._mainTexture);
  46641. });
  46642. this._verticalBlurPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"]("HighlightLayerVBP", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1.0), this._options.blurVerticalSize / 2, {
  46643. width: blurTextureWidth,
  46644. height: blurTextureHeight
  46645. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  46646. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  46647. }
  46648. this._mainTexture.onAfterUnbindObservable.add(function () {
  46649. _this.onBeforeBlurObservable.notifyObservers(_this);
  46650. var internalTexture = _this._blurTexture.getInternalTexture();
  46651. if (internalTexture) {
  46652. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  46653. }
  46654. _this.onAfterBlurObservable.notifyObservers(_this);
  46655. });
  46656. // Prevent autoClear.
  46657. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  46658. };
  46659. /**
  46660. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46661. */
  46662. HighlightLayer.prototype.needStencil = function () {
  46663. return true;
  46664. };
  46665. /**
  46666. * Checks for the readiness of the element composing the layer.
  46667. * @param subMesh the mesh to check for
  46668. * @param useInstances specify wether or not to use instances to render the mesh
  46669. * @param emissiveTexture the associated emissive texture used to generate the glow
  46670. * @return true if ready otherwise, false
  46671. */
  46672. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  46673. var material = subMesh.getMaterial();
  46674. var mesh = subMesh.getRenderingMesh();
  46675. if (!material || !mesh || !this._meshes) {
  46676. return false;
  46677. }
  46678. var emissiveTexture = null;
  46679. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  46680. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  46681. emissiveTexture = material.emissiveTexture;
  46682. }
  46683. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  46684. };
  46685. /**
  46686. * Implementation specific of rendering the generating effect on the main canvas.
  46687. * @param effect The effect used to render through
  46688. */
  46689. HighlightLayer.prototype._internalRender = function (effect) {
  46690. // Texture
  46691. effect.setTexture("textureSampler", this._blurTexture);
  46692. // Cache
  46693. var engine = this._engine;
  46694. engine.cacheStencilState();
  46695. // Stencil operations
  46696. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  46697. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  46698. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  46699. // Draw order
  46700. engine.setStencilMask(0x00);
  46701. engine.setStencilBuffer(true);
  46702. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  46703. // 2 passes inner outer
  46704. if (this.outerGlow) {
  46705. effect.setFloat("offset", 0);
  46706. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  46707. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  46708. }
  46709. if (this.innerGlow) {
  46710. effect.setFloat("offset", 1);
  46711. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  46712. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  46713. }
  46714. // Restore Cache
  46715. engine.restoreStencilState();
  46716. };
  46717. /**
  46718. * Returns true if the layer contains information to display, otherwise false.
  46719. */
  46720. HighlightLayer.prototype.shouldRender = function () {
  46721. if (_super.prototype.shouldRender.call(this)) {
  46722. return this._meshes ? true : false;
  46723. }
  46724. return false;
  46725. };
  46726. /**
  46727. * Returns true if the mesh should render, otherwise false.
  46728. * @param mesh The mesh to render
  46729. * @returns true if it should render otherwise false
  46730. */
  46731. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  46732. // Excluded Mesh
  46733. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  46734. return false;
  46735. }
  46736. if (!_super.prototype.hasMesh.call(this, mesh)) {
  46737. return false;
  46738. }
  46739. return true;
  46740. };
  46741. /**
  46742. * Sets the required values for both the emissive texture and and the main color.
  46743. */
  46744. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  46745. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  46746. if (highlightLayerMesh) {
  46747. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  46748. }
  46749. else {
  46750. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  46751. }
  46752. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  46753. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  46754. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  46755. }
  46756. else {
  46757. this._emissiveTextureAndColor.texture = null;
  46758. }
  46759. };
  46760. /**
  46761. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46762. * @param mesh The mesh to exclude from the highlight layer
  46763. */
  46764. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  46765. if (!this._excludedMeshes) {
  46766. return;
  46767. }
  46768. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  46769. if (!meshExcluded) {
  46770. this._excludedMeshes[mesh.uniqueId] = {
  46771. mesh: mesh,
  46772. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  46773. mesh.getEngine().setStencilBuffer(false);
  46774. }),
  46775. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  46776. mesh.getEngine().setStencilBuffer(true);
  46777. }),
  46778. };
  46779. }
  46780. };
  46781. /**
  46782. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46783. * @param mesh The mesh to highlight
  46784. */
  46785. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  46786. if (!this._excludedMeshes) {
  46787. return;
  46788. }
  46789. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  46790. if (meshExcluded) {
  46791. if (meshExcluded.beforeBind) {
  46792. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  46793. }
  46794. if (meshExcluded.afterRender) {
  46795. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  46796. }
  46797. }
  46798. this._excludedMeshes[mesh.uniqueId] = null;
  46799. };
  46800. /**
  46801. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46802. * @param mesh mesh to test
  46803. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46804. */
  46805. HighlightLayer.prototype.hasMesh = function (mesh) {
  46806. if (!this._meshes) {
  46807. return false;
  46808. }
  46809. if (!_super.prototype.hasMesh.call(this, mesh)) {
  46810. return false;
  46811. }
  46812. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  46813. };
  46814. /**
  46815. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46816. * @param mesh The mesh to highlight
  46817. * @param color The color of the highlight
  46818. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46819. */
  46820. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  46821. var _this = this;
  46822. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  46823. if (!this._meshes) {
  46824. return;
  46825. }
  46826. var meshHighlight = this._meshes[mesh.uniqueId];
  46827. if (meshHighlight) {
  46828. meshHighlight.color = color;
  46829. }
  46830. else {
  46831. this._meshes[mesh.uniqueId] = {
  46832. mesh: mesh,
  46833. color: color,
  46834. // Lambda required for capture due to Observable this context
  46835. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  46836. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  46837. _this._defaultStencilReference(mesh);
  46838. }
  46839. else {
  46840. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  46841. }
  46842. }),
  46843. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  46844. glowEmissiveOnly: glowEmissiveOnly
  46845. };
  46846. mesh.onDisposeObservable.add(function () {
  46847. _this._disposeMesh(mesh);
  46848. });
  46849. }
  46850. this._shouldRender = true;
  46851. };
  46852. /**
  46853. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46854. * @param mesh The mesh to highlight
  46855. */
  46856. HighlightLayer.prototype.removeMesh = function (mesh) {
  46857. if (!this._meshes) {
  46858. return;
  46859. }
  46860. var meshHighlight = this._meshes[mesh.uniqueId];
  46861. if (meshHighlight) {
  46862. if (meshHighlight.observerHighlight) {
  46863. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  46864. }
  46865. if (meshHighlight.observerDefault) {
  46866. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  46867. }
  46868. delete this._meshes[mesh.uniqueId];
  46869. }
  46870. this._shouldRender = false;
  46871. for (var meshHighlightToCheck in this._meshes) {
  46872. if (this._meshes[meshHighlightToCheck]) {
  46873. this._shouldRender = true;
  46874. break;
  46875. }
  46876. }
  46877. };
  46878. /**
  46879. * Force the stencil to the normal expected value for none glowing parts
  46880. */
  46881. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  46882. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  46883. };
  46884. /**
  46885. * Free any resources and references associated to a mesh.
  46886. * Internal use
  46887. * @param mesh The mesh to free.
  46888. * @hidden
  46889. */
  46890. HighlightLayer.prototype._disposeMesh = function (mesh) {
  46891. this.removeMesh(mesh);
  46892. this.removeExcludedMesh(mesh);
  46893. };
  46894. /**
  46895. * Dispose the highlight layer and free resources.
  46896. */
  46897. HighlightLayer.prototype.dispose = function () {
  46898. if (this._meshes) {
  46899. // Clean mesh references
  46900. for (var id in this._meshes) {
  46901. var meshHighlight = this._meshes[id];
  46902. if (meshHighlight && meshHighlight.mesh) {
  46903. if (meshHighlight.observerHighlight) {
  46904. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  46905. }
  46906. if (meshHighlight.observerDefault) {
  46907. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  46908. }
  46909. }
  46910. }
  46911. this._meshes = null;
  46912. }
  46913. if (this._excludedMeshes) {
  46914. for (var id in this._excludedMeshes) {
  46915. var meshHighlight = this._excludedMeshes[id];
  46916. if (meshHighlight) {
  46917. if (meshHighlight.beforeBind) {
  46918. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  46919. }
  46920. if (meshHighlight.afterRender) {
  46921. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  46922. }
  46923. }
  46924. }
  46925. this._excludedMeshes = null;
  46926. }
  46927. _super.prototype.dispose.call(this);
  46928. };
  46929. /**
  46930. * Gets the class name of the effect layer
  46931. * @returns the string with the class name of the effect layer
  46932. */
  46933. HighlightLayer.prototype.getClassName = function () {
  46934. return "HighlightLayer";
  46935. };
  46936. /**
  46937. * Serializes this Highlight layer
  46938. * @returns a serialized Highlight layer object
  46939. */
  46940. HighlightLayer.prototype.serialize = function () {
  46941. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46942. serializationObject.customType = "BABYLON.HighlightLayer";
  46943. // Highlighted meshes
  46944. serializationObject.meshes = [];
  46945. if (this._meshes) {
  46946. for (var m in this._meshes) {
  46947. var mesh = this._meshes[m];
  46948. if (mesh) {
  46949. serializationObject.meshes.push({
  46950. glowEmissiveOnly: mesh.glowEmissiveOnly,
  46951. color: mesh.color.asArray(),
  46952. meshId: mesh.mesh.id
  46953. });
  46954. }
  46955. }
  46956. }
  46957. // Excluded meshes
  46958. serializationObject.excludedMeshes = [];
  46959. if (this._excludedMeshes) {
  46960. for (var e in this._excludedMeshes) {
  46961. var excludedMesh = this._excludedMeshes[e];
  46962. if (excludedMesh) {
  46963. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  46964. }
  46965. }
  46966. }
  46967. return serializationObject;
  46968. };
  46969. /**
  46970. * Creates a Highlight layer from parsed Highlight layer data
  46971. * @param parsedHightlightLayer defines the Highlight layer data
  46972. * @param scene defines the current scene
  46973. * @param rootUrl defines the root URL containing the Highlight layer information
  46974. * @returns a parsed Highlight layer
  46975. */
  46976. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  46977. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  46978. var index;
  46979. // Excluded meshes
  46980. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  46981. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  46982. if (mesh) {
  46983. hl.addExcludedMesh(mesh);
  46984. }
  46985. }
  46986. // Included meshes
  46987. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  46988. var highlightedMesh = parsedHightlightLayer.meshes[index];
  46989. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  46990. if (mesh) {
  46991. hl.addMesh(mesh, _Maths_math_color__WEBPACK_IMPORTED_MODULE_17__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  46992. }
  46993. }
  46994. return hl;
  46995. };
  46996. /**
  46997. * Effect Name of the highlight layer.
  46998. */
  46999. HighlightLayer.EffectName = "HighlightLayer";
  47000. /**
  47001. * The neutral color used during the preparation of the glow effect.
  47002. * This is black by default as the blend operation is a blend operation.
  47003. */
  47004. HighlightLayer.NeutralColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_17__["Color4"](0, 0, 0, 0);
  47005. /**
  47006. * Stencil value used for glowing meshes.
  47007. */
  47008. HighlightLayer.GlowingMeshStencilReference = 0x02;
  47009. /**
  47010. * Stencil value used for the other meshes in the scene.
  47011. */
  47012. HighlightLayer.NormalMeshStencilReference = 0x01;
  47013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47015. ], HighlightLayer.prototype, "innerGlow", void 0);
  47016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47018. ], HighlightLayer.prototype, "outerGlow", void 0);
  47019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47021. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  47022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47024. ], HighlightLayer.prototype, "blurVerticalSize", null);
  47025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  47027. ], HighlightLayer.prototype, "_options", void 0);
  47028. return HighlightLayer;
  47029. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  47030. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  47031. /***/ }),
  47032. /***/ "./Layers/index.ts":
  47033. /*!*************************!*\
  47034. !*** ./Layers/index.ts ***!
  47035. \*************************/
  47036. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  47037. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47038. "use strict";
  47039. __webpack_require__.r(__webpack_exports__);
  47040. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  47041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  47042. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  47043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  47044. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  47045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  47046. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  47047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  47048. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  47049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  47050. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  47051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  47052. /***/ }),
  47053. /***/ "./Layers/layer.ts":
  47054. /*!*************************!*\
  47055. !*** ./Layers/layer.ts ***!
  47056. \*************************/
  47057. /*! exports provided: Layer */
  47058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47059. "use strict";
  47060. __webpack_require__.r(__webpack_exports__);
  47061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  47062. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  47063. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  47064. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  47065. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  47066. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  47067. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  47068. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  47069. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  47070. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  47071. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  47072. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  47073. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  47074. /**
  47075. * This represents a full screen 2d layer.
  47076. * This can be useful to display a picture in the background of your scene for instance.
  47077. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47078. */
  47079. var Layer = /** @class */ (function () {
  47080. /**
  47081. * Instantiates a new layer.
  47082. * This represents a full screen 2d layer.
  47083. * This can be useful to display a picture in the background of your scene for instance.
  47084. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47085. * @param name Define the name of the layer in the scene
  47086. * @param imgUrl Define the url of the texture to display in the layer
  47087. * @param scene Define the scene the layer belongs to
  47088. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47089. * @param color Defines a color for the layer
  47090. */
  47091. function Layer(
  47092. /**
  47093. * Define the name of the layer.
  47094. */
  47095. name, imgUrl, scene, isBackground, color) {
  47096. this.name = name;
  47097. /**
  47098. * Define the scale of the layer in order to zoom in out of the texture.
  47099. */
  47100. this.scale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  47101. /**
  47102. * Define an offset for the layer in order to shift the texture.
  47103. */
  47104. this.offset = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  47105. /**
  47106. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47107. */
  47108. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE;
  47109. /**
  47110. * Define a mask to restrict the layer to only some of the scene cameras.
  47111. */
  47112. this.layerMask = 0x0FFFFFFF;
  47113. /**
  47114. * Define the list of render target the layer is visible into.
  47115. */
  47116. this.renderTargetTextures = [];
  47117. /**
  47118. * Define if the layer is only used in renderTarget or if it also
  47119. * renders in the main frame buffer of the canvas.
  47120. */
  47121. this.renderOnlyInRenderTargetTextures = false;
  47122. this._vertexBuffers = {};
  47123. /**
  47124. * An event triggered when the layer is disposed.
  47125. */
  47126. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  47127. /**
  47128. * An event triggered before rendering the scene
  47129. */
  47130. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  47131. /**
  47132. * An event triggered after rendering the scene
  47133. */
  47134. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  47135. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true) : null;
  47136. this.isBackground = isBackground === undefined ? true : isBackground;
  47137. this.color = color === undefined ? new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](1, 1, 1, 1) : color;
  47138. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  47139. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_7__["SceneComponentConstants"].NAME_LAYER);
  47140. if (!layerComponent) {
  47141. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_8__["LayerSceneComponent"](this._scene);
  47142. this._scene._addComponent(layerComponent);
  47143. }
  47144. this._scene.layers.push(this);
  47145. var engine = this._scene.getEngine();
  47146. // VBO
  47147. var vertices = [];
  47148. vertices.push(1, 1);
  47149. vertices.push(-1, 1);
  47150. vertices.push(-1, -1);
  47151. vertices.push(1, -1);
  47152. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, false, false, 2);
  47153. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = vertexBuffer;
  47154. this._createIndexBuffer();
  47155. // Effects
  47156. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  47157. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  47158. }
  47159. Object.defineProperty(Layer.prototype, "onDispose", {
  47160. /**
  47161. * Back compatibility with callback before the onDisposeObservable existed.
  47162. * The set callback will be triggered when the layer has been disposed.
  47163. */
  47164. set: function (callback) {
  47165. if (this._onDisposeObserver) {
  47166. this.onDisposeObservable.remove(this._onDisposeObserver);
  47167. }
  47168. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  47169. },
  47170. enumerable: true,
  47171. configurable: true
  47172. });
  47173. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  47174. /**
  47175. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47176. * The set callback will be triggered just before rendering the layer.
  47177. */
  47178. set: function (callback) {
  47179. if (this._onBeforeRenderObserver) {
  47180. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  47181. }
  47182. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  47183. },
  47184. enumerable: true,
  47185. configurable: true
  47186. });
  47187. Object.defineProperty(Layer.prototype, "onAfterRender", {
  47188. /**
  47189. * Back compatibility with callback before the onAfterRenderObservable existed.
  47190. * The set callback will be triggered just after rendering the layer.
  47191. */
  47192. set: function (callback) {
  47193. if (this._onAfterRenderObserver) {
  47194. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  47195. }
  47196. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  47197. },
  47198. enumerable: true,
  47199. configurable: true
  47200. });
  47201. Layer.prototype._createIndexBuffer = function () {
  47202. var engine = this._scene.getEngine();
  47203. // Indices
  47204. var indices = [];
  47205. indices.push(0);
  47206. indices.push(1);
  47207. indices.push(2);
  47208. indices.push(0);
  47209. indices.push(2);
  47210. indices.push(3);
  47211. this._indexBuffer = engine.createIndexBuffer(indices);
  47212. };
  47213. /** @hidden */
  47214. Layer.prototype._rebuild = function () {
  47215. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  47216. if (vb) {
  47217. vb._rebuild();
  47218. }
  47219. this._createIndexBuffer();
  47220. };
  47221. /**
  47222. * Renders the layer in the scene.
  47223. */
  47224. Layer.prototype.render = function () {
  47225. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  47226. // Check
  47227. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  47228. return;
  47229. }
  47230. var engine = this._scene.getEngine();
  47231. this.onBeforeRenderObservable.notifyObservers(this);
  47232. // Render
  47233. engine.enableEffect(currentEffect);
  47234. engine.setState(false);
  47235. // Texture
  47236. currentEffect.setTexture("textureSampler", this.texture);
  47237. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  47238. // Color
  47239. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  47240. // Scale / offset
  47241. currentEffect.setVector2("offset", this.offset);
  47242. currentEffect.setVector2("scale", this.scale);
  47243. // VBOs
  47244. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  47245. // Draw order
  47246. if (!this.alphaTest) {
  47247. engine.setAlphaMode(this.alphaBlendingMode);
  47248. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  47249. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  47250. }
  47251. else {
  47252. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  47253. }
  47254. this.onAfterRenderObservable.notifyObservers(this);
  47255. };
  47256. /**
  47257. * Disposes and releases the associated ressources.
  47258. */
  47259. Layer.prototype.dispose = function () {
  47260. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  47261. if (vertexBuffer) {
  47262. vertexBuffer.dispose();
  47263. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  47264. }
  47265. if (this._indexBuffer) {
  47266. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  47267. this._indexBuffer = null;
  47268. }
  47269. if (this.texture) {
  47270. this.texture.dispose();
  47271. this.texture = null;
  47272. }
  47273. // Clean RTT list
  47274. this.renderTargetTextures = [];
  47275. // Remove from scene
  47276. var index = this._scene.layers.indexOf(this);
  47277. this._scene.layers.splice(index, 1);
  47278. // Callback
  47279. this.onDisposeObservable.notifyObservers(this);
  47280. this.onDisposeObservable.clear();
  47281. this.onAfterRenderObservable.clear();
  47282. this.onBeforeRenderObservable.clear();
  47283. };
  47284. return Layer;
  47285. }());
  47286. /***/ }),
  47287. /***/ "./Layers/layerSceneComponent.ts":
  47288. /*!***************************************!*\
  47289. !*** ./Layers/layerSceneComponent.ts ***!
  47290. \***************************************/
  47291. /*! exports provided: LayerSceneComponent */
  47292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47293. "use strict";
  47294. __webpack_require__.r(__webpack_exports__);
  47295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  47296. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  47297. /**
  47298. * Defines the layer scene component responsible to manage any layers
  47299. * in a given scene.
  47300. */
  47301. var LayerSceneComponent = /** @class */ (function () {
  47302. /**
  47303. * Creates a new instance of the component for the given scene
  47304. * @param scene Defines the scene to register the component in
  47305. */
  47306. function LayerSceneComponent(scene) {
  47307. /**
  47308. * The component name helpfull to identify the component in the list of scene components.
  47309. */
  47310. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  47311. this.scene = scene;
  47312. this._engine = scene.getEngine();
  47313. scene.layers = new Array();
  47314. }
  47315. /**
  47316. * Registers the component in a given scene
  47317. */
  47318. LayerSceneComponent.prototype.register = function () {
  47319. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  47320. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  47321. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  47322. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  47323. };
  47324. /**
  47325. * Rebuilds the elements related to this component in case of
  47326. * context lost for instance.
  47327. */
  47328. LayerSceneComponent.prototype.rebuild = function () {
  47329. var layers = this.scene.layers;
  47330. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  47331. var layer = layers_1[_i];
  47332. layer._rebuild();
  47333. }
  47334. };
  47335. /**
  47336. * Disposes the component and the associated ressources.
  47337. */
  47338. LayerSceneComponent.prototype.dispose = function () {
  47339. var layers = this.scene.layers;
  47340. while (layers.length) {
  47341. layers[0].dispose();
  47342. }
  47343. };
  47344. LayerSceneComponent.prototype._draw = function (predicate) {
  47345. var layers = this.scene.layers;
  47346. if (layers.length) {
  47347. this._engine.setDepthBuffer(false);
  47348. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  47349. var layer = layers_2[_i];
  47350. if (predicate(layer)) {
  47351. layer.render();
  47352. }
  47353. }
  47354. this._engine.setDepthBuffer(true);
  47355. }
  47356. };
  47357. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  47358. return !layer.renderOnlyInRenderTargetTextures &&
  47359. layer.isBackground === isBackground &&
  47360. ((layer.layerMask & cameraLayerMask) !== 0);
  47361. };
  47362. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  47363. var _this = this;
  47364. this._draw(function (layer) {
  47365. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  47366. });
  47367. };
  47368. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  47369. var _this = this;
  47370. this._draw(function (layer) {
  47371. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  47372. });
  47373. };
  47374. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  47375. return (layer.renderTargetTextures.length > 0) &&
  47376. layer.isBackground === isBackground &&
  47377. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  47378. ((layer.layerMask & cameraLayerMask) !== 0);
  47379. };
  47380. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  47381. var _this = this;
  47382. this._draw(function (layer) {
  47383. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  47384. });
  47385. };
  47386. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  47387. var _this = this;
  47388. this._draw(function (layer) {
  47389. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  47390. });
  47391. };
  47392. /**
  47393. * Adds all the elements from the container to the scene
  47394. * @param container the container holding the elements
  47395. */
  47396. LayerSceneComponent.prototype.addFromContainer = function (container) {
  47397. var _this = this;
  47398. if (!container.layers) {
  47399. return;
  47400. }
  47401. container.layers.forEach(function (layer) {
  47402. _this.scene.layers.push(layer);
  47403. });
  47404. };
  47405. /**
  47406. * Removes all the elements in the container from the scene
  47407. * @param container contains the elements to remove
  47408. * @param dispose if the removed element should be disposed (default: false)
  47409. */
  47410. LayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  47411. var _this = this;
  47412. if (dispose === void 0) { dispose = false; }
  47413. if (!container.layers) {
  47414. return;
  47415. }
  47416. container.layers.forEach(function (layer) {
  47417. var index = _this.scene.layers.indexOf(layer);
  47418. if (index !== -1) {
  47419. _this.scene.layers.splice(index, 1);
  47420. }
  47421. if (dispose) {
  47422. layer.dispose();
  47423. }
  47424. });
  47425. };
  47426. return LayerSceneComponent;
  47427. }());
  47428. /***/ }),
  47429. /***/ "./Legacy/legacy.ts":
  47430. /*!**************************!*\
  47431. !*** ./Legacy/legacy.ts ***!
  47432. \**************************/
  47433. /*! 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, 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, _MeshCollisionData, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, WebGLPipelineContext, WebGL2ShaderProcessor, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, PlaneDragGizmo, 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, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, EffectRenderer, EffectWrapper, Scalar, Space, Axis, Color3, Color4, TmpColors, ToGammaSpace, ToLinearSpace, Epsilon, Frustum, Plane, Size, Vector2, Vector3, Vector4, Quaternion, Matrix, TmpVectors, Viewport, SphericalHarmonics, SphericalPolynomial, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, MeshLODLevel, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DataBuffer, WebGLDataBuffer, 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, CubeMapToSphericalPolynomialTools, 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, Tools, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, BRDFTextureTools, ColorGradient, Color3Gradient, FactorGradient, GradientHelper, PerfCounter, RetryStrategy, LoadFileError, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRInput, WebXRControllerTeleportation, WebXRControllerPointerSelection, WebXRControllerModelLoader, WebXRController, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, NodeMaterialBlockTargets, NodeMaterialBlockConnectionPointTypes, NodeMaterialConnectionPoint, NodeMaterialBlock, NodeMaterialDefines, NodeMaterial, NodeMaterialWellKnownValues, Orientation, BezierCurve, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, DracoCompression, TiledBoxBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TiledPlaneBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, RecastJSPlugin, RecastJSCrowd, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, _BasisTextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, MultiplyBlock, AddBlock, ClampBlock, CrossBlock, DotBlock, TransformBlock, NodeMaterialOptimizer, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline, VertexOutputBlock, BonesBlock, InstancesBlock, MorphTargetsBlock, FragmentOutputBlock, AlphaTestBlock, ColorMergerBlock, VectorMergerBlock, ColorSplitterBlock, VectorSplitterBlock, ImageProcessingBlock, FogBlock, LightBlock, TextureBlock, InputBlock */
  47434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47435. "use strict";
  47436. __webpack_require__.r(__webpack_exports__);
  47437. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  47438. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  47439. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  47440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  47441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  47442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  47443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  47444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  47445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  47446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  47447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  47448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  47449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  47450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  47451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  47452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  47453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  47454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  47455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  47456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  47457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  47458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  47459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  47460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  47461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  47462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  47463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  47464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  47465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  47466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  47467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  47468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IAnimationState"]; });
  47469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  47470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  47471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  47472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  47473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  47474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  47475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  47476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  47477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  47478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  47479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  47480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  47481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  47482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  47483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  47484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  47485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  47486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  47487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  47488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  47489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  47490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  47491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  47492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  47493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  47494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  47495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  47496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  47497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  47498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  47499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  47500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  47501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  47502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  47503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  47504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  47505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  47506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  47507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  47508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  47509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  47510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  47511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  47512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  47513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  47514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  47515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  47516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  47517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  47518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  47519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  47520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  47521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_MeshCollisionData"]; });
  47522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  47523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  47524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  47525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  47526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  47527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  47528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  47529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  47530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  47531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  47532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  47533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  47534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  47535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  47536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  47537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  47538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  47539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  47540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebGLPipelineContext"]; });
  47541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGL2ShaderProcessor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebGL2ShaderProcessor"]; });
  47542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  47543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  47544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  47545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  47546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  47547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  47548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  47549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  47550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  47551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  47552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  47553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  47554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  47555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  47556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  47557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  47558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  47559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  47560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  47561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  47562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  47563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  47564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  47565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  47566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  47567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  47568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  47569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneDragGizmo"]; });
  47570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  47571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  47572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  47573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  47574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  47575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  47576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  47577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  47578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  47579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  47580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  47581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  47582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  47583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  47584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  47585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  47586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  47587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  47588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  47589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  47590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  47591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  47592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  47593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  47594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  47595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  47596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  47597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  47598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  47599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  47600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  47601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  47602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  47603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  47604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  47605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  47606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  47607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  47608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  47609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  47610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  47611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  47612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  47613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  47614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  47615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  47616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  47617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  47618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  47619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  47620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  47621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  47622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  47623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  47624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectRenderer"]; });
  47625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectWrapper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectWrapper"]; });
  47626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  47627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  47628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  47629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  47630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  47631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpColors", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TmpColors"]; });
  47632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  47633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  47634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  47635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  47636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  47637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  47638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  47639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  47640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  47641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  47642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  47643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpVectors", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"]; });
  47644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  47645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  47646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  47647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  47648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  47649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  47650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  47651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  47652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  47653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  47654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  47655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  47656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  47657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  47658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  47659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  47660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  47661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  47662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  47663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  47664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  47665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  47666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  47667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  47668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  47669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  47670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  47671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  47672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  47673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  47674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  47675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  47676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  47677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  47678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  47679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DataBuffer"]; });
  47680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebGLDataBuffer"]; });
  47681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  47682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  47683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  47684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  47685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  47686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  47687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  47688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  47689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  47690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  47691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  47692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  47693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  47694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  47695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  47696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  47697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  47698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  47699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  47700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  47701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  47702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  47703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  47704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  47705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  47706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  47707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  47708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  47709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  47710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  47711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  47712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  47713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  47714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  47715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  47716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  47717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  47718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  47719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  47720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  47721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  47722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  47723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  47724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  47725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  47726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  47727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  47728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  47729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  47730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  47731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  47732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  47733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  47734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  47735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  47736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  47737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  47738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  47739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  47740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  47741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  47742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  47743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  47744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleviewPostProcess"]; });
  47745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  47746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  47747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  47748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  47749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  47750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  47751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  47752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  47753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  47754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  47755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  47756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  47757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  47758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  47759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  47760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  47761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  47762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  47763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  47764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  47765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  47766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  47767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  47768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  47769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  47770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  47771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  47772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  47773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  47774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  47775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTextureAssetTask"]; });
  47776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  47777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  47778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  47779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  47780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  47781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  47782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  47783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  47784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  47785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  47786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  47787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  47788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  47789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  47790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  47791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  47792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  47793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  47794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  47795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  47796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  47797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  47798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  47799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  47800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  47801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  47802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  47803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  47804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  47805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  47806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  47807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  47808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  47809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  47810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  47811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  47812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  47813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  47814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  47815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  47816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  47817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  47818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  47819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  47820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  47821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  47822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  47823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  47824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  47825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  47826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  47827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  47828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  47829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  47830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  47831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  47832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  47833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  47834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  47835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  47836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  47837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  47838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  47839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  47840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  47841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BRDFTextureTools"]; });
  47842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  47843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  47844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  47845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GradientHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GradientHelper"]; });
  47846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  47847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  47848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  47849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  47850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  47851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  47852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  47853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  47854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  47855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  47856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  47857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  47858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  47859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  47860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  47861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  47862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  47863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  47864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  47865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  47866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  47867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  47868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  47869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  47870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  47871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  47872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  47873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  47874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  47875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  47876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  47877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  47878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  47879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  47880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  47881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  47882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  47883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  47884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  47885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  47886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  47887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  47888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  47889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  47890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  47891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  47892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  47893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  47894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  47895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerTeleportation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRControllerTeleportation"]; });
  47896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerPointerSelection", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRControllerPointerSelection"]; });
  47897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerModelLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRControllerModelLoader"]; });
  47898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  47899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  47900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  47901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  47902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  47903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  47904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  47905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  47906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  47907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  47908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  47909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  47910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  47911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  47912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  47913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  47914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  47915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  47916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  47917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  47918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  47919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  47920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  47921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  47922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  47923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  47924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  47925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  47926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  47927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  47928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  47929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  47930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  47931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HtmlElementTexture"]; });
  47932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockTargets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockTargets"]; });
  47933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockConnectionPointTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"]; });
  47934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialConnectionPoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialConnectionPoint"]; });
  47935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlock"]; });
  47936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialDefines"]; });
  47937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterial"]; });
  47938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialWellKnownValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialWellKnownValues"]; });
  47939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  47940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  47941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  47942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  47943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  47944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  47945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  47946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  47947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  47948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  47949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledBoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TiledBoxBuilder"]; });
  47950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  47951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  47952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphereBuilder"]; });
  47953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  47954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  47955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  47956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  47957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledPlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TiledPlaneBuilder"]; });
  47958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  47959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  47960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  47961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  47962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RecastJSPlugin"]; });
  47963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSCrowd", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RecastJSCrowd"]; });
  47964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  47965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  47966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  47967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  47968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  47969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  47970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  47971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  47972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  47973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  47974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  47975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  47976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  47977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  47978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  47979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  47980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  47981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  47982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  47983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  47984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  47985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BasisTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BasisTextureLoader"]; });
  47986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  47987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  47988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  47989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  47990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiplyBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiplyBlock"]; });
  47991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AddBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AddBlock"]; });
  47992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClampBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClampBlock"]; });
  47993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CrossBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CrossBlock"]; });
  47994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DotBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DotBlock"]; });
  47995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformBlock"]; });
  47996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialOptimizer"]; });
  47997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  47998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  47999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  48000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  48001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  48002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexOutputBlock"]; });
  48003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BonesBlock"]; });
  48004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancesBlock"]; });
  48005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetsBlock"]; });
  48006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FragmentOutputBlock"]; });
  48007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AlphaTestBlock"]; });
  48008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorMergerBlock"]; });
  48009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VectorMergerBlock"]; });
  48010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorSplitterBlock"]; });
  48011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VectorSplitterBlock"]; });
  48012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingBlock"]; });
  48013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FogBlock"]; });
  48014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightBlock"]; });
  48015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureBlock"]; });
  48016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputBlock"]; });
  48017. /**
  48018. * Legacy support, defining window.BABYLON (global variable).
  48019. *
  48020. * This is the entry point for the UMD module.
  48021. * The entry point for a future ESM package should be index.ts
  48022. */
  48023. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  48024. if (typeof globalObject !== "undefined") {
  48025. globalObject.BABYLON = BABYLON;
  48026. globalObject.BABYLON = globalObject.BABYLON || {};
  48027. var BABYLON = globalObject.BABYLON;
  48028. BABYLON.Debug = BABYLON.Debug || {};
  48029. var keys = [];
  48030. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  48031. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  48032. keys.push(key);
  48033. }
  48034. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  48035. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  48036. }
  48037. }
  48038. var Debug = {
  48039. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  48040. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  48041. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  48042. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  48043. };
  48044. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  48045. /***/ }),
  48046. /***/ "./LensFlares/index.ts":
  48047. /*!*****************************!*\
  48048. !*** ./LensFlares/index.ts ***!
  48049. \*****************************/
  48050. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  48051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48052. "use strict";
  48053. __webpack_require__.r(__webpack_exports__);
  48054. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  48055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  48056. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  48057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  48058. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  48059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  48060. /***/ }),
  48061. /***/ "./LensFlares/lensFlare.ts":
  48062. /*!*********************************!*\
  48063. !*** ./LensFlares/lensFlare.ts ***!
  48064. \*********************************/
  48065. /*! exports provided: LensFlare */
  48066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48067. "use strict";
  48068. __webpack_require__.r(__webpack_exports__);
  48069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  48070. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  48071. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  48072. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48073. /**
  48074. * This represents one of the lens effect in a `lensFlareSystem`.
  48075. * It controls one of the indiviual texture used in the effect.
  48076. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48077. */
  48078. var LensFlare = /** @class */ (function () {
  48079. /**
  48080. * Instantiates a new Lens Flare.
  48081. * This represents one of the lens effect in a `lensFlareSystem`.
  48082. * It controls one of the indiviual texture used in the effect.
  48083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48084. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48085. * @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.
  48086. * @param color Define the lens color
  48087. * @param imgUrl Define the lens texture url
  48088. * @param system Define the `lensFlareSystem` this flare is part of
  48089. */
  48090. function LensFlare(
  48091. /**
  48092. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48093. */
  48094. size,
  48095. /**
  48096. * 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.
  48097. */
  48098. position, color, imgUrl, system) {
  48099. this.size = size;
  48100. this.position = position;
  48101. /**
  48102. * Define the alpha mode to render this particular lens.
  48103. */
  48104. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  48105. this.color = color || new _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  48106. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  48107. this._system = system;
  48108. system.lensFlares.push(this);
  48109. }
  48110. /**
  48111. * Creates a new Lens Flare.
  48112. * This represents one of the lens effect in a `lensFlareSystem`.
  48113. * It controls one of the indiviual texture used in the effect.
  48114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48115. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48116. * @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.
  48117. * @param color Define the lens color
  48118. * @param imgUrl Define the lens texture url
  48119. * @param system Define the `lensFlareSystem` this flare is part of
  48120. * @returns The newly created Lens Flare
  48121. */
  48122. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  48123. return new LensFlare(size, position, color, imgUrl, system);
  48124. };
  48125. /**
  48126. * Dispose and release the lens flare with its associated resources.
  48127. */
  48128. LensFlare.prototype.dispose = function () {
  48129. if (this.texture) {
  48130. this.texture.dispose();
  48131. }
  48132. // Remove from scene
  48133. var index = this._system.lensFlares.indexOf(this);
  48134. this._system.lensFlares.splice(index, 1);
  48135. };
  48136. return LensFlare;
  48137. }());
  48138. /***/ }),
  48139. /***/ "./LensFlares/lensFlareSystem.ts":
  48140. /*!***************************************!*\
  48141. !*** ./LensFlares/lensFlareSystem.ts ***!
  48142. \***************************************/
  48143. /*! exports provided: LensFlareSystem */
  48144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48145. "use strict";
  48146. __webpack_require__.r(__webpack_exports__);
  48147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  48148. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48149. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  48150. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  48151. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48152. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  48153. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  48154. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  48155. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  48156. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48157. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  48158. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  48159. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  48160. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  48161. /**
  48162. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48163. * It is usually composed of several `lensFlare`.
  48164. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48165. */
  48166. var LensFlareSystem = /** @class */ (function () {
  48167. /**
  48168. * Instantiates a lens flare system.
  48169. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48170. * It is usually composed of several `lensFlare`.
  48171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48172. * @param name Define the name of the lens flare system in the scene
  48173. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48174. * @param scene Define the scene the lens flare system belongs to
  48175. */
  48176. function LensFlareSystem(
  48177. /**
  48178. * Define the name of the lens flare system
  48179. */
  48180. name, emitter, scene) {
  48181. this.name = name;
  48182. /**
  48183. * List of lens flares used in this system.
  48184. */
  48185. this.lensFlares = new Array();
  48186. /**
  48187. * Define a limit from the border the lens flare can be visible.
  48188. */
  48189. this.borderLimit = 300;
  48190. /**
  48191. * Define a viewport border we do not want to see the lens flare in.
  48192. */
  48193. this.viewportBorder = 0;
  48194. /**
  48195. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48196. */
  48197. this.layerMask = 0x0FFFFFFF;
  48198. this._vertexBuffers = {};
  48199. this._isEnabled = true;
  48200. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  48201. LensFlareSystem._SceneComponentInitialization(this._scene);
  48202. this._emitter = emitter;
  48203. this.id = name;
  48204. scene.lensFlareSystems.push(this);
  48205. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  48206. var engine = scene.getEngine();
  48207. // VBO
  48208. var vertices = [];
  48209. vertices.push(1, 1);
  48210. vertices.push(-1, 1);
  48211. vertices.push(-1, -1);
  48212. vertices.push(1, -1);
  48213. 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);
  48214. // Indices
  48215. var indices = [];
  48216. indices.push(0);
  48217. indices.push(1);
  48218. indices.push(2);
  48219. indices.push(0);
  48220. indices.push(2);
  48221. indices.push(3);
  48222. this._indexBuffer = engine.createIndexBuffer(indices);
  48223. // Effects
  48224. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  48225. }
  48226. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  48227. /**
  48228. * Define if the lens flare system is enabled.
  48229. */
  48230. get: function () {
  48231. return this._isEnabled;
  48232. },
  48233. set: function (value) {
  48234. this._isEnabled = value;
  48235. },
  48236. enumerable: true,
  48237. configurable: true
  48238. });
  48239. /**
  48240. * Get the scene the effects belongs to.
  48241. * @returns the scene holding the lens flare system
  48242. */
  48243. LensFlareSystem.prototype.getScene = function () {
  48244. return this._scene;
  48245. };
  48246. /**
  48247. * Get the emitter of the lens flare system.
  48248. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48249. * @returns the emitter of the lens flare system
  48250. */
  48251. LensFlareSystem.prototype.getEmitter = function () {
  48252. return this._emitter;
  48253. };
  48254. /**
  48255. * Set the emitter of the lens flare system.
  48256. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48257. * @param newEmitter Define the new emitter of the system
  48258. */
  48259. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  48260. this._emitter = newEmitter;
  48261. };
  48262. /**
  48263. * Get the lens flare system emitter position.
  48264. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48265. * @returns the position
  48266. */
  48267. LensFlareSystem.prototype.getEmitterPosition = function () {
  48268. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  48269. };
  48270. /**
  48271. * @hidden
  48272. */
  48273. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  48274. var position = this.getEmitterPosition();
  48275. position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  48276. this._positionX = position.x;
  48277. this._positionY = position.y;
  48278. position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  48279. if (this.viewportBorder > 0) {
  48280. globalViewport.x -= this.viewportBorder;
  48281. globalViewport.y -= this.viewportBorder;
  48282. globalViewport.width += this.viewportBorder * 2;
  48283. globalViewport.height += this.viewportBorder * 2;
  48284. position.x += this.viewportBorder;
  48285. position.y += this.viewportBorder;
  48286. this._positionX += this.viewportBorder;
  48287. this._positionY += this.viewportBorder;
  48288. }
  48289. if (position.z > 0) {
  48290. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  48291. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  48292. return true;
  48293. }
  48294. }
  48295. return true;
  48296. }
  48297. return false;
  48298. };
  48299. /** @hidden */
  48300. LensFlareSystem.prototype._isVisible = function () {
  48301. if (!this._isEnabled || !this._scene.activeCamera) {
  48302. return false;
  48303. }
  48304. var emitterPosition = this.getEmitterPosition();
  48305. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  48306. var distance = direction.length();
  48307. direction.normalize();
  48308. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  48309. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  48310. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  48311. };
  48312. /**
  48313. * @hidden
  48314. */
  48315. LensFlareSystem.prototype.render = function () {
  48316. if (!this._effect.isReady() || !this._scene.activeCamera) {
  48317. return false;
  48318. }
  48319. var engine = this._scene.getEngine();
  48320. var viewport = this._scene.activeCamera.viewport;
  48321. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  48322. // Position
  48323. if (!this.computeEffectivePosition(globalViewport)) {
  48324. return false;
  48325. }
  48326. // Visibility
  48327. if (!this._isVisible()) {
  48328. return false;
  48329. }
  48330. // Intensity
  48331. var awayX;
  48332. var awayY;
  48333. if (this._positionX < this.borderLimit + globalViewport.x) {
  48334. awayX = this.borderLimit + globalViewport.x - this._positionX;
  48335. }
  48336. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  48337. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  48338. }
  48339. else {
  48340. awayX = 0;
  48341. }
  48342. if (this._positionY < this.borderLimit + globalViewport.y) {
  48343. awayY = this.borderLimit + globalViewport.y - this._positionY;
  48344. }
  48345. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  48346. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  48347. }
  48348. else {
  48349. awayY = 0;
  48350. }
  48351. var away = (awayX > awayY) ? awayX : awayY;
  48352. away -= this.viewportBorder;
  48353. if (away > this.borderLimit) {
  48354. away = this.borderLimit;
  48355. }
  48356. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  48357. if (intensity < 0) {
  48358. return false;
  48359. }
  48360. if (intensity > 1.0) {
  48361. intensity = 1.0;
  48362. }
  48363. if (this.viewportBorder > 0) {
  48364. globalViewport.x += this.viewportBorder;
  48365. globalViewport.y += this.viewportBorder;
  48366. globalViewport.width -= this.viewportBorder * 2;
  48367. globalViewport.height -= this.viewportBorder * 2;
  48368. this._positionX -= this.viewportBorder;
  48369. this._positionY -= this.viewportBorder;
  48370. }
  48371. // Position
  48372. var centerX = globalViewport.x + globalViewport.width / 2;
  48373. var centerY = globalViewport.y + globalViewport.height / 2;
  48374. var distX = centerX - this._positionX;
  48375. var distY = centerY - this._positionY;
  48376. // Effects
  48377. engine.enableEffect(this._effect);
  48378. engine.setState(false);
  48379. engine.setDepthBuffer(false);
  48380. // VBOs
  48381. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  48382. // Flares
  48383. for (var index = 0; index < this.lensFlares.length; index++) {
  48384. var flare = this.lensFlares[index];
  48385. if (flare.texture && !flare.texture.isReady()) {
  48386. continue;
  48387. }
  48388. engine.setAlphaMode(flare.alphaMode);
  48389. var x = centerX - (distX * flare.position);
  48390. var y = centerY - (distY * flare.position);
  48391. var cw = flare.size;
  48392. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  48393. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  48394. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  48395. var viewportMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromValues(cw / 2, 0, 0, 0, 0, ch / 2, 0, 0, 0, 0, 1, 0, cx, cy, 0, 1);
  48396. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  48397. // Texture
  48398. this._effect.setTexture("textureSampler", flare.texture);
  48399. // Color
  48400. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  48401. // Draw order
  48402. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  48403. }
  48404. engine.setDepthBuffer(true);
  48405. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  48406. return true;
  48407. };
  48408. /**
  48409. * Dispose and release the lens flare with its associated resources.
  48410. */
  48411. LensFlareSystem.prototype.dispose = function () {
  48412. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  48413. if (vertexBuffer) {
  48414. vertexBuffer.dispose();
  48415. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  48416. }
  48417. if (this._indexBuffer) {
  48418. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  48419. this._indexBuffer = null;
  48420. }
  48421. while (this.lensFlares.length) {
  48422. this.lensFlares[0].dispose();
  48423. }
  48424. // Remove from scene
  48425. var index = this._scene.lensFlareSystems.indexOf(this);
  48426. this._scene.lensFlareSystems.splice(index, 1);
  48427. };
  48428. /**
  48429. * Parse a lens flare system from a JSON repressentation
  48430. * @param parsedLensFlareSystem Define the JSON to parse
  48431. * @param scene Define the scene the parsed system should be instantiated in
  48432. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48433. * @returns the parsed system
  48434. */
  48435. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  48436. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  48437. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  48438. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  48439. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  48440. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  48441. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  48442. var parsedFlare = parsedLensFlareSystem.flares[index];
  48443. _lensFlare__WEBPACK_IMPORTED_MODULE_7__["LensFlare"].AddFlare(parsedFlare.size, parsedFlare.position, _Maths_math_color__WEBPACK_IMPORTED_MODULE_12__["Color3"].FromArray(parsedFlare.color), parsedFlare.textureName ? rootUrl + parsedFlare.textureName : "", lensFlareSystem);
  48444. }
  48445. return lensFlareSystem;
  48446. };
  48447. /**
  48448. * Serialize the current Lens Flare System into a JSON representation.
  48449. * @returns the serialized JSON
  48450. */
  48451. LensFlareSystem.prototype.serialize = function () {
  48452. var serializationObject = {};
  48453. serializationObject.id = this.id;
  48454. serializationObject.name = this.name;
  48455. serializationObject.emitterId = this.getEmitter().id;
  48456. serializationObject.borderLimit = this.borderLimit;
  48457. serializationObject.flares = [];
  48458. for (var index = 0; index < this.lensFlares.length; index++) {
  48459. var flare = this.lensFlares[index];
  48460. serializationObject.flares.push({
  48461. size: flare.size,
  48462. position: flare.position,
  48463. color: flare.color.asArray(),
  48464. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  48465. });
  48466. }
  48467. return serializationObject;
  48468. };
  48469. /** @hidden */
  48470. LensFlareSystem._SceneComponentInitialization = function (_) {
  48471. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  48472. };
  48473. return LensFlareSystem;
  48474. }());
  48475. /***/ }),
  48476. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  48477. /*!*****************************************************!*\
  48478. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  48479. \*****************************************************/
  48480. /*! exports provided: LensFlareSystemSceneComponent */
  48481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48482. "use strict";
  48483. __webpack_require__.r(__webpack_exports__);
  48484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  48485. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48486. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  48487. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  48488. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  48489. // Adds the parser to the scene parsers.
  48490. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  48491. // Lens flares
  48492. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  48493. if (!container.lensFlareSystems) {
  48494. container.lensFlareSystems = new Array();
  48495. }
  48496. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  48497. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  48498. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  48499. container.lensFlareSystems.push(lf);
  48500. }
  48501. }
  48502. });
  48503. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  48504. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  48505. if (this.lensFlareSystems[index].name === name) {
  48506. return this.lensFlareSystems[index];
  48507. }
  48508. }
  48509. return null;
  48510. };
  48511. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  48512. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  48513. if (this.lensFlareSystems[index].id === id) {
  48514. return this.lensFlareSystems[index];
  48515. }
  48516. }
  48517. return null;
  48518. };
  48519. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  48520. var index = this.lensFlareSystems.indexOf(toRemove);
  48521. if (index !== -1) {
  48522. this.lensFlareSystems.splice(index, 1);
  48523. }
  48524. return index;
  48525. };
  48526. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  48527. this.lensFlareSystems.push(newLensFlareSystem);
  48528. };
  48529. /**
  48530. * Defines the lens flare scene component responsible to manage any lens flares
  48531. * in a given scene.
  48532. */
  48533. var LensFlareSystemSceneComponent = /** @class */ (function () {
  48534. /**
  48535. * Creates a new instance of the component for the given scene
  48536. * @param scene Defines the scene to register the component in
  48537. */
  48538. function LensFlareSystemSceneComponent(scene) {
  48539. /**
  48540. * The component name helpfull to identify the component in the list of scene components.
  48541. */
  48542. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  48543. this.scene = scene;
  48544. scene.lensFlareSystems = new Array();
  48545. }
  48546. /**
  48547. * Registers the component in a given scene
  48548. */
  48549. LensFlareSystemSceneComponent.prototype.register = function () {
  48550. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  48551. };
  48552. /**
  48553. * Rebuilds the elements related to this component in case of
  48554. * context lost for instance.
  48555. */
  48556. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  48557. // Nothing to do for lens flare
  48558. };
  48559. /**
  48560. * Adds all the elements from the container to the scene
  48561. * @param container the container holding the elements
  48562. */
  48563. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  48564. var _this = this;
  48565. if (!container.lensFlareSystems) {
  48566. return;
  48567. }
  48568. container.lensFlareSystems.forEach(function (o) {
  48569. _this.scene.addLensFlareSystem(o);
  48570. });
  48571. };
  48572. /**
  48573. * Removes all the elements in the container from the scene
  48574. * @param container contains the elements to remove
  48575. * @param dispose if the removed element should be disposed (default: false)
  48576. */
  48577. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  48578. var _this = this;
  48579. if (!container.lensFlareSystems) {
  48580. return;
  48581. }
  48582. container.lensFlareSystems.forEach(function (o) {
  48583. _this.scene.removeLensFlareSystem(o);
  48584. if (dispose) {
  48585. o.dispose();
  48586. }
  48587. });
  48588. };
  48589. /**
  48590. * Serializes the component data to the specified json object
  48591. * @param serializationObject The object to serialize to
  48592. */
  48593. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  48594. // Lens flares
  48595. serializationObject.lensFlareSystems = [];
  48596. var lensFlareSystems = this.scene.lensFlareSystems;
  48597. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  48598. var lensFlareSystem = lensFlareSystems_1[_i];
  48599. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  48600. }
  48601. };
  48602. /**
  48603. * Disposes the component and the associated ressources.
  48604. */
  48605. LensFlareSystemSceneComponent.prototype.dispose = function () {
  48606. var lensFlareSystems = this.scene.lensFlareSystems;
  48607. while (lensFlareSystems.length) {
  48608. lensFlareSystems[0].dispose();
  48609. }
  48610. };
  48611. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  48612. // Lens flares
  48613. if (this.scene.lensFlaresEnabled) {
  48614. var lensFlareSystems = this.scene.lensFlareSystems;
  48615. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  48616. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  48617. var lensFlareSystem = lensFlareSystems_2[_i];
  48618. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  48619. lensFlareSystem.render();
  48620. }
  48621. }
  48622. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  48623. }
  48624. };
  48625. return LensFlareSystemSceneComponent;
  48626. }());
  48627. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  48628. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  48629. if (!component) {
  48630. component = new LensFlareSystemSceneComponent(scene);
  48631. scene._addComponent(component);
  48632. }
  48633. };
  48634. /***/ }),
  48635. /***/ "./Lights/Shadows/index.ts":
  48636. /*!*********************************!*\
  48637. !*** ./Lights/Shadows/index.ts ***!
  48638. \*********************************/
  48639. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  48640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48641. "use strict";
  48642. __webpack_require__.r(__webpack_exports__);
  48643. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  48644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  48645. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  48646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  48647. /***/ }),
  48648. /***/ "./Lights/Shadows/shadowGenerator.ts":
  48649. /*!*******************************************!*\
  48650. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  48651. \*******************************************/
  48652. /*! exports provided: ShadowGenerator */
  48653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48654. "use strict";
  48655. __webpack_require__.r(__webpack_exports__);
  48656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  48657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48658. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  48659. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  48660. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  48661. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48662. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48663. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  48664. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  48665. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  48666. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  48667. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  48668. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  48669. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  48670. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  48671. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  48672. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  48673. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  48674. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  48675. /**
  48676. * Default implementation IShadowGenerator.
  48677. * This is the main object responsible of generating shadows in the framework.
  48678. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  48679. */
  48680. var ShadowGenerator = /** @class */ (function () {
  48681. /**
  48682. * Creates a ShadowGenerator object.
  48683. * A ShadowGenerator is the required tool to use the shadows.
  48684. * Each light casting shadows needs to use its own ShadowGenerator.
  48685. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  48686. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  48687. * @param light The light object generating the shadows.
  48688. * @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.
  48689. */
  48690. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  48691. /**
  48692. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  48693. */
  48694. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_16__["Observable"]();
  48695. /**
  48696. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  48697. */
  48698. this.onAfterShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_16__["Observable"]();
  48699. /**
  48700. * Observable triggered before a mesh is rendered in the shadow map.
  48701. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  48702. */
  48703. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_16__["Observable"]();
  48704. /**
  48705. * Observable triggered after a mesh is rendered in the shadow map.
  48706. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  48707. */
  48708. this.onAfterShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_16__["Observable"]();
  48709. this._bias = 0.00005;
  48710. this._normalBias = 0;
  48711. this._blurBoxOffset = 1;
  48712. this._blurScale = 2;
  48713. this._blurKernel = 1;
  48714. this._useKernelBlur = false;
  48715. this._filter = ShadowGenerator.FILTER_NONE;
  48716. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  48717. this._contactHardeningLightSizeUVRatio = 0.1;
  48718. this._darkness = 0;
  48719. this._transparencyShadow = false;
  48720. /**
  48721. * Controls the extent to which the shadows fade out at the edge of the frustum
  48722. * Used only by directionals and spots
  48723. */
  48724. this.frustumEdgeFalloff = 0;
  48725. /**
  48726. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  48727. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  48728. * It might on the other hand introduce peter panning.
  48729. */
  48730. this.forceBackFacesOnly = false;
  48731. this._lightDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  48732. this._viewMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  48733. this._projectionMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  48734. this._transformMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  48735. this._cachedPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  48736. this._cachedDirection = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  48737. this._currentFaceIndex = 0;
  48738. this._currentFaceIndexCache = 0;
  48739. this._defaultTextureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  48740. this._mapSize = mapSize;
  48741. this._light = light;
  48742. this._scene = light.getScene();
  48743. light._shadowGenerator = this;
  48744. ShadowGenerator._SceneComponentInitialization(this._scene);
  48745. // Texture type fallback from float to int if not supported.
  48746. var caps = this._scene.getEngine().getCaps();
  48747. if (!usefulFloatFirst) {
  48748. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  48749. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_HALF_FLOAT;
  48750. }
  48751. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  48752. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT;
  48753. }
  48754. else {
  48755. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  48756. }
  48757. }
  48758. else {
  48759. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  48760. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT;
  48761. }
  48762. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  48763. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_HALF_FLOAT;
  48764. }
  48765. else {
  48766. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  48767. }
  48768. }
  48769. this._initializeGenerator();
  48770. this._applyFilterValues();
  48771. }
  48772. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  48773. /**
  48774. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  48775. */
  48776. get: function () {
  48777. return this._bias;
  48778. },
  48779. /**
  48780. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  48781. */
  48782. set: function (bias) {
  48783. this._bias = bias;
  48784. },
  48785. enumerable: true,
  48786. configurable: true
  48787. });
  48788. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  48789. /**
  48790. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  48791. */
  48792. get: function () {
  48793. return this._normalBias;
  48794. },
  48795. /**
  48796. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  48797. */
  48798. set: function (normalBias) {
  48799. this._normalBias = normalBias;
  48800. },
  48801. enumerable: true,
  48802. configurable: true
  48803. });
  48804. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  48805. /**
  48806. * Gets the blur box offset: offset applied during the blur pass.
  48807. * Only useful if useKernelBlur = false
  48808. */
  48809. get: function () {
  48810. return this._blurBoxOffset;
  48811. },
  48812. /**
  48813. * Sets the blur box offset: offset applied during the blur pass.
  48814. * Only useful if useKernelBlur = false
  48815. */
  48816. set: function (value) {
  48817. if (this._blurBoxOffset === value) {
  48818. return;
  48819. }
  48820. this._blurBoxOffset = value;
  48821. this._disposeBlurPostProcesses();
  48822. },
  48823. enumerable: true,
  48824. configurable: true
  48825. });
  48826. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  48827. /**
  48828. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  48829. * 2 means half of the size.
  48830. */
  48831. get: function () {
  48832. return this._blurScale;
  48833. },
  48834. /**
  48835. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  48836. * 2 means half of the size.
  48837. */
  48838. set: function (value) {
  48839. if (this._blurScale === value) {
  48840. return;
  48841. }
  48842. this._blurScale = value;
  48843. this._disposeBlurPostProcesses();
  48844. },
  48845. enumerable: true,
  48846. configurable: true
  48847. });
  48848. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  48849. /**
  48850. * Gets the blur kernel: kernel size of the blur pass.
  48851. * Only useful if useKernelBlur = true
  48852. */
  48853. get: function () {
  48854. return this._blurKernel;
  48855. },
  48856. /**
  48857. * Sets the blur kernel: kernel size of the blur pass.
  48858. * Only useful if useKernelBlur = true
  48859. */
  48860. set: function (value) {
  48861. if (this._blurKernel === value) {
  48862. return;
  48863. }
  48864. this._blurKernel = value;
  48865. this._disposeBlurPostProcesses();
  48866. },
  48867. enumerable: true,
  48868. configurable: true
  48869. });
  48870. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  48871. /**
  48872. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  48873. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  48874. */
  48875. get: function () {
  48876. return this._useKernelBlur;
  48877. },
  48878. /**
  48879. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  48880. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  48881. */
  48882. set: function (value) {
  48883. if (this._useKernelBlur === value) {
  48884. return;
  48885. }
  48886. this._useKernelBlur = value;
  48887. this._disposeBlurPostProcesses();
  48888. },
  48889. enumerable: true,
  48890. configurable: true
  48891. });
  48892. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  48893. /**
  48894. * Gets the depth scale used in ESM mode.
  48895. */
  48896. get: function () {
  48897. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  48898. },
  48899. /**
  48900. * Sets the depth scale used in ESM mode.
  48901. * This can override the scale stored on the light.
  48902. */
  48903. set: function (value) {
  48904. this._depthScale = value;
  48905. },
  48906. enumerable: true,
  48907. configurable: true
  48908. });
  48909. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  48910. /**
  48911. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  48912. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  48913. */
  48914. get: function () {
  48915. return this._filter;
  48916. },
  48917. /**
  48918. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  48919. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  48920. */
  48921. set: function (value) {
  48922. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  48923. if (this._light.needCube()) {
  48924. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  48925. this.useExponentialShadowMap = true;
  48926. return;
  48927. }
  48928. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  48929. this.useCloseExponentialShadowMap = true;
  48930. return;
  48931. }
  48932. // PCF on cubemap would also be expensive
  48933. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  48934. this.usePoissonSampling = true;
  48935. return;
  48936. }
  48937. }
  48938. // Weblg1 fallback for PCF.
  48939. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  48940. if (this._scene.getEngine().webGLVersion === 1) {
  48941. this.usePoissonSampling = true;
  48942. return;
  48943. }
  48944. }
  48945. if (this._filter === value) {
  48946. return;
  48947. }
  48948. this._filter = value;
  48949. this._disposeBlurPostProcesses();
  48950. this._applyFilterValues();
  48951. this._light._markMeshesAsLightDirty();
  48952. },
  48953. enumerable: true,
  48954. configurable: true
  48955. });
  48956. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  48957. /**
  48958. * Gets if the current filter is set to Poisson Sampling.
  48959. */
  48960. get: function () {
  48961. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  48962. },
  48963. /**
  48964. * Sets the current filter to Poisson Sampling.
  48965. */
  48966. set: function (value) {
  48967. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  48968. return;
  48969. }
  48970. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  48971. },
  48972. enumerable: true,
  48973. configurable: true
  48974. });
  48975. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  48976. /**
  48977. * Gets if the current filter is set to ESM.
  48978. */
  48979. get: function () {
  48980. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  48981. },
  48982. /**
  48983. * Sets the current filter is to ESM.
  48984. */
  48985. set: function (value) {
  48986. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  48987. return;
  48988. }
  48989. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  48990. },
  48991. enumerable: true,
  48992. configurable: true
  48993. });
  48994. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  48995. /**
  48996. * Gets if the current filter is set to filtered ESM.
  48997. */
  48998. get: function () {
  48999. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  49000. },
  49001. /**
  49002. * Gets if the current filter is set to filtered ESM.
  49003. */
  49004. set: function (value) {
  49005. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  49006. return;
  49007. }
  49008. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  49009. },
  49010. enumerable: true,
  49011. configurable: true
  49012. });
  49013. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  49014. /**
  49015. * Gets if the current filter is set to "close ESM" (using the inverse of the
  49016. * exponential to prevent steep falloff artifacts).
  49017. */
  49018. get: function () {
  49019. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  49020. },
  49021. /**
  49022. * Sets the current filter to "close ESM" (using the inverse of the
  49023. * exponential to prevent steep falloff artifacts).
  49024. */
  49025. set: function (value) {
  49026. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  49027. return;
  49028. }
  49029. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  49030. },
  49031. enumerable: true,
  49032. configurable: true
  49033. });
  49034. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  49035. /**
  49036. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  49037. * exponential to prevent steep falloff artifacts).
  49038. */
  49039. get: function () {
  49040. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  49041. },
  49042. /**
  49043. * Sets the current filter to filtered "close ESM" (using the inverse of the
  49044. * exponential to prevent steep falloff artifacts).
  49045. */
  49046. set: function (value) {
  49047. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  49048. return;
  49049. }
  49050. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  49051. },
  49052. enumerable: true,
  49053. configurable: true
  49054. });
  49055. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  49056. /**
  49057. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  49058. */
  49059. get: function () {
  49060. return this.filter === ShadowGenerator.FILTER_PCF;
  49061. },
  49062. /**
  49063. * Sets the current filter to "PCF" (percentage closer filtering).
  49064. */
  49065. set: function (value) {
  49066. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  49067. return;
  49068. }
  49069. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  49070. },
  49071. enumerable: true,
  49072. configurable: true
  49073. });
  49074. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  49075. /**
  49076. * Gets the PCF or PCSS Quality.
  49077. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  49078. */
  49079. get: function () {
  49080. return this._filteringQuality;
  49081. },
  49082. /**
  49083. * Sets the PCF or PCSS Quality.
  49084. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  49085. */
  49086. set: function (filteringQuality) {
  49087. if (this._filteringQuality === filteringQuality) {
  49088. return;
  49089. }
  49090. this._filteringQuality = filteringQuality;
  49091. this._disposeBlurPostProcesses();
  49092. this._applyFilterValues();
  49093. this._light._markMeshesAsLightDirty();
  49094. },
  49095. enumerable: true,
  49096. configurable: true
  49097. });
  49098. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  49099. /**
  49100. * Gets if the current filter is set to "PCSS" (contact hardening).
  49101. */
  49102. get: function () {
  49103. return this.filter === ShadowGenerator.FILTER_PCSS;
  49104. },
  49105. /**
  49106. * Sets the current filter to "PCSS" (contact hardening).
  49107. */
  49108. set: function (value) {
  49109. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  49110. return;
  49111. }
  49112. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  49113. },
  49114. enumerable: true,
  49115. configurable: true
  49116. });
  49117. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  49118. /**
  49119. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  49120. * Using a ratio helps keeping shape stability independently of the map size.
  49121. *
  49122. * It does not account for the light projection as it was having too much
  49123. * instability during the light setup or during light position changes.
  49124. *
  49125. * Only valid if useContactHardeningShadow is true.
  49126. */
  49127. get: function () {
  49128. return this._contactHardeningLightSizeUVRatio;
  49129. },
  49130. /**
  49131. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  49132. * Using a ratio helps keeping shape stability independently of the map size.
  49133. *
  49134. * It does not account for the light projection as it was having too much
  49135. * instability during the light setup or during light position changes.
  49136. *
  49137. * Only valid if useContactHardeningShadow is true.
  49138. */
  49139. set: function (contactHardeningLightSizeUVRatio) {
  49140. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  49141. },
  49142. enumerable: true,
  49143. configurable: true
  49144. });
  49145. Object.defineProperty(ShadowGenerator.prototype, "darkness", {
  49146. /** Gets or sets the actual darkness of a shadow */
  49147. get: function () {
  49148. return this._darkness;
  49149. },
  49150. set: function (value) {
  49151. this.setDarkness(value);
  49152. },
  49153. enumerable: true,
  49154. configurable: true
  49155. });
  49156. /**
  49157. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  49158. * 0 means strongest and 1 would means no shadow.
  49159. * @returns the darkness.
  49160. */
  49161. ShadowGenerator.prototype.getDarkness = function () {
  49162. return this._darkness;
  49163. };
  49164. /**
  49165. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  49166. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  49167. * @returns the shadow generator allowing fluent coding.
  49168. */
  49169. ShadowGenerator.prototype.setDarkness = function (darkness) {
  49170. if (darkness >= 1.0) {
  49171. this._darkness = 1.0;
  49172. }
  49173. else if (darkness <= 0.0) {
  49174. this._darkness = 0.0;
  49175. }
  49176. else {
  49177. this._darkness = darkness;
  49178. }
  49179. return this;
  49180. };
  49181. Object.defineProperty(ShadowGenerator.prototype, "transparencyShadow", {
  49182. /** Gets or sets the ability to have transparent shadow */
  49183. get: function () {
  49184. return this._transparencyShadow;
  49185. },
  49186. set: function (value) {
  49187. this.setTransparencyShadow(value);
  49188. },
  49189. enumerable: true,
  49190. configurable: true
  49191. });
  49192. /**
  49193. * Sets the ability to have transparent shadow (boolean).
  49194. * @param transparent True if transparent else False
  49195. * @returns the shadow generator allowing fluent coding
  49196. */
  49197. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  49198. this._transparencyShadow = transparent;
  49199. return this;
  49200. };
  49201. /**
  49202. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  49203. * @returns The render target texture if present otherwise, null
  49204. */
  49205. ShadowGenerator.prototype.getShadowMap = function () {
  49206. return this._shadowMap;
  49207. };
  49208. /**
  49209. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  49210. * @returns The render target texture if the shadow map is present otherwise, null
  49211. */
  49212. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  49213. if (this._shadowMap2) {
  49214. return this._shadowMap2;
  49215. }
  49216. return this._shadowMap;
  49217. };
  49218. /**
  49219. * Gets the class name of that object
  49220. * @returns "ShadowGenerator"
  49221. */
  49222. ShadowGenerator.prototype.getClassName = function () {
  49223. return "ShadowGenerator";
  49224. };
  49225. /**
  49226. * Helper function to add a mesh and its descendants to the list of shadow casters.
  49227. * @param mesh Mesh to add
  49228. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  49229. * @returns the Shadow Generator itself
  49230. */
  49231. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  49232. var _a;
  49233. if (includeDescendants === void 0) { includeDescendants = true; }
  49234. if (!this._shadowMap) {
  49235. return this;
  49236. }
  49237. if (!this._shadowMap.renderList) {
  49238. this._shadowMap.renderList = [];
  49239. }
  49240. this._shadowMap.renderList.push(mesh);
  49241. if (includeDescendants) {
  49242. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  49243. }
  49244. return this;
  49245. };
  49246. /**
  49247. * Helper function to remove a mesh and its descendants from the list of shadow casters
  49248. * @param mesh Mesh to remove
  49249. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  49250. * @returns the Shadow Generator itself
  49251. */
  49252. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  49253. if (includeDescendants === void 0) { includeDescendants = true; }
  49254. if (!this._shadowMap || !this._shadowMap.renderList) {
  49255. return this;
  49256. }
  49257. var index = this._shadowMap.renderList.indexOf(mesh);
  49258. if (index !== -1) {
  49259. this._shadowMap.renderList.splice(index, 1);
  49260. }
  49261. if (includeDescendants) {
  49262. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  49263. var child = _a[_i];
  49264. this.removeShadowCaster(child);
  49265. }
  49266. }
  49267. return this;
  49268. };
  49269. /**
  49270. * Returns the associated light object.
  49271. * @returns the light generating the shadow
  49272. */
  49273. ShadowGenerator.prototype.getLight = function () {
  49274. return this._light;
  49275. };
  49276. ShadowGenerator.prototype._initializeGenerator = function () {
  49277. this._light._markMeshesAsLightDirty();
  49278. this._initializeShadowMap();
  49279. };
  49280. ShadowGenerator.prototype._initializeShadowMap = function () {
  49281. var _this = this;
  49282. // Render target
  49283. var engine = this._scene.getEngine();
  49284. if (engine.webGLVersion > 1) {
  49285. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_9__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube(), undefined, false, false);
  49286. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LESS, true);
  49287. }
  49288. else {
  49289. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_9__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube());
  49290. }
  49291. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].CLAMP_ADDRESSMODE;
  49292. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].CLAMP_ADDRESSMODE;
  49293. this._shadowMap.anisotropicFilteringLevel = 1;
  49294. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE);
  49295. this._shadowMap.renderParticles = false;
  49296. this._shadowMap.ignoreCameraViewport = true;
  49297. // Record Face Index before render.
  49298. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  49299. _this._currentFaceIndex = faceIndex;
  49300. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  49301. engine.setColorWrite(false);
  49302. }
  49303. });
  49304. // Custom render function.
  49305. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  49306. // Blur if required afer render.
  49307. this._shadowMap.onAfterUnbindObservable.add(function () {
  49308. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  49309. engine.setColorWrite(true);
  49310. }
  49311. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  49312. return;
  49313. }
  49314. var shadowMap = _this.getShadowMapForRendering();
  49315. if (shadowMap) {
  49316. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  49317. }
  49318. });
  49319. // Clear according to the chosen filter.
  49320. var clearZero = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  49321. var clearOne = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](1.0, 1.0, 1.0, 1.0);
  49322. this._shadowMap.onClearObservable.add(function (engine) {
  49323. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  49324. engine.clear(clearOne, false, true, false);
  49325. }
  49326. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  49327. engine.clear(clearZero, true, true, false);
  49328. }
  49329. else {
  49330. engine.clear(clearOne, true, true, false);
  49331. }
  49332. });
  49333. };
  49334. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  49335. var _this = this;
  49336. var engine = this._scene.getEngine();
  49337. var targetSize = this._mapSize / this.blurScale;
  49338. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  49339. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_9__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  49340. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].CLAMP_ADDRESSMODE;
  49341. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].CLAMP_ADDRESSMODE;
  49342. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE);
  49343. }
  49344. if (this.useKernelBlur) {
  49345. this._kernelBlurXPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"](this._light.name + "KernelBlurX", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 0), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  49346. this._kernelBlurXPostprocess.width = targetSize;
  49347. this._kernelBlurXPostprocess.height = targetSize;
  49348. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  49349. effect.setTexture("textureSampler", _this._shadowMap);
  49350. });
  49351. this._kernelBlurYPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"](this._light.name + "KernelBlurY", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  49352. this._kernelBlurXPostprocess.autoClear = false;
  49353. this._kernelBlurYPostprocess.autoClear = false;
  49354. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  49355. this._kernelBlurXPostprocess.packedFloat = true;
  49356. this._kernelBlurYPostprocess.packedFloat = true;
  49357. }
  49358. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  49359. }
  49360. else {
  49361. this._boxBlurPostprocess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_10__["PostProcess"](this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, "#define OFFSET " + this._blurBoxOffset, this._textureType);
  49362. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  49363. effect.setFloat2("screenSize", targetSize, targetSize);
  49364. effect.setTexture("textureSampler", _this._shadowMap);
  49365. });
  49366. this._boxBlurPostprocess.autoClear = false;
  49367. this._blurPostProcesses = [this._boxBlurPostprocess];
  49368. }
  49369. };
  49370. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  49371. var index;
  49372. var engine = this._scene.getEngine();
  49373. if (depthOnlySubMeshes.length) {
  49374. engine.setColorWrite(false);
  49375. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  49376. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  49377. }
  49378. engine.setColorWrite(true);
  49379. }
  49380. for (index = 0; index < opaqueSubMeshes.length; index++) {
  49381. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  49382. }
  49383. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  49384. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  49385. }
  49386. if (this._transparencyShadow) {
  49387. for (index = 0; index < transparentSubMeshes.length; index++) {
  49388. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  49389. }
  49390. }
  49391. };
  49392. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  49393. var _this = this;
  49394. var mesh = subMesh.getRenderingMesh();
  49395. var scene = this._scene;
  49396. var engine = scene.getEngine();
  49397. var material = subMesh.getMaterial();
  49398. mesh._internalAbstractMeshDataInfo._isActiveIntermediate = false;
  49399. if (!material || subMesh.verticesCount === 0) {
  49400. return;
  49401. }
  49402. // Culling
  49403. engine.setState(material.backFaceCulling);
  49404. // Managing instances
  49405. var batch = mesh._getInstancesRenderList(subMesh._id);
  49406. if (batch.mustReturn) {
  49407. return;
  49408. }
  49409. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  49410. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  49411. engine.enableEffect(this._effect);
  49412. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  49413. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  49414. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  49415. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  49416. this._effect.setVector3("lightData", this._cachedDirection);
  49417. }
  49418. else {
  49419. this._effect.setVector3("lightData", this._cachedPosition);
  49420. }
  49421. if (scene.activeCamera) {
  49422. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  49423. }
  49424. // Alpha test
  49425. if (material && material.needAlphaTesting()) {
  49426. var alphaTexture = material.getAlphaTestTexture();
  49427. if (alphaTexture) {
  49428. this._effect.setTexture("diffuseSampler", alphaTexture);
  49429. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  49430. }
  49431. }
  49432. // Bones
  49433. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  49434. var skeleton = mesh.skeleton;
  49435. if (skeleton.isUsingTextureForMatrices) {
  49436. var boneTexture = skeleton.getTransformMatrixTexture(mesh);
  49437. if (!boneTexture) {
  49438. return;
  49439. }
  49440. this._effect.setTexture("boneSampler", boneTexture);
  49441. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  49442. }
  49443. else {
  49444. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  49445. }
  49446. }
  49447. // Morph targets
  49448. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  49449. if (this.forceBackFacesOnly) {
  49450. engine.setState(true, 0, false, true);
  49451. }
  49452. // Observables
  49453. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  49454. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  49455. // Draw
  49456. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  49457. if (this.forceBackFacesOnly) {
  49458. engine.setState(true, 0, false, false);
  49459. }
  49460. // Observables
  49461. this.onAfterShadowMapRenderObservable.notifyObservers(this._effect);
  49462. this.onAfterShadowMapRenderMeshObservable.notifyObservers(mesh);
  49463. }
  49464. else {
  49465. // Need to reset refresh rate of the shadowMap
  49466. if (this._shadowMap) {
  49467. this._shadowMap.resetRefreshCounter();
  49468. }
  49469. }
  49470. };
  49471. ShadowGenerator.prototype._applyFilterValues = function () {
  49472. if (!this._shadowMap) {
  49473. return;
  49474. }
  49475. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  49476. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].NEAREST_SAMPLINGMODE);
  49477. }
  49478. else {
  49479. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_8__["Texture"].BILINEAR_SAMPLINGMODE);
  49480. }
  49481. };
  49482. /**
  49483. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  49484. * @param onCompiled Callback triggered at the and of the effects compilation
  49485. * @param options Sets of optional options forcing the compilation with different modes
  49486. */
  49487. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  49488. var _this = this;
  49489. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  49490. var shadowMap = this.getShadowMap();
  49491. if (!shadowMap) {
  49492. if (onCompiled) {
  49493. onCompiled(this);
  49494. }
  49495. return;
  49496. }
  49497. var renderList = shadowMap.renderList;
  49498. if (!renderList) {
  49499. if (onCompiled) {
  49500. onCompiled(this);
  49501. }
  49502. return;
  49503. }
  49504. var subMeshes = new Array();
  49505. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  49506. var mesh = renderList_1[_i];
  49507. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  49508. }
  49509. if (subMeshes.length === 0) {
  49510. if (onCompiled) {
  49511. onCompiled(this);
  49512. }
  49513. return;
  49514. }
  49515. var currentIndex = 0;
  49516. var checkReady = function () {
  49517. if (!_this._scene || !_this._scene.getEngine()) {
  49518. return;
  49519. }
  49520. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  49521. currentIndex++;
  49522. if (currentIndex >= subMeshes.length) {
  49523. if (onCompiled) {
  49524. onCompiled(_this);
  49525. }
  49526. return;
  49527. }
  49528. }
  49529. setTimeout(checkReady, 16);
  49530. };
  49531. checkReady();
  49532. };
  49533. /**
  49534. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  49535. * @param options Sets of optional options forcing the compilation with different modes
  49536. * @returns A promise that resolves when the compilation completes
  49537. */
  49538. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  49539. var _this = this;
  49540. return new Promise(function (resolve) {
  49541. _this.forceCompilation(function () {
  49542. resolve();
  49543. }, options);
  49544. });
  49545. };
  49546. /**
  49547. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  49548. * @param subMesh The submesh we want to render in the shadow map
  49549. * @param useInstances Defines wether will draw in the map using instances
  49550. * @returns true if ready otherwise, false
  49551. */
  49552. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  49553. var defines = [];
  49554. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  49555. defines.push("#define FLOAT");
  49556. }
  49557. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  49558. defines.push("#define ESM");
  49559. }
  49560. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  49561. defines.push("#define DEPTHTEXTURE");
  49562. }
  49563. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  49564. var mesh = subMesh.getMesh();
  49565. var material = subMesh.getMaterial();
  49566. // Normal bias.
  49567. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  49568. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  49569. defines.push("#define NORMAL");
  49570. if (mesh.nonUniformScaling) {
  49571. defines.push("#define NONUNIFORMSCALING");
  49572. }
  49573. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  49574. defines.push("#define DIRECTIONINLIGHTDATA");
  49575. }
  49576. }
  49577. // Alpha test
  49578. if (material && material.needAlphaTesting()) {
  49579. var alphaTexture = material.getAlphaTestTexture();
  49580. if (alphaTexture) {
  49581. defines.push("#define ALPHATEST");
  49582. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  49583. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind);
  49584. defines.push("#define UV1");
  49585. }
  49586. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  49587. if (alphaTexture.coordinatesIndex === 1) {
  49588. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind);
  49589. defines.push("#define UV2");
  49590. }
  49591. }
  49592. }
  49593. }
  49594. // Bones
  49595. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  49596. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  49597. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  49598. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  49599. if (mesh.numBoneInfluencers > 4) {
  49600. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  49601. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  49602. }
  49603. var skeleton = mesh.skeleton;
  49604. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  49605. if (mesh.numBoneInfluencers > 0) {
  49606. fallbacks.addCPUSkinningFallback(0, mesh);
  49607. }
  49608. if (skeleton.isUsingTextureForMatrices) {
  49609. defines.push("#define BONETEXTURE");
  49610. }
  49611. else {
  49612. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  49613. }
  49614. }
  49615. else {
  49616. defines.push("#define NUM_BONE_INFLUENCERS 0");
  49617. }
  49618. // Morph targets
  49619. var manager = mesh.morphTargetManager;
  49620. var morphInfluencers = 0;
  49621. if (manager) {
  49622. if (manager.numInfluencers > 0) {
  49623. defines.push("#define MORPHTARGETS");
  49624. morphInfluencers = manager.numInfluencers;
  49625. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  49626. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, morphInfluencers);
  49627. }
  49628. }
  49629. // Instances
  49630. if (useInstances) {
  49631. defines.push("#define INSTANCES");
  49632. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].PushAttributesForInstances(attribs);
  49633. }
  49634. if (this.customShaderOptions) {
  49635. if (this.customShaderOptions.defines) {
  49636. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  49637. var define = _a[_i];
  49638. if (defines.indexOf(define) === -1) {
  49639. defines.push(define);
  49640. }
  49641. }
  49642. }
  49643. }
  49644. // Get correct effect
  49645. var join = defines.join("\n");
  49646. if (this._cachedDefines !== join) {
  49647. this._cachedDefines = join;
  49648. var shaderName = "shadowMap";
  49649. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  49650. var samplers = ["diffuseSampler", "boneSampler"];
  49651. // Custom shader?
  49652. if (this.customShaderOptions) {
  49653. shaderName = this.customShaderOptions.shaderName;
  49654. if (this.customShaderOptions.attributes) {
  49655. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  49656. var attrib = _c[_b];
  49657. if (attribs.indexOf(attrib) === -1) {
  49658. attribs.push(attrib);
  49659. }
  49660. }
  49661. }
  49662. if (this.customShaderOptions.uniforms) {
  49663. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  49664. var uniform = _e[_d];
  49665. if (uniforms.indexOf(uniform) === -1) {
  49666. uniforms.push(uniform);
  49667. }
  49668. }
  49669. }
  49670. if (this.customShaderOptions.samplers) {
  49671. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  49672. var sampler = _g[_f];
  49673. if (samplers.indexOf(sampler) === -1) {
  49674. samplers.push(sampler);
  49675. }
  49676. }
  49677. }
  49678. }
  49679. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, fallbacks, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  49680. }
  49681. if (!this._effect.isReady()) {
  49682. return false;
  49683. }
  49684. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  49685. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  49686. this._initializeBlurRTTAndPostProcesses();
  49687. }
  49688. }
  49689. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  49690. return false;
  49691. }
  49692. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  49693. return false;
  49694. }
  49695. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  49696. return false;
  49697. }
  49698. return true;
  49699. };
  49700. /**
  49701. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  49702. * @param defines Defines of the material we want to update
  49703. * @param lightIndex Index of the light in the enabled light list of the material
  49704. */
  49705. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  49706. var scene = this._scene;
  49707. var light = this._light;
  49708. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  49709. return;
  49710. }
  49711. defines["SHADOW" + lightIndex] = true;
  49712. if (this.useContactHardeningShadow) {
  49713. defines["SHADOWPCSS" + lightIndex] = true;
  49714. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  49715. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  49716. }
  49717. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  49718. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  49719. }
  49720. // else default to high.
  49721. }
  49722. if (this.usePercentageCloserFiltering) {
  49723. defines["SHADOWPCF" + lightIndex] = true;
  49724. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  49725. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  49726. }
  49727. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  49728. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  49729. }
  49730. // else default to high.
  49731. }
  49732. else if (this.usePoissonSampling) {
  49733. defines["SHADOWPOISSON" + lightIndex] = true;
  49734. }
  49735. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  49736. defines["SHADOWESM" + lightIndex] = true;
  49737. }
  49738. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  49739. defines["SHADOWCLOSEESM" + lightIndex] = true;
  49740. }
  49741. if (light.needCube()) {
  49742. defines["SHADOWCUBE" + lightIndex] = true;
  49743. }
  49744. };
  49745. /**
  49746. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  49747. * defined in the generator but impacting the effect).
  49748. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  49749. * @param effect The effect we are binfing the information for
  49750. */
  49751. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  49752. var light = this._light;
  49753. var scene = this._scene;
  49754. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  49755. return;
  49756. }
  49757. var camera = scene.activeCamera;
  49758. if (!camera) {
  49759. return;
  49760. }
  49761. var shadowMap = this.getShadowMap();
  49762. if (!shadowMap) {
  49763. return;
  49764. }
  49765. if (!light.needCube()) {
  49766. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  49767. }
  49768. // Only PCF uses depth stencil texture.
  49769. if (this._filter === ShadowGenerator.FILTER_PCF) {
  49770. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  49771. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  49772. }
  49773. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  49774. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  49775. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  49776. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  49777. }
  49778. else {
  49779. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  49780. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  49781. }
  49782. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  49783. };
  49784. /**
  49785. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  49786. * (eq to shadow prjection matrix * light transform matrix)
  49787. * @returns The transform matrix used to create the shadow map
  49788. */
  49789. ShadowGenerator.prototype.getTransformMatrix = function () {
  49790. var scene = this._scene;
  49791. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  49792. return this._transformMatrix;
  49793. }
  49794. this._currentRenderID = scene.getRenderId();
  49795. this._currentFaceIndexCache = this._currentFaceIndex;
  49796. var lightPosition = this._light.position;
  49797. if (this._light.computeTransformedInformation()) {
  49798. lightPosition = this._light.transformedPosition;
  49799. }
  49800. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  49801. if (Math.abs(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  49802. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  49803. }
  49804. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  49805. this._cachedPosition.copyFrom(lightPosition);
  49806. this._cachedDirection.copyFrom(this._lightDirection);
  49807. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  49808. var shadowMap = this.getShadowMap();
  49809. if (shadowMap) {
  49810. var renderList = shadowMap.renderList;
  49811. if (renderList) {
  49812. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  49813. }
  49814. }
  49815. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  49816. }
  49817. return this._transformMatrix;
  49818. };
  49819. /**
  49820. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  49821. * Cube and 2D textures for instance.
  49822. */
  49823. ShadowGenerator.prototype.recreateShadowMap = function () {
  49824. var shadowMap = this._shadowMap;
  49825. if (!shadowMap) {
  49826. return;
  49827. }
  49828. // Track render list.
  49829. var renderList = shadowMap.renderList;
  49830. // Clean up existing data.
  49831. this._disposeRTTandPostProcesses();
  49832. // Reinitializes.
  49833. this._initializeGenerator();
  49834. // Reaffect the filter to ensure a correct fallback if necessary.
  49835. this.filter = this.filter;
  49836. // Reaffect the filter.
  49837. this._applyFilterValues();
  49838. // Reaffect Render List.
  49839. this._shadowMap.renderList = renderList;
  49840. };
  49841. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  49842. if (this._shadowMap2) {
  49843. this._shadowMap2.dispose();
  49844. this._shadowMap2 = null;
  49845. }
  49846. if (this._boxBlurPostprocess) {
  49847. this._boxBlurPostprocess.dispose();
  49848. this._boxBlurPostprocess = null;
  49849. }
  49850. if (this._kernelBlurXPostprocess) {
  49851. this._kernelBlurXPostprocess.dispose();
  49852. this._kernelBlurXPostprocess = null;
  49853. }
  49854. if (this._kernelBlurYPostprocess) {
  49855. this._kernelBlurYPostprocess.dispose();
  49856. this._kernelBlurYPostprocess = null;
  49857. }
  49858. this._blurPostProcesses = [];
  49859. };
  49860. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  49861. if (this._shadowMap) {
  49862. this._shadowMap.dispose();
  49863. this._shadowMap = null;
  49864. }
  49865. this._disposeBlurPostProcesses();
  49866. };
  49867. /**
  49868. * Disposes the ShadowGenerator.
  49869. * Returns nothing.
  49870. */
  49871. ShadowGenerator.prototype.dispose = function () {
  49872. this._disposeRTTandPostProcesses();
  49873. if (this._light) {
  49874. this._light._shadowGenerator = null;
  49875. this._light._markMeshesAsLightDirty();
  49876. }
  49877. this.onBeforeShadowMapRenderMeshObservable.clear();
  49878. this.onBeforeShadowMapRenderObservable.clear();
  49879. this.onAfterShadowMapRenderMeshObservable.clear();
  49880. this.onAfterShadowMapRenderObservable.clear();
  49881. };
  49882. /**
  49883. * Serializes the shadow generator setup to a json object.
  49884. * @returns The serialized JSON object
  49885. */
  49886. ShadowGenerator.prototype.serialize = function () {
  49887. var serializationObject = {};
  49888. var shadowMap = this.getShadowMap();
  49889. if (!shadowMap) {
  49890. return serializationObject;
  49891. }
  49892. serializationObject.lightId = this._light.id;
  49893. serializationObject.mapSize = shadowMap.getRenderSize();
  49894. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  49895. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  49896. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  49897. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  49898. serializationObject.usePoissonSampling = this.usePoissonSampling;
  49899. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  49900. serializationObject.depthScale = this.depthScale;
  49901. serializationObject.darkness = this.getDarkness();
  49902. serializationObject.blurBoxOffset = this.blurBoxOffset;
  49903. serializationObject.blurKernel = this.blurKernel;
  49904. serializationObject.blurScale = this.blurScale;
  49905. serializationObject.useKernelBlur = this.useKernelBlur;
  49906. serializationObject.transparencyShadow = this._transparencyShadow;
  49907. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  49908. serializationObject.bias = this.bias;
  49909. serializationObject.normalBias = this.normalBias;
  49910. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  49911. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  49912. serializationObject.filteringQuality = this.filteringQuality;
  49913. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  49914. serializationObject.renderList = [];
  49915. if (shadowMap.renderList) {
  49916. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  49917. var mesh = shadowMap.renderList[meshIndex];
  49918. serializationObject.renderList.push(mesh.id);
  49919. }
  49920. }
  49921. return serializationObject;
  49922. };
  49923. /**
  49924. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  49925. * @param parsedShadowGenerator The JSON object to parse
  49926. * @param scene The scene to create the shadow map for
  49927. * @returns The parsed shadow generator
  49928. */
  49929. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  49930. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  49931. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  49932. var shadowMap = shadowGenerator.getShadowMap();
  49933. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  49934. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  49935. meshes.forEach(function (mesh) {
  49936. if (!shadowMap) {
  49937. return;
  49938. }
  49939. if (!shadowMap.renderList) {
  49940. shadowMap.renderList = [];
  49941. }
  49942. shadowMap.renderList.push(mesh);
  49943. });
  49944. }
  49945. if (parsedShadowGenerator.usePoissonSampling) {
  49946. shadowGenerator.usePoissonSampling = true;
  49947. }
  49948. else if (parsedShadowGenerator.useExponentialShadowMap) {
  49949. shadowGenerator.useExponentialShadowMap = true;
  49950. }
  49951. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  49952. shadowGenerator.useBlurExponentialShadowMap = true;
  49953. }
  49954. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  49955. shadowGenerator.useCloseExponentialShadowMap = true;
  49956. }
  49957. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  49958. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  49959. }
  49960. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  49961. shadowGenerator.usePercentageCloserFiltering = true;
  49962. }
  49963. else if (parsedShadowGenerator.useContactHardeningShadow) {
  49964. shadowGenerator.useContactHardeningShadow = true;
  49965. }
  49966. if (parsedShadowGenerator.filteringQuality) {
  49967. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  49968. }
  49969. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  49970. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  49971. }
  49972. // Backward compat
  49973. else if (parsedShadowGenerator.useVarianceShadowMap) {
  49974. shadowGenerator.useExponentialShadowMap = true;
  49975. }
  49976. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  49977. shadowGenerator.useBlurExponentialShadowMap = true;
  49978. }
  49979. if (parsedShadowGenerator.depthScale) {
  49980. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  49981. }
  49982. if (parsedShadowGenerator.blurScale) {
  49983. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  49984. }
  49985. if (parsedShadowGenerator.blurBoxOffset) {
  49986. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  49987. }
  49988. if (parsedShadowGenerator.useKernelBlur) {
  49989. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  49990. }
  49991. if (parsedShadowGenerator.blurKernel) {
  49992. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  49993. }
  49994. if (parsedShadowGenerator.bias !== undefined) {
  49995. shadowGenerator.bias = parsedShadowGenerator.bias;
  49996. }
  49997. if (parsedShadowGenerator.normalBias !== undefined) {
  49998. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  49999. }
  50000. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  50001. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  50002. }
  50003. if (parsedShadowGenerator.darkness) {
  50004. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  50005. }
  50006. if (parsedShadowGenerator.transparencyShadow) {
  50007. shadowGenerator.setTransparencyShadow(true);
  50008. }
  50009. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  50010. return shadowGenerator;
  50011. };
  50012. /**
  50013. * Shadow generator mode None: no filtering applied.
  50014. */
  50015. ShadowGenerator.FILTER_NONE = 0;
  50016. /**
  50017. * Shadow generator mode ESM: Exponential Shadow Mapping.
  50018. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  50019. */
  50020. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  50021. /**
  50022. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  50023. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  50024. */
  50025. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  50026. /**
  50027. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  50028. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  50029. */
  50030. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  50031. /**
  50032. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  50033. * edge artifacts on steep falloff.
  50034. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  50035. */
  50036. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  50037. /**
  50038. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  50039. * edge artifacts on steep falloff.
  50040. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  50041. */
  50042. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  50043. /**
  50044. * Shadow generator mode PCF: Percentage Closer Filtering
  50045. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  50046. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  50047. */
  50048. ShadowGenerator.FILTER_PCF = 6;
  50049. /**
  50050. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  50051. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  50052. * Contact Hardening
  50053. */
  50054. ShadowGenerator.FILTER_PCSS = 7;
  50055. /**
  50056. * Reserved for PCF and PCSS
  50057. * Highest Quality.
  50058. *
  50059. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  50060. *
  50061. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  50062. */
  50063. ShadowGenerator.QUALITY_HIGH = 0;
  50064. /**
  50065. * Reserved for PCF and PCSS
  50066. * Good tradeoff for quality/perf cross devices
  50067. *
  50068. * Execute PCF on a 3*3 kernel.
  50069. *
  50070. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  50071. */
  50072. ShadowGenerator.QUALITY_MEDIUM = 1;
  50073. /**
  50074. * Reserved for PCF and PCSS
  50075. * The lowest quality but the fastest.
  50076. *
  50077. * Execute PCF on a 1*1 kernel.
  50078. *
  50079. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  50080. */
  50081. ShadowGenerator.QUALITY_LOW = 2;
  50082. /** @hidden */
  50083. ShadowGenerator._SceneComponentInitialization = function (_) {
  50084. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  50085. };
  50086. return ShadowGenerator;
  50087. }());
  50088. /***/ }),
  50089. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  50090. /*!*********************************************************!*\
  50091. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  50092. \*********************************************************/
  50093. /*! exports provided: ShadowGeneratorSceneComponent */
  50094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50095. "use strict";
  50096. __webpack_require__.r(__webpack_exports__);
  50097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  50098. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  50099. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  50100. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  50101. // Adds the parser to the scene parsers.
  50102. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  50103. // Shadows
  50104. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  50105. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  50106. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  50107. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  50108. // SG would be available on their associated lights
  50109. }
  50110. }
  50111. });
  50112. /**
  50113. * Defines the shadow generator component responsible to manage any shadow generators
  50114. * in a given scene.
  50115. */
  50116. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  50117. /**
  50118. * Creates a new instance of the component for the given scene
  50119. * @param scene Defines the scene to register the component in
  50120. */
  50121. function ShadowGeneratorSceneComponent(scene) {
  50122. /**
  50123. * The component name helpfull to identify the component in the list of scene components.
  50124. */
  50125. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  50126. this.scene = scene;
  50127. }
  50128. /**
  50129. * Registers the component in a given scene
  50130. */
  50131. ShadowGeneratorSceneComponent.prototype.register = function () {
  50132. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  50133. };
  50134. /**
  50135. * Rebuilds the elements related to this component in case of
  50136. * context lost for instance.
  50137. */
  50138. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  50139. // Nothing To Do Here.
  50140. };
  50141. /**
  50142. * Serializes the component data to the specified json object
  50143. * @param serializationObject The object to serialize to
  50144. */
  50145. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  50146. // Shadows
  50147. serializationObject.shadowGenerators = [];
  50148. var lights = this.scene.lights;
  50149. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  50150. var light = lights_1[_i];
  50151. var shadowGenerator = light.getShadowGenerator();
  50152. if (shadowGenerator) {
  50153. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  50154. }
  50155. }
  50156. };
  50157. /**
  50158. * Adds all the elements from the container to the scene
  50159. * @param container the container holding the elements
  50160. */
  50161. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  50162. // Nothing To Do Here. (directly attached to a light)
  50163. };
  50164. /**
  50165. * Removes all the elements in the container from the scene
  50166. * @param container contains the elements to remove
  50167. * @param dispose if the removed element should be disposed (default: false)
  50168. */
  50169. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  50170. // Nothing To Do Here. (directly attached to a light)
  50171. };
  50172. /**
  50173. * Rebuilds the elements related to this component in case of
  50174. * context lost for instance.
  50175. */
  50176. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  50177. // Nothing To Do Here.
  50178. };
  50179. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  50180. // Shadows
  50181. var scene = this.scene;
  50182. if (this.scene.shadowsEnabled) {
  50183. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  50184. var light = scene.lights[lightIndex];
  50185. var shadowGenerator = light.getShadowGenerator();
  50186. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  50187. var shadowMap = (shadowGenerator.getShadowMap());
  50188. if (scene.textures.indexOf(shadowMap) !== -1) {
  50189. renderTargets.push(shadowMap);
  50190. }
  50191. }
  50192. }
  50193. }
  50194. };
  50195. return ShadowGeneratorSceneComponent;
  50196. }());
  50197. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  50198. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  50199. if (!component) {
  50200. component = new ShadowGeneratorSceneComponent(scene);
  50201. scene._addComponent(component);
  50202. }
  50203. };
  50204. /***/ }),
  50205. /***/ "./Lights/directionalLight.ts":
  50206. /*!************************************!*\
  50207. !*** ./Lights/directionalLight.ts ***!
  50208. \************************************/
  50209. /*! exports provided: DirectionalLight */
  50210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50211. "use strict";
  50212. __webpack_require__.r(__webpack_exports__);
  50213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  50214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50215. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  50216. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  50217. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  50218. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  50219. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  50220. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  50221. return function () { return new DirectionalLight(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  50222. });
  50223. /**
  50224. * A directional light is defined by a direction (what a surprise!).
  50225. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50226. * 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.
  50227. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50228. */
  50229. var DirectionalLight = /** @class */ (function (_super) {
  50230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  50231. /**
  50232. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50233. * The directional light is emitted from everywhere in the given direction.
  50234. * It can cast shadows.
  50235. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50236. * @param name The friendly name of the light
  50237. * @param direction The direction of the light
  50238. * @param scene The scene the light belongs to
  50239. */
  50240. function DirectionalLight(name, direction, scene) {
  50241. var _this = _super.call(this, name, scene) || this;
  50242. _this._shadowFrustumSize = 0;
  50243. _this._shadowOrthoScale = 0.1;
  50244. /**
  50245. * Automatically compute the projection matrix to best fit (including all the casters)
  50246. * on each frame.
  50247. */
  50248. _this.autoUpdateExtends = true;
  50249. // Cache
  50250. _this._orthoLeft = Number.MAX_VALUE;
  50251. _this._orthoRight = Number.MIN_VALUE;
  50252. _this._orthoTop = Number.MIN_VALUE;
  50253. _this._orthoBottom = Number.MAX_VALUE;
  50254. _this.position = direction.scale(-1.0);
  50255. _this.direction = direction;
  50256. return _this;
  50257. }
  50258. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  50259. /**
  50260. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50261. */
  50262. get: function () {
  50263. return this._shadowFrustumSize;
  50264. },
  50265. /**
  50266. * Specifies a fix frustum size for the shadow generation.
  50267. */
  50268. set: function (value) {
  50269. this._shadowFrustumSize = value;
  50270. this.forceProjectionMatrixCompute();
  50271. },
  50272. enumerable: true,
  50273. configurable: true
  50274. });
  50275. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  50276. /**
  50277. * Gets the shadow projection scale against the optimal computed one.
  50278. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50279. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50280. */
  50281. get: function () {
  50282. return this._shadowOrthoScale;
  50283. },
  50284. /**
  50285. * Sets the shadow projection scale against the optimal computed one.
  50286. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50287. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50288. */
  50289. set: function (value) {
  50290. this._shadowOrthoScale = value;
  50291. this.forceProjectionMatrixCompute();
  50292. },
  50293. enumerable: true,
  50294. configurable: true
  50295. });
  50296. /**
  50297. * Returns the string "DirectionalLight".
  50298. * @return The class name
  50299. */
  50300. DirectionalLight.prototype.getClassName = function () {
  50301. return "DirectionalLight";
  50302. };
  50303. /**
  50304. * Returns the integer 1.
  50305. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50306. */
  50307. DirectionalLight.prototype.getTypeID = function () {
  50308. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  50309. };
  50310. /**
  50311. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50312. * Returns the DirectionalLight Shadow projection matrix.
  50313. */
  50314. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  50315. if (this.shadowFrustumSize > 0) {
  50316. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  50317. }
  50318. else {
  50319. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  50320. }
  50321. };
  50322. /**
  50323. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50324. * Returns the DirectionalLight Shadow projection matrix.
  50325. */
  50326. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  50327. var activeCamera = this.getScene().activeCamera;
  50328. if (!activeCamera) {
  50329. return;
  50330. }
  50331. _Maths_math_vector__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);
  50332. };
  50333. /**
  50334. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50335. * Returns the DirectionalLight Shadow projection matrix.
  50336. */
  50337. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  50338. var activeCamera = this.getScene().activeCamera;
  50339. if (!activeCamera) {
  50340. return;
  50341. }
  50342. // Check extends
  50343. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  50344. var tempVector3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  50345. this._orthoLeft = Number.MAX_VALUE;
  50346. this._orthoRight = Number.MIN_VALUE;
  50347. this._orthoTop = Number.MIN_VALUE;
  50348. this._orthoBottom = Number.MAX_VALUE;
  50349. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  50350. var mesh = renderList[meshIndex];
  50351. if (!mesh) {
  50352. continue;
  50353. }
  50354. var boundingInfo = mesh.getBoundingInfo();
  50355. var boundingBox = boundingInfo.boundingBox;
  50356. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  50357. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  50358. if (tempVector3.x < this._orthoLeft) {
  50359. this._orthoLeft = tempVector3.x;
  50360. }
  50361. if (tempVector3.y < this._orthoBottom) {
  50362. this._orthoBottom = tempVector3.y;
  50363. }
  50364. if (tempVector3.x > this._orthoRight) {
  50365. this._orthoRight = tempVector3.x;
  50366. }
  50367. if (tempVector3.y > this._orthoTop) {
  50368. this._orthoTop = tempVector3.y;
  50369. }
  50370. }
  50371. }
  50372. }
  50373. var xOffset = this._orthoRight - this._orthoLeft;
  50374. var yOffset = this._orthoTop - this._orthoBottom;
  50375. _Maths_math_vector__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);
  50376. };
  50377. DirectionalLight.prototype._buildUniformLayout = function () {
  50378. this._uniformBuffer.addUniform("vLightData", 4);
  50379. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  50380. this._uniformBuffer.addUniform("vLightSpecular", 3);
  50381. this._uniformBuffer.addUniform("shadowsInfo", 3);
  50382. this._uniformBuffer.addUniform("depthValues", 2);
  50383. this._uniformBuffer.create();
  50384. };
  50385. /**
  50386. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50387. * @param effect The effect to update
  50388. * @param lightIndex The index of the light in the effect to update
  50389. * @returns The directional light
  50390. */
  50391. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  50392. if (this.computeTransformedInformation()) {
  50393. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  50394. return this;
  50395. }
  50396. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  50397. return this;
  50398. };
  50399. /**
  50400. * Gets the minZ used for shadow according to both the scene and the light.
  50401. *
  50402. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50403. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50404. * @param activeCamera The camera we are returning the min for
  50405. * @returns the depth min z
  50406. */
  50407. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  50408. return 1;
  50409. };
  50410. /**
  50411. * Gets the maxZ used for shadow according to both the scene and the light.
  50412. *
  50413. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50414. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50415. * @param activeCamera The camera we are returning the max for
  50416. * @returns the depth max z
  50417. */
  50418. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  50419. return 1;
  50420. };
  50421. /**
  50422. * Prepares the list of defines specific to the light type.
  50423. * @param defines the list of defines
  50424. * @param lightIndex defines the index of the light for the effect
  50425. */
  50426. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  50427. defines["DIRLIGHT" + lightIndex] = true;
  50428. };
  50429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50431. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  50432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50434. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  50435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50437. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  50438. return DirectionalLight;
  50439. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  50440. /***/ }),
  50441. /***/ "./Lights/hemisphericLight.ts":
  50442. /*!************************************!*\
  50443. !*** ./Lights/hemisphericLight.ts ***!
  50444. \************************************/
  50445. /*! exports provided: HemisphericLight */
  50446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50447. "use strict";
  50448. __webpack_require__.r(__webpack_exports__);
  50449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  50450. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50451. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  50452. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  50453. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  50454. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  50455. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  50456. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  50457. return function () { return new HemisphericLight(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  50458. });
  50459. /**
  50460. * The HemisphericLight simulates the ambient environment light,
  50461. * so the passed direction is the light reflection direction, not the incoming direction.
  50462. */
  50463. var HemisphericLight = /** @class */ (function (_super) {
  50464. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  50465. /**
  50466. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  50467. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  50468. * The HemisphericLight can't cast shadows.
  50469. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50470. * @param name The friendly name of the light
  50471. * @param direction The direction of the light reflection
  50472. * @param scene The scene the light belongs to
  50473. */
  50474. function HemisphericLight(name, direction, scene) {
  50475. var _this = _super.call(this, name, scene) || this;
  50476. /**
  50477. * The groundColor is the light in the opposite direction to the one specified during creation.
  50478. * 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.
  50479. */
  50480. _this.groundColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.0, 0.0, 0.0);
  50481. _this.direction = direction || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  50482. return _this;
  50483. }
  50484. HemisphericLight.prototype._buildUniformLayout = function () {
  50485. this._uniformBuffer.addUniform("vLightData", 4);
  50486. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  50487. this._uniformBuffer.addUniform("vLightSpecular", 3);
  50488. this._uniformBuffer.addUniform("vLightGround", 3);
  50489. this._uniformBuffer.addUniform("shadowsInfo", 3);
  50490. this._uniformBuffer.addUniform("depthValues", 2);
  50491. this._uniformBuffer.create();
  50492. };
  50493. /**
  50494. * Returns the string "HemisphericLight".
  50495. * @return The class name
  50496. */
  50497. HemisphericLight.prototype.getClassName = function () {
  50498. return "HemisphericLight";
  50499. };
  50500. /**
  50501. * Sets the HemisphericLight direction towards the passed target (Vector3).
  50502. * Returns the updated direction.
  50503. * @param target The target the direction should point to
  50504. * @return The computed direction
  50505. */
  50506. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  50507. this.direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  50508. return this.direction;
  50509. };
  50510. /**
  50511. * Returns the shadow generator associated to the light.
  50512. * @returns Always null for hemispheric lights because it does not support shadows.
  50513. */
  50514. HemisphericLight.prototype.getShadowGenerator = function () {
  50515. return null;
  50516. };
  50517. /**
  50518. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  50519. * @param effect The effect to update
  50520. * @param lightIndex The index of the light in the effect to update
  50521. * @returns The hemispheric light
  50522. */
  50523. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  50524. var normalizeDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  50525. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  50526. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  50527. return this;
  50528. };
  50529. /**
  50530. * Computes the world matrix of the node
  50531. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  50532. * @param useWasUpdatedFlag defines a reserved property
  50533. * @returns the world matrix
  50534. */
  50535. HemisphericLight.prototype.computeWorldMatrix = function () {
  50536. if (!this._worldMatrix) {
  50537. this._worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  50538. }
  50539. return this._worldMatrix;
  50540. };
  50541. /**
  50542. * Returns the integer 3.
  50543. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50544. */
  50545. HemisphericLight.prototype.getTypeID = function () {
  50546. return _light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  50547. };
  50548. /**
  50549. * Prepares the list of defines specific to the light type.
  50550. * @param defines the list of defines
  50551. * @param lightIndex defines the index of the light for the effect
  50552. */
  50553. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  50554. defines["HEMILIGHT" + lightIndex] = true;
  50555. };
  50556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50558. ], HemisphericLight.prototype, "groundColor", void 0);
  50559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50561. ], HemisphericLight.prototype, "direction", void 0);
  50562. return HemisphericLight;
  50563. }(_light__WEBPACK_IMPORTED_MODULE_5__["Light"]));
  50564. /***/ }),
  50565. /***/ "./Lights/index.ts":
  50566. /*!*************************!*\
  50567. !*** ./Lights/index.ts ***!
  50568. \*************************/
  50569. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  50570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50571. "use strict";
  50572. __webpack_require__.r(__webpack_exports__);
  50573. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  50574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  50575. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  50576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  50577. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  50578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  50579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  50580. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  50581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  50582. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  50583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  50584. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  50585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  50586. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  50587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  50588. /***/ }),
  50589. /***/ "./Lights/light.ts":
  50590. /*!*************************!*\
  50591. !*** ./Lights/light.ts ***!
  50592. \*************************/
  50593. /*! exports provided: Light */
  50594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50595. "use strict";
  50596. __webpack_require__.r(__webpack_exports__);
  50597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  50598. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50599. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  50600. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  50601. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  50602. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  50603. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  50604. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  50605. /**
  50606. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  50607. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  50608. * 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.
  50609. */
  50610. var Light = /** @class */ (function (_super) {
  50611. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  50612. /**
  50613. * Creates a Light object in the scene.
  50614. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50615. * @param name The firendly name of the light
  50616. * @param scene The scene the light belongs too
  50617. */
  50618. function Light(name, scene) {
  50619. var _this = _super.call(this, name, scene) || this;
  50620. /**
  50621. * Diffuse gives the basic color to an object.
  50622. */
  50623. _this.diffuse = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  50624. /**
  50625. * Specular produces a highlight color on an object.
  50626. * Note: This is note affecting PBR materials.
  50627. */
  50628. _this.specular = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  50629. /**
  50630. * Defines the falloff type for this light. This lets overrriding how punctual light are
  50631. * falling off base on range or angle.
  50632. * This can be set to any values in Light.FALLOFF_x.
  50633. *
  50634. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  50635. * other types of materials.
  50636. */
  50637. _this.falloffType = Light.FALLOFF_DEFAULT;
  50638. /**
  50639. * Strength of the light.
  50640. * Note: By default it is define in the framework own unit.
  50641. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  50642. */
  50643. _this.intensity = 1.0;
  50644. _this._range = Number.MAX_VALUE;
  50645. _this._inverseSquaredRange = 0;
  50646. /**
  50647. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  50648. * of light.
  50649. */
  50650. _this._photometricScale = 1.0;
  50651. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  50652. _this._radius = 0.00001;
  50653. /**
  50654. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  50655. * exceeding the number allowed of the materials.
  50656. */
  50657. _this.renderPriority = 0;
  50658. _this._shadowEnabled = true;
  50659. _this._excludeWithLayerMask = 0;
  50660. _this._includeOnlyWithLayerMask = 0;
  50661. _this._lightmapMode = 0;
  50662. /**
  50663. * @hidden Internal use only.
  50664. */
  50665. _this._excludedMeshesIds = new Array();
  50666. /**
  50667. * @hidden Internal use only.
  50668. */
  50669. _this._includedOnlyMeshesIds = new Array();
  50670. /** @hidden */
  50671. _this._isLight = true;
  50672. _this.getScene().addLight(_this);
  50673. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](_this.getScene().getEngine());
  50674. _this._buildUniformLayout();
  50675. _this.includedOnlyMeshes = new Array();
  50676. _this.excludedMeshes = new Array();
  50677. _this._resyncMeshes();
  50678. return _this;
  50679. }
  50680. Object.defineProperty(Light.prototype, "range", {
  50681. /**
  50682. * Defines how far from the source the light is impacting in scene units.
  50683. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  50684. */
  50685. get: function () {
  50686. return this._range;
  50687. },
  50688. /**
  50689. * Defines how far from the source the light is impacting in scene units.
  50690. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  50691. */
  50692. set: function (value) {
  50693. this._range = value;
  50694. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  50695. },
  50696. enumerable: true,
  50697. configurable: true
  50698. });
  50699. Object.defineProperty(Light.prototype, "intensityMode", {
  50700. /**
  50701. * Gets the photometric scale used to interpret the intensity.
  50702. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  50703. */
  50704. get: function () {
  50705. return this._intensityMode;
  50706. },
  50707. /**
  50708. * Sets the photometric scale used to interpret the intensity.
  50709. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  50710. */
  50711. set: function (value) {
  50712. this._intensityMode = value;
  50713. this._computePhotometricScale();
  50714. },
  50715. enumerable: true,
  50716. configurable: true
  50717. });
  50718. Object.defineProperty(Light.prototype, "radius", {
  50719. /**
  50720. * Gets the light radius used by PBR Materials to simulate soft area lights.
  50721. */
  50722. get: function () {
  50723. return this._radius;
  50724. },
  50725. /**
  50726. * sets the light radius used by PBR Materials to simulate soft area lights.
  50727. */
  50728. set: function (value) {
  50729. this._radius = value;
  50730. this._computePhotometricScale();
  50731. },
  50732. enumerable: true,
  50733. configurable: true
  50734. });
  50735. Object.defineProperty(Light.prototype, "shadowEnabled", {
  50736. /**
  50737. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  50738. * the current shadow generator.
  50739. */
  50740. get: function () {
  50741. return this._shadowEnabled;
  50742. },
  50743. /**
  50744. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  50745. * the current shadow generator.
  50746. */
  50747. set: function (value) {
  50748. if (this._shadowEnabled === value) {
  50749. return;
  50750. }
  50751. this._shadowEnabled = value;
  50752. this._markMeshesAsLightDirty();
  50753. },
  50754. enumerable: true,
  50755. configurable: true
  50756. });
  50757. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  50758. /**
  50759. * Gets the only meshes impacted by this light.
  50760. */
  50761. get: function () {
  50762. return this._includedOnlyMeshes;
  50763. },
  50764. /**
  50765. * Sets the only meshes impacted by this light.
  50766. */
  50767. set: function (value) {
  50768. this._includedOnlyMeshes = value;
  50769. this._hookArrayForIncludedOnly(value);
  50770. },
  50771. enumerable: true,
  50772. configurable: true
  50773. });
  50774. Object.defineProperty(Light.prototype, "excludedMeshes", {
  50775. /**
  50776. * Gets the meshes not impacted by this light.
  50777. */
  50778. get: function () {
  50779. return this._excludedMeshes;
  50780. },
  50781. /**
  50782. * Sets the meshes not impacted by this light.
  50783. */
  50784. set: function (value) {
  50785. this._excludedMeshes = value;
  50786. this._hookArrayForExcluded(value);
  50787. },
  50788. enumerable: true,
  50789. configurable: true
  50790. });
  50791. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  50792. /**
  50793. * Gets the layer id use to find what meshes are not impacted by the light.
  50794. * Inactive if 0
  50795. */
  50796. get: function () {
  50797. return this._excludeWithLayerMask;
  50798. },
  50799. /**
  50800. * Sets the layer id use to find what meshes are not impacted by the light.
  50801. * Inactive if 0
  50802. */
  50803. set: function (value) {
  50804. this._excludeWithLayerMask = value;
  50805. this._resyncMeshes();
  50806. },
  50807. enumerable: true,
  50808. configurable: true
  50809. });
  50810. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  50811. /**
  50812. * Gets the layer id use to find what meshes are impacted by the light.
  50813. * Inactive if 0
  50814. */
  50815. get: function () {
  50816. return this._includeOnlyWithLayerMask;
  50817. },
  50818. /**
  50819. * Sets the layer id use to find what meshes are impacted by the light.
  50820. * Inactive if 0
  50821. */
  50822. set: function (value) {
  50823. this._includeOnlyWithLayerMask = value;
  50824. this._resyncMeshes();
  50825. },
  50826. enumerable: true,
  50827. configurable: true
  50828. });
  50829. Object.defineProperty(Light.prototype, "lightmapMode", {
  50830. /**
  50831. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  50832. */
  50833. get: function () {
  50834. return this._lightmapMode;
  50835. },
  50836. /**
  50837. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  50838. */
  50839. set: function (value) {
  50840. if (this._lightmapMode === value) {
  50841. return;
  50842. }
  50843. this._lightmapMode = value;
  50844. this._markMeshesAsLightDirty();
  50845. },
  50846. enumerable: true,
  50847. configurable: true
  50848. });
  50849. /**
  50850. * Returns the string "Light".
  50851. * @returns the class name
  50852. */
  50853. Light.prototype.getClassName = function () {
  50854. return "Light";
  50855. };
  50856. /**
  50857. * Converts the light information to a readable string for debug purpose.
  50858. * @param fullDetails Supports for multiple levels of logging within scene loading
  50859. * @returns the human readable light info
  50860. */
  50861. Light.prototype.toString = function (fullDetails) {
  50862. var ret = "Name: " + this.name;
  50863. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  50864. if (this.animations) {
  50865. for (var i = 0; i < this.animations.length; i++) {
  50866. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  50867. }
  50868. }
  50869. if (fullDetails) {
  50870. }
  50871. return ret;
  50872. };
  50873. /** @hidden */
  50874. Light.prototype._syncParentEnabledState = function () {
  50875. _super.prototype._syncParentEnabledState.call(this);
  50876. this._resyncMeshes();
  50877. };
  50878. /**
  50879. * Set the enabled state of this node.
  50880. * @param value - the new enabled state
  50881. */
  50882. Light.prototype.setEnabled = function (value) {
  50883. _super.prototype.setEnabled.call(this, value);
  50884. this._resyncMeshes();
  50885. };
  50886. /**
  50887. * Returns the Light associated shadow generator if any.
  50888. * @return the associated shadow generator.
  50889. */
  50890. Light.prototype.getShadowGenerator = function () {
  50891. return this._shadowGenerator;
  50892. };
  50893. /**
  50894. * Returns a Vector3, the absolute light position in the World.
  50895. * @returns the world space position of the light
  50896. */
  50897. Light.prototype.getAbsolutePosition = function () {
  50898. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  50899. };
  50900. /**
  50901. * Specifies if the light will affect the passed mesh.
  50902. * @param mesh The mesh to test against the light
  50903. * @return true the mesh is affected otherwise, false.
  50904. */
  50905. Light.prototype.canAffectMesh = function (mesh) {
  50906. if (!mesh) {
  50907. return true;
  50908. }
  50909. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  50910. return false;
  50911. }
  50912. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  50913. return false;
  50914. }
  50915. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  50916. return false;
  50917. }
  50918. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  50919. return false;
  50920. }
  50921. return true;
  50922. };
  50923. /**
  50924. * Sort function to order lights for rendering.
  50925. * @param a First Light object to compare to second.
  50926. * @param b Second Light object to compare first.
  50927. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  50928. */
  50929. Light.CompareLightsPriority = function (a, b) {
  50930. //shadow-casting lights have priority over non-shadow-casting lights
  50931. //the renderPrioirty is a secondary sort criterion
  50932. if (a.shadowEnabled !== b.shadowEnabled) {
  50933. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  50934. }
  50935. return b.renderPriority - a.renderPriority;
  50936. };
  50937. /**
  50938. * Releases resources associated with this node.
  50939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50941. */
  50942. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  50943. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  50944. if (this._shadowGenerator) {
  50945. this._shadowGenerator.dispose();
  50946. this._shadowGenerator = null;
  50947. }
  50948. // Animations
  50949. this.getScene().stopAnimation(this);
  50950. // Remove from meshes
  50951. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  50952. var mesh = _a[_i];
  50953. mesh._removeLightSource(this);
  50954. }
  50955. this._uniformBuffer.dispose();
  50956. // Remove from scene
  50957. this.getScene().removeLight(this);
  50958. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  50959. };
  50960. /**
  50961. * Returns the light type ID (integer).
  50962. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50963. */
  50964. Light.prototype.getTypeID = function () {
  50965. return 0;
  50966. };
  50967. /**
  50968. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  50969. * @returns the scaled intensity in intensity mode unit
  50970. */
  50971. Light.prototype.getScaledIntensity = function () {
  50972. return this._photometricScale * this.intensity;
  50973. };
  50974. /**
  50975. * Returns a new Light object, named "name", from the current one.
  50976. * @param name The name of the cloned light
  50977. * @returns the new created light
  50978. */
  50979. Light.prototype.clone = function (name) {
  50980. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  50981. if (!constructor) {
  50982. return null;
  50983. }
  50984. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  50985. };
  50986. /**
  50987. * Serializes the current light into a Serialization object.
  50988. * @returns the serialized object.
  50989. */
  50990. Light.prototype.serialize = function () {
  50991. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50992. // Type
  50993. serializationObject.type = this.getTypeID();
  50994. // Parent
  50995. if (this.parent) {
  50996. serializationObject.parentId = this.parent.id;
  50997. }
  50998. // Inclusion / exclusions
  50999. if (this.excludedMeshes.length > 0) {
  51000. serializationObject.excludedMeshesIds = [];
  51001. this.excludedMeshes.forEach(function (mesh) {
  51002. serializationObject.excludedMeshesIds.push(mesh.id);
  51003. });
  51004. }
  51005. if (this.includedOnlyMeshes.length > 0) {
  51006. serializationObject.includedOnlyMeshesIds = [];
  51007. this.includedOnlyMeshes.forEach(function (mesh) {
  51008. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  51009. });
  51010. }
  51011. // Animations
  51012. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  51013. serializationObject.ranges = this.serializeAnimationRanges();
  51014. return serializationObject;
  51015. };
  51016. /**
  51017. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  51018. * This new light is named "name" and added to the passed scene.
  51019. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  51020. * @param name The friendly name of the light
  51021. * @param scene The scene the new light will belong to
  51022. * @returns the constructor function
  51023. */
  51024. Light.GetConstructorFromName = function (type, name, scene) {
  51025. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_4__["Node"].Construct("Light_Type_" + type, name, scene);
  51026. if (constructorFunc) {
  51027. return constructorFunc;
  51028. }
  51029. // Default to no light for none present once.
  51030. return null;
  51031. };
  51032. /**
  51033. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  51034. * @param parsedLight The JSON representation of the light
  51035. * @param scene The scene to create the parsed light in
  51036. * @returns the created light after parsing
  51037. */
  51038. Light.Parse = function (parsedLight, scene) {
  51039. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  51040. if (!constructor) {
  51041. return null;
  51042. }
  51043. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  51044. // Inclusion / exclusions
  51045. if (parsedLight.excludedMeshesIds) {
  51046. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  51047. }
  51048. if (parsedLight.includedOnlyMeshesIds) {
  51049. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  51050. }
  51051. // Parent
  51052. if (parsedLight.parentId) {
  51053. light._waitingParentId = parsedLight.parentId;
  51054. }
  51055. // Falloff
  51056. if (parsedLight.falloffType !== undefined) {
  51057. light.falloffType = parsedLight.falloffType;
  51058. }
  51059. // Lightmaps
  51060. if (parsedLight.lightmapMode !== undefined) {
  51061. light.lightmapMode = parsedLight.lightmapMode;
  51062. }
  51063. // Animations
  51064. if (parsedLight.animations) {
  51065. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  51066. var parsedAnimation = parsedLight.animations[animationIndex];
  51067. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].GetClass("BABYLON.Animation");
  51068. if (internalClass) {
  51069. light.animations.push(internalClass.Parse(parsedAnimation));
  51070. }
  51071. }
  51072. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  51073. }
  51074. if (parsedLight.autoAnimate) {
  51075. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  51076. }
  51077. return light;
  51078. };
  51079. Light.prototype._hookArrayForExcluded = function (array) {
  51080. var _this = this;
  51081. var oldPush = array.push;
  51082. array.push = function () {
  51083. var items = [];
  51084. for (var _i = 0; _i < arguments.length; _i++) {
  51085. items[_i] = arguments[_i];
  51086. }
  51087. var result = oldPush.apply(array, items);
  51088. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  51089. var item = items_1[_a];
  51090. item._resyncLighSource(_this);
  51091. }
  51092. return result;
  51093. };
  51094. var oldSplice = array.splice;
  51095. array.splice = function (index, deleteCount) {
  51096. var deleted = oldSplice.apply(array, [index, deleteCount]);
  51097. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  51098. var item = deleted_1[_i];
  51099. item._resyncLighSource(_this);
  51100. }
  51101. return deleted;
  51102. };
  51103. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  51104. var item = array_1[_i];
  51105. item._resyncLighSource(this);
  51106. }
  51107. };
  51108. Light.prototype._hookArrayForIncludedOnly = function (array) {
  51109. var _this = this;
  51110. var oldPush = array.push;
  51111. array.push = function () {
  51112. var items = [];
  51113. for (var _i = 0; _i < arguments.length; _i++) {
  51114. items[_i] = arguments[_i];
  51115. }
  51116. var result = oldPush.apply(array, items);
  51117. _this._resyncMeshes();
  51118. return result;
  51119. };
  51120. var oldSplice = array.splice;
  51121. array.splice = function (index, deleteCount) {
  51122. var deleted = oldSplice.apply(array, [index, deleteCount]);
  51123. _this._resyncMeshes();
  51124. return deleted;
  51125. };
  51126. this._resyncMeshes();
  51127. };
  51128. Light.prototype._resyncMeshes = function () {
  51129. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  51130. var mesh = _a[_i];
  51131. mesh._resyncLighSource(this);
  51132. }
  51133. };
  51134. /**
  51135. * Forces the meshes to update their light related information in their rendering used effects
  51136. * @hidden Internal Use Only
  51137. */
  51138. Light.prototype._markMeshesAsLightDirty = function () {
  51139. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  51140. var mesh = _a[_i];
  51141. if (mesh.lightSources.indexOf(this) !== -1) {
  51142. mesh._markSubMeshesAsLightDirty();
  51143. }
  51144. }
  51145. };
  51146. /**
  51147. * Recomputes the cached photometric scale if needed.
  51148. */
  51149. Light.prototype._computePhotometricScale = function () {
  51150. this._photometricScale = this._getPhotometricScale();
  51151. this.getScene().resetCachedMaterial();
  51152. };
  51153. /**
  51154. * Returns the Photometric Scale according to the light type and intensity mode.
  51155. */
  51156. Light.prototype._getPhotometricScale = function () {
  51157. var photometricScale = 0.0;
  51158. var lightTypeID = this.getTypeID();
  51159. //get photometric mode
  51160. var photometricMode = this.intensityMode;
  51161. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  51162. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  51163. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  51164. }
  51165. else {
  51166. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  51167. }
  51168. }
  51169. //compute photometric scale
  51170. switch (lightTypeID) {
  51171. case Light.LIGHTTYPEID_POINTLIGHT:
  51172. case Light.LIGHTTYPEID_SPOTLIGHT:
  51173. switch (photometricMode) {
  51174. case Light.INTENSITYMODE_LUMINOUSPOWER:
  51175. photometricScale = 1.0 / (4.0 * Math.PI);
  51176. break;
  51177. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  51178. photometricScale = 1.0;
  51179. break;
  51180. case Light.INTENSITYMODE_LUMINANCE:
  51181. photometricScale = this.radius * this.radius;
  51182. break;
  51183. }
  51184. break;
  51185. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  51186. switch (photometricMode) {
  51187. case Light.INTENSITYMODE_ILLUMINANCE:
  51188. photometricScale = 1.0;
  51189. break;
  51190. case Light.INTENSITYMODE_LUMINANCE:
  51191. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  51192. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  51193. var apexAngleRadians = this.radius;
  51194. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  51195. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  51196. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  51197. photometricScale = solidAngle;
  51198. break;
  51199. }
  51200. break;
  51201. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  51202. // No fall off in hemisperic light.
  51203. photometricScale = 1.0;
  51204. break;
  51205. }
  51206. return photometricScale;
  51207. };
  51208. /**
  51209. * Reorder the light in the scene according to their defined priority.
  51210. * @hidden Internal Use Only
  51211. */
  51212. Light.prototype._reorderLightsInScene = function () {
  51213. var scene = this.getScene();
  51214. if (this._renderPriority != 0) {
  51215. scene.requireLightSorting = true;
  51216. }
  51217. this.getScene().sortLightsByPriority();
  51218. };
  51219. /**
  51220. * Falloff Default: light is falling off following the material specification:
  51221. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  51222. */
  51223. Light.FALLOFF_DEFAULT = 0;
  51224. /**
  51225. * Falloff Physical: light is falling off following the inverse squared distance law.
  51226. */
  51227. Light.FALLOFF_PHYSICAL = 1;
  51228. /**
  51229. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  51230. * to enhance interoperability with other engines.
  51231. */
  51232. Light.FALLOFF_GLTF = 2;
  51233. /**
  51234. * Falloff Standard: light is falling off like in the standard material
  51235. * to enhance interoperability with other materials.
  51236. */
  51237. Light.FALLOFF_STANDARD = 3;
  51238. //lightmapMode Consts
  51239. /**
  51240. * If every light affecting the material is in this lightmapMode,
  51241. * material.lightmapTexture adds or multiplies
  51242. * (depends on material.useLightmapAsShadowmap)
  51243. * after every other light calculations.
  51244. */
  51245. Light.LIGHTMAP_DEFAULT = 0;
  51246. /**
  51247. * material.lightmapTexture as only diffuse lighting from this light
  51248. * adds only specular lighting from this light
  51249. * adds dynamic shadows
  51250. */
  51251. Light.LIGHTMAP_SPECULAR = 1;
  51252. /**
  51253. * material.lightmapTexture as only lighting
  51254. * no light calculation from this light
  51255. * only adds dynamic shadows from this light
  51256. */
  51257. Light.LIGHTMAP_SHADOWSONLY = 2;
  51258. // Intensity Mode Consts
  51259. /**
  51260. * Each light type uses the default quantity according to its type:
  51261. * point/spot lights use luminous intensity
  51262. * directional lights use illuminance
  51263. */
  51264. Light.INTENSITYMODE_AUTOMATIC = 0;
  51265. /**
  51266. * lumen (lm)
  51267. */
  51268. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  51269. /**
  51270. * candela (lm/sr)
  51271. */
  51272. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  51273. /**
  51274. * lux (lm/m^2)
  51275. */
  51276. Light.INTENSITYMODE_ILLUMINANCE = 3;
  51277. /**
  51278. * nit (cd/m^2)
  51279. */
  51280. Light.INTENSITYMODE_LUMINANCE = 4;
  51281. // Light types ids const.
  51282. /**
  51283. * Light type const id of the point light.
  51284. */
  51285. Light.LIGHTTYPEID_POINTLIGHT = 0;
  51286. /**
  51287. * Light type const id of the directional light.
  51288. */
  51289. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  51290. /**
  51291. * Light type const id of the spot light.
  51292. */
  51293. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  51294. /**
  51295. * Light type const id of the hemispheric light.
  51296. */
  51297. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  51298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51300. ], Light.prototype, "diffuse", void 0);
  51301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51303. ], Light.prototype, "specular", void 0);
  51304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51306. ], Light.prototype, "falloffType", void 0);
  51307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51309. ], Light.prototype, "intensity", void 0);
  51310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51312. ], Light.prototype, "range", null);
  51313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51315. ], Light.prototype, "intensityMode", null);
  51316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51318. ], Light.prototype, "radius", null);
  51319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51321. ], Light.prototype, "_renderPriority", void 0);
  51322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  51324. ], Light.prototype, "renderPriority", void 0);
  51325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  51327. ], Light.prototype, "_shadowEnabled", void 0);
  51328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  51330. ], Light.prototype, "_excludeWithLayerMask", void 0);
  51331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  51333. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  51334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  51336. ], Light.prototype, "_lightmapMode", void 0);
  51337. return Light;
  51338. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  51339. /***/ }),
  51340. /***/ "./Lights/pointLight.ts":
  51341. /*!******************************!*\
  51342. !*** ./Lights/pointLight.ts ***!
  51343. \******************************/
  51344. /*! exports provided: PointLight */
  51345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51346. "use strict";
  51347. __webpack_require__.r(__webpack_exports__);
  51348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  51349. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51350. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  51351. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  51352. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  51353. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  51354. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  51355. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  51356. return function () { return new PointLight(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  51357. });
  51358. /**
  51359. * A point light is a light defined by an unique point in world space.
  51360. * The light is emitted in every direction from this point.
  51361. * A good example of a point light is a standard light bulb.
  51362. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51363. */
  51364. var PointLight = /** @class */ (function (_super) {
  51365. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  51366. /**
  51367. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51368. * A PointLight emits the light in every direction.
  51369. * It can cast shadows.
  51370. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51371. * ```javascript
  51372. * var pointLight = new PointLight("pl", camera.position, scene);
  51373. * ```
  51374. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51375. * @param name The light friendly name
  51376. * @param position The position of the point light in the scene
  51377. * @param scene The scene the lights belongs to
  51378. */
  51379. function PointLight(name, position, scene) {
  51380. var _this = _super.call(this, name, scene) || this;
  51381. _this._shadowAngle = Math.PI / 2;
  51382. _this.position = position;
  51383. return _this;
  51384. }
  51385. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  51386. /**
  51387. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51388. * This specifies what angle the shadow will use to be created.
  51389. *
  51390. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51391. */
  51392. get: function () {
  51393. return this._shadowAngle;
  51394. },
  51395. /**
  51396. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51397. * This specifies what angle the shadow will use to be created.
  51398. *
  51399. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51400. */
  51401. set: function (value) {
  51402. this._shadowAngle = value;
  51403. this.forceProjectionMatrixCompute();
  51404. },
  51405. enumerable: true,
  51406. configurable: true
  51407. });
  51408. Object.defineProperty(PointLight.prototype, "direction", {
  51409. /**
  51410. * Gets the direction if it has been set.
  51411. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51412. */
  51413. get: function () {
  51414. return this._direction;
  51415. },
  51416. /**
  51417. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51418. */
  51419. set: function (value) {
  51420. var previousNeedCube = this.needCube();
  51421. this._direction = value;
  51422. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  51423. this._shadowGenerator.recreateShadowMap();
  51424. }
  51425. },
  51426. enumerable: true,
  51427. configurable: true
  51428. });
  51429. /**
  51430. * Returns the string "PointLight"
  51431. * @returns the class name
  51432. */
  51433. PointLight.prototype.getClassName = function () {
  51434. return "PointLight";
  51435. };
  51436. /**
  51437. * Returns the integer 0.
  51438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51439. */
  51440. PointLight.prototype.getTypeID = function () {
  51441. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  51442. };
  51443. /**
  51444. * Specifies wether or not the shadowmap should be a cube texture.
  51445. * @returns true if the shadowmap needs to be a cube texture.
  51446. */
  51447. PointLight.prototype.needCube = function () {
  51448. return !this.direction;
  51449. };
  51450. /**
  51451. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51452. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51453. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51454. */
  51455. PointLight.prototype.getShadowDirection = function (faceIndex) {
  51456. if (this.direction) {
  51457. return _super.prototype.getShadowDirection.call(this, faceIndex);
  51458. }
  51459. else {
  51460. switch (faceIndex) {
  51461. case 0:
  51462. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  51463. case 1:
  51464. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  51465. case 2:
  51466. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  51467. case 3:
  51468. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  51469. case 4:
  51470. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  51471. case 5:
  51472. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  51473. }
  51474. }
  51475. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  51476. };
  51477. /**
  51478. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51479. * - fov = PI / 2
  51480. * - aspect ratio : 1.0
  51481. * - z-near and far equal to the active camera minZ and maxZ.
  51482. * Returns the PointLight.
  51483. */
  51484. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  51485. var activeCamera = this.getScene().activeCamera;
  51486. if (!activeCamera) {
  51487. return;
  51488. }
  51489. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  51490. };
  51491. PointLight.prototype._buildUniformLayout = function () {
  51492. this._uniformBuffer.addUniform("vLightData", 4);
  51493. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  51494. this._uniformBuffer.addUniform("vLightSpecular", 3);
  51495. this._uniformBuffer.addUniform("vLightFalloff", 4);
  51496. this._uniformBuffer.addUniform("shadowsInfo", 3);
  51497. this._uniformBuffer.addUniform("depthValues", 2);
  51498. this._uniformBuffer.create();
  51499. };
  51500. /**
  51501. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51502. * @param effect The effect to update
  51503. * @param lightIndex The index of the light in the effect to update
  51504. * @returns The point light
  51505. */
  51506. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  51507. if (this.computeTransformedInformation()) {
  51508. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  51509. }
  51510. else {
  51511. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  51512. }
  51513. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  51514. return this;
  51515. };
  51516. /**
  51517. * Prepares the list of defines specific to the light type.
  51518. * @param defines the list of defines
  51519. * @param lightIndex defines the index of the light for the effect
  51520. */
  51521. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  51522. defines["POINTLIGHT" + lightIndex] = true;
  51523. };
  51524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51526. ], PointLight.prototype, "shadowAngle", null);
  51527. return PointLight;
  51528. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  51529. /***/ }),
  51530. /***/ "./Lights/shadowLight.ts":
  51531. /*!*******************************!*\
  51532. !*** ./Lights/shadowLight.ts ***!
  51533. \*******************************/
  51534. /*! exports provided: ShadowLight */
  51535. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51536. "use strict";
  51537. __webpack_require__.r(__webpack_exports__);
  51538. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  51539. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51540. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  51541. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  51542. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  51543. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  51544. /**
  51545. * Base implementation IShadowLight
  51546. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  51547. */
  51548. var ShadowLight = /** @class */ (function (_super) {
  51549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  51550. function ShadowLight() {
  51551. var _this = _super !== null && _super.apply(this, arguments) || this;
  51552. _this._needProjectionMatrixCompute = true;
  51553. return _this;
  51554. }
  51555. ShadowLight.prototype._setPosition = function (value) {
  51556. this._position = value;
  51557. };
  51558. Object.defineProperty(ShadowLight.prototype, "position", {
  51559. /**
  51560. * Sets the position the shadow will be casted from. Also use as the light position for both
  51561. * point and spot lights.
  51562. */
  51563. get: function () {
  51564. return this._position;
  51565. },
  51566. /**
  51567. * Sets the position the shadow will be casted from. Also use as the light position for both
  51568. * point and spot lights.
  51569. */
  51570. set: function (value) {
  51571. this._setPosition(value);
  51572. },
  51573. enumerable: true,
  51574. configurable: true
  51575. });
  51576. ShadowLight.prototype._setDirection = function (value) {
  51577. this._direction = value;
  51578. };
  51579. Object.defineProperty(ShadowLight.prototype, "direction", {
  51580. /**
  51581. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  51582. * Also use as the light direction on spot and directional lights.
  51583. */
  51584. get: function () {
  51585. return this._direction;
  51586. },
  51587. /**
  51588. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  51589. * Also use as the light direction on spot and directional lights.
  51590. */
  51591. set: function (value) {
  51592. this._setDirection(value);
  51593. },
  51594. enumerable: true,
  51595. configurable: true
  51596. });
  51597. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  51598. /**
  51599. * Gets the shadow projection clipping minimum z value.
  51600. */
  51601. get: function () {
  51602. return this._shadowMinZ;
  51603. },
  51604. /**
  51605. * Sets the shadow projection clipping minimum z value.
  51606. */
  51607. set: function (value) {
  51608. this._shadowMinZ = value;
  51609. this.forceProjectionMatrixCompute();
  51610. },
  51611. enumerable: true,
  51612. configurable: true
  51613. });
  51614. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  51615. /**
  51616. * Sets the shadow projection clipping maximum z value.
  51617. */
  51618. get: function () {
  51619. return this._shadowMaxZ;
  51620. },
  51621. /**
  51622. * Gets the shadow projection clipping maximum z value.
  51623. */
  51624. set: function (value) {
  51625. this._shadowMaxZ = value;
  51626. this.forceProjectionMatrixCompute();
  51627. },
  51628. enumerable: true,
  51629. configurable: true
  51630. });
  51631. /**
  51632. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  51633. * @returns true if the information has been computed, false if it does not need to (no parenting)
  51634. */
  51635. ShadowLight.prototype.computeTransformedInformation = function () {
  51636. if (this.parent && this.parent.getWorldMatrix) {
  51637. if (!this.transformedPosition) {
  51638. this.transformedPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  51639. }
  51640. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  51641. // In case the direction is present.
  51642. if (this.direction) {
  51643. if (!this.transformedDirection) {
  51644. this.transformedDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  51645. }
  51646. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  51647. }
  51648. return true;
  51649. }
  51650. return false;
  51651. };
  51652. /**
  51653. * Return the depth scale used for the shadow map.
  51654. * @returns the depth scale.
  51655. */
  51656. ShadowLight.prototype.getDepthScale = function () {
  51657. return 50.0;
  51658. };
  51659. /**
  51660. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  51661. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51662. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51663. */
  51664. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  51665. return this.transformedDirection ? this.transformedDirection : this.direction;
  51666. };
  51667. /**
  51668. * Returns the ShadowLight absolute position in the World.
  51669. * @returns the position vector in world space
  51670. */
  51671. ShadowLight.prototype.getAbsolutePosition = function () {
  51672. return this.transformedPosition ? this.transformedPosition : this.position;
  51673. };
  51674. /**
  51675. * Sets the ShadowLight direction toward the passed target.
  51676. * @param target The point to target in local space
  51677. * @returns the updated ShadowLight direction
  51678. */
  51679. ShadowLight.prototype.setDirectionToTarget = function (target) {
  51680. this.direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  51681. return this.direction;
  51682. };
  51683. /**
  51684. * Returns the light rotation in euler definition.
  51685. * @returns the x y z rotation in local space.
  51686. */
  51687. ShadowLight.prototype.getRotation = function () {
  51688. this.direction.normalize();
  51689. var xaxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y);
  51690. var yaxis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  51691. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  51692. };
  51693. /**
  51694. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  51695. * @returns true if a cube texture needs to be use
  51696. */
  51697. ShadowLight.prototype.needCube = function () {
  51698. return false;
  51699. };
  51700. /**
  51701. * Detects if the projection matrix requires to be recomputed this frame.
  51702. * @returns true if it requires to be recomputed otherwise, false.
  51703. */
  51704. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  51705. return this._needProjectionMatrixCompute;
  51706. };
  51707. /**
  51708. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  51709. */
  51710. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  51711. this._needProjectionMatrixCompute = true;
  51712. };
  51713. /** @hidden */
  51714. ShadowLight.prototype._initCache = function () {
  51715. _super.prototype._initCache.call(this);
  51716. this._cache.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  51717. };
  51718. /** @hidden */
  51719. ShadowLight.prototype._isSynchronized = function () {
  51720. if (!this._cache.position.equals(this.position)) {
  51721. return false;
  51722. }
  51723. return true;
  51724. };
  51725. /**
  51726. * Computes the world matrix of the node
  51727. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  51728. * @returns the world matrix
  51729. */
  51730. ShadowLight.prototype.computeWorldMatrix = function (force) {
  51731. if (!force && this.isSynchronized()) {
  51732. this._currentRenderId = this.getScene().getRenderId();
  51733. return this._worldMatrix;
  51734. }
  51735. this._updateCache();
  51736. this._cache.position.copyFrom(this.position);
  51737. if (!this._worldMatrix) {
  51738. this._worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  51739. }
  51740. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  51741. if (this.parent && this.parent.getWorldMatrix) {
  51742. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  51743. this._markSyncedWithParent();
  51744. }
  51745. // Cache the determinant
  51746. this._worldMatrixDeterminantIsDirty = true;
  51747. return this._worldMatrix;
  51748. };
  51749. /**
  51750. * Gets the minZ used for shadow according to both the scene and the light.
  51751. * @param activeCamera The camera we are returning the min for
  51752. * @returns the depth min z
  51753. */
  51754. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  51755. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  51756. };
  51757. /**
  51758. * Gets the maxZ used for shadow according to both the scene and the light.
  51759. * @param activeCamera The camera we are returning the max for
  51760. * @returns the depth max z
  51761. */
  51762. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  51763. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  51764. };
  51765. /**
  51766. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  51767. * @param matrix The materix to updated with the projection information
  51768. * @param viewMatrix The transform matrix of the light
  51769. * @param renderList The list of mesh to render in the map
  51770. * @returns The current light
  51771. */
  51772. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  51773. if (this.customProjectionMatrixBuilder) {
  51774. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  51775. }
  51776. else {
  51777. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  51778. }
  51779. return this;
  51780. };
  51781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51783. ], ShadowLight.prototype, "position", null);
  51784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51786. ], ShadowLight.prototype, "direction", null);
  51787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51789. ], ShadowLight.prototype, "shadowMinZ", null);
  51790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51792. ], ShadowLight.prototype, "shadowMaxZ", null);
  51793. return ShadowLight;
  51794. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  51795. /***/ }),
  51796. /***/ "./Lights/spotLight.ts":
  51797. /*!*****************************!*\
  51798. !*** ./Lights/spotLight.ts ***!
  51799. \*****************************/
  51800. /*! exports provided: SpotLight */
  51801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51802. "use strict";
  51803. __webpack_require__.r(__webpack_exports__);
  51804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  51805. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51806. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  51807. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  51808. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  51809. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  51810. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  51811. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  51812. return function () { return new SpotLight(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), 0, 0, scene); };
  51813. });
  51814. /**
  51815. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51816. * These values define a cone of light starting from the position, emitting toward the direction.
  51817. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51818. * and the exponent defines the speed of the decay of the light with distance (reach).
  51819. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51820. */
  51821. var SpotLight = /** @class */ (function (_super) {
  51822. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  51823. /**
  51824. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51825. * It can cast shadows.
  51826. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51827. * @param name The light friendly name
  51828. * @param position The position of the spot light in the scene
  51829. * @param direction The direction of the light in the scene
  51830. * @param angle The cone angle of the light in Radians
  51831. * @param exponent The light decay speed with the distance from the emission spot
  51832. * @param scene The scene the lights belongs to
  51833. */
  51834. function SpotLight(name, position, direction, angle, exponent, scene) {
  51835. var _this = _super.call(this, name, scene) || this;
  51836. _this._innerAngle = 0;
  51837. _this._projectionTextureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  51838. _this._projectionTextureLightNear = 1e-6;
  51839. _this._projectionTextureLightFar = 1000.0;
  51840. _this._projectionTextureUpDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  51841. _this._projectionTextureViewLightDirty = true;
  51842. _this._projectionTextureProjectionLightDirty = true;
  51843. _this._projectionTextureDirty = true;
  51844. _this._projectionTextureViewTargetVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  51845. _this._projectionTextureViewLightMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  51846. _this._projectionTextureProjectionLightMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  51847. _this._projectionTextureScalingMatrix = _Maths_math_vector__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);
  51848. _this.position = position;
  51849. _this.direction = direction;
  51850. _this.angle = angle;
  51851. _this.exponent = exponent;
  51852. return _this;
  51853. }
  51854. Object.defineProperty(SpotLight.prototype, "angle", {
  51855. /**
  51856. * Gets the cone angle of the spot light in Radians.
  51857. */
  51858. get: function () {
  51859. return this._angle;
  51860. },
  51861. /**
  51862. * Sets the cone angle of the spot light in Radians.
  51863. */
  51864. set: function (value) {
  51865. this._angle = value;
  51866. this._cosHalfAngle = Math.cos(value * 0.5);
  51867. this._projectionTextureProjectionLightDirty = true;
  51868. this.forceProjectionMatrixCompute();
  51869. this._computeAngleValues();
  51870. },
  51871. enumerable: true,
  51872. configurable: true
  51873. });
  51874. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  51875. /**
  51876. * Only used in gltf falloff mode, this defines the angle where
  51877. * the directional falloff will start before cutting at angle which could be seen
  51878. * as outer angle.
  51879. */
  51880. get: function () {
  51881. return this._innerAngle;
  51882. },
  51883. /**
  51884. * Only used in gltf falloff mode, this defines the angle where
  51885. * the directional falloff will start before cutting at angle which could be seen
  51886. * as outer angle.
  51887. */
  51888. set: function (value) {
  51889. this._innerAngle = value;
  51890. this._computeAngleValues();
  51891. },
  51892. enumerable: true,
  51893. configurable: true
  51894. });
  51895. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  51896. /**
  51897. * Allows scaling the angle of the light for shadow generation only.
  51898. */
  51899. get: function () {
  51900. return this._shadowAngleScale;
  51901. },
  51902. /**
  51903. * Allows scaling the angle of the light for shadow generation only.
  51904. */
  51905. set: function (value) {
  51906. this._shadowAngleScale = value;
  51907. this.forceProjectionMatrixCompute();
  51908. },
  51909. enumerable: true,
  51910. configurable: true
  51911. });
  51912. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  51913. /**
  51914. * Allows reading the projecton texture
  51915. */
  51916. get: function () {
  51917. return this._projectionTextureMatrix;
  51918. },
  51919. enumerable: true,
  51920. configurable: true
  51921. });
  51922. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  51923. /**
  51924. * Gets the near clip of the Spotlight for texture projection.
  51925. */
  51926. get: function () {
  51927. return this._projectionTextureLightNear;
  51928. },
  51929. /**
  51930. * Sets the near clip of the Spotlight for texture projection.
  51931. */
  51932. set: function (value) {
  51933. this._projectionTextureLightNear = value;
  51934. this._projectionTextureProjectionLightDirty = true;
  51935. },
  51936. enumerable: true,
  51937. configurable: true
  51938. });
  51939. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  51940. /**
  51941. * Gets the far clip of the Spotlight for texture projection.
  51942. */
  51943. get: function () {
  51944. return this._projectionTextureLightFar;
  51945. },
  51946. /**
  51947. * Sets the far clip of the Spotlight for texture projection.
  51948. */
  51949. set: function (value) {
  51950. this._projectionTextureLightFar = value;
  51951. this._projectionTextureProjectionLightDirty = true;
  51952. },
  51953. enumerable: true,
  51954. configurable: true
  51955. });
  51956. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  51957. /**
  51958. * Gets the Up vector of the Spotlight for texture projection.
  51959. */
  51960. get: function () {
  51961. return this._projectionTextureUpDirection;
  51962. },
  51963. /**
  51964. * Sets the Up vector of the Spotlight for texture projection.
  51965. */
  51966. set: function (value) {
  51967. this._projectionTextureUpDirection = value;
  51968. this._projectionTextureProjectionLightDirty = true;
  51969. },
  51970. enumerable: true,
  51971. configurable: true
  51972. });
  51973. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  51974. /**
  51975. * Gets the projection texture of the light.
  51976. */
  51977. get: function () {
  51978. return this._projectionTexture;
  51979. },
  51980. /**
  51981. * Sets the projection texture of the light.
  51982. */
  51983. set: function (value) {
  51984. var _this = this;
  51985. if (this._projectionTexture === value) {
  51986. return;
  51987. }
  51988. this._projectionTexture = value;
  51989. this._projectionTextureDirty = true;
  51990. if (this._projectionTexture && !this._projectionTexture.isReady()) {
  51991. var texture = this._projectionTexture;
  51992. if (texture.onLoadObservable) {
  51993. texture.onLoadObservable.addOnce(function () {
  51994. _this._markMeshesAsLightDirty();
  51995. });
  51996. }
  51997. }
  51998. },
  51999. enumerable: true,
  52000. configurable: true
  52001. });
  52002. /**
  52003. * Returns the string "SpotLight".
  52004. * @returns the class name
  52005. */
  52006. SpotLight.prototype.getClassName = function () {
  52007. return "SpotLight";
  52008. };
  52009. /**
  52010. * Returns the integer 2.
  52011. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52012. */
  52013. SpotLight.prototype.getTypeID = function () {
  52014. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  52015. };
  52016. /**
  52017. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52018. */
  52019. SpotLight.prototype._setDirection = function (value) {
  52020. _super.prototype._setDirection.call(this, value);
  52021. this._projectionTextureViewLightDirty = true;
  52022. };
  52023. /**
  52024. * Overrides the position setter to recompute the projection texture view light Matrix.
  52025. */
  52026. SpotLight.prototype._setPosition = function (value) {
  52027. _super.prototype._setPosition.call(this, value);
  52028. this._projectionTextureViewLightDirty = true;
  52029. };
  52030. /**
  52031. * 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.
  52032. * Returns the SpotLight.
  52033. */
  52034. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  52035. var activeCamera = this.getScene().activeCamera;
  52036. if (!activeCamera) {
  52037. return;
  52038. }
  52039. this._shadowAngleScale = this._shadowAngleScale || 1;
  52040. var angle = this._shadowAngleScale * this._angle;
  52041. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  52042. };
  52043. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  52044. this._projectionTextureViewLightDirty = false;
  52045. this._projectionTextureDirty = true;
  52046. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  52047. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  52048. };
  52049. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  52050. this._projectionTextureProjectionLightDirty = false;
  52051. this._projectionTextureDirty = true;
  52052. var light_far = this.projectionTextureLightFar;
  52053. var light_near = this.projectionTextureLightNear;
  52054. var P = light_far / (light_far - light_near);
  52055. var Q = -P * light_near;
  52056. var S = 1.0 / Math.tan(this._angle / 2.0);
  52057. var A = 1.0;
  52058. _Maths_math_vector__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);
  52059. };
  52060. /**
  52061. * Main function for light texture projection matrix computing.
  52062. */
  52063. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  52064. this._projectionTextureDirty = false;
  52065. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  52066. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  52067. };
  52068. SpotLight.prototype._buildUniformLayout = function () {
  52069. this._uniformBuffer.addUniform("vLightData", 4);
  52070. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  52071. this._uniformBuffer.addUniform("vLightSpecular", 3);
  52072. this._uniformBuffer.addUniform("vLightDirection", 3);
  52073. this._uniformBuffer.addUniform("vLightFalloff", 4);
  52074. this._uniformBuffer.addUniform("shadowsInfo", 3);
  52075. this._uniformBuffer.addUniform("depthValues", 2);
  52076. this._uniformBuffer.create();
  52077. };
  52078. SpotLight.prototype._computeAngleValues = function () {
  52079. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  52080. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  52081. };
  52082. /**
  52083. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52084. * @param effect The effect to update
  52085. * @param lightIndex The index of the light in the effect to update
  52086. * @returns The spot light
  52087. */
  52088. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  52089. var normalizeDirection;
  52090. if (this.computeTransformedInformation()) {
  52091. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  52092. normalizeDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  52093. }
  52094. else {
  52095. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  52096. normalizeDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  52097. }
  52098. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  52099. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  52100. if (this.projectionTexture && this.projectionTexture.isReady()) {
  52101. if (this._projectionTextureViewLightDirty) {
  52102. this._computeProjectionTextureViewLightMatrix();
  52103. }
  52104. if (this._projectionTextureProjectionLightDirty) {
  52105. this._computeProjectionTextureProjectionLightMatrix();
  52106. }
  52107. if (this._projectionTextureDirty) {
  52108. this._computeProjectionTextureMatrix();
  52109. }
  52110. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  52111. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  52112. }
  52113. return this;
  52114. };
  52115. /**
  52116. * Disposes the light and the associated resources.
  52117. */
  52118. SpotLight.prototype.dispose = function () {
  52119. _super.prototype.dispose.call(this);
  52120. if (this._projectionTexture) {
  52121. this._projectionTexture.dispose();
  52122. }
  52123. };
  52124. /**
  52125. * Prepares the list of defines specific to the light type.
  52126. * @param defines the list of defines
  52127. * @param lightIndex defines the index of the light for the effect
  52128. */
  52129. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  52130. defines["SPOTLIGHT" + lightIndex] = true;
  52131. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture && this.projectionTexture.isReady() ? true : false;
  52132. };
  52133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52135. ], SpotLight.prototype, "angle", null);
  52136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52138. ], SpotLight.prototype, "innerAngle", null);
  52139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52141. ], SpotLight.prototype, "shadowAngleScale", null);
  52142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52144. ], SpotLight.prototype, "exponent", void 0);
  52145. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52147. ], SpotLight.prototype, "projectionTextureLightNear", null);
  52148. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52150. ], SpotLight.prototype, "projectionTextureLightFar", null);
  52151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52153. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  52154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  52156. ], SpotLight.prototype, "_projectionTexture", void 0);
  52157. return SpotLight;
  52158. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  52159. /***/ }),
  52160. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  52161. /*!**********************************************!*\
  52162. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  52163. \**********************************************/
  52164. /*! exports provided: _BabylonLoaderRegistered */
  52165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52166. "use strict";
  52167. __webpack_require__.r(__webpack_exports__);
  52168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  52169. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  52170. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  52171. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  52172. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  52173. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  52174. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  52175. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  52176. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  52177. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  52178. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  52179. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  52180. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  52181. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  52182. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  52183. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  52184. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  52185. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  52186. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  52187. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  52188. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  52189. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  52190. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  52191. /* harmony import */ var _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Physics/Plugins/ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  52192. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  52193. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52194. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  52195. /* harmony import */ var _Misc_stringTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Misc/stringTools */ "./Misc/stringTools.ts");
  52196. /** @hidden */
  52197. var _BabylonLoaderRegistered = true;
  52198. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  52199. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  52200. var parsedMaterial = parsedData.materials[index];
  52201. if (parsedMaterial.id === id) {
  52202. return _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].Parse(parsedMaterial, scene, rootUrl);
  52203. }
  52204. }
  52205. return null;
  52206. };
  52207. var isDescendantOf = function (mesh, names, hierarchyIds) {
  52208. for (var i in names) {
  52209. if (mesh.name === names[i]) {
  52210. hierarchyIds.push(mesh.id);
  52211. return true;
  52212. }
  52213. }
  52214. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  52215. hierarchyIds.push(mesh.id);
  52216. return true;
  52217. }
  52218. return false;
  52219. };
  52220. var logOperation = function (operation, producer) {
  52221. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  52222. };
  52223. var loadDetailLevels = function (scene, mesh) {
  52224. var mastermesh = mesh;
  52225. // Every value specified in the ids array of the lod data points to another mesh which should be used as the lower LOD level.
  52226. // The distances (or coverages) array values specified are used along with the lod mesh ids as a hint to determine the switching threshold for the various LODs.
  52227. if (mesh._waitingData.lods) {
  52228. if (mesh._waitingData.lods.ids && mesh._waitingData.lods.ids.length > 0) {
  52229. var lodmeshes = mesh._waitingData.lods.ids;
  52230. var wasenabled = mastermesh.isEnabled(false);
  52231. if (mesh._waitingData.lods.distances) {
  52232. var distances = mesh._waitingData.lods.distances;
  52233. if (distances.length >= lodmeshes.length) {
  52234. var culling = (distances.length > lodmeshes.length) ? distances[distances.length - 1] : 0;
  52235. mastermesh.setEnabled(false);
  52236. for (var index = 0; index < lodmeshes.length; index++) {
  52237. var lodid = lodmeshes[index];
  52238. var lodmesh = scene.getMeshByID(lodid);
  52239. if (lodmesh != null) {
  52240. mastermesh.addLODLevel(distances[index], lodmesh);
  52241. }
  52242. }
  52243. if (culling > 0) {
  52244. mastermesh.addLODLevel(culling, null);
  52245. }
  52246. if (wasenabled === true) {
  52247. mastermesh.setEnabled(true);
  52248. }
  52249. }
  52250. else {
  52251. _Misc_tools__WEBPACK_IMPORTED_MODULE_25__["Tools"].Warn("Invalid level of detail distances for " + mesh.name);
  52252. }
  52253. }
  52254. }
  52255. mesh._waitingData.lods = null;
  52256. }
  52257. };
  52258. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  52259. if (addToScene === void 0) { addToScene = false; }
  52260. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_16__["AssetContainer"](scene);
  52261. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  52262. // when SceneLoader.debugLogging = true (default), or exception encountered.
  52263. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  52264. // and avoid problems with multiple concurrent .babylon loads.
  52265. var log = "importScene has failed JSON parse";
  52266. try {
  52267. var parsedData = JSON.parse(data);
  52268. log = "";
  52269. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  52270. var index;
  52271. var cache;
  52272. // Environment texture
  52273. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  52274. // PBR needed for both HDR texture (gamma space) & a sky box
  52275. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  52276. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  52277. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  52278. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_10__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  52279. if (parsedData.environmentTextureRotationY) {
  52280. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  52281. }
  52282. scene.environmentTexture = hdrTexture;
  52283. }
  52284. else {
  52285. if (_Misc_stringTools__WEBPACK_IMPORTED_MODULE_26__["StringTools"].EndsWith(parsedData.environmentTexture, ".env")) {
  52286. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__["CubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  52287. if (parsedData.environmentTextureRotationY) {
  52288. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  52289. }
  52290. scene.environmentTexture = compressedTexture;
  52291. }
  52292. else {
  52293. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  52294. if (parsedData.environmentTextureRotationY) {
  52295. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  52296. }
  52297. scene.environmentTexture = cubeTexture;
  52298. }
  52299. }
  52300. if (parsedData.createDefaultSkybox === true) {
  52301. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  52302. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  52303. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  52304. }
  52305. container.environmentTexture = scene.environmentTexture;
  52306. }
  52307. // Lights
  52308. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  52309. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  52310. var parsedLight = parsedData.lights[index];
  52311. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_12__["Light"].Parse(parsedLight, scene);
  52312. if (light) {
  52313. container.lights.push(light);
  52314. log += (index === 0 ? "\n\tLights:" : "");
  52315. log += "\n\t\t" + light.toString(fullDetails);
  52316. }
  52317. }
  52318. }
  52319. // Reflection probes
  52320. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  52321. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  52322. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  52323. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_23__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  52324. if (reflectionProbe) {
  52325. container.reflectionProbes.push(reflectionProbe);
  52326. log += (index === 0 ? "\n\tReflection Probes:" : "");
  52327. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  52328. }
  52329. }
  52330. }
  52331. // Animations
  52332. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  52333. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  52334. var parsedAnimation = parsedData.animations[index];
  52335. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"].GetClass("BABYLON.Animation");
  52336. if (internalClass) {
  52337. var animation = internalClass.Parse(parsedAnimation);
  52338. scene.animations.push(animation);
  52339. container.animations.push(animation);
  52340. log += (index === 0 ? "\n\tAnimations:" : "");
  52341. log += "\n\t\t" + animation.toString(fullDetails);
  52342. }
  52343. }
  52344. }
  52345. // Materials
  52346. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  52347. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  52348. var parsedMaterial = parsedData.materials[index];
  52349. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].Parse(parsedMaterial, scene, rootUrl);
  52350. if (mat) {
  52351. container.materials.push(mat);
  52352. log += (index === 0 ? "\n\tMaterials:" : "");
  52353. log += "\n\t\t" + mat.toString(fullDetails);
  52354. // Textures
  52355. var textures = mat.getActiveTextures();
  52356. textures.forEach(function (t) {
  52357. if (container.textures.indexOf(t) == -1) {
  52358. container.textures.push(t);
  52359. }
  52360. });
  52361. }
  52362. }
  52363. }
  52364. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  52365. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  52366. var parsedMultiMaterial = parsedData.multiMaterials[index];
  52367. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  52368. container.multiMaterials.push(mmat);
  52369. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  52370. log += "\n\t\t" + mmat.toString(fullDetails);
  52371. // Textures
  52372. var textures = mmat.getActiveTextures();
  52373. textures.forEach(function (t) {
  52374. if (container.textures.indexOf(t) == -1) {
  52375. container.textures.push(t);
  52376. }
  52377. });
  52378. }
  52379. }
  52380. // Morph targets
  52381. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  52382. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  52383. var managerData = _a[_i];
  52384. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene));
  52385. }
  52386. }
  52387. // Skeletons
  52388. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  52389. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  52390. var parsedSkeleton = parsedData.skeletons[index];
  52391. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  52392. container.skeletons.push(skeleton);
  52393. log += (index === 0 ? "\n\tSkeletons:" : "");
  52394. log += "\n\t\t" + skeleton.toString(fullDetails);
  52395. }
  52396. }
  52397. // Geometries
  52398. var geometries = parsedData.geometries;
  52399. if (geometries !== undefined && geometries !== null) {
  52400. var addedGeometry = new Array();
  52401. // VertexData
  52402. var vertexData = geometries.vertexData;
  52403. if (vertexData !== undefined && vertexData !== null) {
  52404. for (index = 0, cache = vertexData.length; index < cache; index++) {
  52405. var parsedVertexData = vertexData[index];
  52406. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_5__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  52407. }
  52408. }
  52409. addedGeometry.forEach(function (g) {
  52410. if (g) {
  52411. container.geometries.push(g);
  52412. }
  52413. });
  52414. }
  52415. // Transform nodes
  52416. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  52417. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  52418. var parsedTransformNode = parsedData.transformNodes[index];
  52419. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_6__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  52420. container.transformNodes.push(node);
  52421. }
  52422. }
  52423. // Meshes
  52424. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  52425. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  52426. var parsedMesh = parsedData.meshes[index];
  52427. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  52428. container.meshes.push(mesh);
  52429. log += (index === 0 ? "\n\tMeshes:" : "");
  52430. log += "\n\t\t" + mesh.toString(fullDetails);
  52431. }
  52432. }
  52433. // Cameras
  52434. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  52435. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  52436. var parsedCamera = parsedData.cameras[index];
  52437. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  52438. container.cameras.push(camera);
  52439. log += (index === 0 ? "\n\tCameras:" : "");
  52440. log += "\n\t\t" + camera.toString(fullDetails);
  52441. }
  52442. }
  52443. // Animation Groups
  52444. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  52445. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  52446. var parsedAnimationGroup = parsedData.animationGroups[index];
  52447. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  52448. container.animationGroups.push(animationGroup);
  52449. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  52450. log += "\n\t\t" + animationGroup.toString(fullDetails);
  52451. }
  52452. }
  52453. // Browsing all the graph to connect the dots
  52454. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  52455. var camera = scene.cameras[index];
  52456. if (camera._waitingParentId) {
  52457. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  52458. camera._waitingParentId = null;
  52459. }
  52460. }
  52461. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  52462. var light_1 = scene.lights[index];
  52463. if (light_1 && light_1._waitingParentId) {
  52464. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  52465. light_1._waitingParentId = null;
  52466. }
  52467. }
  52468. // Connect parents & children and parse actions and lods
  52469. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  52470. var transformNode = scene.transformNodes[index];
  52471. if (transformNode._waitingParentId) {
  52472. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  52473. transformNode._waitingParentId = null;
  52474. }
  52475. }
  52476. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  52477. var mesh = scene.meshes[index];
  52478. if (mesh._waitingParentId) {
  52479. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  52480. mesh._waitingParentId = null;
  52481. }
  52482. if (mesh._waitingData.lods) {
  52483. loadDetailLevels(scene, mesh);
  52484. }
  52485. }
  52486. // link skeleton transform nodes
  52487. for (index = 0, cache = scene.skeletons.length; index < cache; index++) {
  52488. var skeleton = scene.skeletons[index];
  52489. if (skeleton._hasWaitingData) {
  52490. if (skeleton.bones != null) {
  52491. skeleton.bones.forEach(function (bone) {
  52492. if (bone._waitingTransformNodeId) {
  52493. var linkTransformNode = scene.getLastEntryByID(bone._waitingTransformNodeId);
  52494. if (linkTransformNode) {
  52495. bone.linkTransformNode(linkTransformNode);
  52496. }
  52497. bone._waitingTransformNodeId = null;
  52498. }
  52499. });
  52500. }
  52501. skeleton._hasWaitingData = null;
  52502. }
  52503. }
  52504. // freeze world matrix application
  52505. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  52506. var currentMesh = scene.meshes[index];
  52507. if (currentMesh._waitingData.freezeWorldMatrix) {
  52508. currentMesh.freezeWorldMatrix();
  52509. currentMesh._waitingData.freezeWorldMatrix = null;
  52510. }
  52511. else {
  52512. currentMesh.computeWorldMatrix(true);
  52513. }
  52514. }
  52515. // Lights exclusions / inclusions
  52516. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  52517. var light_2 = scene.lights[index];
  52518. // Excluded check
  52519. if (light_2._excludedMeshesIds.length > 0) {
  52520. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  52521. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  52522. if (excludedMesh) {
  52523. light_2.excludedMeshes.push(excludedMesh);
  52524. }
  52525. }
  52526. light_2._excludedMeshesIds = [];
  52527. }
  52528. // Included check
  52529. if (light_2._includedOnlyMeshesIds.length > 0) {
  52530. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  52531. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  52532. if (includedOnlyMesh) {
  52533. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  52534. }
  52535. }
  52536. light_2._includedOnlyMeshesIds = [];
  52537. }
  52538. }
  52539. _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  52540. // Actions (scene) Done last as it can access other objects.
  52541. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  52542. var mesh = scene.meshes[index];
  52543. if (mesh._waitingData.actions) {
  52544. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(mesh._waitingData.actions, mesh, scene);
  52545. mesh._waitingData.actions = null;
  52546. }
  52547. }
  52548. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  52549. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(parsedData.actions, null, scene);
  52550. }
  52551. if (!addToScene) {
  52552. container.removeAllFromScene();
  52553. }
  52554. }
  52555. catch (err) {
  52556. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  52557. if (onError) {
  52558. onError(msg, err);
  52559. }
  52560. else {
  52561. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  52562. throw err;
  52563. }
  52564. }
  52565. finally {
  52566. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  52567. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  52568. }
  52569. }
  52570. return container;
  52571. };
  52572. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].RegisterPlugin({
  52573. name: "babylon.js",
  52574. extensions: ".babylon",
  52575. canDirectLoad: function (data) {
  52576. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  52577. return true;
  52578. }
  52579. return false;
  52580. },
  52581. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  52582. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  52583. // when SceneLoader.debugLogging = true (default), or exception encountered.
  52584. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  52585. // and avoid problems with multiple concurrent .babylon loads.
  52586. var log = "importMesh has failed JSON parse";
  52587. try {
  52588. var parsedData = JSON.parse(data);
  52589. log = "";
  52590. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  52591. if (!meshesNames) {
  52592. meshesNames = null;
  52593. }
  52594. else if (!Array.isArray(meshesNames)) {
  52595. meshesNames = [meshesNames];
  52596. }
  52597. var hierarchyIds = new Array();
  52598. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  52599. var loadedSkeletonsIds = [];
  52600. var loadedMaterialsIds = [];
  52601. var index;
  52602. var cache;
  52603. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  52604. var parsedMesh = parsedData.meshes[index];
  52605. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  52606. if (meshesNames !== null) {
  52607. // Remove found mesh name from list.
  52608. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  52609. }
  52610. //Geometry?
  52611. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  52612. //does the file contain geometries?
  52613. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  52614. //find the correct geometry and add it to the scene
  52615. var found = false;
  52616. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  52617. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  52618. return;
  52619. }
  52620. else {
  52621. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  52622. if (parsedGeometryData.id === parsedMesh.geometryId) {
  52623. switch (geometryType) {
  52624. case "vertexData":
  52625. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_5__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  52626. break;
  52627. }
  52628. found = true;
  52629. }
  52630. });
  52631. }
  52632. });
  52633. if (found === false) {
  52634. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  52635. }
  52636. }
  52637. }
  52638. // Material ?
  52639. if (parsedMesh.materialId) {
  52640. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  52641. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  52642. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  52643. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  52644. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  52645. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  52646. var subMatId = parsedMultiMaterial.materials[matIndex];
  52647. loadedMaterialsIds.push(subMatId);
  52648. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  52649. if (mat) {
  52650. log += "\n\tMaterial " + mat.toString(fullDetails);
  52651. }
  52652. }
  52653. loadedMaterialsIds.push(parsedMultiMaterial.id);
  52654. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  52655. if (mmat) {
  52656. materialFound = true;
  52657. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  52658. }
  52659. break;
  52660. }
  52661. }
  52662. }
  52663. if (materialFound === false) {
  52664. loadedMaterialsIds.push(parsedMesh.materialId);
  52665. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  52666. if (!mat) {
  52667. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  52668. }
  52669. else {
  52670. log += "\n\tMaterial " + mat.toString(fullDetails);
  52671. }
  52672. }
  52673. }
  52674. // Skeleton ?
  52675. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  52676. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  52677. if (skeletonAlreadyLoaded === false) {
  52678. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  52679. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  52680. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  52681. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  52682. skeletons.push(skeleton);
  52683. loadedSkeletonsIds.push(parsedSkeleton.id);
  52684. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  52685. }
  52686. }
  52687. }
  52688. }
  52689. // Morph targets ?
  52690. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  52691. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  52692. var managerData = _a[_i];
  52693. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene);
  52694. }
  52695. }
  52696. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  52697. meshes.push(mesh);
  52698. log += "\n\tMesh " + mesh.toString(fullDetails);
  52699. }
  52700. }
  52701. // Connecting parents and lods
  52702. var currentMesh;
  52703. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  52704. currentMesh = scene.meshes[index];
  52705. if (currentMesh._waitingParentId) {
  52706. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  52707. currentMesh._waitingParentId = null;
  52708. }
  52709. if (currentMesh._waitingData.lods) {
  52710. loadDetailLevels(scene, currentMesh);
  52711. }
  52712. }
  52713. // link skeleton transform nodes
  52714. for (index = 0, cache = scene.skeletons.length; index < cache; index++) {
  52715. var skeleton = scene.skeletons[index];
  52716. if (skeleton._hasWaitingData) {
  52717. if (skeleton.bones != null) {
  52718. skeleton.bones.forEach(function (bone) {
  52719. if (bone._waitingTransformNodeId) {
  52720. var linkTransformNode = scene.getLastEntryByID(bone._waitingTransformNodeId);
  52721. if (linkTransformNode) {
  52722. bone.linkTransformNode(linkTransformNode);
  52723. }
  52724. bone._waitingTransformNodeId = null;
  52725. }
  52726. });
  52727. }
  52728. skeleton._hasWaitingData = null;
  52729. }
  52730. }
  52731. // freeze and compute world matrix application
  52732. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  52733. currentMesh = scene.meshes[index];
  52734. if (currentMesh._waitingData.freezeWorldMatrix) {
  52735. currentMesh.freezeWorldMatrix();
  52736. currentMesh._waitingData.freezeWorldMatrix = null;
  52737. }
  52738. else {
  52739. currentMesh.computeWorldMatrix(true);
  52740. }
  52741. }
  52742. }
  52743. // Particles
  52744. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  52745. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_13__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  52746. if (parser) {
  52747. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  52748. var parsedParticleSystem = parsedData.particleSystems[index];
  52749. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  52750. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  52751. }
  52752. }
  52753. }
  52754. }
  52755. return true;
  52756. }
  52757. catch (err) {
  52758. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  52759. if (onError) {
  52760. onError(msg, err);
  52761. }
  52762. else {
  52763. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  52764. throw err;
  52765. }
  52766. }
  52767. finally {
  52768. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  52769. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  52770. }
  52771. }
  52772. return false;
  52773. },
  52774. load: function (scene, data, rootUrl, onError) {
  52775. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  52776. // when SceneLoader.debugLogging = true (default), or exception encountered.
  52777. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  52778. // and avoid problems with multiple concurrent .babylon loads.
  52779. var log = "importScene has failed JSON parse";
  52780. try {
  52781. var parsedData = JSON.parse(data);
  52782. log = "";
  52783. // Scene
  52784. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  52785. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  52786. }
  52787. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  52788. scene.autoClear = parsedData.autoClear;
  52789. }
  52790. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  52791. scene.clearColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedData.clearColor);
  52792. }
  52793. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  52794. scene.ambientColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(parsedData.ambientColor);
  52795. }
  52796. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  52797. scene.gravity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  52798. }
  52799. // Fog
  52800. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  52801. scene.fogMode = parsedData.fogMode;
  52802. scene.fogColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(parsedData.fogColor);
  52803. scene.fogStart = parsedData.fogStart;
  52804. scene.fogEnd = parsedData.fogEnd;
  52805. scene.fogDensity = parsedData.fogDensity;
  52806. log += "\tFog mode for scene: ";
  52807. switch (scene.fogMode) {
  52808. // getters not compiling, so using hardcoded
  52809. case 1:
  52810. log += "exp\n";
  52811. break;
  52812. case 2:
  52813. log += "exp2\n";
  52814. break;
  52815. case 3:
  52816. log += "linear\n";
  52817. break;
  52818. }
  52819. }
  52820. //Physics
  52821. if (parsedData.physicsEnabled) {
  52822. var physicsPlugin;
  52823. if (parsedData.physicsEngine === "cannon") {
  52824. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__["CannonJSPlugin"]();
  52825. }
  52826. else if (parsedData.physicsEngine === "oimo") {
  52827. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["OimoJSPlugin"]();
  52828. }
  52829. else if (parsedData.physicsEngine === "ammo") {
  52830. physicsPlugin = new _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_22__["AmmoJSPlugin"]();
  52831. }
  52832. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  52833. //else - default engine, which is currently oimo
  52834. var physicsGravity = parsedData.physicsGravity ? _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  52835. scene.enablePhysics(physicsGravity, physicsPlugin);
  52836. }
  52837. // Metadata
  52838. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  52839. scene.metadata = parsedData.metadata;
  52840. }
  52841. //collisions, if defined. otherwise, default is true
  52842. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  52843. scene.collisionsEnabled = parsedData.collisionsEnabled;
  52844. }
  52845. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  52846. if (!container) {
  52847. return false;
  52848. }
  52849. if (parsedData.autoAnimate) {
  52850. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  52851. }
  52852. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  52853. scene.setActiveCameraByID(parsedData.activeCameraID);
  52854. }
  52855. // Environment texture
  52856. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  52857. // PBR needed for both HDR texture (gamma space) & a sky box
  52858. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  52859. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  52860. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  52861. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_10__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  52862. if (parsedData.environmentTextureRotationY) {
  52863. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  52864. }
  52865. scene.environmentTexture = hdrTexture;
  52866. }
  52867. else {
  52868. if (_Misc_stringTools__WEBPACK_IMPORTED_MODULE_26__["StringTools"].EndsWith(parsedData.environmentTexture, ".env")) {
  52869. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__["CubeTexture"](rootUrl + parsedData.environmentTexture, scene);
  52870. if (parsedData.environmentTextureRotationY) {
  52871. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  52872. }
  52873. scene.environmentTexture = compressedTexture;
  52874. }
  52875. else {
  52876. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_9__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  52877. if (parsedData.environmentTextureRotationY) {
  52878. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  52879. }
  52880. scene.environmentTexture = cubeTexture;
  52881. }
  52882. }
  52883. if (parsedData.createDefaultSkybox === true) {
  52884. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  52885. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  52886. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  52887. }
  52888. }
  52889. // Finish
  52890. return true;
  52891. }
  52892. catch (err) {
  52893. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  52894. if (onError) {
  52895. onError(msg, err);
  52896. }
  52897. else {
  52898. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  52899. throw err;
  52900. }
  52901. }
  52902. finally {
  52903. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  52904. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  52905. }
  52906. }
  52907. return false;
  52908. },
  52909. loadAssetContainer: function (scene, data, rootUrl, onError) {
  52910. var container = loadAssetContainer(scene, data, rootUrl, onError);
  52911. return container;
  52912. }
  52913. });
  52914. /***/ }),
  52915. /***/ "./Loading/Plugins/index.ts":
  52916. /*!**********************************!*\
  52917. !*** ./Loading/Plugins/index.ts ***!
  52918. \**********************************/
  52919. /*! exports provided: _BabylonLoaderRegistered */
  52920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52921. "use strict";
  52922. __webpack_require__.r(__webpack_exports__);
  52923. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  52924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  52925. /***/ }),
  52926. /***/ "./Loading/index.ts":
  52927. /*!**************************!*\
  52928. !*** ./Loading/index.ts ***!
  52929. \**************************/
  52930. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  52931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52932. "use strict";
  52933. __webpack_require__.r(__webpack_exports__);
  52934. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  52935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  52936. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  52937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  52938. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  52939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  52940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  52941. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  52942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  52943. /***/ }),
  52944. /***/ "./Loading/loadingScreen.ts":
  52945. /*!**********************************!*\
  52946. !*** ./Loading/loadingScreen.ts ***!
  52947. \**********************************/
  52948. /*! exports provided: DefaultLoadingScreen */
  52949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52950. "use strict";
  52951. __webpack_require__.r(__webpack_exports__);
  52952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  52953. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  52954. /**
  52955. * Class used for the default loading screen
  52956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52957. */
  52958. var DefaultLoadingScreen = /** @class */ (function () {
  52959. /**
  52960. * Creates a new default loading screen
  52961. * @param _renderingCanvas defines the canvas used to render the scene
  52962. * @param _loadingText defines the default text to display
  52963. * @param _loadingDivBackgroundColor defines the default background color
  52964. */
  52965. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  52966. var _this = this;
  52967. if (_loadingText === void 0) { _loadingText = ""; }
  52968. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  52969. this._renderingCanvas = _renderingCanvas;
  52970. this._loadingText = _loadingText;
  52971. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  52972. // Resize
  52973. this._resizeLoadingUI = function () {
  52974. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  52975. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  52976. if (!_this._loadingDiv) {
  52977. return;
  52978. }
  52979. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  52980. _this._loadingDiv.style.left = canvasRect.left + "px";
  52981. _this._loadingDiv.style.top = canvasRect.top + "px";
  52982. _this._loadingDiv.style.width = canvasRect.width + "px";
  52983. _this._loadingDiv.style.height = canvasRect.height + "px";
  52984. };
  52985. }
  52986. /**
  52987. * Function called to display the loading screen
  52988. */
  52989. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  52990. if (this._loadingDiv) {
  52991. // Do not add a loading screen if there is already one
  52992. return;
  52993. }
  52994. this._loadingDiv = document.createElement("div");
  52995. this._loadingDiv.id = "babylonjsLoadingDiv";
  52996. this._loadingDiv.style.opacity = "0";
  52997. this._loadingDiv.style.transition = "opacity 1.5s ease";
  52998. this._loadingDiv.style.pointerEvents = "none";
  52999. // Loading text
  53000. this._loadingTextDiv = document.createElement("div");
  53001. this._loadingTextDiv.style.position = "absolute";
  53002. this._loadingTextDiv.style.left = "0";
  53003. this._loadingTextDiv.style.top = "50%";
  53004. this._loadingTextDiv.style.marginTop = "80px";
  53005. this._loadingTextDiv.style.width = "100%";
  53006. this._loadingTextDiv.style.height = "20px";
  53007. this._loadingTextDiv.style.fontFamily = "Arial";
  53008. this._loadingTextDiv.style.fontSize = "14px";
  53009. this._loadingTextDiv.style.color = "white";
  53010. this._loadingTextDiv.style.textAlign = "center";
  53011. this._loadingTextDiv.innerHTML = "Loading";
  53012. this._loadingDiv.appendChild(this._loadingTextDiv);
  53013. //set the predefined text
  53014. this._loadingTextDiv.innerHTML = this._loadingText;
  53015. // Generating keyframes
  53016. var style = document.createElement('style');
  53017. style.type = 'text/css';
  53018. 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 }";
  53019. style.innerHTML = keyFrames;
  53020. document.getElementsByTagName('head')[0].appendChild(style);
  53021. // Loading img
  53022. var imgBack = new Image();
  53023. if (!DefaultLoadingScreen.DefaultLogoUrl) {
  53024. imgBack.src = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+";
  53025. }
  53026. else {
  53027. imgBack.src = DefaultLoadingScreen.DefaultLogoUrl;
  53028. }
  53029. imgBack.style.position = "absolute";
  53030. imgBack.style.left = "40%";
  53031. imgBack.style.top = "40%";
  53032. imgBack.style.width = "20%";
  53033. imgBack.style.height = "20%";
  53034. // Loading spinner
  53035. var imgSpinner = new Image();
  53036. if (!DefaultLoadingScreen.DefaultSpinnerUrl) {
  53037. imgSpinner.src = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==";
  53038. }
  53039. else {
  53040. imgSpinner.src = DefaultLoadingScreen.DefaultSpinnerUrl;
  53041. }
  53042. imgSpinner.style.position = "absolute";
  53043. imgSpinner.style.left = "30%";
  53044. imgSpinner.style.top = "30%";
  53045. imgSpinner.style.width = "40%";
  53046. imgSpinner.style.height = "40%";
  53047. imgSpinner.style.animation = "spin1 0.75s infinite linear";
  53048. imgSpinner.style.webkitAnimation = "spin1 0.75s infinite linear";
  53049. imgSpinner.style.transformOrigin = "50% 50%";
  53050. imgSpinner.style.webkitTransformOrigin = "50% 50%";
  53051. this._loadingDiv.appendChild(imgBack);
  53052. this._loadingDiv.appendChild(imgSpinner);
  53053. this._resizeLoadingUI();
  53054. window.addEventListener("resize", this._resizeLoadingUI);
  53055. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  53056. document.body.appendChild(this._loadingDiv);
  53057. this._loadingDiv.style.opacity = "1";
  53058. };
  53059. /**
  53060. * Function called to hide the loading screen
  53061. */
  53062. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  53063. var _this = this;
  53064. if (!this._loadingDiv) {
  53065. return;
  53066. }
  53067. var onTransitionEnd = function () {
  53068. if (!_this._loadingDiv) {
  53069. return;
  53070. }
  53071. if (_this._loadingDiv.parentElement) {
  53072. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  53073. }
  53074. window.removeEventListener("resize", _this._resizeLoadingUI);
  53075. _this._loadingDiv = null;
  53076. };
  53077. this._loadingDiv.style.opacity = "0";
  53078. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  53079. };
  53080. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  53081. get: function () {
  53082. return this._loadingText;
  53083. },
  53084. /**
  53085. * Gets or sets the text to display while loading
  53086. */
  53087. set: function (text) {
  53088. this._loadingText = text;
  53089. if (this._loadingTextDiv) {
  53090. this._loadingTextDiv.innerHTML = this._loadingText;
  53091. }
  53092. },
  53093. enumerable: true,
  53094. configurable: true
  53095. });
  53096. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  53097. /**
  53098. * Gets or sets the color to use for the background
  53099. */
  53100. get: function () {
  53101. return this._loadingDivBackgroundColor;
  53102. },
  53103. set: function (color) {
  53104. this._loadingDivBackgroundColor = color;
  53105. if (!this._loadingDiv) {
  53106. return;
  53107. }
  53108. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  53109. },
  53110. enumerable: true,
  53111. configurable: true
  53112. });
  53113. /** Gets or sets the logo url to use for the default loading screen */
  53114. DefaultLoadingScreen.DefaultLogoUrl = "";
  53115. /** Gets or sets the spinner url to use for the default loading screen */
  53116. DefaultLoadingScreen.DefaultSpinnerUrl = "";
  53117. return DefaultLoadingScreen;
  53118. }());
  53119. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  53120. /***/ }),
  53121. /***/ "./Loading/sceneLoader.ts":
  53122. /*!********************************!*\
  53123. !*** ./Loading/sceneLoader.ts ***!
  53124. \********************************/
  53125. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  53126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53127. "use strict";
  53128. __webpack_require__.r(__webpack_exports__);
  53129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  53130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  53131. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  53132. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  53133. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  53134. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  53135. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  53136. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  53137. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  53138. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  53139. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  53140. /**
  53141. * Class used to represent data loading progression
  53142. */
  53143. var SceneLoaderProgressEvent = /** @class */ (function () {
  53144. /**
  53145. * Create a new progress event
  53146. * @param lengthComputable defines if data length to load can be evaluated
  53147. * @param loaded defines the loaded data length
  53148. * @param total defines the data length to load
  53149. */
  53150. function SceneLoaderProgressEvent(
  53151. /** defines if data length to load can be evaluated */
  53152. lengthComputable,
  53153. /** defines the loaded data length */
  53154. loaded,
  53155. /** defines the data length to load */
  53156. total) {
  53157. this.lengthComputable = lengthComputable;
  53158. this.loaded = loaded;
  53159. this.total = total;
  53160. }
  53161. /**
  53162. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  53163. * @param event defines the source event
  53164. * @returns a new SceneLoaderProgressEvent
  53165. */
  53166. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  53167. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  53168. };
  53169. return SceneLoaderProgressEvent;
  53170. }());
  53171. /**
  53172. * Class used to load scene from various file formats using registered plugins
  53173. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  53174. */
  53175. var SceneLoader = /** @class */ (function () {
  53176. function SceneLoader() {
  53177. }
  53178. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  53179. /**
  53180. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53181. */
  53182. get: function () {
  53183. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  53184. },
  53185. set: function (value) {
  53186. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  53187. },
  53188. enumerable: true,
  53189. configurable: true
  53190. });
  53191. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  53192. /**
  53193. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53194. */
  53195. get: function () {
  53196. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  53197. },
  53198. set: function (value) {
  53199. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  53200. },
  53201. enumerable: true,
  53202. configurable: true
  53203. });
  53204. Object.defineProperty(SceneLoader, "loggingLevel", {
  53205. /**
  53206. * Defines the current logging level (while loading the scene)
  53207. * @ignorenaming
  53208. */
  53209. get: function () {
  53210. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  53211. },
  53212. set: function (value) {
  53213. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  53214. },
  53215. enumerable: true,
  53216. configurable: true
  53217. });
  53218. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  53219. /**
  53220. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53221. */
  53222. get: function () {
  53223. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  53224. },
  53225. set: function (value) {
  53226. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  53227. },
  53228. enumerable: true,
  53229. configurable: true
  53230. });
  53231. SceneLoader._getDefaultPlugin = function () {
  53232. return SceneLoader._registeredPlugins[".babylon"];
  53233. };
  53234. SceneLoader._getPluginForExtension = function (extension) {
  53235. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  53236. if (registeredPlugin) {
  53237. return registeredPlugin;
  53238. }
  53239. _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");
  53240. return SceneLoader._getDefaultPlugin();
  53241. };
  53242. SceneLoader._getPluginForDirectLoad = function (data) {
  53243. for (var extension in SceneLoader._registeredPlugins) {
  53244. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  53245. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  53246. return SceneLoader._registeredPlugins[extension];
  53247. }
  53248. }
  53249. return SceneLoader._getDefaultPlugin();
  53250. };
  53251. SceneLoader._getPluginForFilename = function (sceneFilename) {
  53252. var queryStringPosition = sceneFilename.indexOf("?");
  53253. if (queryStringPosition !== -1) {
  53254. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  53255. }
  53256. var dotPosition = sceneFilename.lastIndexOf(".");
  53257. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  53258. return SceneLoader._getPluginForExtension(extension);
  53259. };
  53260. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  53261. SceneLoader._getDirectLoad = function (sceneFilename) {
  53262. if (sceneFilename.substr(0, 5) === "data:") {
  53263. return sceneFilename.substr(5);
  53264. }
  53265. return null;
  53266. };
  53267. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  53268. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  53269. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  53270. var plugin;
  53271. if (registeredPlugin.plugin.createPlugin) {
  53272. plugin = registeredPlugin.plugin.createPlugin();
  53273. }
  53274. else {
  53275. plugin = registeredPlugin.plugin;
  53276. }
  53277. if (!plugin) {
  53278. 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.";
  53279. }
  53280. var useArrayBuffer = registeredPlugin.isBinary;
  53281. var offlineProvider;
  53282. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  53283. var dataCallback = function (data, responseURL) {
  53284. if (scene.isDisposed) {
  53285. onError("Scene has been disposed");
  53286. return;
  53287. }
  53288. scene.offlineProvider = offlineProvider;
  53289. onSuccess(plugin, data, responseURL);
  53290. };
  53291. var request = null;
  53292. var pluginDisposed = false;
  53293. var onDisposeObservable = plugin.onDisposeObservable;
  53294. if (onDisposeObservable) {
  53295. onDisposeObservable.add(function () {
  53296. pluginDisposed = true;
  53297. if (request) {
  53298. request.abort();
  53299. request = null;
  53300. }
  53301. onDispose();
  53302. });
  53303. }
  53304. var manifestChecked = function () {
  53305. if (pluginDisposed) {
  53306. return;
  53307. }
  53308. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  53309. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  53310. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  53311. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  53312. });
  53313. };
  53314. if (directLoad) {
  53315. dataCallback(directLoad);
  53316. return plugin;
  53317. }
  53318. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  53319. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  53320. var engine = scene.getEngine();
  53321. var canUseOfflineSupport = engine.enableOfflineSupport;
  53322. if (canUseOfflineSupport) {
  53323. // Also check for exceptions
  53324. var exceptionFound = false;
  53325. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  53326. var regex = _a[_i];
  53327. if (regex.test(fileInfo.url)) {
  53328. exceptionFound = true;
  53329. break;
  53330. }
  53331. }
  53332. canUseOfflineSupport = !exceptionFound;
  53333. }
  53334. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  53335. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  53336. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  53337. }
  53338. else {
  53339. manifestChecked();
  53340. }
  53341. }
  53342. // Loading file from disk via input file or drag'n'drop
  53343. else {
  53344. if (file) {
  53345. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  53346. }
  53347. else {
  53348. onError("Unable to find file named " + fileInfo.name);
  53349. }
  53350. }
  53351. return plugin;
  53352. };
  53353. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  53354. var url;
  53355. var name;
  53356. var file = null;
  53357. if (!sceneFilename) {
  53358. url = rootUrl;
  53359. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  53360. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  53361. }
  53362. else if (sceneFilename.name) {
  53363. var sceneFile = sceneFilename;
  53364. url = rootUrl + sceneFile.name;
  53365. name = sceneFile.name;
  53366. file = sceneFile;
  53367. }
  53368. else {
  53369. var filename = sceneFilename;
  53370. if (filename.substr(0, 1) === "/") {
  53371. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  53372. return null;
  53373. }
  53374. url = rootUrl + filename;
  53375. name = filename;
  53376. }
  53377. return {
  53378. url: url,
  53379. rootUrl: rootUrl,
  53380. name: name,
  53381. file: file
  53382. };
  53383. };
  53384. // Public functions
  53385. /**
  53386. * Gets a plugin that can load the given extension
  53387. * @param extension defines the extension to load
  53388. * @returns a plugin or null if none works
  53389. */
  53390. SceneLoader.GetPluginForExtension = function (extension) {
  53391. return SceneLoader._getPluginForExtension(extension).plugin;
  53392. };
  53393. /**
  53394. * Gets a boolean indicating that the given extension can be loaded
  53395. * @param extension defines the extension to load
  53396. * @returns true if the extension is supported
  53397. */
  53398. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  53399. return !!SceneLoader._registeredPlugins[extension];
  53400. };
  53401. /**
  53402. * Adds a new plugin to the list of registered plugins
  53403. * @param plugin defines the plugin to add
  53404. */
  53405. SceneLoader.RegisterPlugin = function (plugin) {
  53406. if (typeof plugin.extensions === "string") {
  53407. var extension = plugin.extensions;
  53408. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  53409. plugin: plugin,
  53410. isBinary: false
  53411. };
  53412. }
  53413. else {
  53414. var extensions = plugin.extensions;
  53415. Object.keys(extensions).forEach(function (extension) {
  53416. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  53417. plugin: plugin,
  53418. isBinary: extensions[extension].isBinary
  53419. };
  53420. });
  53421. }
  53422. };
  53423. /**
  53424. * Import meshes into a scene
  53425. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53426. * @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)
  53427. * @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)
  53428. * @param scene the instance of BABYLON.Scene to append to
  53429. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  53430. * @param onProgress a callback with a progress event for each file being loaded
  53431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53432. * @param pluginExtension the extension used to determine the plugin
  53433. * @returns The loaded plugin
  53434. */
  53435. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  53436. if (sceneFilename === void 0) { sceneFilename = ""; }
  53437. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  53438. if (onSuccess === void 0) { onSuccess = null; }
  53439. if (onProgress === void 0) { onProgress = null; }
  53440. if (onError === void 0) { onError = null; }
  53441. if (pluginExtension === void 0) { pluginExtension = null; }
  53442. if (!scene) {
  53443. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  53444. return null;
  53445. }
  53446. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  53447. if (!fileInfo) {
  53448. return null;
  53449. }
  53450. var loadingToken = {};
  53451. scene._addPendingData(loadingToken);
  53452. var disposeHandler = function () {
  53453. scene._removePendingData(loadingToken);
  53454. };
  53455. var errorHandler = function (message, exception) {
  53456. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  53457. if (onError) {
  53458. onError(scene, errorMessage, exception);
  53459. }
  53460. else {
  53461. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  53462. // should the exception be thrown?
  53463. }
  53464. disposeHandler();
  53465. };
  53466. var progressHandler = onProgress ? function (event) {
  53467. try {
  53468. onProgress(event);
  53469. }
  53470. catch (e) {
  53471. errorHandler("Error in onProgress callback: " + e, e);
  53472. }
  53473. } : undefined;
  53474. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  53475. scene.importedMeshesFiles.push(fileInfo.url);
  53476. if (onSuccess) {
  53477. try {
  53478. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  53479. }
  53480. catch (e) {
  53481. errorHandler("Error in onSuccess callback: " + e, e);
  53482. }
  53483. }
  53484. scene._removePendingData(loadingToken);
  53485. };
  53486. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  53487. if (plugin.rewriteRootURL) {
  53488. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  53489. }
  53490. if (plugin.importMesh) {
  53491. var syncedPlugin = plugin;
  53492. var meshes = new Array();
  53493. var particleSystems = new Array();
  53494. var skeletons = new Array();
  53495. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  53496. return;
  53497. }
  53498. scene.loadingPluginName = plugin.name;
  53499. successHandler(meshes, particleSystems, skeletons, []);
  53500. }
  53501. else {
  53502. var asyncedPlugin = plugin;
  53503. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  53504. scene.loadingPluginName = plugin.name;
  53505. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  53506. }).catch(function (error) {
  53507. errorHandler(error.message, error);
  53508. });
  53509. }
  53510. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  53511. };
  53512. /**
  53513. * Import meshes into a scene
  53514. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53515. * @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)
  53516. * @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)
  53517. * @param scene the instance of BABYLON.Scene to append to
  53518. * @param onProgress a callback with a progress event for each file being loaded
  53519. * @param pluginExtension the extension used to determine the plugin
  53520. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53521. */
  53522. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  53523. if (sceneFilename === void 0) { sceneFilename = ""; }
  53524. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  53525. if (onProgress === void 0) { onProgress = null; }
  53526. if (pluginExtension === void 0) { pluginExtension = null; }
  53527. return new Promise(function (resolve, reject) {
  53528. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  53529. resolve({
  53530. meshes: meshes,
  53531. particleSystems: particleSystems,
  53532. skeletons: skeletons,
  53533. animationGroups: animationGroups
  53534. });
  53535. }, onProgress, function (scene, message, exception) {
  53536. reject(exception || new Error(message));
  53537. }, pluginExtension);
  53538. });
  53539. };
  53540. /**
  53541. * Load a scene
  53542. * @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)
  53543. * @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)
  53544. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53545. * @param onSuccess a callback with the scene when import succeeds
  53546. * @param onProgress a callback with a progress event for each file being loaded
  53547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53548. * @param pluginExtension the extension used to determine the plugin
  53549. * @returns The loaded plugin
  53550. */
  53551. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  53552. if (sceneFilename === void 0) { sceneFilename = ""; }
  53553. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  53554. if (onSuccess === void 0) { onSuccess = null; }
  53555. if (onProgress === void 0) { onProgress = null; }
  53556. if (onError === void 0) { onError = null; }
  53557. if (pluginExtension === void 0) { pluginExtension = null; }
  53558. if (!engine) {
  53559. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  53560. return null;
  53561. }
  53562. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  53563. };
  53564. /**
  53565. * Load a scene
  53566. * @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)
  53567. * @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)
  53568. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53569. * @param onProgress a callback with a progress event for each file being loaded
  53570. * @param pluginExtension the extension used to determine the plugin
  53571. * @returns The loaded scene
  53572. */
  53573. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  53574. if (sceneFilename === void 0) { sceneFilename = ""; }
  53575. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  53576. if (onProgress === void 0) { onProgress = null; }
  53577. if (pluginExtension === void 0) { pluginExtension = null; }
  53578. return new Promise(function (resolve, reject) {
  53579. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  53580. resolve(scene);
  53581. }, onProgress, function (scene, message, exception) {
  53582. reject(exception || new Error(message));
  53583. }, pluginExtension);
  53584. });
  53585. };
  53586. /**
  53587. * Append a scene
  53588. * @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)
  53589. * @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)
  53590. * @param scene is the instance of BABYLON.Scene to append to
  53591. * @param onSuccess a callback with the scene when import succeeds
  53592. * @param onProgress a callback with a progress event for each file being loaded
  53593. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53594. * @param pluginExtension the extension used to determine the plugin
  53595. * @returns The loaded plugin
  53596. */
  53597. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  53598. if (sceneFilename === void 0) { sceneFilename = ""; }
  53599. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  53600. if (onSuccess === void 0) { onSuccess = null; }
  53601. if (onProgress === void 0) { onProgress = null; }
  53602. if (onError === void 0) { onError = null; }
  53603. if (pluginExtension === void 0) { pluginExtension = null; }
  53604. if (!scene) {
  53605. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  53606. return null;
  53607. }
  53608. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  53609. if (!fileInfo) {
  53610. return null;
  53611. }
  53612. if (SceneLoader.ShowLoadingScreen) {
  53613. scene.getEngine().displayLoadingUI();
  53614. }
  53615. var loadingToken = {};
  53616. scene._addPendingData(loadingToken);
  53617. var disposeHandler = function () {
  53618. scene._removePendingData(loadingToken);
  53619. scene.getEngine().hideLoadingUI();
  53620. };
  53621. var errorHandler = function (message, exception) {
  53622. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  53623. if (onError) {
  53624. onError(scene, errorMessage, exception);
  53625. }
  53626. else {
  53627. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  53628. // should the exception be thrown?
  53629. }
  53630. disposeHandler();
  53631. };
  53632. var progressHandler = onProgress ? function (event) {
  53633. try {
  53634. onProgress(event);
  53635. }
  53636. catch (e) {
  53637. errorHandler("Error in onProgress callback", e);
  53638. }
  53639. } : undefined;
  53640. var successHandler = function () {
  53641. if (onSuccess) {
  53642. try {
  53643. onSuccess(scene);
  53644. }
  53645. catch (e) {
  53646. errorHandler("Error in onSuccess callback", e);
  53647. }
  53648. }
  53649. scene._removePendingData(loadingToken);
  53650. };
  53651. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  53652. if (plugin.load) {
  53653. var syncedPlugin = plugin;
  53654. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  53655. return;
  53656. }
  53657. scene.loadingPluginName = plugin.name;
  53658. successHandler();
  53659. }
  53660. else {
  53661. var asyncedPlugin = plugin;
  53662. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  53663. scene.loadingPluginName = plugin.name;
  53664. successHandler();
  53665. }).catch(function (error) {
  53666. errorHandler(error.message, error);
  53667. });
  53668. }
  53669. if (SceneLoader.ShowLoadingScreen) {
  53670. scene.executeWhenReady(function () {
  53671. scene.getEngine().hideLoadingUI();
  53672. });
  53673. }
  53674. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  53675. };
  53676. /**
  53677. * Append a scene
  53678. * @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)
  53679. * @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)
  53680. * @param scene is the instance of BABYLON.Scene to append to
  53681. * @param onProgress a callback with a progress event for each file being loaded
  53682. * @param pluginExtension the extension used to determine the plugin
  53683. * @returns The given scene
  53684. */
  53685. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  53686. if (sceneFilename === void 0) { sceneFilename = ""; }
  53687. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  53688. if (onProgress === void 0) { onProgress = null; }
  53689. if (pluginExtension === void 0) { pluginExtension = null; }
  53690. return new Promise(function (resolve, reject) {
  53691. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  53692. resolve(scene);
  53693. }, onProgress, function (scene, message, exception) {
  53694. reject(exception || new Error(message));
  53695. }, pluginExtension);
  53696. });
  53697. };
  53698. /**
  53699. * Load a scene into an asset container
  53700. * @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)
  53701. * @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)
  53702. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53703. * @param onSuccess a callback with the scene when import succeeds
  53704. * @param onProgress a callback with a progress event for each file being loaded
  53705. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53706. * @param pluginExtension the extension used to determine the plugin
  53707. * @returns The loaded plugin
  53708. */
  53709. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  53710. if (sceneFilename === void 0) { sceneFilename = ""; }
  53711. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  53712. if (onSuccess === void 0) { onSuccess = null; }
  53713. if (onProgress === void 0) { onProgress = null; }
  53714. if (onError === void 0) { onError = null; }
  53715. if (pluginExtension === void 0) { pluginExtension = null; }
  53716. if (!scene) {
  53717. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  53718. return null;
  53719. }
  53720. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  53721. if (!fileInfo) {
  53722. return null;
  53723. }
  53724. var loadingToken = {};
  53725. scene._addPendingData(loadingToken);
  53726. var disposeHandler = function () {
  53727. scene._removePendingData(loadingToken);
  53728. };
  53729. var errorHandler = function (message, exception) {
  53730. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  53731. if (onError) {
  53732. onError(scene, errorMessage, exception);
  53733. }
  53734. else {
  53735. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  53736. // should the exception be thrown?
  53737. }
  53738. disposeHandler();
  53739. };
  53740. var progressHandler = onProgress ? function (event) {
  53741. try {
  53742. onProgress(event);
  53743. }
  53744. catch (e) {
  53745. errorHandler("Error in onProgress callback", e);
  53746. }
  53747. } : undefined;
  53748. var successHandler = function (assets) {
  53749. if (onSuccess) {
  53750. try {
  53751. onSuccess(assets);
  53752. }
  53753. catch (e) {
  53754. errorHandler("Error in onSuccess callback", e);
  53755. }
  53756. }
  53757. scene._removePendingData(loadingToken);
  53758. };
  53759. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  53760. if (plugin.loadAssetContainer) {
  53761. var syncedPlugin = plugin;
  53762. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  53763. if (!assetContainer) {
  53764. return;
  53765. }
  53766. scene.loadingPluginName = plugin.name;
  53767. successHandler(assetContainer);
  53768. }
  53769. else if (plugin.loadAssetContainerAsync) {
  53770. var asyncedPlugin = plugin;
  53771. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  53772. scene.loadingPluginName = plugin.name;
  53773. successHandler(assetContainer);
  53774. }).catch(function (error) {
  53775. errorHandler(error.message, error);
  53776. });
  53777. }
  53778. else {
  53779. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  53780. }
  53781. if (SceneLoader.ShowLoadingScreen) {
  53782. scene.executeWhenReady(function () {
  53783. scene.getEngine().hideLoadingUI();
  53784. });
  53785. }
  53786. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  53787. };
  53788. /**
  53789. * Load a scene into an asset container
  53790. * @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)
  53791. * @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)
  53792. * @param scene is the instance of Scene to append to
  53793. * @param onProgress a callback with a progress event for each file being loaded
  53794. * @param pluginExtension the extension used to determine the plugin
  53795. * @returns The loaded asset container
  53796. */
  53797. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  53798. if (sceneFilename === void 0) { sceneFilename = ""; }
  53799. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  53800. if (onProgress === void 0) { onProgress = null; }
  53801. if (pluginExtension === void 0) { pluginExtension = null; }
  53802. return new Promise(function (resolve, reject) {
  53803. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  53804. resolve(assetContainer);
  53805. }, onProgress, function (scene, message, exception) {
  53806. reject(exception || new Error(message));
  53807. }, pluginExtension);
  53808. });
  53809. };
  53810. /**
  53811. * No logging while loading
  53812. */
  53813. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  53814. /**
  53815. * Minimal logging while loading
  53816. */
  53817. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  53818. /**
  53819. * Summary logging while loading
  53820. */
  53821. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  53822. /**
  53823. * Detailled logging while loading
  53824. */
  53825. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  53826. // Members
  53827. /**
  53828. * Event raised when a plugin is used to load a scene
  53829. */
  53830. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  53831. SceneLoader._registeredPlugins = {};
  53832. return SceneLoader;
  53833. }());
  53834. /***/ }),
  53835. /***/ "./Loading/sceneLoaderFlags.ts":
  53836. /*!*************************************!*\
  53837. !*** ./Loading/sceneLoaderFlags.ts ***!
  53838. \*************************************/
  53839. /*! exports provided: SceneLoaderFlags */
  53840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53841. "use strict";
  53842. __webpack_require__.r(__webpack_exports__);
  53843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  53844. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  53845. /**
  53846. * Class used to represent data loading progression
  53847. */
  53848. var SceneLoaderFlags = /** @class */ (function () {
  53849. function SceneLoaderFlags() {
  53850. }
  53851. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  53852. /**
  53853. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53854. */
  53855. get: function () {
  53856. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  53857. },
  53858. set: function (value) {
  53859. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  53860. },
  53861. enumerable: true,
  53862. configurable: true
  53863. });
  53864. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  53865. /**
  53866. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53867. */
  53868. get: function () {
  53869. return SceneLoaderFlags._ShowLoadingScreen;
  53870. },
  53871. set: function (value) {
  53872. SceneLoaderFlags._ShowLoadingScreen = value;
  53873. },
  53874. enumerable: true,
  53875. configurable: true
  53876. });
  53877. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  53878. /**
  53879. * Defines the current logging level (while loading the scene)
  53880. * @ignorenaming
  53881. */
  53882. get: function () {
  53883. return SceneLoaderFlags._loggingLevel;
  53884. },
  53885. set: function (value) {
  53886. SceneLoaderFlags._loggingLevel = value;
  53887. },
  53888. enumerable: true,
  53889. configurable: true
  53890. });
  53891. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  53892. /**
  53893. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53894. */
  53895. get: function () {
  53896. return SceneLoaderFlags._CleanBoneMatrixWeights;
  53897. },
  53898. set: function (value) {
  53899. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  53900. },
  53901. enumerable: true,
  53902. configurable: true
  53903. });
  53904. // Flags
  53905. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  53906. SceneLoaderFlags._ShowLoadingScreen = true;
  53907. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  53908. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  53909. return SceneLoaderFlags;
  53910. }());
  53911. /***/ }),
  53912. /***/ "./Materials/Background/backgroundMaterial.ts":
  53913. /*!****************************************************!*\
  53914. !*** ./Materials/Background/backgroundMaterial.ts ***!
  53915. \****************************************************/
  53916. /*! exports provided: BackgroundMaterial */
  53917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53918. "use strict";
  53919. __webpack_require__.r(__webpack_exports__);
  53920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  53921. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53922. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53923. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  53924. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  53925. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  53926. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  53927. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  53928. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53929. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  53930. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  53931. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  53932. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53933. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  53934. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53935. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53936. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  53937. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  53938. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  53939. /**
  53940. * Background material defines definition.
  53941. * @hidden Mainly internal Use
  53942. */
  53943. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  53944. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  53945. /**
  53946. * Constructor of the defines.
  53947. */
  53948. function BackgroundMaterialDefines() {
  53949. var _this = _super.call(this) || this;
  53950. /**
  53951. * True if the diffuse texture is in use.
  53952. */
  53953. _this.DIFFUSE = false;
  53954. /**
  53955. * The direct UV channel to use.
  53956. */
  53957. _this.DIFFUSEDIRECTUV = 0;
  53958. /**
  53959. * True if the diffuse texture is in gamma space.
  53960. */
  53961. _this.GAMMADIFFUSE = false;
  53962. /**
  53963. * True if the diffuse texture has opacity in the alpha channel.
  53964. */
  53965. _this.DIFFUSEHASALPHA = false;
  53966. /**
  53967. * True if you want the material to fade to transparent at grazing angle.
  53968. */
  53969. _this.OPACITYFRESNEL = false;
  53970. /**
  53971. * True if an extra blur needs to be added in the reflection.
  53972. */
  53973. _this.REFLECTIONBLUR = false;
  53974. /**
  53975. * True if you want the material to fade to reflection at grazing angle.
  53976. */
  53977. _this.REFLECTIONFRESNEL = false;
  53978. /**
  53979. * True if you want the material to falloff as far as you move away from the scene center.
  53980. */
  53981. _this.REFLECTIONFALLOFF = false;
  53982. /**
  53983. * False if the current Webgl implementation does not support the texture lod extension.
  53984. */
  53985. _this.TEXTURELODSUPPORT = false;
  53986. /**
  53987. * True to ensure the data are premultiplied.
  53988. */
  53989. _this.PREMULTIPLYALPHA = false;
  53990. /**
  53991. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  53992. */
  53993. _this.USERGBCOLOR = false;
  53994. /**
  53995. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  53996. * stays aligned with the desired configuration.
  53997. */
  53998. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  53999. /**
  54000. * True to add noise in order to reduce the banding effect.
  54001. */
  54002. _this.NOISE = false;
  54003. /**
  54004. * is the reflection texture in BGR color scheme?
  54005. * Mainly used to solve a bug in ios10 video tag
  54006. */
  54007. _this.REFLECTIONBGR = false;
  54008. _this.IMAGEPROCESSING = false;
  54009. _this.VIGNETTE = false;
  54010. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  54011. _this.VIGNETTEBLENDMODEOPAQUE = false;
  54012. _this.TONEMAPPING = false;
  54013. _this.TONEMAPPING_ACES = false;
  54014. _this.CONTRAST = false;
  54015. _this.COLORCURVES = false;
  54016. _this.COLORGRADING = false;
  54017. _this.COLORGRADING3D = false;
  54018. _this.SAMPLER3DGREENDEPTH = false;
  54019. _this.SAMPLER3DBGRMAP = false;
  54020. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  54021. _this.EXPOSURE = false;
  54022. _this.MULTIVIEW = false;
  54023. // Reflection.
  54024. _this.REFLECTION = false;
  54025. _this.REFLECTIONMAP_3D = false;
  54026. _this.REFLECTIONMAP_SPHERICAL = false;
  54027. _this.REFLECTIONMAP_PLANAR = false;
  54028. _this.REFLECTIONMAP_CUBIC = false;
  54029. _this.REFLECTIONMAP_PROJECTION = false;
  54030. _this.REFLECTIONMAP_SKYBOX = false;
  54031. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  54032. _this.REFLECTIONMAP_EXPLICIT = false;
  54033. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  54034. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  54035. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  54036. _this.INVERTCUBICMAP = false;
  54037. _this.REFLECTIONMAP_OPPOSITEZ = false;
  54038. _this.LODINREFLECTIONALPHA = false;
  54039. _this.GAMMAREFLECTION = false;
  54040. _this.RGBDREFLECTION = false;
  54041. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  54042. // Default BJS.
  54043. _this.MAINUV1 = false;
  54044. _this.MAINUV2 = false;
  54045. _this.UV1 = false;
  54046. _this.UV2 = false;
  54047. _this.CLIPPLANE = false;
  54048. _this.CLIPPLANE2 = false;
  54049. _this.CLIPPLANE3 = false;
  54050. _this.CLIPPLANE4 = false;
  54051. _this.POINTSIZE = false;
  54052. _this.FOG = false;
  54053. _this.NORMAL = false;
  54054. _this.NUM_BONE_INFLUENCERS = 0;
  54055. _this.BonesPerMesh = 0;
  54056. _this.INSTANCES = false;
  54057. _this.SHADOWFLOAT = false;
  54058. _this.rebuild();
  54059. return _this;
  54060. }
  54061. return BackgroundMaterialDefines;
  54062. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  54063. /**
  54064. * Background material used to create an efficient environement around your scene.
  54065. */
  54066. var BackgroundMaterial = /** @class */ (function (_super) {
  54067. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  54068. /**
  54069. * Instantiates a Background Material in the given scene
  54070. * @param name The friendly name of the material
  54071. * @param scene The scene to add the material to
  54072. */
  54073. function BackgroundMaterial(name, scene) {
  54074. var _this = _super.call(this, name, scene) || this;
  54075. /**
  54076. * Key light Color (multiply against the environement texture)
  54077. */
  54078. _this.primaryColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_15__["Color3"].White();
  54079. _this._primaryColorShadowLevel = 0;
  54080. _this._primaryColorHighlightLevel = 0;
  54081. /**
  54082. * Reflection Texture used in the material.
  54083. * Should be author in a specific way for the best result (refer to the documentation).
  54084. */
  54085. _this.reflectionTexture = null;
  54086. /**
  54087. * Reflection Texture level of blur.
  54088. *
  54089. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54090. * texture twice.
  54091. */
  54092. _this.reflectionBlur = 0;
  54093. /**
  54094. * Diffuse Texture used in the material.
  54095. * Should be author in a specific way for the best result (refer to the documentation).
  54096. */
  54097. _this.diffuseTexture = null;
  54098. _this._shadowLights = null;
  54099. /**
  54100. * Specify the list of lights casting shadow on the material.
  54101. * All scene shadow lights will be included if null.
  54102. */
  54103. _this.shadowLights = null;
  54104. /**
  54105. * Helps adjusting the shadow to a softer level if required.
  54106. * 0 means black shadows and 1 means no shadows.
  54107. */
  54108. _this.shadowLevel = 0;
  54109. /**
  54110. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54111. * It is usually zero but might be interesting to modify according to your setup.
  54112. */
  54113. _this.sceneCenter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  54114. /**
  54115. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54116. * This helps ensuring a nice transition when the camera goes under the ground.
  54117. */
  54118. _this.opacityFresnel = true;
  54119. /**
  54120. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54121. * This helps adding a mirror texture on the ground.
  54122. */
  54123. _this.reflectionFresnel = false;
  54124. /**
  54125. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54126. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54127. */
  54128. _this.reflectionFalloffDistance = 0.0;
  54129. /**
  54130. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54131. */
  54132. _this.reflectionAmount = 1.0;
  54133. /**
  54134. * This specifies the weight of the reflection at grazing angle.
  54135. */
  54136. _this.reflectionReflectance0 = 0.05;
  54137. /**
  54138. * This specifies the weight of the reflection at a perpendicular point of view.
  54139. */
  54140. _this.reflectionReflectance90 = 0.5;
  54141. /**
  54142. * Helps to directly use the maps channels instead of their level.
  54143. */
  54144. _this.useRGBColor = true;
  54145. /**
  54146. * This helps reducing the banding effect that could occur on the background.
  54147. */
  54148. _this.enableNoise = false;
  54149. _this._fovMultiplier = 1.0;
  54150. /**
  54151. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54152. */
  54153. _this.useEquirectangularFOV = false;
  54154. _this._maxSimultaneousLights = 4;
  54155. /**
  54156. * Number of Simultaneous lights allowed on the material.
  54157. */
  54158. _this.maxSimultaneousLights = 4;
  54159. /**
  54160. * Keep track of the image processing observer to allow dispose and replace.
  54161. */
  54162. _this._imageProcessingObserver = null;
  54163. /**
  54164. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54165. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54166. */
  54167. _this.switchToBGR = false;
  54168. // Temp values kept as cache in the material.
  54169. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  54170. _this._reflectionControls = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  54171. _this._white = _Maths_math_color__WEBPACK_IMPORTED_MODULE_15__["Color3"].White();
  54172. _this._primaryShadowColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_15__["Color3"].Black();
  54173. _this._primaryHighlightColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_15__["Color3"].Black();
  54174. // Setup the default processing configuration to the scene.
  54175. _this._attachImageProcessingConfiguration(null);
  54176. _this.getRenderTargetTextures = function () {
  54177. _this._renderTargets.reset();
  54178. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  54179. _this._renderTargets.push(_this._diffuseTexture);
  54180. }
  54181. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  54182. _this._renderTargets.push(_this._reflectionTexture);
  54183. }
  54184. return _this._renderTargets;
  54185. };
  54186. return _this;
  54187. }
  54188. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  54189. /**
  54190. * Experimental Internal Use Only.
  54191. *
  54192. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54193. * This acts as a helper to set the primary color to a more "human friendly" value.
  54194. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54195. * output color as close as possible from the chosen value.
  54196. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54197. * part of lighting setup.)
  54198. */
  54199. get: function () {
  54200. return this.__perceptualColor;
  54201. },
  54202. set: function (value) {
  54203. this.__perceptualColor = value;
  54204. this._computePrimaryColorFromPerceptualColor();
  54205. this._markAllSubMeshesAsLightsDirty();
  54206. },
  54207. enumerable: true,
  54208. configurable: true
  54209. });
  54210. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  54211. /**
  54212. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54213. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54214. */
  54215. get: function () {
  54216. return this._primaryColorShadowLevel;
  54217. },
  54218. set: function (value) {
  54219. this._primaryColorShadowLevel = value;
  54220. this._computePrimaryColors();
  54221. this._markAllSubMeshesAsLightsDirty();
  54222. },
  54223. enumerable: true,
  54224. configurable: true
  54225. });
  54226. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  54227. /**
  54228. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54229. * The primary color is used at the level chosen to define what the white area would look.
  54230. */
  54231. get: function () {
  54232. return this._primaryColorHighlightLevel;
  54233. },
  54234. set: function (value) {
  54235. this._primaryColorHighlightLevel = value;
  54236. this._computePrimaryColors();
  54237. this._markAllSubMeshesAsLightsDirty();
  54238. },
  54239. enumerable: true,
  54240. configurable: true
  54241. });
  54242. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  54243. /**
  54244. * Sets the reflection reflectance fresnel values according to the default standard
  54245. * empirically know to work well :-)
  54246. */
  54247. set: function (value) {
  54248. var reflectionWeight = value;
  54249. if (reflectionWeight < 0.5) {
  54250. reflectionWeight = reflectionWeight * 2.0;
  54251. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  54252. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  54253. }
  54254. else {
  54255. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  54256. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  54257. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  54258. }
  54259. },
  54260. enumerable: true,
  54261. configurable: true
  54262. });
  54263. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  54264. /**
  54265. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54266. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54267. * Recommended to be keep at 1.0 except for special cases.
  54268. */
  54269. get: function () {
  54270. return this._fovMultiplier;
  54271. },
  54272. set: function (value) {
  54273. if (isNaN(value)) {
  54274. value = 1.0;
  54275. }
  54276. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  54277. },
  54278. enumerable: true,
  54279. configurable: true
  54280. });
  54281. /**
  54282. * Attaches a new image processing configuration to the PBR Material.
  54283. * @param configuration (if null the scene configuration will be use)
  54284. */
  54285. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  54286. var _this = this;
  54287. if (configuration === this._imageProcessingConfiguration) {
  54288. return;
  54289. }
  54290. // Detaches observer.
  54291. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  54292. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  54293. }
  54294. // Pick the scene configuration if needed.
  54295. if (!configuration) {
  54296. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  54297. }
  54298. else {
  54299. this._imageProcessingConfiguration = configuration;
  54300. }
  54301. // Attaches observer.
  54302. if (this._imageProcessingConfiguration) {
  54303. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  54304. _this._computePrimaryColorFromPerceptualColor();
  54305. _this._markAllSubMeshesAsImageProcessingDirty();
  54306. });
  54307. }
  54308. };
  54309. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  54310. /**
  54311. * Gets the image processing configuration used either in this material.
  54312. */
  54313. get: function () {
  54314. return this._imageProcessingConfiguration;
  54315. },
  54316. /**
  54317. * Sets the Default image processing configuration used either in the this material.
  54318. *
  54319. * If sets to null, the scene one is in use.
  54320. */
  54321. set: function (value) {
  54322. this._attachImageProcessingConfiguration(value);
  54323. // Ensure the effect will be rebuilt.
  54324. this._markAllSubMeshesAsTexturesDirty();
  54325. },
  54326. enumerable: true,
  54327. configurable: true
  54328. });
  54329. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  54330. /**
  54331. * Gets wether the color curves effect is enabled.
  54332. */
  54333. get: function () {
  54334. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54335. },
  54336. /**
  54337. * Sets wether the color curves effect is enabled.
  54338. */
  54339. set: function (value) {
  54340. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54341. },
  54342. enumerable: true,
  54343. configurable: true
  54344. });
  54345. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  54346. /**
  54347. * Gets wether the color grading effect is enabled.
  54348. */
  54349. get: function () {
  54350. return this.imageProcessingConfiguration.colorGradingEnabled;
  54351. },
  54352. /**
  54353. * Gets wether the color grading effect is enabled.
  54354. */
  54355. set: function (value) {
  54356. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54357. },
  54358. enumerable: true,
  54359. configurable: true
  54360. });
  54361. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  54362. /**
  54363. * Gets wether tonemapping is enabled or not.
  54364. */
  54365. get: function () {
  54366. return this._imageProcessingConfiguration.toneMappingEnabled;
  54367. },
  54368. /**
  54369. * Sets wether tonemapping is enabled or not
  54370. */
  54371. set: function (value) {
  54372. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54373. },
  54374. enumerable: true,
  54375. configurable: true
  54376. });
  54377. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  54378. /**
  54379. * The camera exposure used on this material.
  54380. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54381. * This corresponds to a photographic exposure.
  54382. */
  54383. get: function () {
  54384. return this._imageProcessingConfiguration.exposure;
  54385. },
  54386. /**
  54387. * The camera exposure used on this material.
  54388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54389. * This corresponds to a photographic exposure.
  54390. */
  54391. set: function (value) {
  54392. this._imageProcessingConfiguration.exposure = value;
  54393. },
  54394. enumerable: true,
  54395. configurable: true
  54396. });
  54397. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  54398. /**
  54399. * Gets The camera contrast used on this material.
  54400. */
  54401. get: function () {
  54402. return this._imageProcessingConfiguration.contrast;
  54403. },
  54404. /**
  54405. * Sets The camera contrast used on this material.
  54406. */
  54407. set: function (value) {
  54408. this._imageProcessingConfiguration.contrast = value;
  54409. },
  54410. enumerable: true,
  54411. configurable: true
  54412. });
  54413. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  54414. /**
  54415. * Gets the Color Grading 2D Lookup Texture.
  54416. */
  54417. get: function () {
  54418. return this._imageProcessingConfiguration.colorGradingTexture;
  54419. },
  54420. /**
  54421. * Sets the Color Grading 2D Lookup Texture.
  54422. */
  54423. set: function (value) {
  54424. this.imageProcessingConfiguration.colorGradingTexture = value;
  54425. },
  54426. enumerable: true,
  54427. configurable: true
  54428. });
  54429. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  54430. /**
  54431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54433. * 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;
  54434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54435. */
  54436. get: function () {
  54437. return this.imageProcessingConfiguration.colorCurves;
  54438. },
  54439. /**
  54440. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54441. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54442. * 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;
  54443. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54444. */
  54445. set: function (value) {
  54446. this.imageProcessingConfiguration.colorCurves = value;
  54447. },
  54448. enumerable: true,
  54449. configurable: true
  54450. });
  54451. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  54452. /**
  54453. * Gets a boolean indicating that current material needs to register RTT
  54454. */
  54455. get: function () {
  54456. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  54457. return true;
  54458. }
  54459. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  54460. return true;
  54461. }
  54462. return false;
  54463. },
  54464. enumerable: true,
  54465. configurable: true
  54466. });
  54467. /**
  54468. * The entire material has been created in order to prevent overdraw.
  54469. * @returns false
  54470. */
  54471. BackgroundMaterial.prototype.needAlphaTesting = function () {
  54472. return true;
  54473. };
  54474. /**
  54475. * The entire material has been created in order to prevent overdraw.
  54476. * @returns true if blending is enable
  54477. */
  54478. BackgroundMaterial.prototype.needAlphaBlending = function () {
  54479. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  54480. };
  54481. /**
  54482. * Checks wether the material is ready to be rendered for a given mesh.
  54483. * @param mesh The mesh to render
  54484. * @param subMesh The submesh to check against
  54485. * @param useInstances Specify wether or not the material is used with instances
  54486. * @returns true if all the dependencies are ready (Textures, Effects...)
  54487. */
  54488. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  54489. var _this = this;
  54490. if (useInstances === void 0) { useInstances = false; }
  54491. if (subMesh.effect && this.isFrozen) {
  54492. if (this._wasPreviouslyReady) {
  54493. return true;
  54494. }
  54495. }
  54496. if (!subMesh._materialDefines) {
  54497. subMesh._materialDefines = new BackgroundMaterialDefines();
  54498. }
  54499. var scene = this.getScene();
  54500. var defines = subMesh._materialDefines;
  54501. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  54502. if (defines._renderId === scene.getRenderId()) {
  54503. return true;
  54504. }
  54505. }
  54506. var engine = scene.getEngine();
  54507. // Lights
  54508. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  54509. defines._needNormals = true;
  54510. // Multiview
  54511. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  54512. // Textures
  54513. if (defines._areTexturesDirty) {
  54514. defines._needUVs = false;
  54515. if (scene.texturesEnabled) {
  54516. if (scene.getEngine().getCaps().textureLOD) {
  54517. defines.TEXTURELODSUPPORT = true;
  54518. }
  54519. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  54520. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  54521. return false;
  54522. }
  54523. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  54524. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  54525. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  54526. defines.OPACITYFRESNEL = this._opacityFresnel;
  54527. }
  54528. else {
  54529. defines.DIFFUSE = false;
  54530. defines.DIFFUSEHASALPHA = false;
  54531. defines.GAMMADIFFUSE = false;
  54532. defines.OPACITYFRESNEL = false;
  54533. }
  54534. var reflectionTexture = this._reflectionTexture;
  54535. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  54536. if (!reflectionTexture.isReadyOrNotBlocking()) {
  54537. return false;
  54538. }
  54539. defines.REFLECTION = true;
  54540. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  54541. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  54542. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  54543. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  54544. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  54545. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  54546. defines.REFLECTIONBGR = this.switchToBGR;
  54547. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  54548. defines.INVERTCUBICMAP = true;
  54549. }
  54550. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  54551. switch (reflectionTexture.coordinatesMode) {
  54552. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  54553. defines.REFLECTIONMAP_EXPLICIT = true;
  54554. break;
  54555. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  54556. defines.REFLECTIONMAP_PLANAR = true;
  54557. break;
  54558. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  54559. defines.REFLECTIONMAP_PROJECTION = true;
  54560. break;
  54561. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  54562. defines.REFLECTIONMAP_SKYBOX = true;
  54563. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  54564. break;
  54565. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  54566. defines.REFLECTIONMAP_SPHERICAL = true;
  54567. break;
  54568. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  54569. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  54570. break;
  54571. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  54572. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  54573. break;
  54574. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  54575. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  54576. break;
  54577. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  54578. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  54579. default:
  54580. defines.REFLECTIONMAP_CUBIC = true;
  54581. break;
  54582. }
  54583. if (this.reflectionFresnel) {
  54584. defines.REFLECTIONFRESNEL = true;
  54585. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  54586. this._reflectionControls.x = this.reflectionAmount;
  54587. this._reflectionControls.y = this.reflectionReflectance0;
  54588. this._reflectionControls.z = this.reflectionReflectance90;
  54589. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  54590. }
  54591. else {
  54592. defines.REFLECTIONFRESNEL = false;
  54593. defines.REFLECTIONFALLOFF = false;
  54594. }
  54595. }
  54596. else {
  54597. defines.REFLECTION = false;
  54598. defines.REFLECTIONFRESNEL = false;
  54599. defines.REFLECTIONFALLOFF = false;
  54600. defines.REFLECTIONBLUR = false;
  54601. defines.REFLECTIONMAP_3D = false;
  54602. defines.REFLECTIONMAP_SPHERICAL = false;
  54603. defines.REFLECTIONMAP_PLANAR = false;
  54604. defines.REFLECTIONMAP_CUBIC = false;
  54605. defines.REFLECTIONMAP_PROJECTION = false;
  54606. defines.REFLECTIONMAP_SKYBOX = false;
  54607. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  54608. defines.REFLECTIONMAP_EXPLICIT = false;
  54609. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  54610. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  54611. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  54612. defines.INVERTCUBICMAP = false;
  54613. defines.REFLECTIONMAP_OPPOSITEZ = false;
  54614. defines.LODINREFLECTIONALPHA = false;
  54615. defines.GAMMAREFLECTION = false;
  54616. defines.RGBDREFLECTION = false;
  54617. }
  54618. }
  54619. 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);
  54620. defines.USERGBCOLOR = this._useRGBColor;
  54621. defines.NOISE = this._enableNoise;
  54622. }
  54623. if (defines._areLightsDirty) {
  54624. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  54625. }
  54626. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  54627. if (!this._imageProcessingConfiguration.isReady()) {
  54628. return false;
  54629. }
  54630. this._imageProcessingConfiguration.prepareDefines(defines);
  54631. }
  54632. // Misc.
  54633. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  54634. // Values that need to be evaluated on every frame
  54635. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  54636. // Attribs
  54637. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  54638. if (mesh) {
  54639. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  54640. mesh.createNormals(true);
  54641. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  54642. }
  54643. }
  54644. }
  54645. // Get correct effect
  54646. if (defines.isDirty) {
  54647. defines.markAsProcessed();
  54648. scene.resetCachedMaterial();
  54649. // Fallbacks
  54650. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  54651. if (defines.FOG) {
  54652. fallbacks.addFallback(0, "FOG");
  54653. }
  54654. if (defines.POINTSIZE) {
  54655. fallbacks.addFallback(1, "POINTSIZE");
  54656. }
  54657. if (defines.MULTIVIEW) {
  54658. fallbacks.addFallback(0, "MULTIVIEW");
  54659. }
  54660. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  54661. //Attributes
  54662. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  54663. if (defines.NORMAL) {
  54664. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  54665. }
  54666. if (defines.UV1) {
  54667. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  54668. }
  54669. if (defines.UV2) {
  54670. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  54671. }
  54672. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  54673. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  54674. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  54675. "vFogInfos", "vFogColor", "pointSize",
  54676. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  54677. "vPrimaryColor", "vPrimaryColorShadow",
  54678. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  54679. "shadowLevel", "alpha",
  54680. "vBackgroundCenter", "vReflectionControl",
  54681. "vDiffuseInfos", "diffuseMatrix",
  54682. ];
  54683. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  54684. var uniformBuffers = ["Material", "Scene"];
  54685. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  54686. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  54687. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  54688. }
  54689. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  54690. uniformsNames: uniforms,
  54691. uniformBuffersNames: uniformBuffers,
  54692. samplers: samplers,
  54693. defines: defines,
  54694. maxSimultaneousLights: this._maxSimultaneousLights
  54695. });
  54696. var onCompiled = function (effect) {
  54697. if (_this.onCompiled) {
  54698. _this.onCompiled(effect);
  54699. }
  54700. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  54701. };
  54702. var join = defines.toString();
  54703. subMesh.setEffect(scene.getEngine().createEffect("background", {
  54704. attributes: attribs,
  54705. uniformsNames: uniforms,
  54706. uniformBuffersNames: uniformBuffers,
  54707. samplers: samplers,
  54708. defines: join,
  54709. fallbacks: fallbacks,
  54710. onCompiled: onCompiled,
  54711. onError: this.onError,
  54712. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  54713. }, engine), defines);
  54714. this.buildUniformLayout();
  54715. }
  54716. if (!subMesh.effect || !subMesh.effect.isReady()) {
  54717. return false;
  54718. }
  54719. defines._renderId = scene.getRenderId();
  54720. this._wasPreviouslyReady = true;
  54721. return true;
  54722. };
  54723. /**
  54724. * Compute the primary color according to the chosen perceptual color.
  54725. */
  54726. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  54727. if (!this.__perceptualColor) {
  54728. return;
  54729. }
  54730. this._primaryColor.copyFrom(this.__perceptualColor);
  54731. // Revert gamma space.
  54732. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  54733. // Revert image processing configuration.
  54734. if (this._imageProcessingConfiguration) {
  54735. // Revert Exposure.
  54736. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  54737. }
  54738. this._computePrimaryColors();
  54739. };
  54740. /**
  54741. * Compute the highlights and shadow colors according to their chosen levels.
  54742. */
  54743. BackgroundMaterial.prototype._computePrimaryColors = function () {
  54744. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  54745. return;
  54746. }
  54747. // Find the highlight color based on the configuration.
  54748. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  54749. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  54750. // Find the shadow color based on the configuration.
  54751. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  54752. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  54753. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  54754. };
  54755. /**
  54756. * Build the uniform buffer used in the material.
  54757. */
  54758. BackgroundMaterial.prototype.buildUniformLayout = function () {
  54759. // Order is important !
  54760. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  54761. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  54762. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  54763. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  54764. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  54765. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  54766. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  54767. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  54768. this._uniformBuffer.addUniform("pointSize", 1);
  54769. this._uniformBuffer.addUniform("shadowLevel", 1);
  54770. this._uniformBuffer.addUniform("alpha", 1);
  54771. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  54772. this._uniformBuffer.addUniform("vReflectionControl", 4);
  54773. this._uniformBuffer.create();
  54774. };
  54775. /**
  54776. * Unbind the material.
  54777. */
  54778. BackgroundMaterial.prototype.unbind = function () {
  54779. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  54780. this._uniformBuffer.setTexture("diffuseSampler", null);
  54781. }
  54782. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  54783. this._uniformBuffer.setTexture("reflectionSampler", null);
  54784. }
  54785. _super.prototype.unbind.call(this);
  54786. };
  54787. /**
  54788. * Bind only the world matrix to the material.
  54789. * @param world The world matrix to bind.
  54790. */
  54791. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  54792. this._activeEffect.setMatrix("world", world);
  54793. };
  54794. /**
  54795. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54796. * @param world The world matrix to bind.
  54797. * @param subMesh The submesh to bind for.
  54798. */
  54799. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  54800. var scene = this.getScene();
  54801. var defines = subMesh._materialDefines;
  54802. if (!defines) {
  54803. return;
  54804. }
  54805. var effect = subMesh.effect;
  54806. if (!effect) {
  54807. return;
  54808. }
  54809. this._activeEffect = effect;
  54810. // Matrices
  54811. this.bindOnlyWorldMatrix(world);
  54812. // Bones
  54813. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  54814. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  54815. if (mustRebind) {
  54816. this._uniformBuffer.bindToEffect(effect, "Material");
  54817. this.bindViewProjection(effect);
  54818. var reflectionTexture = this._reflectionTexture;
  54819. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  54820. // Texture uniforms
  54821. if (scene.texturesEnabled) {
  54822. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  54823. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  54824. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  54825. }
  54826. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  54827. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  54828. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  54829. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  54830. }
  54831. }
  54832. if (this.shadowLevel > 0) {
  54833. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  54834. }
  54835. this._uniformBuffer.updateFloat("alpha", this.alpha);
  54836. // Point size
  54837. if (this.pointsCloud) {
  54838. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  54839. }
  54840. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  54841. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  54842. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  54843. }
  54844. else {
  54845. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  54846. }
  54847. }
  54848. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  54849. // Textures
  54850. if (scene.texturesEnabled) {
  54851. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  54852. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  54853. }
  54854. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  54855. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  54856. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  54857. }
  54858. else if (!defines.REFLECTIONBLUR) {
  54859. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  54860. }
  54861. else {
  54862. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  54863. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  54864. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  54865. }
  54866. if (defines.REFLECTIONFRESNEL) {
  54867. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  54868. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  54869. }
  54870. }
  54871. }
  54872. // Clip plane
  54873. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  54874. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  54875. }
  54876. if (mustRebind || !this.isFrozen) {
  54877. if (scene.lightsEnabled) {
  54878. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  54879. }
  54880. // View
  54881. this.bindView(effect);
  54882. // Fog
  54883. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  54884. // image processing
  54885. if (this._imageProcessingConfiguration) {
  54886. this._imageProcessingConfiguration.bind(this._activeEffect);
  54887. }
  54888. }
  54889. this._uniformBuffer.update();
  54890. this._afterBind(mesh, this._activeEffect);
  54891. };
  54892. /**
  54893. * Dispose the material.
  54894. * @param forceDisposeEffect Force disposal of the associated effect.
  54895. * @param forceDisposeTextures Force disposal of the associated textures.
  54896. */
  54897. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  54898. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  54899. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  54900. if (forceDisposeTextures) {
  54901. if (this.diffuseTexture) {
  54902. this.diffuseTexture.dispose();
  54903. }
  54904. if (this.reflectionTexture) {
  54905. this.reflectionTexture.dispose();
  54906. }
  54907. }
  54908. this._renderTargets.dispose();
  54909. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  54910. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  54911. }
  54912. _super.prototype.dispose.call(this, forceDisposeEffect);
  54913. };
  54914. /**
  54915. * Clones the material.
  54916. * @param name The cloned name.
  54917. * @returns The cloned material.
  54918. */
  54919. BackgroundMaterial.prototype.clone = function (name) {
  54920. var _this = this;
  54921. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  54922. };
  54923. /**
  54924. * Serializes the current material to its JSON representation.
  54925. * @returns The JSON representation.
  54926. */
  54927. BackgroundMaterial.prototype.serialize = function () {
  54928. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54929. serializationObject.customType = "BABYLON.BackgroundMaterial";
  54930. return serializationObject;
  54931. };
  54932. /**
  54933. * Gets the class name of the material
  54934. * @returns "BackgroundMaterial"
  54935. */
  54936. BackgroundMaterial.prototype.getClassName = function () {
  54937. return "BackgroundMaterial";
  54938. };
  54939. /**
  54940. * Parse a JSON input to create back a background material.
  54941. * @param source The JSON data to parse
  54942. * @param scene The scene to create the parsed material in
  54943. * @param rootUrl The root url of the assets the material depends upon
  54944. * @returns the instantiated BackgroundMaterial.
  54945. */
  54946. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  54947. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  54948. };
  54949. /**
  54950. * Standard reflectance value at parallel view angle.
  54951. */
  54952. BackgroundMaterial.StandardReflectance0 = 0.05;
  54953. /**
  54954. * Standard reflectance value at grazing angle.
  54955. */
  54956. BackgroundMaterial.StandardReflectance90 = 0.5;
  54957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54959. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  54960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54962. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  54963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54965. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  54966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54968. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  54969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54971. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  54972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54974. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  54975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54977. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  54978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54980. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  54981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54983. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  54984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54986. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  54987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54989. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  54990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54992. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  54993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54995. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  54996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54998. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  54999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55001. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  55002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  55004. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  55005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55007. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  55008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55010. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  55011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55013. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  55014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55016. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  55017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55019. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  55020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55022. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  55023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55025. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  55026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55028. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  55029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55031. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  55032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55034. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  55035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55037. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  55038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55040. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  55041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55043. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  55044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55046. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  55047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55049. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  55050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55052. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  55053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55055. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  55056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55058. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  55059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55061. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  55062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  55064. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  55065. return BackgroundMaterial;
  55066. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  55067. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  55068. /***/ }),
  55069. /***/ "./Materials/Background/index.ts":
  55070. /*!***************************************!*\
  55071. !*** ./Materials/Background/index.ts ***!
  55072. \***************************************/
  55073. /*! exports provided: BackgroundMaterial */
  55074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55075. "use strict";
  55076. __webpack_require__.r(__webpack_exports__);
  55077. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  55078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  55079. /***/ }),
  55080. /***/ "./Materials/Node/Blocks/Dual/fogBlock.ts":
  55081. /*!************************************************!*\
  55082. !*** ./Materials/Node/Blocks/Dual/fogBlock.ts ***!
  55083. \************************************************/
  55084. /*! exports provided: FogBlock */
  55085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55086. "use strict";
  55087. __webpack_require__.r(__webpack_exports__);
  55088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return FogBlock; });
  55089. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55090. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55091. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55092. /* harmony import */ var _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialWellKnownValues */ "./Materials/Node/nodeMaterialWellKnownValues.ts");
  55093. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55094. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../materialHelper */ "./Materials/materialHelper.ts");
  55095. /* harmony import */ var _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  55096. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55097. /**
  55098. * Block used to add support for scene fog
  55099. */
  55100. var FogBlock = /** @class */ (function (_super) {
  55101. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FogBlock, _super);
  55102. /**
  55103. * Create a new FogBlock
  55104. * @param name defines the block name
  55105. */
  55106. function FogBlock(name) {
  55107. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].VertexAndFragment, true) || this;
  55108. // Vertex
  55109. _this.registerInput("worldPosition", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Vertex);
  55110. _this.registerInput("view", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Vertex);
  55111. // Fragment
  55112. _this.registerInput("color", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Fragment);
  55113. _this.registerInput("fogColor", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Fragment);
  55114. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Fragment);
  55115. return _this;
  55116. }
  55117. /**
  55118. * Gets the current class name
  55119. * @returns the class name
  55120. */
  55121. FogBlock.prototype.getClassName = function () {
  55122. return "FogBlock";
  55123. };
  55124. Object.defineProperty(FogBlock.prototype, "worldPosition", {
  55125. /**
  55126. * Gets the world position input component
  55127. */
  55128. get: function () {
  55129. return this._inputs[0];
  55130. },
  55131. enumerable: true,
  55132. configurable: true
  55133. });
  55134. Object.defineProperty(FogBlock.prototype, "view", {
  55135. /**
  55136. * Gets the view input component
  55137. */
  55138. get: function () {
  55139. return this._inputs[1];
  55140. },
  55141. enumerable: true,
  55142. configurable: true
  55143. });
  55144. Object.defineProperty(FogBlock.prototype, "color", {
  55145. /**
  55146. * Gets the color input component
  55147. */
  55148. get: function () {
  55149. return this._inputs[2];
  55150. },
  55151. enumerable: true,
  55152. configurable: true
  55153. });
  55154. Object.defineProperty(FogBlock.prototype, "fogColor", {
  55155. /**
  55156. * Gets the fog color input component
  55157. */
  55158. get: function () {
  55159. return this._inputs[3];
  55160. },
  55161. enumerable: true,
  55162. configurable: true
  55163. });
  55164. Object.defineProperty(FogBlock.prototype, "output", {
  55165. /**
  55166. * Gets the output component
  55167. */
  55168. get: function () {
  55169. return this._outputs[0];
  55170. },
  55171. enumerable: true,
  55172. configurable: true
  55173. });
  55174. FogBlock.prototype.autoConfigure = function () {
  55175. if (!this.view.isConnected) {
  55176. var viewInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("view");
  55177. viewInput.setAsWellKnownValue(_nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialWellKnownValues"].View);
  55178. viewInput.output.connectTo(this.view);
  55179. }
  55180. if (!this.fogColor.isConnected) {
  55181. var fogColorInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("fogColor", undefined, _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3);
  55182. fogColorInput.setAsWellKnownValue(_nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialWellKnownValues"].FogColor);
  55183. fogColorInput.output.connectTo(this.fogColor);
  55184. }
  55185. };
  55186. FogBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
  55187. var scene = mesh.getScene();
  55188. defines.setValue("FOG", nodeMaterial.fogEnabled && _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].GetFogState(mesh, scene));
  55189. };
  55190. FogBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  55191. if (!mesh) {
  55192. return;
  55193. }
  55194. var scene = mesh.getScene();
  55195. effect.setFloat4(this._fogParameters, scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  55196. };
  55197. FogBlock.prototype._buildBlock = function (state) {
  55198. _super.prototype._buildBlock.call(this, state);
  55199. state.sharedData.blocksWithDefines.push(this);
  55200. if (state.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Fragment) {
  55201. state.sharedData.bindableBlocks.push(this);
  55202. state._emitFunctionFromInclude("fogFragmentDeclaration", "//" + this.name, {
  55203. removeUniforms: true,
  55204. removeVaryings: true,
  55205. removeIfDef: false,
  55206. replaceStrings: [{ search: /float CalcFogFactor\(\)/, replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)" }]
  55207. });
  55208. var tempFogVariablename = state._getFreeVariableName("fog");
  55209. var color = this.color;
  55210. var fogColor = this.fogColor;
  55211. this._fogParameters = state._getFreeVariableName("fogParameters");
  55212. var output = this._outputs[0];
  55213. state._emitUniformFromString(this._fogParameters, "vec4");
  55214. state.compilationString += "#ifdef FOG\r\n";
  55215. state.compilationString += "float " + tempFogVariablename + " = CalcFogFactor(" + this._fogDistanceName + ", " + this._fogParameters + ");\r\n";
  55216. state.compilationString += this._declareOutput(output, state) + (" = " + tempFogVariablename + " * " + color.associatedVariableName + " + (1.0 - " + tempFogVariablename + ") * " + fogColor.associatedVariableName + ";\r\n");
  55217. state.compilationString += "#else\r\n" + this._declareOutput(output, state) + " = " + color.associatedVariableName + ";\r\n";
  55218. state.compilationString += "#endif\r\n";
  55219. }
  55220. else {
  55221. var worldPos = this.worldPosition;
  55222. var view = this.view;
  55223. this._fogDistanceName = state._getFreeVariableName("vFogDistance");
  55224. state._emitVaryingFromString(this._fogDistanceName, "vec3");
  55225. state.compilationString += this._fogDistanceName + " = (" + view.associatedVariableName + " * " + worldPos.associatedVariableName + ").xyz;\r\n";
  55226. }
  55227. return this;
  55228. };
  55229. return FogBlock;
  55230. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  55231. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.FogBlock"] = FogBlock;
  55232. /***/ }),
  55233. /***/ "./Materials/Node/Blocks/Dual/index.ts":
  55234. /*!*********************************************!*\
  55235. !*** ./Materials/Node/Blocks/Dual/index.ts ***!
  55236. \*********************************************/
  55237. /*! exports provided: FogBlock, LightBlock, TextureBlock */
  55238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55239. "use strict";
  55240. __webpack_require__.r(__webpack_exports__);
  55241. /* harmony import */ var _fogBlock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fogBlock */ "./Materials/Node/Blocks/Dual/fogBlock.ts");
  55242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return _fogBlock__WEBPACK_IMPORTED_MODULE_0__["FogBlock"]; });
  55243. /* harmony import */ var _lightBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lightBlock */ "./Materials/Node/Blocks/Dual/lightBlock.ts");
  55244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return _lightBlock__WEBPACK_IMPORTED_MODULE_1__["LightBlock"]; });
  55245. /* harmony import */ var _textureBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textureBlock */ "./Materials/Node/Blocks/Dual/textureBlock.ts");
  55246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return _textureBlock__WEBPACK_IMPORTED_MODULE_2__["TextureBlock"]; });
  55247. /***/ }),
  55248. /***/ "./Materials/Node/Blocks/Dual/lightBlock.ts":
  55249. /*!**************************************************!*\
  55250. !*** ./Materials/Node/Blocks/Dual/lightBlock.ts ***!
  55251. \**************************************************/
  55252. /*! exports provided: LightBlock */
  55253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55254. "use strict";
  55255. __webpack_require__.r(__webpack_exports__);
  55256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return LightBlock; });
  55257. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55258. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55259. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55260. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55261. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../materialHelper */ "./Materials/materialHelper.ts");
  55262. /* harmony import */ var _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../nodeMaterialWellKnownValues */ "./Materials/Node/nodeMaterialWellKnownValues.ts");
  55263. /* harmony import */ var _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  55264. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55265. /**
  55266. * Block used to add light in the fragment shader
  55267. */
  55268. var LightBlock = /** @class */ (function (_super) {
  55269. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightBlock, _super);
  55270. /**
  55271. * Create a new LightBlock
  55272. * @param name defines the block name
  55273. */
  55274. function LightBlock(name) {
  55275. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].VertexAndFragment) || this;
  55276. _this.registerInput("worldPosition", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector4, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Vertex);
  55277. _this.registerInput("worldNormal", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector4, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Vertex);
  55278. _this.registerInput("cameraPosition", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector3, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Fragment);
  55279. _this.registerOutput("diffuseOutput", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Color3, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Fragment);
  55280. _this.registerOutput("specularOutput", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Color3, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Fragment);
  55281. return _this;
  55282. }
  55283. /**
  55284. * Gets the current class name
  55285. * @returns the class name
  55286. */
  55287. LightBlock.prototype.getClassName = function () {
  55288. return "LightBlock";
  55289. };
  55290. Object.defineProperty(LightBlock.prototype, "worldPosition", {
  55291. /**
  55292. * Gets the world position input component
  55293. */
  55294. get: function () {
  55295. return this._inputs[0];
  55296. },
  55297. enumerable: true,
  55298. configurable: true
  55299. });
  55300. Object.defineProperty(LightBlock.prototype, "worldNormal", {
  55301. /**
  55302. * Gets the world normal input component
  55303. */
  55304. get: function () {
  55305. return this._inputs[1];
  55306. },
  55307. enumerable: true,
  55308. configurable: true
  55309. });
  55310. Object.defineProperty(LightBlock.prototype, "cameraPosition", {
  55311. /**
  55312. * Gets the camera (or eye) position component
  55313. */
  55314. get: function () {
  55315. return this._inputs[2];
  55316. },
  55317. enumerable: true,
  55318. configurable: true
  55319. });
  55320. Object.defineProperty(LightBlock.prototype, "diffuseOutput", {
  55321. /**
  55322. * Gets the diffuse output component
  55323. */
  55324. get: function () {
  55325. return this._outputs[0];
  55326. },
  55327. enumerable: true,
  55328. configurable: true
  55329. });
  55330. Object.defineProperty(LightBlock.prototype, "specularOutput", {
  55331. /**
  55332. * Gets the specular output component
  55333. */
  55334. get: function () {
  55335. return this._outputs[1];
  55336. },
  55337. enumerable: true,
  55338. configurable: true
  55339. });
  55340. LightBlock.prototype.autoConfigure = function () {
  55341. if (!this.cameraPosition.isConnected) {
  55342. var cameraPositionInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("cameraPosition");
  55343. cameraPositionInput.setAsWellKnownValue(_nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_5__["NodeMaterialWellKnownValues"].CameraPosition);
  55344. cameraPositionInput.output.connectTo(this.cameraPosition);
  55345. }
  55346. };
  55347. LightBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
  55348. if (!defines._areLightsDirty) {
  55349. return;
  55350. }
  55351. var scene = mesh.getScene();
  55352. if (!this.light) {
  55353. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, nodeMaterial.maxSimultaneousLights);
  55354. }
  55355. else {
  55356. var state = {
  55357. needNormals: false,
  55358. needRebuild: false,
  55359. lightmapMode: false,
  55360. shadowEnabled: false,
  55361. specularEnabled: false
  55362. };
  55363. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForLight(scene, mesh, this.light, this._lightId, defines, true, state);
  55364. if (state.needRebuild) {
  55365. defines.rebuild();
  55366. }
  55367. }
  55368. };
  55369. LightBlock.prototype.updateUniformsAndSamples = function (state, nodeMaterial, defines) {
  55370. for (var lightIndex = 0; lightIndex < nodeMaterial.maxSimultaneousLights; lightIndex++) {
  55371. if (!defines["LIGHT" + lightIndex]) {
  55372. break;
  55373. }
  55374. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareUniformsAndSamplersForLight(lightIndex, state.uniforms, state.samplers, false, state.uniformBuffers);
  55375. }
  55376. };
  55377. LightBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  55378. if (!mesh) {
  55379. return;
  55380. }
  55381. var scene = mesh.getScene();
  55382. if (!this.light) {
  55383. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindLights(scene, mesh, effect, true, nodeMaterial.maxSimultaneousLights, false);
  55384. }
  55385. else {
  55386. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindLight(this.light, this._lightId, scene, mesh, effect, true, false);
  55387. }
  55388. };
  55389. LightBlock.prototype._injectVertexCode = function (state) {
  55390. var worldPos = this.worldPosition;
  55391. var worldNormal = this.worldNormal;
  55392. // Inject code in vertex
  55393. var worldPosVaryingName = "v_" + worldPos.associatedVariableName;
  55394. state._emitVaryingFromString(worldPosVaryingName, "vec3");
  55395. var worldNormalVaryingName = "v_" + worldNormal.associatedVariableName;
  55396. state._emitVaryingFromString(worldNormalVaryingName, "vec3");
  55397. state.compilationString += worldPosVaryingName + " = " + worldPos.associatedVariableName + ".xyz;\r\n";
  55398. state.compilationString += worldNormalVaryingName + " = " + worldNormal.associatedVariableName + ".xyz;\r\n";
  55399. };
  55400. LightBlock.prototype._buildBlock = function (state) {
  55401. _super.prototype._buildBlock.call(this, state);
  55402. if (state.target !== _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Fragment) {
  55403. // Vertex
  55404. this._injectVertexCode(state);
  55405. return;
  55406. }
  55407. // Fragment
  55408. state.sharedData.bindableBlocks.push(this);
  55409. state.sharedData.blocksWithDefines.push(this);
  55410. var comments = "//" + this.name;
  55411. var worldPos = this.worldPosition;
  55412. state._emitFunctionFromInclude("lightsFragmentFunctions", comments, {
  55413. replaceStrings: [
  55414. { search: /vPositionW/g, replace: "v_" + worldPos.associatedVariableName }
  55415. ]
  55416. });
  55417. if (!this.light) { // Emit for all lights
  55418. state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
  55419. repeatKey: "maxSimultaneousLights"
  55420. });
  55421. this._lightId = 0;
  55422. state.sharedData.dynamicUniformBlocks.push(this);
  55423. }
  55424. else {
  55425. this._lightId = (state.counters["lightCounter"] !== undefined ? state.counters["lightCounter"] : -1) + 1;
  55426. state.counters["lightCounter"] = this._lightId;
  55427. state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
  55428. replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }]
  55429. }, this._lightId.toString());
  55430. // Uniforms and samplers
  55431. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareUniformsAndSamplersForLight(this._lightId, state.uniforms, state.samplers, undefined, state.uniformBuffers);
  55432. }
  55433. // Code
  55434. if (this._lightId === 0) {
  55435. state.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + ("v_" + worldPos.associatedVariableName) + ");\r\n";
  55436. state.compilationString += "lightingInfo info;\r\n";
  55437. state.compilationString += "float shadow = 1.;\r\n";
  55438. state.compilationString += "float glossiness = 0.;\r\n";
  55439. state.compilationString += "vec3 diffuseBase = vec3(0., 0., 0.);\r\n";
  55440. state.compilationString += "vec3 specularBase = vec3(0., 0., 0.);\r\n";
  55441. state.compilationString += "vec3 normalW = v_" + this.worldNormal.associatedVariableName + ";\r\n";
  55442. }
  55443. if (this.light) {
  55444. state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
  55445. replaceStrings: [
  55446. { search: /{X}/g, replace: this._lightId.toString() }
  55447. ]
  55448. });
  55449. }
  55450. else {
  55451. state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
  55452. repeatKey: "maxSimultaneousLights"
  55453. });
  55454. }
  55455. var diffuseOutput = this.diffuseOutput;
  55456. var specularOutput = this.specularOutput;
  55457. state.compilationString += this._declareOutput(diffuseOutput, state) + " = diffuseBase;\r\n";
  55458. state.compilationString += "#ifdef SPECULARTERM\r\n";
  55459. state.compilationString += this._declareOutput(specularOutput, state) + " = specularBase;\r\n";
  55460. state.compilationString += "#endif\r\n";
  55461. return this;
  55462. };
  55463. LightBlock.prototype.serialize = function () {
  55464. var serializationObject = _super.prototype.serialize.call(this);
  55465. if (this.light) {
  55466. serializationObject.lightId = this.light.id;
  55467. }
  55468. return serializationObject;
  55469. };
  55470. LightBlock.prototype._deserialize = function (serializationObject, scene, rootUrl) {
  55471. _super.prototype._deserialize.call(this, serializationObject, scene, rootUrl);
  55472. if (serializationObject.lightId) {
  55473. this.light = scene.getLightByID(serializationObject.lightId);
  55474. }
  55475. };
  55476. return LightBlock;
  55477. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  55478. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.LightBlock"] = LightBlock;
  55479. /***/ }),
  55480. /***/ "./Materials/Node/Blocks/Dual/textureBlock.ts":
  55481. /*!****************************************************!*\
  55482. !*** ./Materials/Node/Blocks/Dual/textureBlock.ts ***!
  55483. \****************************************************/
  55484. /*! exports provided: TextureBlock */
  55485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55486. "use strict";
  55487. __webpack_require__.r(__webpack_exports__);
  55488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return TextureBlock; });
  55489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55490. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55491. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55492. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55493. /* harmony import */ var _Input_inputBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  55494. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55495. /* harmony import */ var _Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Textures/texture */ "./Materials/Textures/texture.ts");
  55496. /**
  55497. * Block used to read a texture from a sampler
  55498. */
  55499. var TextureBlock = /** @class */ (function (_super) {
  55500. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureBlock, _super);
  55501. /**
  55502. * Create a new TextureBlock
  55503. * @param name defines the block name
  55504. */
  55505. function TextureBlock(name) {
  55506. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].VertexAndFragment) || this;
  55507. _this.registerInput("uv", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2, false, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Vertex);
  55508. _this.registerOutput("rgba", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment);
  55509. _this.registerOutput("rgb", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment);
  55510. _this.registerOutput("r", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment);
  55511. _this.registerOutput("g", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment);
  55512. _this.registerOutput("b", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment);
  55513. _this.registerOutput("a", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment);
  55514. return _this;
  55515. }
  55516. /**
  55517. * Gets the current class name
  55518. * @returns the class name
  55519. */
  55520. TextureBlock.prototype.getClassName = function () {
  55521. return "TextureBlock";
  55522. };
  55523. Object.defineProperty(TextureBlock.prototype, "uv", {
  55524. /**
  55525. * Gets the uv input component
  55526. */
  55527. get: function () {
  55528. return this._inputs[0];
  55529. },
  55530. enumerable: true,
  55531. configurable: true
  55532. });
  55533. Object.defineProperty(TextureBlock.prototype, "output", {
  55534. /**
  55535. * Gets the output component
  55536. */
  55537. get: function () {
  55538. return this._outputs[0];
  55539. },
  55540. enumerable: true,
  55541. configurable: true
  55542. });
  55543. TextureBlock.prototype.autoConfigure = function () {
  55544. if (!this.uv.isConnected) {
  55545. var uvInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_4__["InputBlock"]("uv");
  55546. uvInput.setAsAttribute();
  55547. uvInput.output.connectTo(this.uv);
  55548. }
  55549. };
  55550. TextureBlock.prototype.initializeDefines = function (mesh, nodeMaterial, defines, useInstances) {
  55551. if (useInstances === void 0) { useInstances = false; }
  55552. if (!defines._areTexturesDirty) {
  55553. return;
  55554. }
  55555. defines.setValue(this._mainUVDefineName, false);
  55556. };
  55557. TextureBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
  55558. if (!defines._areTexturesDirty) {
  55559. return;
  55560. }
  55561. if (!this.texture || !this.texture.getTextureMatrix) {
  55562. return;
  55563. }
  55564. if (!this.texture.getTextureMatrix().isIdentityAs3x2()) {
  55565. defines.setValue(this._defineName, true);
  55566. }
  55567. else {
  55568. defines.setValue(this._defineName, false);
  55569. defines.setValue(this._mainUVDefineName, true);
  55570. }
  55571. };
  55572. TextureBlock.prototype.isReady = function () {
  55573. if (this.texture && !this.texture.isReadyOrNotBlocking()) {
  55574. return false;
  55575. }
  55576. return true;
  55577. };
  55578. TextureBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  55579. if (!mesh || !this.texture) {
  55580. return;
  55581. }
  55582. effect.setFloat(this._textureInfoName, this.texture.level);
  55583. effect.setMatrix(this._textureTransformName, this.texture.getTextureMatrix());
  55584. effect.setTexture(this._samplerName, this.texture);
  55585. };
  55586. TextureBlock.prototype._injectVertexCode = function (state) {
  55587. var uvInput = this.uv;
  55588. // Inject code in vertex
  55589. this._defineName = state._getFreeDefineName("UVTRANSFORM");
  55590. this._mainUVDefineName = state._getFreeDefineName("vMain" + uvInput.associatedVariableName);
  55591. if (uvInput.connectedPoint.ownerBlock.isInput) {
  55592. var uvInputOwnerBlock = uvInput.connectedPoint.ownerBlock;
  55593. if (!uvInputOwnerBlock.isAttribute) {
  55594. state._emitUniformFromString(uvInput.associatedVariableName, "vec2");
  55595. }
  55596. }
  55597. this._mainUVName = "vMain" + uvInput.associatedVariableName;
  55598. this._transformedUVName = state._getFreeVariableName("transformedUV");
  55599. this._textureTransformName = state._getFreeVariableName("textureTransform");
  55600. this._textureInfoName = state._getFreeVariableName("textureInfoName");
  55601. state._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName);
  55602. state._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName);
  55603. state._emitUniformFromString(this._textureTransformName, "mat4", this._defineName);
  55604. state.compilationString += "#ifdef " + this._defineName + "\r\n";
  55605. state.compilationString += this._transformedUVName + " = vec2(" + this._textureTransformName + " * vec4(" + uvInput.associatedVariableName + ", 1.0, 0.0));\r\n";
  55606. state.compilationString += "#else\r\n";
  55607. state.compilationString += this._mainUVName + " = " + uvInput.associatedVariableName + ";\r\n";
  55608. state.compilationString += "#endif\r\n";
  55609. };
  55610. TextureBlock.prototype._writeOutput = function (state, output, swizzle) {
  55611. var uvInput = this.uv;
  55612. var complement = " * " + this._textureInfoName;
  55613. state.compilationString += "#ifdef " + this._defineName + "\r\n";
  55614. state.compilationString += this._declareOutput(output, state) + " = texture2D(" + this._samplerName + ", " + this._transformedUVName + ")." + swizzle + complement + ";\r\n";
  55615. state.compilationString += "#else\r\n";
  55616. state.compilationString += this._declareOutput(output, state) + " = texture2D(" + this._samplerName + ", " + ("vMain" + uvInput.associatedVariableName) + ")." + swizzle + complement + ";\r\n";
  55617. state.compilationString += "#endif\r\n";
  55618. };
  55619. TextureBlock.prototype._buildBlock = function (state) {
  55620. _super.prototype._buildBlock.call(this, state);
  55621. if (state.target !== _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) {
  55622. // Vertex
  55623. this._injectVertexCode(state);
  55624. return;
  55625. }
  55626. state.sharedData.blockingBlocks.push(this);
  55627. state.sharedData.textureBlocks.push(this);
  55628. this._samplerName = state._getFreeVariableName(this.name + "Sampler");
  55629. state.samplers.push(this._samplerName);
  55630. state._samplerDeclaration += "uniform sampler2D " + this._samplerName + ";\r\n";
  55631. // Fragment
  55632. state.sharedData.blocksWithDefines.push(this);
  55633. state.sharedData.bindableBlocks.push(this);
  55634. state._emitUniformFromString(this._textureInfoName, "float");
  55635. for (var _i = 0, _a = this._outputs; _i < _a.length; _i++) {
  55636. var output = _a[_i];
  55637. if (output.connectedBlocks.length) {
  55638. this._writeOutput(state, output, output.name);
  55639. }
  55640. }
  55641. return this;
  55642. };
  55643. TextureBlock.prototype.serialize = function () {
  55644. var serializationObject = _super.prototype.serialize.call(this);
  55645. if (this.texture) {
  55646. serializationObject.texture = this.texture.serialize();
  55647. }
  55648. return serializationObject;
  55649. };
  55650. TextureBlock.prototype._deserialize = function (serializationObject, scene, rootUrl) {
  55651. _super.prototype._deserialize.call(this, serializationObject, scene, rootUrl);
  55652. if (serializationObject.texture) {
  55653. this.texture = _Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].Parse(serializationObject.texture, scene, rootUrl);
  55654. }
  55655. };
  55656. return TextureBlock;
  55657. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  55658. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.TextureBlock"] = TextureBlock;
  55659. /***/ }),
  55660. /***/ "./Materials/Node/Blocks/Fragment/alphaTestBlock.ts":
  55661. /*!**********************************************************!*\
  55662. !*** ./Materials/Node/Blocks/Fragment/alphaTestBlock.ts ***!
  55663. \**********************************************************/
  55664. /*! exports provided: AlphaTestBlock */
  55665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55666. "use strict";
  55667. __webpack_require__.r(__webpack_exports__);
  55668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return AlphaTestBlock; });
  55669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55670. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55671. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55672. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55673. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55674. /**
  55675. * Block used to add an alpha test in the fragment shader
  55676. */
  55677. var AlphaTestBlock = /** @class */ (function (_super) {
  55678. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AlphaTestBlock, _super);
  55679. /**
  55680. * Create a new AlphaTestBlock
  55681. * @param name defines the block name
  55682. */
  55683. function AlphaTestBlock(name) {
  55684. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) || this;
  55685. /**
  55686. * Gets or sets the alpha value where alpha testing happens
  55687. */
  55688. _this.alphaCutOff = 0.4;
  55689. _this.registerInput("color", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4);
  55690. return _this;
  55691. }
  55692. /**
  55693. * Gets the current class name
  55694. * @returns the class name
  55695. */
  55696. AlphaTestBlock.prototype.getClassName = function () {
  55697. return "AlphaTestBlock";
  55698. };
  55699. Object.defineProperty(AlphaTestBlock.prototype, "color", {
  55700. /**
  55701. * Gets the color input component
  55702. */
  55703. get: function () {
  55704. return this._inputs[0];
  55705. },
  55706. enumerable: true,
  55707. configurable: true
  55708. });
  55709. AlphaTestBlock.prototype._buildBlock = function (state) {
  55710. _super.prototype._buildBlock.call(this, state);
  55711. state.sharedData.hints.needAlphaTesting = true;
  55712. state.compilationString += "if (" + this.color.associatedVariableName + ".a < " + this.alphaCutOff + ") discard;\r\n";
  55713. return this;
  55714. };
  55715. return AlphaTestBlock;
  55716. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  55717. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.AlphaTestBlock"] = AlphaTestBlock;
  55718. /***/ }),
  55719. /***/ "./Materials/Node/Blocks/Fragment/colorMergerBlock.ts":
  55720. /*!************************************************************!*\
  55721. !*** ./Materials/Node/Blocks/Fragment/colorMergerBlock.ts ***!
  55722. \************************************************************/
  55723. /*! exports provided: ColorMergerBlock */
  55724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55725. "use strict";
  55726. __webpack_require__.r(__webpack_exports__);
  55727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return ColorMergerBlock; });
  55728. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55729. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55730. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55731. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55732. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55733. /**
  55734. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55735. */
  55736. var ColorMergerBlock = /** @class */ (function (_super) {
  55737. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorMergerBlock, _super);
  55738. /**
  55739. * Create a new ColorMergerBlock
  55740. * @param name defines the block name
  55741. */
  55742. function ColorMergerBlock(name) {
  55743. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) || this;
  55744. _this.registerInput("r", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55745. _this.registerInput("g", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55746. _this.registerInput("b", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55747. _this.registerInput("a", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, true);
  55748. _this.registerOutput("rgba", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4);
  55749. _this.registerOutput("rgb", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3);
  55750. return _this;
  55751. }
  55752. /**
  55753. * Gets the current class name
  55754. * @returns the class name
  55755. */
  55756. ColorMergerBlock.prototype.getClassName = function () {
  55757. return "ColorMergerBlock";
  55758. };
  55759. Object.defineProperty(ColorMergerBlock.prototype, "r", {
  55760. /**
  55761. * Gets the r component input
  55762. */
  55763. get: function () {
  55764. return this._inputs[0];
  55765. },
  55766. enumerable: true,
  55767. configurable: true
  55768. });
  55769. Object.defineProperty(ColorMergerBlock.prototype, "g", {
  55770. /**
  55771. * Gets the g component input
  55772. */
  55773. get: function () {
  55774. return this._inputs[1];
  55775. },
  55776. enumerable: true,
  55777. configurable: true
  55778. });
  55779. Object.defineProperty(ColorMergerBlock.prototype, "b", {
  55780. /**
  55781. * Gets the b component input
  55782. */
  55783. get: function () {
  55784. return this._inputs[2];
  55785. },
  55786. enumerable: true,
  55787. configurable: true
  55788. });
  55789. Object.defineProperty(ColorMergerBlock.prototype, "a", {
  55790. /**
  55791. * Gets the a component input
  55792. */
  55793. get: function () {
  55794. return this._inputs[3];
  55795. },
  55796. enumerable: true,
  55797. configurable: true
  55798. });
  55799. ColorMergerBlock.prototype._buildBlock = function (state) {
  55800. _super.prototype._buildBlock.call(this, state);
  55801. var rInput = this.r;
  55802. var gInput = this.g;
  55803. var bInput = this.b;
  55804. var aInput = this.a;
  55805. var color4Output = this._outputs[0];
  55806. var color3Output = this._outputs[1];
  55807. if (color4Output.endpoints.length) {
  55808. state.compilationString += this._declareOutput(color4Output, state) + (" = vec4(" + this._writeVariable(rInput) + ", " + this._writeVariable(gInput) + ", " + this._writeVariable(bInput) + ", " + (aInput.isConnected ? this._writeVariable(aInput) : "0.0") + ");\r\n");
  55809. }
  55810. else if (color3Output.endpoints.length) {
  55811. state.compilationString += this._declareOutput(color3Output, state) + (" = vec3(" + this._writeVariable(rInput) + ", " + this._writeVariable(gInput) + ", " + this._writeVariable(bInput) + ");\r\n");
  55812. }
  55813. return this;
  55814. };
  55815. return ColorMergerBlock;
  55816. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  55817. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorMergerBlock"] = ColorMergerBlock;
  55818. /***/ }),
  55819. /***/ "./Materials/Node/Blocks/Fragment/colorSplitterBlock.ts":
  55820. /*!**************************************************************!*\
  55821. !*** ./Materials/Node/Blocks/Fragment/colorSplitterBlock.ts ***!
  55822. \**************************************************************/
  55823. /*! exports provided: ColorSplitterBlock */
  55824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55825. "use strict";
  55826. __webpack_require__.r(__webpack_exports__);
  55827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return ColorSplitterBlock; });
  55828. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55829. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55830. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55831. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55832. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55833. /**
  55834. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55835. */
  55836. var ColorSplitterBlock = /** @class */ (function (_super) {
  55837. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorSplitterBlock, _super);
  55838. /**
  55839. * Create a new ColorSplitterBlock
  55840. * @param name defines the block name
  55841. */
  55842. function ColorSplitterBlock(name) {
  55843. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) || this;
  55844. _this.registerInput("rgba", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4, true);
  55845. _this.registerInput("rgb", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3, true);
  55846. _this.registerOutput("rgb", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3);
  55847. _this.registerOutput("r", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55848. _this.registerOutput("g", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55849. _this.registerOutput("b", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55850. _this.registerOutput("a", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  55851. return _this;
  55852. }
  55853. /**
  55854. * Gets the current class name
  55855. * @returns the class name
  55856. */
  55857. ColorSplitterBlock.prototype.getClassName = function () {
  55858. return "ColorSplitterBlock";
  55859. };
  55860. Object.defineProperty(ColorSplitterBlock.prototype, "rgba", {
  55861. /**
  55862. * Gets the rgba input component
  55863. */
  55864. get: function () {
  55865. return this._inputs[0];
  55866. },
  55867. enumerable: true,
  55868. configurable: true
  55869. });
  55870. Object.defineProperty(ColorSplitterBlock.prototype, "rgb", {
  55871. /**
  55872. * Gets the rgb input component
  55873. */
  55874. get: function () {
  55875. return this._inputs[1];
  55876. },
  55877. enumerable: true,
  55878. configurable: true
  55879. });
  55880. ColorSplitterBlock.prototype._buildBlock = function (state) {
  55881. _super.prototype._buildBlock.call(this, state);
  55882. var input = this.rgba.isConnected ? this.rgba : this.rgb;
  55883. var rgbOutput = this._outputs[0];
  55884. var rOutput = this._outputs[1];
  55885. var gOutput = this._outputs[2];
  55886. var bOutput = this._outputs[3];
  55887. var aOutput = this._outputs[4];
  55888. if (rgbOutput.connectedBlocks.length > 0) {
  55889. state.compilationString += this._declareOutput(rgbOutput, state) + (" = " + input.associatedVariableName + ".rgb;\r\n");
  55890. }
  55891. if (rOutput.connectedBlocks.length > 0) {
  55892. state.compilationString += this._declareOutput(rOutput, state) + (" = " + input.associatedVariableName + ".r;\r\n");
  55893. }
  55894. if (gOutput.connectedBlocks.length > 0) {
  55895. state.compilationString += this._declareOutput(gOutput, state) + (" = " + input.associatedVariableName + ".g;\r\n");
  55896. }
  55897. if (bOutput.connectedBlocks.length > 0) {
  55898. state.compilationString += this._declareOutput(bOutput, state) + (" = " + input.associatedVariableName + ".b;\r\n");
  55899. }
  55900. if (aOutput.connectedBlocks.length > 0) {
  55901. state.compilationString += this._declareOutput(aOutput, state) + (" = " + input.associatedVariableName + ".a;\r\n");
  55902. }
  55903. return this;
  55904. };
  55905. return ColorSplitterBlock;
  55906. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  55907. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorSplitterBlock"] = ColorSplitterBlock;
  55908. /***/ }),
  55909. /***/ "./Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts":
  55910. /*!***************************************************************!*\
  55911. !*** ./Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts ***!
  55912. \***************************************************************/
  55913. /*! exports provided: FragmentOutputBlock */
  55914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55915. "use strict";
  55916. __webpack_require__.r(__webpack_exports__);
  55917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return FragmentOutputBlock; });
  55918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55919. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  55920. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  55921. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  55922. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55923. /**
  55924. * Block used to output the final color
  55925. */
  55926. var FragmentOutputBlock = /** @class */ (function (_super) {
  55927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FragmentOutputBlock, _super);
  55928. /**
  55929. * Create a new FragmentOutputBlock
  55930. * @param name defines the block name
  55931. */
  55932. function FragmentOutputBlock(name) {
  55933. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment, true) || this;
  55934. _this.registerInput("rgba", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4, true);
  55935. _this.registerInput("rgb", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3, true);
  55936. _this.registerInput("a", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, true);
  55937. return _this;
  55938. }
  55939. /**
  55940. * Gets the current class name
  55941. * @returns the class name
  55942. */
  55943. FragmentOutputBlock.prototype.getClassName = function () {
  55944. return "FragmentOutputBlock";
  55945. };
  55946. Object.defineProperty(FragmentOutputBlock.prototype, "rgba", {
  55947. /**
  55948. * Gets the rgba input component
  55949. */
  55950. get: function () {
  55951. return this._inputs[0];
  55952. },
  55953. enumerable: true,
  55954. configurable: true
  55955. });
  55956. Object.defineProperty(FragmentOutputBlock.prototype, "rgb", {
  55957. /**
  55958. * Gets the rgb input component
  55959. */
  55960. get: function () {
  55961. return this._inputs[1];
  55962. },
  55963. enumerable: true,
  55964. configurable: true
  55965. });
  55966. Object.defineProperty(FragmentOutputBlock.prototype, "a", {
  55967. /**
  55968. * Gets the a input component
  55969. */
  55970. get: function () {
  55971. return this._inputs[2];
  55972. },
  55973. enumerable: true,
  55974. configurable: true
  55975. });
  55976. FragmentOutputBlock.prototype._buildBlock = function (state) {
  55977. _super.prototype._buildBlock.call(this, state);
  55978. var rgba = this.rgba;
  55979. var rgb = this.rgb;
  55980. var a = this.a;
  55981. state.sharedData.hints.needAlphaBlending = rgba.isConnected || a.isConnected;
  55982. if (rgba.connectedPoint) {
  55983. state.compilationString += "gl_FragColor = " + rgba.associatedVariableName + ";\r\n";
  55984. }
  55985. else if (rgb.connectedPoint) {
  55986. if (a.connectedPoint) {
  55987. state.compilationString += "gl_FragColor = vec4(" + rgb.associatedVariableName + ", " + a.associatedVariableName + ");\r\n";
  55988. }
  55989. else {
  55990. state.compilationString += "gl_FragColor = vec4(" + rgb.associatedVariableName + ", 1.0);\r\n";
  55991. }
  55992. }
  55993. else {
  55994. state.sharedData.checks.notConnectedNonOptionalInputs.push(rgba);
  55995. }
  55996. return this;
  55997. };
  55998. return FragmentOutputBlock;
  55999. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  56000. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.FragmentOutputBlock"] = FragmentOutputBlock;
  56001. /***/ }),
  56002. /***/ "./Materials/Node/Blocks/Fragment/imageProcessingBlock.ts":
  56003. /*!****************************************************************!*\
  56004. !*** ./Materials/Node/Blocks/Fragment/imageProcessingBlock.ts ***!
  56005. \****************************************************************/
  56006. /*! exports provided: ImageProcessingBlock */
  56007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56008. "use strict";
  56009. __webpack_require__.r(__webpack_exports__);
  56010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return ImageProcessingBlock; });
  56011. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56012. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  56013. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  56014. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  56015. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56016. /**
  56017. * Block used to add image processing support to fragment shader
  56018. */
  56019. var ImageProcessingBlock = /** @class */ (function (_super) {
  56020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingBlock, _super);
  56021. /**
  56022. * Create a new ImageProcessingBlock
  56023. * @param name defines the block name
  56024. */
  56025. function ImageProcessingBlock(name) {
  56026. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) || this;
  56027. _this.registerInput("color", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3OrColor4);
  56028. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4);
  56029. return _this;
  56030. }
  56031. /**
  56032. * Gets the current class name
  56033. * @returns the class name
  56034. */
  56035. ImageProcessingBlock.prototype.getClassName = function () {
  56036. return "ImageProcessingBlock";
  56037. };
  56038. Object.defineProperty(ImageProcessingBlock.prototype, "color", {
  56039. /**
  56040. * Gets the color input component
  56041. */
  56042. get: function () {
  56043. return this._inputs[0];
  56044. },
  56045. enumerable: true,
  56046. configurable: true
  56047. });
  56048. Object.defineProperty(ImageProcessingBlock.prototype, "output", {
  56049. /**
  56050. * Gets the output component
  56051. */
  56052. get: function () {
  56053. return this._outputs[0];
  56054. },
  56055. enumerable: true,
  56056. configurable: true
  56057. });
  56058. /**
  56059. * Initialize the block and prepare the context for build
  56060. * @param state defines the state that will be used for the build
  56061. */
  56062. ImageProcessingBlock.prototype.initialize = function (state) {
  56063. state._excludeVariableName("exposureLinear");
  56064. state._excludeVariableName("contrast");
  56065. state._excludeVariableName("vInverseScreenSize");
  56066. state._excludeVariableName("vignetteSettings1");
  56067. state._excludeVariableName("vignetteSettings2");
  56068. state._excludeVariableName("vCameraColorCurveNegative");
  56069. state._excludeVariableName("vCameraColorCurveNeutral");
  56070. state._excludeVariableName("vCameraColorCurvePositive");
  56071. state._excludeVariableName("txColorTransform");
  56072. state._excludeVariableName("colorTransformSettings");
  56073. };
  56074. ImageProcessingBlock.prototype.isReady = function (mesh, nodeMaterial, defines) {
  56075. if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
  56076. if (!nodeMaterial.imageProcessingConfiguration.isReady()) {
  56077. return false;
  56078. }
  56079. }
  56080. return true;
  56081. };
  56082. ImageProcessingBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
  56083. if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
  56084. nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);
  56085. }
  56086. };
  56087. ImageProcessingBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  56088. if (!mesh) {
  56089. return;
  56090. }
  56091. if (!nodeMaterial.imageProcessingConfiguration) {
  56092. return;
  56093. }
  56094. nodeMaterial.imageProcessingConfiguration.bind(effect);
  56095. };
  56096. ImageProcessingBlock.prototype._buildBlock = function (state) {
  56097. _super.prototype._buildBlock.call(this, state);
  56098. // Register for defines
  56099. state.sharedData.blocksWithDefines.push(this);
  56100. // Register for blocking
  56101. state.sharedData.blockingBlocks.push(this);
  56102. // Register for binding
  56103. state.sharedData.bindableBlocks.push(this);
  56104. // Uniforms
  56105. state.uniforms.push("exposureLinear");
  56106. state.uniforms.push("contrast");
  56107. state.uniforms.push("vInverseScreenSize");
  56108. state.uniforms.push("vignetteSettings1");
  56109. state.uniforms.push("vignetteSettings2");
  56110. state.uniforms.push("vCameraColorCurveNegative");
  56111. state.uniforms.push("vCameraColorCurveNeutral");
  56112. state.uniforms.push("vCameraColorCurvePositive");
  56113. state.uniforms.push("txColorTransform");
  56114. state.uniforms.push("colorTransformSettings");
  56115. // Emit code
  56116. var color = this.color;
  56117. var output = this._outputs[0];
  56118. var comments = "//" + this.name;
  56119. state._emitFunctionFromInclude("helperFunctions", comments);
  56120. state._emitFunctionFromInclude("imageProcessingDeclaration", comments);
  56121. state._emitFunctionFromInclude("imageProcessingFunctions", comments);
  56122. if (color.connectedPoint.type === _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4) {
  56123. state.compilationString += this._declareOutput(output, state) + " = " + color.associatedVariableName + ";\r\n";
  56124. }
  56125. else {
  56126. state.compilationString += this._declareOutput(output, state) + " = vec4(" + color.associatedVariableName + ", 1.0);\r\n";
  56127. }
  56128. state.compilationString += "#ifdef IMAGEPROCESSINGPOSTPROCESS\r\n";
  56129. state.compilationString += output.associatedVariableName + ".rgb = toLinearSpace(" + color.associatedVariableName + ".rgb);\r\n";
  56130. state.compilationString += "#else\r\n";
  56131. state.compilationString += "#ifdef IMAGEPROCESSING\r\n";
  56132. state.compilationString += output.associatedVariableName + ".rgb = toLinearSpace(" + color.associatedVariableName + ".rgb);\r\n";
  56133. state.compilationString += output.associatedVariableName + " = applyImageProcessing(" + output.associatedVariableName + ");\r\n";
  56134. state.compilationString += "#endif\r\n";
  56135. state.compilationString += "#endif\r\n";
  56136. return this;
  56137. };
  56138. return ImageProcessingBlock;
  56139. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  56140. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ImageProcessingBlock"] = ImageProcessingBlock;
  56141. /***/ }),
  56142. /***/ "./Materials/Node/Blocks/Fragment/index.ts":
  56143. /*!*************************************************!*\
  56144. !*** ./Materials/Node/Blocks/Fragment/index.ts ***!
  56145. \*************************************************/
  56146. /*! exports provided: FragmentOutputBlock, AlphaTestBlock, ColorMergerBlock, VectorMergerBlock, ColorSplitterBlock, VectorSplitterBlock, ImageProcessingBlock */
  56147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56148. "use strict";
  56149. __webpack_require__.r(__webpack_exports__);
  56150. /* harmony import */ var _fragmentOutputBlock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fragmentOutputBlock */ "./Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts");
  56151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return _fragmentOutputBlock__WEBPACK_IMPORTED_MODULE_0__["FragmentOutputBlock"]; });
  56152. /* harmony import */ var _alphaTestBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./alphaTestBlock */ "./Materials/Node/Blocks/Fragment/alphaTestBlock.ts");
  56153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return _alphaTestBlock__WEBPACK_IMPORTED_MODULE_1__["AlphaTestBlock"]; });
  56154. /* harmony import */ var _colorMergerBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorMergerBlock */ "./Materials/Node/Blocks/Fragment/colorMergerBlock.ts");
  56155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return _colorMergerBlock__WEBPACK_IMPORTED_MODULE_2__["ColorMergerBlock"]; });
  56156. /* harmony import */ var _vectorMergerBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vectorMergerBlock */ "./Materials/Node/Blocks/Fragment/vectorMergerBlock.ts");
  56157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return _vectorMergerBlock__WEBPACK_IMPORTED_MODULE_3__["VectorMergerBlock"]; });
  56158. /* harmony import */ var _colorSplitterBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./colorSplitterBlock */ "./Materials/Node/Blocks/Fragment/colorSplitterBlock.ts");
  56159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return _colorSplitterBlock__WEBPACK_IMPORTED_MODULE_4__["ColorSplitterBlock"]; });
  56160. /* harmony import */ var _vectorSplitterBlock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./vectorSplitterBlock */ "./Materials/Node/Blocks/Fragment/vectorSplitterBlock.ts");
  56161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return _vectorSplitterBlock__WEBPACK_IMPORTED_MODULE_5__["VectorSplitterBlock"]; });
  56162. /* harmony import */ var _imageProcessingBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingBlock */ "./Materials/Node/Blocks/Fragment/imageProcessingBlock.ts");
  56163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return _imageProcessingBlock__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingBlock"]; });
  56164. /***/ }),
  56165. /***/ "./Materials/Node/Blocks/Fragment/vectorMergerBlock.ts":
  56166. /*!*************************************************************!*\
  56167. !*** ./Materials/Node/Blocks/Fragment/vectorMergerBlock.ts ***!
  56168. \*************************************************************/
  56169. /*! exports provided: VectorMergerBlock */
  56170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56171. "use strict";
  56172. __webpack_require__.r(__webpack_exports__);
  56173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return VectorMergerBlock; });
  56174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56175. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  56176. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  56177. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  56178. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56179. /**
  56180. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56181. */
  56182. var VectorMergerBlock = /** @class */ (function (_super) {
  56183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VectorMergerBlock, _super);
  56184. /**
  56185. * Create a new VectorMergerBlock
  56186. * @param name defines the block name
  56187. */
  56188. function VectorMergerBlock(name) {
  56189. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) || this;
  56190. _this.registerInput("x", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  56191. _this.registerInput("y", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  56192. _this.registerInput("z", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, true);
  56193. _this.registerInput("w", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float, true);
  56194. _this.registerOutput("xyzw", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  56195. _this.registerOutput("xyz", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  56196. _this.registerOutput("xy", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2);
  56197. return _this;
  56198. }
  56199. /**
  56200. * Gets the current class name
  56201. * @returns the class name
  56202. */
  56203. VectorMergerBlock.prototype.getClassName = function () {
  56204. return "VectorMergerBlock";
  56205. };
  56206. Object.defineProperty(VectorMergerBlock.prototype, "x", {
  56207. /**
  56208. * Gets the x component input
  56209. */
  56210. get: function () {
  56211. return this._inputs[0];
  56212. },
  56213. enumerable: true,
  56214. configurable: true
  56215. });
  56216. Object.defineProperty(VectorMergerBlock.prototype, "y", {
  56217. /**
  56218. * Gets the y component input
  56219. */
  56220. get: function () {
  56221. return this._inputs[1];
  56222. },
  56223. enumerable: true,
  56224. configurable: true
  56225. });
  56226. Object.defineProperty(VectorMergerBlock.prototype, "z", {
  56227. /**
  56228. * Gets the z component input
  56229. */
  56230. get: function () {
  56231. return this._inputs[2];
  56232. },
  56233. enumerable: true,
  56234. configurable: true
  56235. });
  56236. Object.defineProperty(VectorMergerBlock.prototype, "w", {
  56237. /**
  56238. * Gets the w component input
  56239. */
  56240. get: function () {
  56241. return this._inputs[3];
  56242. },
  56243. enumerable: true,
  56244. configurable: true
  56245. });
  56246. VectorMergerBlock.prototype._buildBlock = function (state) {
  56247. _super.prototype._buildBlock.call(this, state);
  56248. var xInput = this.x;
  56249. var yInput = this.y;
  56250. var zInput = this.z;
  56251. var wInput = this.w;
  56252. var v4Output = this._outputs[0];
  56253. var v3Output = this._outputs[1];
  56254. var v2Output = this._outputs[2];
  56255. if (v4Output.endpoints.length) {
  56256. state.compilationString += this._declareOutput(v4Output, state) + (" = vec4(" + this._writeVariable(xInput) + ", " + this._writeVariable(yInput) + ", " + (zInput.isConnected ? this._writeVariable(zInput) : "0.0") + ", " + (zInput.isConnected ? this._writeVariable(wInput) : "0.0") + ");\r\n");
  56257. }
  56258. else if (v3Output.endpoints.length) {
  56259. state.compilationString += this._declareOutput(v3Output, state) + (" = vec3(" + this._writeVariable(xInput) + ", " + this._writeVariable(yInput) + ", " + (zInput.isConnected ? this._writeVariable(zInput) : "0.0") + ");\r\n");
  56260. }
  56261. else if (v2Output.endpoints.length) {
  56262. state.compilationString += this._declareOutput(v2Output, state) + (" = vec2(" + this._writeVariable(xInput) + ", " + this._writeVariable(yInput) + ");\r\n");
  56263. }
  56264. return this;
  56265. };
  56266. return VectorMergerBlock;
  56267. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  56268. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.VectorMergerBlock"] = VectorMergerBlock;
  56269. /***/ }),
  56270. /***/ "./Materials/Node/Blocks/Fragment/vectorSplitterBlock.ts":
  56271. /*!***************************************************************!*\
  56272. !*** ./Materials/Node/Blocks/Fragment/vectorSplitterBlock.ts ***!
  56273. \***************************************************************/
  56274. /*! exports provided: VectorSplitterBlock */
  56275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56276. "use strict";
  56277. __webpack_require__.r(__webpack_exports__);
  56278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return VectorSplitterBlock; });
  56279. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56280. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  56281. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  56282. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  56283. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56284. /**
  56285. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56286. */
  56287. var VectorSplitterBlock = /** @class */ (function (_super) {
  56288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VectorSplitterBlock, _super);
  56289. /**
  56290. * Create a new VectorSplitterBlock
  56291. * @param name defines the block name
  56292. */
  56293. function VectorSplitterBlock(name) {
  56294. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Fragment) || this;
  56295. _this.registerInput("xyzw", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4, true);
  56296. _this.registerInput("xyz", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3, true);
  56297. _this.registerOutput("xyz", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  56298. _this.registerOutput("x", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  56299. _this.registerOutput("y", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  56300. _this.registerOutput("z", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  56301. _this.registerOutput("w", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  56302. return _this;
  56303. }
  56304. /**
  56305. * Gets the current class name
  56306. * @returns the class name
  56307. */
  56308. VectorSplitterBlock.prototype.getClassName = function () {
  56309. return "VectorSplitterBlock";
  56310. };
  56311. Object.defineProperty(VectorSplitterBlock.prototype, "xyzw", {
  56312. /**
  56313. * Gets the rgba input component
  56314. */
  56315. get: function () {
  56316. return this._inputs[0];
  56317. },
  56318. enumerable: true,
  56319. configurable: true
  56320. });
  56321. Object.defineProperty(VectorSplitterBlock.prototype, "xyz", {
  56322. /**
  56323. * Gets the rgb input component
  56324. */
  56325. get: function () {
  56326. return this._inputs[1];
  56327. },
  56328. enumerable: true,
  56329. configurable: true
  56330. });
  56331. VectorSplitterBlock.prototype._buildBlock = function (state) {
  56332. _super.prototype._buildBlock.call(this, state);
  56333. var input = this.xyzw.isConnected ? this.xyzw : this.xyz;
  56334. var xyzOutput = this._outputs[0];
  56335. var xOutput = this._outputs[1];
  56336. var yOutput = this._outputs[2];
  56337. var zOutput = this._outputs[3];
  56338. var wOutput = this._outputs[4];
  56339. if (xyzOutput.connectedBlocks.length > 0) {
  56340. state.compilationString += this._declareOutput(xyzOutput, state) + (" = " + input.associatedVariableName + ".xyz;\r\n");
  56341. }
  56342. if (xOutput.connectedBlocks.length > 0) {
  56343. state.compilationString += this._declareOutput(xOutput, state) + (" = " + input.associatedVariableName + ".x;\r\n");
  56344. }
  56345. if (yOutput.connectedBlocks.length > 0) {
  56346. state.compilationString += this._declareOutput(yOutput, state) + (" = " + input.associatedVariableName + ".y;\r\n");
  56347. }
  56348. if (zOutput.connectedBlocks.length > 0) {
  56349. state.compilationString += this._declareOutput(zOutput, state) + (" = " + input.associatedVariableName + ".z;\r\n");
  56350. }
  56351. if (wOutput.connectedBlocks.length > 0) {
  56352. state.compilationString += this._declareOutput(wOutput, state) + (" = " + input.associatedVariableName + ".w;\r\n");
  56353. }
  56354. return this;
  56355. };
  56356. return VectorSplitterBlock;
  56357. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  56358. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.VectorSplitterBlock"] = VectorSplitterBlock;
  56359. /***/ }),
  56360. /***/ "./Materials/Node/Blocks/Input/index.ts":
  56361. /*!**********************************************!*\
  56362. !*** ./Materials/Node/Blocks/Input/index.ts ***!
  56363. \**********************************************/
  56364. /*! exports provided: InputBlock */
  56365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56366. "use strict";
  56367. __webpack_require__.r(__webpack_exports__);
  56368. /* harmony import */ var _inputBlock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  56369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return _inputBlock__WEBPACK_IMPORTED_MODULE_0__["InputBlock"]; });
  56370. /***/ }),
  56371. /***/ "./Materials/Node/Blocks/Input/inputBlock.ts":
  56372. /*!***************************************************!*\
  56373. !*** ./Materials/Node/Blocks/Input/inputBlock.ts ***!
  56374. \***************************************************/
  56375. /*! exports provided: InputBlock */
  56376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56377. "use strict";
  56378. __webpack_require__.r(__webpack_exports__);
  56379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return InputBlock; });
  56380. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56381. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  56382. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  56383. /* harmony import */ var _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../NodeMaterialBlockConnectionPointMode */ "./Materials/Node/NodeMaterialBlockConnectionPointMode.ts");
  56384. /* harmony import */ var _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../nodeMaterialWellKnownValues */ "./Materials/Node/nodeMaterialWellKnownValues.ts");
  56385. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../../Maths/math.vector */ "./Maths/math.vector.ts");
  56386. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  56387. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../../Maths/math */ "./Maths/math.ts");
  56389. /**
  56390. * Block used to expose an input value
  56391. */
  56392. var InputBlock = /** @class */ (function (_super) {
  56393. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputBlock, _super);
  56394. /**
  56395. * Creates a new InputBlock
  56396. * @param name defines the block name
  56397. * @param target defines the target of that block (Vertex by default)
  56398. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56399. */
  56400. function InputBlock(name, target, type) {
  56401. if (target === void 0) { target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_6__["NodeMaterialBlockTargets"].Vertex; }
  56402. if (type === void 0) { type = _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect; }
  56403. var _this = _super.call(this, name, target, false, true) || this;
  56404. _this._mode = _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Undefined;
  56405. /** @hidden */
  56406. _this._wellKnownValue = null;
  56407. _this._type = type;
  56408. _this.registerOutput("output", type);
  56409. return _this;
  56410. }
  56411. Object.defineProperty(InputBlock.prototype, "type", {
  56412. /**
  56413. * Gets or sets the connection point type (default is float)
  56414. */
  56415. get: function () {
  56416. if (this._type === _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect) {
  56417. if (this.isUniform && this.value != null) {
  56418. if (!isNaN(this.value)) {
  56419. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float;
  56420. }
  56421. switch (this.value.getClassName()) {
  56422. case "Vector2":
  56423. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2;
  56424. case "Vector3":
  56425. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3;
  56426. case "Vector4":
  56427. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4;
  56428. case "Color3":
  56429. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3;
  56430. case "Color4":
  56431. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4;
  56432. }
  56433. }
  56434. if (this.isAttribute) {
  56435. switch (this.name) {
  56436. case "position":
  56437. case "normal":
  56438. case "tangent":
  56439. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3;
  56440. case "uv":
  56441. case "uv2":
  56442. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2;
  56443. }
  56444. }
  56445. if (this.isWellKnownValue) {
  56446. switch (this._wellKnownValue) {
  56447. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].World:
  56448. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldView:
  56449. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldViewProjection:
  56450. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].View:
  56451. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].ViewProjection:
  56452. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].Projection:
  56453. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix;
  56454. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].CameraPosition:
  56455. return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3;
  56456. }
  56457. }
  56458. }
  56459. return this._type;
  56460. },
  56461. enumerable: true,
  56462. configurable: true
  56463. });
  56464. Object.defineProperty(InputBlock.prototype, "output", {
  56465. /**
  56466. * Gets the output component
  56467. */
  56468. get: function () {
  56469. return this._outputs[0];
  56470. },
  56471. enumerable: true,
  56472. configurable: true
  56473. });
  56474. /**
  56475. * Set the source of this connection point to a vertex attribute
  56476. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56477. * @returns the current connection point
  56478. */
  56479. InputBlock.prototype.setAsAttribute = function (attributeName) {
  56480. if (attributeName) {
  56481. this.name = attributeName;
  56482. }
  56483. this._mode = _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Attribute;
  56484. return this;
  56485. };
  56486. /**
  56487. * Set the source of this connection point to a well known value
  56488. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  56489. * @returns the current connection point
  56490. */
  56491. InputBlock.prototype.setAsWellKnownValue = function (value) {
  56492. this.wellKnownValue = value;
  56493. return this;
  56494. };
  56495. Object.defineProperty(InputBlock.prototype, "value", {
  56496. /**
  56497. * Gets or sets the value of that point.
  56498. * Please note that this value will be ignored if valueCallback is defined
  56499. */
  56500. get: function () {
  56501. return this._storedValue;
  56502. },
  56503. set: function (value) {
  56504. this._storedValue = value;
  56505. this._mode = _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Uniform;
  56506. },
  56507. enumerable: true,
  56508. configurable: true
  56509. });
  56510. Object.defineProperty(InputBlock.prototype, "valueCallback", {
  56511. /**
  56512. * Gets or sets a callback used to get the value of that point.
  56513. * Please note that setting this value will force the connection point to ignore the value property
  56514. */
  56515. get: function () {
  56516. return this._valueCallback;
  56517. },
  56518. set: function (value) {
  56519. this._valueCallback = value;
  56520. this._mode = _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Uniform;
  56521. },
  56522. enumerable: true,
  56523. configurable: true
  56524. });
  56525. Object.defineProperty(InputBlock.prototype, "associatedVariableName", {
  56526. /**
  56527. * Gets or sets the associated variable name in the shader
  56528. */
  56529. get: function () {
  56530. return this._associatedVariableName;
  56531. },
  56532. set: function (value) {
  56533. this._associatedVariableName = value;
  56534. },
  56535. enumerable: true,
  56536. configurable: true
  56537. });
  56538. Object.defineProperty(InputBlock.prototype, "isUndefined", {
  56539. /**
  56540. * Gets a boolean indicating that this connection point not defined yet
  56541. */
  56542. get: function () {
  56543. return this._mode === _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Undefined;
  56544. },
  56545. enumerable: true,
  56546. configurable: true
  56547. });
  56548. Object.defineProperty(InputBlock.prototype, "isUniform", {
  56549. /**
  56550. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56551. * In this case the connection point name must be the name of the uniform to use.
  56552. * Can only be set on inputs
  56553. */
  56554. get: function () {
  56555. return this._mode === _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Uniform;
  56556. },
  56557. set: function (value) {
  56558. this._mode = value ? _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Uniform : _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Undefined;
  56559. this.associatedVariableName = "";
  56560. },
  56561. enumerable: true,
  56562. configurable: true
  56563. });
  56564. Object.defineProperty(InputBlock.prototype, "isAttribute", {
  56565. /**
  56566. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56567. * In this case the connection point name must be the name of the attribute to use
  56568. * Can only be set on inputs
  56569. */
  56570. get: function () {
  56571. return this._mode === _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Attribute;
  56572. },
  56573. set: function (value) {
  56574. this._mode = value ? _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Attribute : _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Undefined;
  56575. this.associatedVariableName = "";
  56576. },
  56577. enumerable: true,
  56578. configurable: true
  56579. });
  56580. Object.defineProperty(InputBlock.prototype, "isVarying", {
  56581. /**
  56582. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56583. * Can only be set on exit points
  56584. */
  56585. get: function () {
  56586. return this._mode === _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Varying;
  56587. },
  56588. set: function (value) {
  56589. this._mode = value ? _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Varying : _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Undefined;
  56590. this.associatedVariableName = "";
  56591. },
  56592. enumerable: true,
  56593. configurable: true
  56594. });
  56595. Object.defineProperty(InputBlock.prototype, "isWellKnownValue", {
  56596. /**
  56597. * Gets a boolean indicating that the current connection point is a well known value
  56598. */
  56599. get: function () {
  56600. return this._wellKnownValue != null;
  56601. },
  56602. enumerable: true,
  56603. configurable: true
  56604. });
  56605. Object.defineProperty(InputBlock.prototype, "wellKnownValue", {
  56606. /**
  56607. * Gets or sets the current well known value or null if not defined as well know value
  56608. */
  56609. get: function () {
  56610. return this._wellKnownValue;
  56611. },
  56612. set: function (value) {
  56613. this._mode = _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Uniform;
  56614. this.associatedVariableName = "";
  56615. this._wellKnownValue = value;
  56616. },
  56617. enumerable: true,
  56618. configurable: true
  56619. });
  56620. /**
  56621. * Gets the current class name
  56622. * @returns the class name
  56623. */
  56624. InputBlock.prototype.getClassName = function () {
  56625. return "InputBlock";
  56626. };
  56627. InputBlock.prototype._emitDefine = function (define) {
  56628. if (define[0] === "!") {
  56629. return "#ifndef " + define.substring(1) + "\r\n";
  56630. }
  56631. return "#ifdef " + define + "\r\n";
  56632. };
  56633. /**
  56634. * Set the input block to its default value (based on its type)
  56635. */
  56636. InputBlock.prototype.setDefaultValue = function () {
  56637. switch (this.type) {
  56638. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float:
  56639. this.value = 0;
  56640. break;
  56641. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2:
  56642. this.value = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  56643. break;
  56644. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3:
  56645. this.value = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  56646. break;
  56647. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4:
  56648. this.value = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector4"].Zero();
  56649. break;
  56650. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3:
  56651. this.value = _Maths_math__WEBPACK_IMPORTED_MODULE_8__["Color3"].White();
  56652. break;
  56653. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4:
  56654. this.value = new _Maths_math__WEBPACK_IMPORTED_MODULE_8__["Color4"](1, 1, 1, 1);
  56655. break;
  56656. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix:
  56657. this.value = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  56658. break;
  56659. }
  56660. };
  56661. InputBlock.prototype._emit = function (state, define) {
  56662. // Uniforms
  56663. if (this.isUniform) {
  56664. if (!this.associatedVariableName) {
  56665. this.associatedVariableName = state._getFreeVariableName("u_" + this.name);
  56666. }
  56667. if (state.uniforms.indexOf(this.associatedVariableName) !== -1) {
  56668. return;
  56669. }
  56670. state.uniforms.push(this.associatedVariableName);
  56671. if (define) {
  56672. state._uniformDeclaration += this._emitDefine(define);
  56673. }
  56674. state._uniformDeclaration += "uniform " + state._getGLType(this.type) + " " + this.associatedVariableName + ";\r\n";
  56675. if (define) {
  56676. state._uniformDeclaration += "#endif\r\n";
  56677. }
  56678. // well known
  56679. var hints = state.sharedData.hints;
  56680. if (this._wellKnownValue !== null) {
  56681. switch (this._wellKnownValue) {
  56682. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldView:
  56683. hints.needWorldViewMatrix = true;
  56684. break;
  56685. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldViewProjection:
  56686. hints.needWorldViewProjectionMatrix = true;
  56687. break;
  56688. }
  56689. }
  56690. return;
  56691. }
  56692. // Attribute
  56693. if (this.isAttribute) {
  56694. this.associatedVariableName = this.name;
  56695. if (this.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_6__["NodeMaterialBlockTargets"].Vertex && state._vertexState) { // Attribute for fragment need to be carried over by varyings
  56696. this._emit(state._vertexState, define);
  56697. return;
  56698. }
  56699. if (state.attributes.indexOf(this.associatedVariableName) !== -1) {
  56700. return;
  56701. }
  56702. state.attributes.push(this.associatedVariableName);
  56703. if (define) {
  56704. state._attributeDeclaration += this._emitDefine(define);
  56705. }
  56706. state._attributeDeclaration += "attribute " + state._getGLType(this.type) + " " + this.associatedVariableName + ";\r\n";
  56707. if (define) {
  56708. state._attributeDeclaration += "#endif\r\n";
  56709. }
  56710. }
  56711. };
  56712. /** @hidden */
  56713. InputBlock.prototype._transmitWorld = function (effect, world, worldView, worldViewProjection) {
  56714. if (!this._wellKnownValue) {
  56715. return;
  56716. }
  56717. var variableName = this.associatedVariableName;
  56718. switch (this._wellKnownValue) {
  56719. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].World:
  56720. effect.setMatrix(variableName, world);
  56721. break;
  56722. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldView:
  56723. effect.setMatrix(variableName, worldView);
  56724. break;
  56725. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldViewProjection:
  56726. effect.setMatrix(variableName, worldViewProjection);
  56727. break;
  56728. }
  56729. };
  56730. /** @hidden */
  56731. InputBlock.prototype._transmit = function (effect, scene) {
  56732. if (this.isAttribute) {
  56733. return;
  56734. }
  56735. var variableName = this.associatedVariableName;
  56736. if (this._wellKnownValue) {
  56737. switch (this._wellKnownValue) {
  56738. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].World:
  56739. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldView:
  56740. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].WorldViewProjection:
  56741. return;
  56742. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].View:
  56743. effect.setMatrix(variableName, scene.getViewMatrix());
  56744. break;
  56745. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].Projection:
  56746. effect.setMatrix(variableName, scene.getProjectionMatrix());
  56747. break;
  56748. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].ViewProjection:
  56749. effect.setMatrix(variableName, scene.getTransformMatrix());
  56750. break;
  56751. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].CameraPosition:
  56752. effect.setVector3(variableName, scene.activeCamera.globalPosition);
  56753. break;
  56754. case _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].FogColor:
  56755. effect.setColor3(variableName, scene.fogColor);
  56756. break;
  56757. }
  56758. return;
  56759. }
  56760. var value = this._valueCallback ? this._valueCallback() : this._storedValue;
  56761. if (value === null) {
  56762. return;
  56763. }
  56764. switch (this.type) {
  56765. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float:
  56766. effect.setFloat(variableName, value);
  56767. break;
  56768. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Int:
  56769. effect.setInt(variableName, value);
  56770. break;
  56771. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3:
  56772. effect.setColor3(variableName, value);
  56773. break;
  56774. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color4:
  56775. effect.setDirectColor4(variableName, value);
  56776. break;
  56777. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2:
  56778. effect.setVector2(variableName, value);
  56779. break;
  56780. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3:
  56781. effect.setVector3(variableName, value);
  56782. break;
  56783. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Color3OrColor4:
  56784. effect.setFloat4(variableName, value.r, value.g, value.b, value.a || 1.0);
  56785. break;
  56786. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4OrColor4:
  56787. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4:
  56788. effect.setVector4(variableName, value);
  56789. break;
  56790. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix:
  56791. effect.setMatrix(variableName, value);
  56792. break;
  56793. }
  56794. };
  56795. InputBlock.prototype._buildBlock = function (state) {
  56796. _super.prototype._buildBlock.call(this, state);
  56797. if (this.isUniform || this.isWellKnownValue) {
  56798. state.sharedData.inputBlocks.push(this);
  56799. }
  56800. this._emit(state);
  56801. };
  56802. InputBlock.prototype.serialize = function () {
  56803. var serializationObject = _super.prototype.serialize.call(this);
  56804. serializationObject.type = this.type;
  56805. serializationObject.mode = this._mode;
  56806. serializationObject.wellKnownValue = this._wellKnownValue;
  56807. if (this._storedValue != null && this._mode === _NodeMaterialBlockConnectionPointMode__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointMode"].Uniform) {
  56808. if (this._storedValue.asArray) {
  56809. serializationObject.valueType = "BABYLON." + this._storedValue.getClassName();
  56810. serializationObject.value = this._storedValue.asArray();
  56811. }
  56812. else {
  56813. serializationObject.valueType = "number";
  56814. serializationObject.value = this._storedValue;
  56815. }
  56816. }
  56817. return serializationObject;
  56818. };
  56819. InputBlock.prototype._deserialize = function (serializationObject, scene, rootUrl) {
  56820. _super.prototype._deserialize.call(this, serializationObject, scene, rootUrl);
  56821. this._type = serializationObject.type;
  56822. this._mode = serializationObject.mode;
  56823. this._wellKnownValue = serializationObject.wellKnownValue;
  56824. if (!serializationObject.valueType) {
  56825. return;
  56826. }
  56827. if (serializationObject.valueType === "number") {
  56828. this._storedValue = serializationObject.value;
  56829. }
  56830. else {
  56831. var valueType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass(serializationObject.valueType);
  56832. if (valueType) {
  56833. this._storedValue = valueType.FromArray(serializationObject.value);
  56834. }
  56835. }
  56836. };
  56837. return InputBlock;
  56838. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  56839. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.InputBlock"] = InputBlock;
  56840. /***/ }),
  56841. /***/ "./Materials/Node/Blocks/Vertex/bonesBlock.ts":
  56842. /*!****************************************************!*\
  56843. !*** ./Materials/Node/Blocks/Vertex/bonesBlock.ts ***!
  56844. \****************************************************/
  56845. /*! exports provided: BonesBlock */
  56846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56847. "use strict";
  56848. __webpack_require__.r(__webpack_exports__);
  56849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return BonesBlock; });
  56850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56851. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  56852. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  56853. /* harmony import */ var _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialWellKnownValues */ "./Materials/Node/nodeMaterialWellKnownValues.ts");
  56854. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  56855. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../materialHelper */ "./Materials/materialHelper.ts");
  56856. /* harmony import */ var _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  56857. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56858. /**
  56859. * Block used to add support for vertex skinning (bones)
  56860. */
  56861. var BonesBlock = /** @class */ (function (_super) {
  56862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BonesBlock, _super);
  56863. /**
  56864. * Creates a new BonesBlock
  56865. * @param name defines the block name
  56866. */
  56867. function BonesBlock(name) {
  56868. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialBlockTargets"].Vertex) || this;
  56869. _this.registerInput("matricesIndices", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  56870. _this.registerInput("matricesWeights", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  56871. _this.registerInput("matricesIndicesExtra", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4, true);
  56872. _this.registerInput("matricesWeightsExtra", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4, true);
  56873. _this.registerInput("world", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix);
  56874. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix);
  56875. return _this;
  56876. }
  56877. /**
  56878. * Initialize the block and prepare the context for build
  56879. * @param state defines the state that will be used for the build
  56880. */
  56881. BonesBlock.prototype.initialize = function (state) {
  56882. state._excludeVariableName("boneSampler");
  56883. state._excludeVariableName("boneTextureWidth");
  56884. state._excludeVariableName("mBones");
  56885. state._excludeVariableName("BonesPerMesh");
  56886. };
  56887. /**
  56888. * Gets the current class name
  56889. * @returns the class name
  56890. */
  56891. BonesBlock.prototype.getClassName = function () {
  56892. return "BonesBlock";
  56893. };
  56894. Object.defineProperty(BonesBlock.prototype, "matricesIndices", {
  56895. /**
  56896. * Gets the matrix indices input component
  56897. */
  56898. get: function () {
  56899. return this._inputs[0];
  56900. },
  56901. enumerable: true,
  56902. configurable: true
  56903. });
  56904. Object.defineProperty(BonesBlock.prototype, "matricesWeights", {
  56905. /**
  56906. * Gets the matrix weights input component
  56907. */
  56908. get: function () {
  56909. return this._inputs[1];
  56910. },
  56911. enumerable: true,
  56912. configurable: true
  56913. });
  56914. Object.defineProperty(BonesBlock.prototype, "matricesIndicesExtra", {
  56915. /**
  56916. * Gets the extra matrix indices input component
  56917. */
  56918. get: function () {
  56919. return this._inputs[2];
  56920. },
  56921. enumerable: true,
  56922. configurable: true
  56923. });
  56924. Object.defineProperty(BonesBlock.prototype, "matricesWeightsExtra", {
  56925. /**
  56926. * Gets the extra matrix weights input component
  56927. */
  56928. get: function () {
  56929. return this._inputs[3];
  56930. },
  56931. enumerable: true,
  56932. configurable: true
  56933. });
  56934. Object.defineProperty(BonesBlock.prototype, "world", {
  56935. /**
  56936. * Gets the world input component
  56937. */
  56938. get: function () {
  56939. return this._inputs[4];
  56940. },
  56941. enumerable: true,
  56942. configurable: true
  56943. });
  56944. Object.defineProperty(BonesBlock.prototype, "output", {
  56945. /**
  56946. * Gets the output component
  56947. */
  56948. get: function () {
  56949. return this._outputs[0];
  56950. },
  56951. enumerable: true,
  56952. configurable: true
  56953. });
  56954. BonesBlock.prototype.autoConfigure = function () {
  56955. if (!this.matricesIndices.isConnected) {
  56956. var matricesIndicesInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("matricesIndices", undefined, _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  56957. matricesIndicesInput.setAsAttribute("matricesIndices");
  56958. matricesIndicesInput.output.connectTo(this.matricesIndices);
  56959. }
  56960. if (!this.matricesWeights.isConnected) {
  56961. var matricesWeightsInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("matricesWeights", undefined, _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  56962. matricesWeightsInput.setAsAttribute("matricesWeights");
  56963. matricesWeightsInput.output.connectTo(this.matricesWeights);
  56964. }
  56965. if (!this.world.isConnected) {
  56966. var worldInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("world", undefined, _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix);
  56967. worldInput.setAsWellKnownValue(_nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialWellKnownValues"].World);
  56968. worldInput.output.connectTo(this.world);
  56969. }
  56970. };
  56971. BonesBlock.prototype.provideFallbacks = function (mesh, fallbacks) {
  56972. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  56973. fallbacks.addCPUSkinningFallback(0, mesh);
  56974. }
  56975. };
  56976. BonesBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  56977. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, effect);
  56978. };
  56979. BonesBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
  56980. if (!defines._areAttributesDirty) {
  56981. return;
  56982. }
  56983. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForBones(mesh, defines);
  56984. };
  56985. BonesBlock.prototype._buildBlock = function (state) {
  56986. _super.prototype._buildBlock.call(this, state);
  56987. // Register for compilation fallbacks
  56988. state.sharedData.blocksWithFallbacks.push(this);
  56989. // Register for binding
  56990. state.sharedData.bindableBlocks.push(this);
  56991. // Register for defines
  56992. state.sharedData.blocksWithDefines.push(this);
  56993. // Register internal uniforms and samplers
  56994. state.uniforms.push("boneTextureWidth");
  56995. state.uniforms.push("mBones");
  56996. state.samplers.push("boneSampler");
  56997. // Emit code
  56998. var comments = "//" + this.name;
  56999. state._emitFunctionFromInclude("bonesDeclaration", comments, {
  57000. removeAttributes: true,
  57001. removeUniforms: false,
  57002. removeVaryings: true,
  57003. removeIfDef: false
  57004. });
  57005. var influenceVariablename = state._getFreeVariableName("influence");
  57006. state.compilationString += state._emitCodeFromInclude("bonesVertex", comments, {
  57007. replaceStrings: [
  57008. {
  57009. search: /finalWorld=finalWorld\*influence;/,
  57010. replace: ""
  57011. },
  57012. {
  57013. search: /influence/gm,
  57014. replace: influenceVariablename
  57015. }
  57016. ]
  57017. });
  57018. var output = this._outputs[0];
  57019. var worldInput = this.world;
  57020. state.compilationString += "#if NUM_BONE_INFLUENCERS>0\r\n";
  57021. state.compilationString += this._declareOutput(output, state) + (" = " + worldInput.associatedVariableName + " * " + influenceVariablename + ";\r\n");
  57022. state.compilationString += "#else\r\n";
  57023. state.compilationString += this._declareOutput(output, state) + (" = " + worldInput.associatedVariableName + ";\r\n");
  57024. state.compilationString += "#endif\r\n";
  57025. return this;
  57026. };
  57027. return BonesBlock;
  57028. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57029. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.BonesBlock"] = BonesBlock;
  57030. /***/ }),
  57031. /***/ "./Materials/Node/Blocks/Vertex/index.ts":
  57032. /*!***********************************************!*\
  57033. !*** ./Materials/Node/Blocks/Vertex/index.ts ***!
  57034. \***********************************************/
  57035. /*! exports provided: VertexOutputBlock, BonesBlock, InstancesBlock, MorphTargetsBlock */
  57036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57037. "use strict";
  57038. __webpack_require__.r(__webpack_exports__);
  57039. /* harmony import */ var _vertexOutputBlock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vertexOutputBlock */ "./Materials/Node/Blocks/Vertex/vertexOutputBlock.ts");
  57040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return _vertexOutputBlock__WEBPACK_IMPORTED_MODULE_0__["VertexOutputBlock"]; });
  57041. /* harmony import */ var _bonesBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bonesBlock */ "./Materials/Node/Blocks/Vertex/bonesBlock.ts");
  57042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return _bonesBlock__WEBPACK_IMPORTED_MODULE_1__["BonesBlock"]; });
  57043. /* harmony import */ var _instancesBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./instancesBlock */ "./Materials/Node/Blocks/Vertex/instancesBlock.ts");
  57044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return _instancesBlock__WEBPACK_IMPORTED_MODULE_2__["InstancesBlock"]; });
  57045. /* harmony import */ var _morphTargetsBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTargetsBlock */ "./Materials/Node/Blocks/Vertex/morphTargetsBlock.ts");
  57046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return _morphTargetsBlock__WEBPACK_IMPORTED_MODULE_3__["MorphTargetsBlock"]; });
  57047. /***/ }),
  57048. /***/ "./Materials/Node/Blocks/Vertex/instancesBlock.ts":
  57049. /*!********************************************************!*\
  57050. !*** ./Materials/Node/Blocks/Vertex/instancesBlock.ts ***!
  57051. \********************************************************/
  57052. /*! exports provided: InstancesBlock */
  57053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57054. "use strict";
  57055. __webpack_require__.r(__webpack_exports__);
  57056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return InstancesBlock; });
  57057. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57058. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57059. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57060. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57061. /* harmony import */ var _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../nodeMaterialWellKnownValues */ "./Materials/Node/nodeMaterialWellKnownValues.ts");
  57062. /* harmony import */ var _Input_inputBlock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  57063. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57064. /**
  57065. * Block used to add support for instances
  57066. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57067. */
  57068. var InstancesBlock = /** @class */ (function (_super) {
  57069. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancesBlock, _super);
  57070. /**
  57071. * Creates a new InstancesBlock
  57072. * @param name defines the block name
  57073. */
  57074. function InstancesBlock(name) {
  57075. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Vertex) || this;
  57076. _this.registerInput("world0", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  57077. _this.registerInput("world1", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  57078. _this.registerInput("world2", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  57079. _this.registerInput("world3", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  57080. _this.registerInput("world", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Matrix, true);
  57081. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockConnectionPointTypes"].Matrix);
  57082. return _this;
  57083. }
  57084. /**
  57085. * Gets the current class name
  57086. * @returns the class name
  57087. */
  57088. InstancesBlock.prototype.getClassName = function () {
  57089. return "InstancesBlock";
  57090. };
  57091. Object.defineProperty(InstancesBlock.prototype, "world0", {
  57092. /**
  57093. * Gets the first world row input component
  57094. */
  57095. get: function () {
  57096. return this._inputs[0];
  57097. },
  57098. enumerable: true,
  57099. configurable: true
  57100. });
  57101. Object.defineProperty(InstancesBlock.prototype, "world1", {
  57102. /**
  57103. * Gets the second world row input component
  57104. */
  57105. get: function () {
  57106. return this._inputs[1];
  57107. },
  57108. enumerable: true,
  57109. configurable: true
  57110. });
  57111. Object.defineProperty(InstancesBlock.prototype, "world2", {
  57112. /**
  57113. * Gets the third world row input component
  57114. */
  57115. get: function () {
  57116. return this._inputs[2];
  57117. },
  57118. enumerable: true,
  57119. configurable: true
  57120. });
  57121. Object.defineProperty(InstancesBlock.prototype, "world3", {
  57122. /**
  57123. * Gets the forth world row input component
  57124. */
  57125. get: function () {
  57126. return this._inputs[3];
  57127. },
  57128. enumerable: true,
  57129. configurable: true
  57130. });
  57131. Object.defineProperty(InstancesBlock.prototype, "world", {
  57132. /**
  57133. * Gets the world input component
  57134. */
  57135. get: function () {
  57136. return this._inputs[4];
  57137. },
  57138. enumerable: true,
  57139. configurable: true
  57140. });
  57141. Object.defineProperty(InstancesBlock.prototype, "output", {
  57142. /**
  57143. * Gets the output component
  57144. */
  57145. get: function () {
  57146. return this._outputs[0];
  57147. },
  57148. enumerable: true,
  57149. configurable: true
  57150. });
  57151. InstancesBlock.prototype.autoConfigure = function () {
  57152. if (!this.world0.connectedPoint) {
  57153. var world0Input = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_5__["InputBlock"]("world0");
  57154. world0Input.setAsAttribute("world0");
  57155. world0Input.output.connectTo(this.world0);
  57156. }
  57157. if (!this.world1.connectedPoint) {
  57158. var world1Input = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_5__["InputBlock"]("world1");
  57159. world1Input.setAsAttribute("world1");
  57160. world1Input.output.connectTo(this.world1);
  57161. }
  57162. if (!this.world2.connectedPoint) {
  57163. var world2Input = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_5__["InputBlock"]("world2");
  57164. world2Input.setAsAttribute("world2");
  57165. world2Input.output.connectTo(this.world2);
  57166. }
  57167. if (!this.world3.connectedPoint) {
  57168. var world3Input = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_5__["InputBlock"]("world3");
  57169. world3Input.setAsAttribute("world3");
  57170. world3Input.output.connectTo(this.world3);
  57171. }
  57172. if (!this.world.connectedPoint) {
  57173. var worldInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_5__["InputBlock"]("world");
  57174. worldInput.setAsWellKnownValue(_nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialWellKnownValues"].World);
  57175. worldInput.output.connectTo(this.world);
  57176. }
  57177. this.world.define = "!INSTANCES";
  57178. };
  57179. InstancesBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines, useInstances) {
  57180. if (useInstances === void 0) { useInstances = false; }
  57181. var changed = false;
  57182. if (defines["INSTANCES"] !== useInstances) {
  57183. defines.setValue("INSTANCES", useInstances);
  57184. changed = true;
  57185. }
  57186. if (changed) {
  57187. defines.markAsUnprocessed();
  57188. }
  57189. };
  57190. InstancesBlock.prototype._buildBlock = function (state) {
  57191. _super.prototype._buildBlock.call(this, state);
  57192. // Register for defines
  57193. state.sharedData.blocksWithDefines.push(this);
  57194. // Emit code
  57195. var output = this._outputs[0];
  57196. var world0 = this.world0;
  57197. var world1 = this.world1;
  57198. var world2 = this.world2;
  57199. var world3 = this.world3;
  57200. state.compilationString += "#ifdef INSTANCES\r\n";
  57201. state.compilationString += this._declareOutput(output, state) + (" = mat4(" + world0.associatedVariableName + ", " + world1.associatedVariableName + ", " + world2.associatedVariableName + ", " + world3.associatedVariableName + ");\r\n");
  57202. state.compilationString += "#else\r\n";
  57203. state.compilationString += this._declareOutput(output, state) + (" = " + this.world.associatedVariableName + ";\r\n");
  57204. state.compilationString += "#endif\r\n";
  57205. return this;
  57206. };
  57207. return InstancesBlock;
  57208. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57209. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InstancesBlock"] = InstancesBlock;
  57210. /***/ }),
  57211. /***/ "./Materials/Node/Blocks/Vertex/morphTargetsBlock.ts":
  57212. /*!***********************************************************!*\
  57213. !*** ./Materials/Node/Blocks/Vertex/morphTargetsBlock.ts ***!
  57214. \***********************************************************/
  57215. /*! exports provided: MorphTargetsBlock */
  57216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57217. "use strict";
  57218. __webpack_require__.r(__webpack_exports__);
  57219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return MorphTargetsBlock; });
  57220. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57221. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57222. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57223. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57224. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../materialHelper */ "./Materials/materialHelper.ts");
  57225. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../../Meshes/buffer */ "./Meshes/buffer.ts");
  57226. /* harmony import */ var _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  57227. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57228. /**
  57229. * Block used to add morph targets support to vertex shader
  57230. */
  57231. var MorphTargetsBlock = /** @class */ (function (_super) {
  57232. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MorphTargetsBlock, _super);
  57233. /**
  57234. * Create a new MorphTargetsBlock
  57235. * @param name defines the block name
  57236. */
  57237. function MorphTargetsBlock(name) {
  57238. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Vertex) || this;
  57239. _this._repeatebleContentGenerated = 0;
  57240. _this.registerInput("position", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  57241. _this.registerInput("normal", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  57242. _this.registerInput("tangent", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  57243. _this.registerInput("uv", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2);
  57244. _this.registerOutput("positionOutput", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  57245. _this.registerOutput("normalOutput", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  57246. _this.registerOutput("tangentOutput", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3);
  57247. _this.registerOutput("uvOutput", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2);
  57248. return _this;
  57249. }
  57250. /**
  57251. * Gets the current class name
  57252. * @returns the class name
  57253. */
  57254. MorphTargetsBlock.prototype.getClassName = function () {
  57255. return "MorphTargetsBlock";
  57256. };
  57257. Object.defineProperty(MorphTargetsBlock.prototype, "position", {
  57258. /**
  57259. * Gets the position input component
  57260. */
  57261. get: function () {
  57262. return this._inputs[0];
  57263. },
  57264. enumerable: true,
  57265. configurable: true
  57266. });
  57267. Object.defineProperty(MorphTargetsBlock.prototype, "normal", {
  57268. /**
  57269. * Gets the normal input component
  57270. */
  57271. get: function () {
  57272. return this._inputs[1];
  57273. },
  57274. enumerable: true,
  57275. configurable: true
  57276. });
  57277. Object.defineProperty(MorphTargetsBlock.prototype, "tangent", {
  57278. /**
  57279. * Gets the tangent input component
  57280. */
  57281. get: function () {
  57282. return this._inputs[2];
  57283. },
  57284. enumerable: true,
  57285. configurable: true
  57286. });
  57287. Object.defineProperty(MorphTargetsBlock.prototype, "uv", {
  57288. /**
  57289. * Gets the tangent input component
  57290. */
  57291. get: function () {
  57292. return this._inputs[3];
  57293. },
  57294. enumerable: true,
  57295. configurable: true
  57296. });
  57297. Object.defineProperty(MorphTargetsBlock.prototype, "positionOutput", {
  57298. /**
  57299. * Gets the position output component
  57300. */
  57301. get: function () {
  57302. return this._outputs[0];
  57303. },
  57304. enumerable: true,
  57305. configurable: true
  57306. });
  57307. Object.defineProperty(MorphTargetsBlock.prototype, "normalOutput", {
  57308. /**
  57309. * Gets the normal output component
  57310. */
  57311. get: function () {
  57312. return this._outputs[1];
  57313. },
  57314. enumerable: true,
  57315. configurable: true
  57316. });
  57317. Object.defineProperty(MorphTargetsBlock.prototype, "tangentOutput", {
  57318. /**
  57319. * Gets the tangent output component
  57320. */
  57321. get: function () {
  57322. return this._outputs[2];
  57323. },
  57324. enumerable: true,
  57325. configurable: true
  57326. });
  57327. Object.defineProperty(MorphTargetsBlock.prototype, "uvOutput", {
  57328. /**
  57329. * Gets the tangent output component
  57330. */
  57331. get: function () {
  57332. return this._outputs[3];
  57333. },
  57334. enumerable: true,
  57335. configurable: true
  57336. });
  57337. MorphTargetsBlock.prototype.initialize = function (state) {
  57338. state._excludeVariableName("morphTargetInfluences");
  57339. };
  57340. MorphTargetsBlock.prototype.autoConfigure = function () {
  57341. if (!this.position.isConnected) {
  57342. var positionInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("position");
  57343. positionInput.setAsAttribute("position");
  57344. positionInput.output.connectTo(this.position);
  57345. }
  57346. if (!this.normal.isConnected) {
  57347. var normalInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("normal");
  57348. normalInput.setAsAttribute("normal");
  57349. normalInput.output.connectTo(this.normal);
  57350. }
  57351. if (!this.tangent.isConnected) {
  57352. var tangentInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("tangent");
  57353. tangentInput.setAsAttribute("tangent");
  57354. tangentInput.output.connectTo(this.tangent);
  57355. }
  57356. if (!this.uv.isConnected) {
  57357. var uvInput = new _Input_inputBlock__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]("uv");
  57358. uvInput.setAsAttribute("uv");
  57359. uvInput.output.connectTo(this.uv);
  57360. }
  57361. };
  57362. MorphTargetsBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
  57363. if (!defines._areAttributesDirty) {
  57364. return;
  57365. }
  57366. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMorphTargets(mesh, defines);
  57367. };
  57368. MorphTargetsBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  57369. if (mesh && this._repeatebleContentGenerated) {
  57370. _materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  57371. }
  57372. };
  57373. MorphTargetsBlock.prototype.replaceRepeatableContent = function (vertexShaderState, fragmentShaderState, mesh, defines) {
  57374. var position = this.position;
  57375. var normal = this.normal;
  57376. var tangent = this.tangent;
  57377. var uv = this.uv;
  57378. var positionOutput = this.positionOutput;
  57379. var normalOutput = this.normalOutput;
  57380. var tangentOutput = this.tangentOutput;
  57381. var uvOutput = this.uvOutput;
  57382. var state = vertexShaderState;
  57383. var repeatCount = defines.NUM_MORPH_INFLUENCERS;
  57384. this._repeatebleContentGenerated = repeatCount;
  57385. var manager = mesh.morphTargetManager;
  57386. var hasNormals = manager && manager.supportsNormals && defines["NORMAL"];
  57387. var hasTangents = manager && manager.supportsTangents && defines["TANGENT"];
  57388. var hasUVs = manager && manager.supportsUVs && defines["UV1"];
  57389. var injectionCode = "";
  57390. for (var index = 0; index < repeatCount; index++) {
  57391. injectionCode += "#ifdef MORPHTARGETS\r\n";
  57392. injectionCode += positionOutput.associatedVariableName + " += (position" + index + " - " + position.associatedVariableName + ") * morphTargetInfluences[" + index + "];\r\n";
  57393. if (hasNormals) {
  57394. injectionCode += "#ifdef MORPHTARGETS_NORMAL\r\n";
  57395. injectionCode += normalOutput.associatedVariableName + " += (normal" + index + " - " + normal.associatedVariableName + ") * morphTargetInfluences[" + index + "];\r\n";
  57396. injectionCode += "#endif\r\n";
  57397. }
  57398. if (hasTangents) {
  57399. injectionCode += "#ifdef MORPHTARGETS_TANGENT\r\n";
  57400. injectionCode += tangentOutput.associatedVariableName + ".xyz += (tangent" + index + " - " + tangent.associatedVariableName + ".xyz) * morphTargetInfluences[" + index + "];\r\n";
  57401. injectionCode += "#endif\r\n";
  57402. }
  57403. if (hasUVs) {
  57404. injectionCode += "#ifdef MORPHTARGETS_UV\r\n";
  57405. injectionCode += uvOutput.associatedVariableName + ".xyz += (uv_" + index + " - " + uv.associatedVariableName + ".xyz) * morphTargetInfluences[" + index + "];\r\n";
  57406. injectionCode += "#endif\r\n";
  57407. }
  57408. injectionCode += "#endif\r\n";
  57409. }
  57410. state.compilationString = state.compilationString.replace(this._repeatableContentAnchor, injectionCode);
  57411. if (repeatCount > 0) {
  57412. for (var index = 0; index < repeatCount; index++) {
  57413. state.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind + index);
  57414. if (hasNormals) {
  57415. state.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind + index);
  57416. }
  57417. if (hasTangents) {
  57418. state.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].TangentKind + index);
  57419. }
  57420. }
  57421. }
  57422. };
  57423. MorphTargetsBlock.prototype._buildBlock = function (state) {
  57424. _super.prototype._buildBlock.call(this, state);
  57425. // Register for defines
  57426. state.sharedData.blocksWithDefines.push(this);
  57427. // Register for binding
  57428. state.sharedData.bindableBlocks.push(this);
  57429. // Register for repeatable content generation
  57430. state.sharedData.repeatableContentBlocks.push(this);
  57431. // Emit code
  57432. var position = this.position;
  57433. var normal = this.normal;
  57434. var tangent = this.tangent;
  57435. var uv = this.uv;
  57436. var positionOutput = this.positionOutput;
  57437. var normalOutput = this.normalOutput;
  57438. var tangentOutput = this.tangentOutput;
  57439. var uvOutput = this.uvOutput;
  57440. var comments = "//" + this.name;
  57441. state.uniforms.push("morphTargetInfluences");
  57442. state._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", comments);
  57443. state._emitFunctionFromInclude("morphTargetsVertexDeclaration", comments, {
  57444. repeatKey: "maxSimultaneousMorphTargets"
  57445. });
  57446. state.compilationString += this._declareOutput(positionOutput, state) + " = " + position.associatedVariableName + ";\r\n";
  57447. state.compilationString += "#ifdef NORMAL\r\n";
  57448. state.compilationString += this._declareOutput(normalOutput, state) + " = " + normal.associatedVariableName + ";\r\n";
  57449. state.compilationString += "#endif\r\n";
  57450. state.compilationString += "#ifdef TANGENT\r\n";
  57451. state.compilationString += this._declareOutput(tangentOutput, state) + " = " + tangent.associatedVariableName + ";\r\n";
  57452. state.compilationString += "#endif\r\n";
  57453. state.compilationString += "#ifdef UV1\r\n";
  57454. state.compilationString += this._declareOutput(uvOutput, state) + " = " + uv.associatedVariableName + ";\r\n";
  57455. state.compilationString += "#endif\r\n";
  57456. // Repeatable content
  57457. this._repeatableContentAnchor = state._repeatableContentAnchor;
  57458. state.compilationString += this._repeatableContentAnchor;
  57459. return this;
  57460. };
  57461. return MorphTargetsBlock;
  57462. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57463. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.MorphTargetsBlock"] = MorphTargetsBlock;
  57464. /***/ }),
  57465. /***/ "./Materials/Node/Blocks/Vertex/vertexOutputBlock.ts":
  57466. /*!***********************************************************!*\
  57467. !*** ./Materials/Node/Blocks/Vertex/vertexOutputBlock.ts ***!
  57468. \***********************************************************/
  57469. /*! exports provided: VertexOutputBlock */
  57470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57471. "use strict";
  57472. __webpack_require__.r(__webpack_exports__);
  57473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return VertexOutputBlock; });
  57474. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57475. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57476. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57477. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57478. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57479. /**
  57480. * Block used to output the vertex position
  57481. */
  57482. var VertexOutputBlock = /** @class */ (function (_super) {
  57483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VertexOutputBlock, _super);
  57484. /**
  57485. * Creates a new VertexOutputBlock
  57486. * @param name defines the block name
  57487. */
  57488. function VertexOutputBlock(name) {
  57489. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Vertex, true) || this;
  57490. _this.registerInput("vector", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  57491. return _this;
  57492. }
  57493. /**
  57494. * Gets the current class name
  57495. * @returns the class name
  57496. */
  57497. VertexOutputBlock.prototype.getClassName = function () {
  57498. return "VertexOutputBlock";
  57499. };
  57500. Object.defineProperty(VertexOutputBlock.prototype, "vector", {
  57501. /**
  57502. * Gets the vector input component
  57503. */
  57504. get: function () {
  57505. return this._inputs[0];
  57506. },
  57507. enumerable: true,
  57508. configurable: true
  57509. });
  57510. VertexOutputBlock.prototype._buildBlock = function (state) {
  57511. _super.prototype._buildBlock.call(this, state);
  57512. var input = this.vector;
  57513. state.compilationString += "gl_Position = " + input.associatedVariableName + ";\r\n";
  57514. return this;
  57515. };
  57516. return VertexOutputBlock;
  57517. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57518. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.VertexOutputBlock"] = VertexOutputBlock;
  57519. /***/ }),
  57520. /***/ "./Materials/Node/Blocks/addBlock.ts":
  57521. /*!*******************************************!*\
  57522. !*** ./Materials/Node/Blocks/addBlock.ts ***!
  57523. \*******************************************/
  57524. /*! exports provided: AddBlock */
  57525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57526. "use strict";
  57527. __webpack_require__.r(__webpack_exports__);
  57528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AddBlock", function() { return AddBlock; });
  57529. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57530. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57531. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57532. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57533. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57534. /**
  57535. * Block used to add 2 vectors
  57536. */
  57537. var AddBlock = /** @class */ (function (_super) {
  57538. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AddBlock, _super);
  57539. /**
  57540. * Creates a new AddBlock
  57541. * @param name defines the block name
  57542. */
  57543. function AddBlock(name) {
  57544. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Neutral) || this;
  57545. _this.registerInput("left", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57546. _this.registerInput("right", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57547. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].BasedOnInput);
  57548. _this._outputs[0]._typeConnectionSource = _this._inputs[0];
  57549. return _this;
  57550. }
  57551. /**
  57552. * Gets the current class name
  57553. * @returns the class name
  57554. */
  57555. AddBlock.prototype.getClassName = function () {
  57556. return "AddBlock";
  57557. };
  57558. Object.defineProperty(AddBlock.prototype, "left", {
  57559. /**
  57560. * Gets the left operand input component
  57561. */
  57562. get: function () {
  57563. return this._inputs[0];
  57564. },
  57565. enumerable: true,
  57566. configurable: true
  57567. });
  57568. Object.defineProperty(AddBlock.prototype, "right", {
  57569. /**
  57570. * Gets the right operand input component
  57571. */
  57572. get: function () {
  57573. return this._inputs[1];
  57574. },
  57575. enumerable: true,
  57576. configurable: true
  57577. });
  57578. Object.defineProperty(AddBlock.prototype, "output", {
  57579. /**
  57580. * Gets the output component
  57581. */
  57582. get: function () {
  57583. return this._outputs[0];
  57584. },
  57585. enumerable: true,
  57586. configurable: true
  57587. });
  57588. AddBlock.prototype._buildBlock = function (state) {
  57589. _super.prototype._buildBlock.call(this, state);
  57590. var output = this._outputs[0];
  57591. state.compilationString += this._declareOutput(output, state) + (" = " + this.left.associatedVariableName + " + " + this.right.associatedVariableName + ";\r\n");
  57592. return this;
  57593. };
  57594. return AddBlock;
  57595. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57596. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.AddBlock"] = AddBlock;
  57597. /***/ }),
  57598. /***/ "./Materials/Node/Blocks/clampBlock.ts":
  57599. /*!*********************************************!*\
  57600. !*** ./Materials/Node/Blocks/clampBlock.ts ***!
  57601. \*********************************************/
  57602. /*! exports provided: ClampBlock */
  57603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57604. "use strict";
  57605. __webpack_require__.r(__webpack_exports__);
  57606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClampBlock", function() { return ClampBlock; });
  57607. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57608. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57609. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57610. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57611. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57612. /**
  57613. * Block used to clamp a float
  57614. */
  57615. var ClampBlock = /** @class */ (function (_super) {
  57616. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ClampBlock, _super);
  57617. /**
  57618. * Creates a new ClampBlock
  57619. * @param name defines the block name
  57620. */
  57621. function ClampBlock(name) {
  57622. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Neutral) || this;
  57623. /** Gets or sets the minimum range */
  57624. _this.minimum = 0.0;
  57625. /** Gets or sets the maximum range */
  57626. _this.maximum = 1.0;
  57627. _this.registerInput("value", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  57628. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  57629. return _this;
  57630. }
  57631. /**
  57632. * Gets the current class name
  57633. * @returns the class name
  57634. */
  57635. ClampBlock.prototype.getClassName = function () {
  57636. return "ClampBlock";
  57637. };
  57638. Object.defineProperty(ClampBlock.prototype, "value", {
  57639. /**
  57640. * Gets the value input component
  57641. */
  57642. get: function () {
  57643. return this._inputs[0];
  57644. },
  57645. enumerable: true,
  57646. configurable: true
  57647. });
  57648. Object.defineProperty(ClampBlock.prototype, "output", {
  57649. /**
  57650. * Gets the output component
  57651. */
  57652. get: function () {
  57653. return this._outputs[0];
  57654. },
  57655. enumerable: true,
  57656. configurable: true
  57657. });
  57658. ClampBlock.prototype._buildBlock = function (state) {
  57659. _super.prototype._buildBlock.call(this, state);
  57660. var output = this._outputs[0];
  57661. state.compilationString += this._declareOutput(output, state) + (" = clamp(" + this.value.associatedVariableName + ", " + this._writeFloat(this.minimum) + ", " + this._writeFloat(this.maximum) + ");\r\n");
  57662. return this;
  57663. };
  57664. return ClampBlock;
  57665. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57666. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ClampBlock"] = ClampBlock;
  57667. /***/ }),
  57668. /***/ "./Materials/Node/Blocks/crossBlock.ts":
  57669. /*!*********************************************!*\
  57670. !*** ./Materials/Node/Blocks/crossBlock.ts ***!
  57671. \*********************************************/
  57672. /*! exports provided: CrossBlock */
  57673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57674. "use strict";
  57675. __webpack_require__.r(__webpack_exports__);
  57676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CrossBlock", function() { return CrossBlock; });
  57677. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57678. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57679. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57680. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57681. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57682. /**
  57683. * Block used to apply a cross product between 2 vectors
  57684. */
  57685. var CrossBlock = /** @class */ (function (_super) {
  57686. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CrossBlock, _super);
  57687. /**
  57688. * Creates a new CrossBlock
  57689. * @param name defines the block name
  57690. */
  57691. function CrossBlock(name) {
  57692. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Neutral) || this;
  57693. _this.registerInput("left", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57694. _this.registerInput("right", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57695. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].BasedOnInput);
  57696. _this._outputs[0]._typeConnectionSource = _this._inputs[0];
  57697. return _this;
  57698. }
  57699. /**
  57700. * Gets the current class name
  57701. * @returns the class name
  57702. */
  57703. CrossBlock.prototype.getClassName = function () {
  57704. return "CrossBlock";
  57705. };
  57706. Object.defineProperty(CrossBlock.prototype, "left", {
  57707. /**
  57708. * Gets the left operand input component
  57709. */
  57710. get: function () {
  57711. return this._inputs[0];
  57712. },
  57713. enumerable: true,
  57714. configurable: true
  57715. });
  57716. Object.defineProperty(CrossBlock.prototype, "right", {
  57717. /**
  57718. * Gets the right operand input component
  57719. */
  57720. get: function () {
  57721. return this._inputs[1];
  57722. },
  57723. enumerable: true,
  57724. configurable: true
  57725. });
  57726. Object.defineProperty(CrossBlock.prototype, "output", {
  57727. /**
  57728. * Gets the output component
  57729. */
  57730. get: function () {
  57731. return this._outputs[0];
  57732. },
  57733. enumerable: true,
  57734. configurable: true
  57735. });
  57736. CrossBlock.prototype._buildBlock = function (state) {
  57737. _super.prototype._buildBlock.call(this, state);
  57738. var output = this._outputs[0];
  57739. state.compilationString += this._declareOutput(output, state) + (" = cross(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + ");\r\n");
  57740. return this;
  57741. };
  57742. return CrossBlock;
  57743. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57744. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.CrossBlock"] = CrossBlock;
  57745. /***/ }),
  57746. /***/ "./Materials/Node/Blocks/dotBlock.ts":
  57747. /*!*******************************************!*\
  57748. !*** ./Materials/Node/Blocks/dotBlock.ts ***!
  57749. \*******************************************/
  57750. /*! exports provided: DotBlock */
  57751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57752. "use strict";
  57753. __webpack_require__.r(__webpack_exports__);
  57754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DotBlock", function() { return DotBlock; });
  57755. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57756. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57757. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57758. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57759. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57760. /**
  57761. * Block used to apply a dot product between 2 vectors
  57762. */
  57763. var DotBlock = /** @class */ (function (_super) {
  57764. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DotBlock, _super);
  57765. /**
  57766. * Creates a new DotBlock
  57767. * @param name defines the block name
  57768. */
  57769. function DotBlock(name) {
  57770. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Neutral) || this;
  57771. _this.registerInput("left", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57772. _this.registerInput("right", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57773. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Float);
  57774. return _this;
  57775. }
  57776. /**
  57777. * Gets the current class name
  57778. * @returns the class name
  57779. */
  57780. DotBlock.prototype.getClassName = function () {
  57781. return "DotBlock";
  57782. };
  57783. Object.defineProperty(DotBlock.prototype, "left", {
  57784. /**
  57785. * Gets the left operand input component
  57786. */
  57787. get: function () {
  57788. return this._inputs[0];
  57789. },
  57790. enumerable: true,
  57791. configurable: true
  57792. });
  57793. Object.defineProperty(DotBlock.prototype, "right", {
  57794. /**
  57795. * Gets the right operand input component
  57796. */
  57797. get: function () {
  57798. return this._inputs[1];
  57799. },
  57800. enumerable: true,
  57801. configurable: true
  57802. });
  57803. Object.defineProperty(DotBlock.prototype, "output", {
  57804. /**
  57805. * Gets the output component
  57806. */
  57807. get: function () {
  57808. return this._outputs[0];
  57809. },
  57810. enumerable: true,
  57811. configurable: true
  57812. });
  57813. DotBlock.prototype._buildBlock = function (state) {
  57814. _super.prototype._buildBlock.call(this, state);
  57815. var output = this._outputs[0];
  57816. state.compilationString += this._declareOutput(output, state) + (" = dot(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + ");\r\n");
  57817. return this;
  57818. };
  57819. return DotBlock;
  57820. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57821. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.DotBlock"] = DotBlock;
  57822. /***/ }),
  57823. /***/ "./Materials/Node/Blocks/index.ts":
  57824. /*!****************************************!*\
  57825. !*** ./Materials/Node/Blocks/index.ts ***!
  57826. \****************************************/
  57827. /*! exports provided: MultiplyBlock, AddBlock, ClampBlock, CrossBlock, DotBlock, TransformBlock, VertexOutputBlock, BonesBlock, InstancesBlock, MorphTargetsBlock, FragmentOutputBlock, AlphaTestBlock, ColorMergerBlock, VectorMergerBlock, ColorSplitterBlock, VectorSplitterBlock, ImageProcessingBlock, FogBlock, LightBlock, TextureBlock, InputBlock */
  57828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57829. "use strict";
  57830. __webpack_require__.r(__webpack_exports__);
  57831. /* harmony import */ var _Vertex_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Vertex/index */ "./Materials/Node/Blocks/Vertex/index.ts");
  57832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return _Vertex_index__WEBPACK_IMPORTED_MODULE_0__["VertexOutputBlock"]; });
  57833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return _Vertex_index__WEBPACK_IMPORTED_MODULE_0__["BonesBlock"]; });
  57834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return _Vertex_index__WEBPACK_IMPORTED_MODULE_0__["InstancesBlock"]; });
  57835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return _Vertex_index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetsBlock"]; });
  57836. /* harmony import */ var _Fragment_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Fragment/index */ "./Materials/Node/Blocks/Fragment/index.ts");
  57837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["FragmentOutputBlock"]; });
  57838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["AlphaTestBlock"]; });
  57839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["ColorMergerBlock"]; });
  57840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["VectorMergerBlock"]; });
  57841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["ColorSplitterBlock"]; });
  57842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["VectorSplitterBlock"]; });
  57843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return _Fragment_index__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingBlock"]; });
  57844. /* harmony import */ var _Dual_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Dual/index */ "./Materials/Node/Blocks/Dual/index.ts");
  57845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return _Dual_index__WEBPACK_IMPORTED_MODULE_2__["FogBlock"]; });
  57846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return _Dual_index__WEBPACK_IMPORTED_MODULE_2__["LightBlock"]; });
  57847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return _Dual_index__WEBPACK_IMPORTED_MODULE_2__["TextureBlock"]; });
  57848. /* harmony import */ var _Input_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Input/index */ "./Materials/Node/Blocks/Input/index.ts");
  57849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return _Input_index__WEBPACK_IMPORTED_MODULE_3__["InputBlock"]; });
  57850. /* harmony import */ var _multiplyBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./multiplyBlock */ "./Materials/Node/Blocks/multiplyBlock.ts");
  57851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiplyBlock", function() { return _multiplyBlock__WEBPACK_IMPORTED_MODULE_4__["MultiplyBlock"]; });
  57852. /* harmony import */ var _addBlock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./addBlock */ "./Materials/Node/Blocks/addBlock.ts");
  57853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AddBlock", function() { return _addBlock__WEBPACK_IMPORTED_MODULE_5__["AddBlock"]; });
  57854. /* harmony import */ var _clampBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./clampBlock */ "./Materials/Node/Blocks/clampBlock.ts");
  57855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClampBlock", function() { return _clampBlock__WEBPACK_IMPORTED_MODULE_6__["ClampBlock"]; });
  57856. /* harmony import */ var _crossBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./crossBlock */ "./Materials/Node/Blocks/crossBlock.ts");
  57857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CrossBlock", function() { return _crossBlock__WEBPACK_IMPORTED_MODULE_7__["CrossBlock"]; });
  57858. /* harmony import */ var _dotBlock__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./dotBlock */ "./Materials/Node/Blocks/dotBlock.ts");
  57859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DotBlock", function() { return _dotBlock__WEBPACK_IMPORTED_MODULE_8__["DotBlock"]; });
  57860. /* harmony import */ var _transformBlock__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./transformBlock */ "./Materials/Node/Blocks/transformBlock.ts");
  57861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformBlock", function() { return _transformBlock__WEBPACK_IMPORTED_MODULE_9__["TransformBlock"]; });
  57862. /***/ }),
  57863. /***/ "./Materials/Node/Blocks/multiplyBlock.ts":
  57864. /*!************************************************!*\
  57865. !*** ./Materials/Node/Blocks/multiplyBlock.ts ***!
  57866. \************************************************/
  57867. /*! exports provided: MultiplyBlock */
  57868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57869. "use strict";
  57870. __webpack_require__.r(__webpack_exports__);
  57871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiplyBlock", function() { return MultiplyBlock; });
  57872. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57873. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57874. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57875. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57876. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57877. /**
  57878. * Block used to multiply 2 values
  57879. */
  57880. var MultiplyBlock = /** @class */ (function (_super) {
  57881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiplyBlock, _super);
  57882. /**
  57883. * Creates a new MultiplyBlock
  57884. * @param name defines the block name
  57885. */
  57886. function MultiplyBlock(name) {
  57887. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Neutral) || this;
  57888. _this.registerInput("left", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57889. _this.registerInput("right", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].BasedOnInput);
  57890. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].BasedOnInput);
  57891. _this._outputs[0]._typeConnectionSource = _this._inputs[0];
  57892. _this._inputs[1]._typeConnectionSource = _this._inputs[0];
  57893. return _this;
  57894. }
  57895. /**
  57896. * Gets the current class name
  57897. * @returns the class name
  57898. */
  57899. MultiplyBlock.prototype.getClassName = function () {
  57900. return "MultiplyBlock";
  57901. };
  57902. Object.defineProperty(MultiplyBlock.prototype, "left", {
  57903. /**
  57904. * Gets the left operand input component
  57905. */
  57906. get: function () {
  57907. return this._inputs[0];
  57908. },
  57909. enumerable: true,
  57910. configurable: true
  57911. });
  57912. Object.defineProperty(MultiplyBlock.prototype, "right", {
  57913. /**
  57914. * Gets the right operand input component
  57915. */
  57916. get: function () {
  57917. return this._inputs[1];
  57918. },
  57919. enumerable: true,
  57920. configurable: true
  57921. });
  57922. Object.defineProperty(MultiplyBlock.prototype, "output", {
  57923. /**
  57924. * Gets the output component
  57925. */
  57926. get: function () {
  57927. return this._outputs[0];
  57928. },
  57929. enumerable: true,
  57930. configurable: true
  57931. });
  57932. MultiplyBlock.prototype._buildBlock = function (state) {
  57933. _super.prototype._buildBlock.call(this, state);
  57934. var output = this._outputs[0];
  57935. state.compilationString += this._declareOutput(output, state) + (" = " + this.left.associatedVariableName + " * " + this.right.associatedVariableName + ";\r\n");
  57936. return this;
  57937. };
  57938. return MultiplyBlock;
  57939. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  57940. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.MultiplyBlock"] = MultiplyBlock;
  57941. /***/ }),
  57942. /***/ "./Materials/Node/Blocks/transformBlock.ts":
  57943. /*!*************************************************!*\
  57944. !*** ./Materials/Node/Blocks/transformBlock.ts ***!
  57945. \*************************************************/
  57946. /*! exports provided: TransformBlock */
  57947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57948. "use strict";
  57949. __webpack_require__.r(__webpack_exports__);
  57950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformBlock", function() { return TransformBlock; });
  57951. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57952. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  57953. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  57954. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  57955. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57956. /**
  57957. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57958. */
  57959. var TransformBlock = /** @class */ (function (_super) {
  57960. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformBlock, _super);
  57961. /**
  57962. * Creates a new TransformBlock
  57963. * @param name defines the block name
  57964. */
  57965. function TransformBlock(name) {
  57966. var _this = _super.call(this, name, _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlockTargets"].Neutral) || this;
  57967. /**
  57968. * Defines the value to use to complement W value to transform it to a Vector4
  57969. */
  57970. _this.complementW = 1;
  57971. /**
  57972. * Defines the value to use to complement z value to transform it to a Vector4
  57973. */
  57974. _this.complementZ = 0;
  57975. _this.registerInput("vector", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].AutoDetect);
  57976. _this.registerInput("transform", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Matrix);
  57977. _this.registerOutput("output", _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector4);
  57978. return _this;
  57979. }
  57980. /**
  57981. * Gets the current class name
  57982. * @returns the class name
  57983. */
  57984. TransformBlock.prototype.getClassName = function () {
  57985. return "TransformBlock";
  57986. };
  57987. Object.defineProperty(TransformBlock.prototype, "vector", {
  57988. /**
  57989. * Gets the vector input
  57990. */
  57991. get: function () {
  57992. return this._inputs[0];
  57993. },
  57994. enumerable: true,
  57995. configurable: true
  57996. });
  57997. Object.defineProperty(TransformBlock.prototype, "output", {
  57998. /**
  57999. * Gets the output component
  58000. */
  58001. get: function () {
  58002. return this._outputs[0];
  58003. },
  58004. enumerable: true,
  58005. configurable: true
  58006. });
  58007. Object.defineProperty(TransformBlock.prototype, "transform", {
  58008. /**
  58009. * Gets the matrix transform input
  58010. */
  58011. get: function () {
  58012. return this._inputs[1];
  58013. },
  58014. enumerable: true,
  58015. configurable: true
  58016. });
  58017. TransformBlock.prototype._buildBlock = function (state) {
  58018. _super.prototype._buildBlock.call(this, state);
  58019. var output = this._outputs[0];
  58020. var vector = this.vector;
  58021. var transform = this.transform;
  58022. if (vector.connectedPoint) {
  58023. switch (vector.connectedPoint.type) {
  58024. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector2:
  58025. state.compilationString += this._declareOutput(output, state) + (" = " + transform.associatedVariableName + " * vec4(" + vector.associatedVariableName + ", " + this._writeFloat(this.complementZ) + ", " + this._writeFloat(this.complementW) + ");\r\n");
  58026. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockConnectionPointTypes"].Vector3:
  58027. state.compilationString += this._declareOutput(output, state) + (" = " + transform.associatedVariableName + " * vec4(" + vector.associatedVariableName + ", " + this._writeFloat(this.complementW) + ");\r\n");
  58028. break;
  58029. default:
  58030. state.compilationString += this._declareOutput(output, state) + (" = " + transform.associatedVariableName + " * " + vector.associatedVariableName + ";\r\n");
  58031. break;
  58032. }
  58033. }
  58034. return this;
  58035. };
  58036. return TransformBlock;
  58037. }(_nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlock"]));
  58038. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.TransformBlock"] = TransformBlock;
  58039. /***/ }),
  58040. /***/ "./Materials/Node/NodeMaterialBlockConnectionPointMode.ts":
  58041. /*!****************************************************************!*\
  58042. !*** ./Materials/Node/NodeMaterialBlockConnectionPointMode.ts ***!
  58043. \****************************************************************/
  58044. /*! exports provided: NodeMaterialBlockConnectionPointMode */
  58045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58046. "use strict";
  58047. __webpack_require__.r(__webpack_exports__);
  58048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockConnectionPointMode", function() { return NodeMaterialBlockConnectionPointMode; });
  58049. /**
  58050. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  58051. */
  58052. var NodeMaterialBlockConnectionPointMode;
  58053. (function (NodeMaterialBlockConnectionPointMode) {
  58054. /** Value is an uniform */
  58055. NodeMaterialBlockConnectionPointMode[NodeMaterialBlockConnectionPointMode["Uniform"] = 0] = "Uniform";
  58056. /** Value is a mesh attribute */
  58057. NodeMaterialBlockConnectionPointMode[NodeMaterialBlockConnectionPointMode["Attribute"] = 1] = "Attribute";
  58058. /** Value is a varying between vertex and fragment shaders */
  58059. NodeMaterialBlockConnectionPointMode[NodeMaterialBlockConnectionPointMode["Varying"] = 2] = "Varying";
  58060. /** Mode is undefined */
  58061. NodeMaterialBlockConnectionPointMode[NodeMaterialBlockConnectionPointMode["Undefined"] = 3] = "Undefined";
  58062. })(NodeMaterialBlockConnectionPointMode || (NodeMaterialBlockConnectionPointMode = {}));
  58063. /***/ }),
  58064. /***/ "./Materials/Node/Optimizers/index.ts":
  58065. /*!********************************************!*\
  58066. !*** ./Materials/Node/Optimizers/index.ts ***!
  58067. \********************************************/
  58068. /*! exports provided: NodeMaterialOptimizer */
  58069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58070. "use strict";
  58071. __webpack_require__.r(__webpack_exports__);
  58072. /* harmony import */ var _nodeMaterialOptimizer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./nodeMaterialOptimizer */ "./Materials/Node/Optimizers/nodeMaterialOptimizer.ts");
  58073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialOptimizer", function() { return _nodeMaterialOptimizer__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialOptimizer"]; });
  58074. /***/ }),
  58075. /***/ "./Materials/Node/Optimizers/nodeMaterialOptimizer.ts":
  58076. /*!************************************************************!*\
  58077. !*** ./Materials/Node/Optimizers/nodeMaterialOptimizer.ts ***!
  58078. \************************************************************/
  58079. /*! exports provided: NodeMaterialOptimizer */
  58080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58081. "use strict";
  58082. __webpack_require__.r(__webpack_exports__);
  58083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialOptimizer", function() { return NodeMaterialOptimizer; });
  58084. /**
  58085. * Root class for all node material optimizers
  58086. */
  58087. var NodeMaterialOptimizer = /** @class */ (function () {
  58088. function NodeMaterialOptimizer() {
  58089. }
  58090. /**
  58091. * Function used to optimize a NodeMaterial graph
  58092. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  58093. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  58094. */
  58095. NodeMaterialOptimizer.prototype.optimize = function (vertexOutputNodes, fragmentOutputNodes) {
  58096. // Do nothing by default
  58097. };
  58098. return NodeMaterialOptimizer;
  58099. }());
  58100. /***/ }),
  58101. /***/ "./Materials/Node/index.ts":
  58102. /*!*********************************!*\
  58103. !*** ./Materials/Node/index.ts ***!
  58104. \*********************************/
  58105. /*! exports provided: NodeMaterialBlockTargets, NodeMaterialBlockConnectionPointTypes, NodeMaterialConnectionPoint, NodeMaterialBlock, NodeMaterialDefines, NodeMaterial, NodeMaterialWellKnownValues, MultiplyBlock, AddBlock, ClampBlock, CrossBlock, DotBlock, TransformBlock, NodeMaterialOptimizer, VertexOutputBlock, BonesBlock, InstancesBlock, MorphTargetsBlock, FragmentOutputBlock, AlphaTestBlock, ColorMergerBlock, VectorMergerBlock, ColorSplitterBlock, VectorSplitterBlock, ImageProcessingBlock, FogBlock, LightBlock, TextureBlock, InputBlock */
  58106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58107. "use strict";
  58108. __webpack_require__.r(__webpack_exports__);
  58109. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  58110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockTargets", function() { return _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockTargets"]; });
  58111. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  58112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockConnectionPointTypes", function() { return _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlockConnectionPointTypes"]; });
  58113. /* harmony import */ var _nodeMaterialBlockConnectionPoint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nodeMaterialBlockConnectionPoint */ "./Materials/Node/nodeMaterialBlockConnectionPoint.ts");
  58114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialConnectionPoint", function() { return _nodeMaterialBlockConnectionPoint__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialConnectionPoint"]; });
  58115. /* harmony import */ var _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nodeMaterialBlock */ "./Materials/Node/nodeMaterialBlock.ts");
  58116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlock", function() { return _nodeMaterialBlock__WEBPACK_IMPORTED_MODULE_3__["NodeMaterialBlock"]; });
  58117. /* harmony import */ var _nodeMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./nodeMaterial */ "./Materials/Node/nodeMaterial.ts");
  58118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialDefines", function() { return _nodeMaterial__WEBPACK_IMPORTED_MODULE_4__["NodeMaterialDefines"]; });
  58119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterial", function() { return _nodeMaterial__WEBPACK_IMPORTED_MODULE_4__["NodeMaterial"]; });
  58120. /* harmony import */ var _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nodeMaterialWellKnownValues */ "./Materials/Node/nodeMaterialWellKnownValues.ts");
  58121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialWellKnownValues", function() { return _nodeMaterialWellKnownValues__WEBPACK_IMPORTED_MODULE_5__["NodeMaterialWellKnownValues"]; });
  58122. /* harmony import */ var _Blocks_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Blocks/index */ "./Materials/Node/Blocks/index.ts");
  58123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiplyBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["MultiplyBlock"]; });
  58124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AddBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["AddBlock"]; });
  58125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClampBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["ClampBlock"]; });
  58126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CrossBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["CrossBlock"]; });
  58127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DotBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["DotBlock"]; });
  58128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["TransformBlock"]; });
  58129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["VertexOutputBlock"]; });
  58130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["BonesBlock"]; });
  58131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["InstancesBlock"]; });
  58132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["MorphTargetsBlock"]; });
  58133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["FragmentOutputBlock"]; });
  58134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["AlphaTestBlock"]; });
  58135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["ColorMergerBlock"]; });
  58136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["VectorMergerBlock"]; });
  58137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["ColorSplitterBlock"]; });
  58138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["VectorSplitterBlock"]; });
  58139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingBlock"]; });
  58140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["FogBlock"]; });
  58141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["LightBlock"]; });
  58142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["TextureBlock"]; });
  58143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return _Blocks_index__WEBPACK_IMPORTED_MODULE_6__["InputBlock"]; });
  58144. /* harmony import */ var _Optimizers_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Optimizers/index */ "./Materials/Node/Optimizers/index.ts");
  58145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialOptimizer", function() { return _Optimizers_index__WEBPACK_IMPORTED_MODULE_7__["NodeMaterialOptimizer"]; });
  58146. /***/ }),
  58147. /***/ "./Materials/Node/nodeMaterial.ts":
  58148. /*!****************************************!*\
  58149. !*** ./Materials/Node/nodeMaterial.ts ***!
  58150. \****************************************/
  58151. /*! exports provided: NodeMaterialDefines, NodeMaterial */
  58152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58153. "use strict";
  58154. __webpack_require__.r(__webpack_exports__);
  58155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialDefines", function() { return NodeMaterialDefines; });
  58156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterial", function() { return NodeMaterial; });
  58157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58158. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../pushMaterial */ "./Materials/pushMaterial.ts");
  58159. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  58160. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  58161. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58162. /* harmony import */ var _nodeMaterialBuildState__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nodeMaterialBuildState */ "./Materials/Node/nodeMaterialBuildState.ts");
  58163. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../effect */ "./Materials/effect.ts");
  58164. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58165. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  58166. /* harmony import */ var _nodeMaterialBuildStateSharedData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./nodeMaterialBuildStateSharedData */ "./Materials/Node/nodeMaterialBuildStateSharedData.ts");
  58167. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  58168. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  58169. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58170. /* harmony import */ var _Blocks_transformBlock__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Blocks/transformBlock */ "./Materials/Node/Blocks/transformBlock.ts");
  58171. /* harmony import */ var _Blocks_Vertex_vertexOutputBlock__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Blocks/Vertex/vertexOutputBlock */ "./Materials/Node/Blocks/Vertex/vertexOutputBlock.ts");
  58172. /* harmony import */ var _Blocks_Fragment_fragmentOutputBlock__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Blocks/Fragment/fragmentOutputBlock */ "./Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts");
  58173. /* harmony import */ var _Blocks_Input_inputBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Blocks/Input/inputBlock */ "./Materials/Node/Blocks/Input/inputBlock.ts");
  58174. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58175. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58176. /** @hidden */
  58177. var NodeMaterialDefines = /** @class */ (function (_super) {
  58178. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NodeMaterialDefines, _super);
  58179. function NodeMaterialDefines() {
  58180. var _this = _super.call(this) || this;
  58181. /** BONES */
  58182. _this.NUM_BONE_INFLUENCERS = 0;
  58183. _this.BonesPerMesh = 0;
  58184. _this.BONETEXTURE = false;
  58185. /** MORPH TARGETS */
  58186. _this.MORPHTARGETS = false;
  58187. _this.MORPHTARGETS_NORMAL = false;
  58188. _this.MORPHTARGETS_TANGENT = false;
  58189. _this.MORPHTARGETS_UV = false;
  58190. _this.NUM_MORPH_INFLUENCERS = 0;
  58191. /** IMAGE PROCESSING */
  58192. _this.IMAGEPROCESSING = false;
  58193. _this.VIGNETTE = false;
  58194. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  58195. _this.VIGNETTEBLENDMODEOPAQUE = false;
  58196. _this.TONEMAPPING = false;
  58197. _this.TONEMAPPING_ACES = false;
  58198. _this.CONTRAST = false;
  58199. _this.EXPOSURE = false;
  58200. _this.COLORCURVES = false;
  58201. _this.COLORGRADING = false;
  58202. _this.COLORGRADING3D = false;
  58203. _this.SAMPLER3DGREENDEPTH = false;
  58204. _this.SAMPLER3DBGRMAP = false;
  58205. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  58206. _this.rebuild();
  58207. return _this;
  58208. }
  58209. NodeMaterialDefines.prototype.setValue = function (name, value) {
  58210. if (this[name] === undefined) {
  58211. this._keys.push(name);
  58212. }
  58213. this[name] = value;
  58214. };
  58215. return NodeMaterialDefines;
  58216. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  58217. /**
  58218. * Class used to create a node based material built by assembling shader blocks
  58219. */
  58220. var NodeMaterial = /** @class */ (function (_super) {
  58221. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NodeMaterial, _super);
  58222. /**
  58223. * Create a new node based material
  58224. * @param name defines the material name
  58225. * @param scene defines the hosting scene
  58226. * @param options defines creation option
  58227. */
  58228. function NodeMaterial(name, scene, options) {
  58229. if (options === void 0) { options = {}; }
  58230. var _this = _super.call(this, name, scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].LastCreatedScene) || this;
  58231. _this._buildId = 0;
  58232. _this._buildWasSuccessful = false;
  58233. _this._cachedWorldViewMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  58234. _this._cachedWorldViewProjectionMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  58235. _this._optimizers = new Array();
  58236. _this.BJSNODEMATERIALEDITOR = _this._getGlobalNodeMaterialEditor();
  58237. /**
  58238. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  58239. */
  58240. _this.ignoreAlpha = false;
  58241. /**
  58242. * Defines the maximum number of lights that can be used in the material
  58243. */
  58244. _this.maxSimultaneousLights = 4;
  58245. /**
  58246. * Observable raised when the material is built
  58247. */
  58248. _this.onBuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_7__["Observable"]();
  58249. /**
  58250. * Gets or sets the root nodes of the material vertex shader
  58251. */
  58252. _this._vertexOutputNodes = new Array();
  58253. /**
  58254. * Gets or sets the root nodes of the material fragment (pixel) shader
  58255. */
  58256. _this._fragmentOutputNodes = new Array();
  58257. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ emitComments: false }, options);
  58258. // Setup the default processing configuration to the scene.
  58259. _this._attachImageProcessingConfiguration(null);
  58260. return _this;
  58261. }
  58262. /** Get the inspector from bundle or global */
  58263. NodeMaterial.prototype._getGlobalNodeMaterialEditor = function () {
  58264. // UMD Global name detection from Webpack Bundle UMD Name.
  58265. if (typeof NODEEDITOR !== 'undefined') {
  58266. return NODEEDITOR;
  58267. }
  58268. // In case of module let's check the global emitted from the editor entry point.
  58269. if (typeof BABYLON !== 'undefined' && typeof BABYLON.NodeEditor !== 'undefined') {
  58270. return BABYLON;
  58271. }
  58272. return undefined;
  58273. };
  58274. Object.defineProperty(NodeMaterial.prototype, "options", {
  58275. /** Gets or sets options to control the node material overall behavior */
  58276. get: function () {
  58277. return this._options;
  58278. },
  58279. set: function (options) {
  58280. this._options = options;
  58281. },
  58282. enumerable: true,
  58283. configurable: true
  58284. });
  58285. Object.defineProperty(NodeMaterial.prototype, "imageProcessingConfiguration", {
  58286. /**
  58287. * Gets the image processing configuration used either in this material.
  58288. */
  58289. get: function () {
  58290. return this._imageProcessingConfiguration;
  58291. },
  58292. /**
  58293. * Sets the Default image processing configuration used either in the this material.
  58294. *
  58295. * If sets to null, the scene one is in use.
  58296. */
  58297. set: function (value) {
  58298. this._attachImageProcessingConfiguration(value);
  58299. // Ensure the effect will be rebuilt.
  58300. this._markAllSubMeshesAsTexturesDirty();
  58301. },
  58302. enumerable: true,
  58303. configurable: true
  58304. });
  58305. /**
  58306. * Gets the current class name of the material e.g. "NodeMaterial"
  58307. * @returns the class name
  58308. */
  58309. NodeMaterial.prototype.getClassName = function () {
  58310. return "NodeMaterial";
  58311. };
  58312. /**
  58313. * Attaches a new image processing configuration to the Standard Material.
  58314. * @param configuration
  58315. */
  58316. NodeMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  58317. var _this = this;
  58318. if (configuration === this._imageProcessingConfiguration) {
  58319. return;
  58320. }
  58321. // Detaches observer.
  58322. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  58323. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  58324. }
  58325. // Pick the scene configuration if needed.
  58326. if (!configuration) {
  58327. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  58328. }
  58329. else {
  58330. this._imageProcessingConfiguration = configuration;
  58331. }
  58332. // Attaches observer.
  58333. if (this._imageProcessingConfiguration) {
  58334. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  58335. _this._markAllSubMeshesAsImageProcessingDirty();
  58336. });
  58337. }
  58338. };
  58339. /**
  58340. * Adds a new optimizer to the list of optimizers
  58341. * @param optimizer defines the optimizers to add
  58342. * @returns the current material
  58343. */
  58344. NodeMaterial.prototype.registerOptimizer = function (optimizer) {
  58345. var index = this._optimizers.indexOf(optimizer);
  58346. if (index > -1) {
  58347. return;
  58348. }
  58349. this._optimizers.push(optimizer);
  58350. return this;
  58351. };
  58352. /**
  58353. * Remove an optimizer from the list of optimizers
  58354. * @param optimizer defines the optimizers to remove
  58355. * @returns the current material
  58356. */
  58357. NodeMaterial.prototype.unregisterOptimizer = function (optimizer) {
  58358. var index = this._optimizers.indexOf(optimizer);
  58359. if (index === -1) {
  58360. return;
  58361. }
  58362. this._optimizers.splice(index, 1);
  58363. return this;
  58364. };
  58365. /**
  58366. * Add a new block to the list of output nodes
  58367. * @param node defines the node to add
  58368. * @returns the current material
  58369. */
  58370. NodeMaterial.prototype.addOutputNode = function (node) {
  58371. if (node.target === null) {
  58372. throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
  58373. }
  58374. if ((node.target & _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Vertex) !== 0) {
  58375. this._addVertexOutputNode(node);
  58376. }
  58377. if ((node.target & _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Fragment) !== 0) {
  58378. this._addFragmentOutputNode(node);
  58379. }
  58380. return this;
  58381. };
  58382. /**
  58383. * Remove a block from the list of root nodes
  58384. * @param node defines the node to remove
  58385. * @returns the current material
  58386. */
  58387. NodeMaterial.prototype.removeOutputNode = function (node) {
  58388. if (node.target === null) {
  58389. return this;
  58390. }
  58391. if ((node.target & _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Vertex) !== 0) {
  58392. this._removeVertexOutputNode(node);
  58393. }
  58394. if ((node.target & _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Fragment) !== 0) {
  58395. this._removeFragmentOutputNode(node);
  58396. }
  58397. return this;
  58398. };
  58399. NodeMaterial.prototype._addVertexOutputNode = function (node) {
  58400. if (this._vertexOutputNodes.indexOf(node) !== -1) {
  58401. return;
  58402. }
  58403. node.target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Vertex;
  58404. this._vertexOutputNodes.push(node);
  58405. return this;
  58406. };
  58407. NodeMaterial.prototype._removeVertexOutputNode = function (node) {
  58408. var index = this._vertexOutputNodes.indexOf(node);
  58409. if (index === -1) {
  58410. return;
  58411. }
  58412. this._vertexOutputNodes.splice(index, 1);
  58413. return this;
  58414. };
  58415. NodeMaterial.prototype._addFragmentOutputNode = function (node) {
  58416. if (this._fragmentOutputNodes.indexOf(node) !== -1) {
  58417. return;
  58418. }
  58419. node.target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Fragment;
  58420. this._fragmentOutputNodes.push(node);
  58421. return this;
  58422. };
  58423. NodeMaterial.prototype._removeFragmentOutputNode = function (node) {
  58424. var index = this._fragmentOutputNodes.indexOf(node);
  58425. if (index === -1) {
  58426. return;
  58427. }
  58428. this._fragmentOutputNodes.splice(index, 1);
  58429. return this;
  58430. };
  58431. /**
  58432. * Specifies if the material will require alpha blending
  58433. * @returns a boolean specifying if alpha blending is needed
  58434. */
  58435. NodeMaterial.prototype.needAlphaBlending = function () {
  58436. if (this.ignoreAlpha) {
  58437. return false;
  58438. }
  58439. return (this.alpha < 1.0) || this._sharedData.hints.needAlphaBlending;
  58440. };
  58441. /**
  58442. * Specifies if this material should be rendered in alpha test mode
  58443. * @returns a boolean specifying if an alpha test is needed.
  58444. */
  58445. NodeMaterial.prototype.needAlphaTesting = function () {
  58446. return this._sharedData.hints.needAlphaTesting;
  58447. };
  58448. NodeMaterial.prototype._initializeBlock = function (node, state, nodesToProcessForOtherBuildState) {
  58449. node.initialize(state);
  58450. node.autoConfigure();
  58451. if (node.isInput) {
  58452. node.associatedVariableName = "";
  58453. }
  58454. for (var _i = 0, _a = node.inputs; _i < _a.length; _i++) {
  58455. var input = _a[_i];
  58456. input.associatedVariableName = "";
  58457. var connectedPoint = input.connectedPoint;
  58458. if (connectedPoint) {
  58459. var block = connectedPoint.ownerBlock;
  58460. if (block !== node) {
  58461. if (block.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].VertexAndFragment) {
  58462. nodesToProcessForOtherBuildState.push(block);
  58463. }
  58464. this._initializeBlock(block, state, nodesToProcessForOtherBuildState);
  58465. }
  58466. }
  58467. }
  58468. for (var _b = 0, _c = node.outputs; _b < _c.length; _b++) {
  58469. var output = _c[_b];
  58470. output.associatedVariableName = "";
  58471. }
  58472. };
  58473. NodeMaterial.prototype._resetDualBlocks = function (node, id) {
  58474. if (node.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].VertexAndFragment) {
  58475. node.buildId = id;
  58476. }
  58477. for (var _i = 0, _a = node.inputs; _i < _a.length; _i++) {
  58478. var inputs = _a[_i];
  58479. var connectedPoint = inputs.connectedPoint;
  58480. if (connectedPoint) {
  58481. var block = connectedPoint.ownerBlock;
  58482. if (block !== node) {
  58483. this._resetDualBlocks(block, id);
  58484. }
  58485. }
  58486. }
  58487. };
  58488. /**
  58489. * Build the material and generates the inner effect
  58490. * @param verbose defines if the build should log activity
  58491. */
  58492. NodeMaterial.prototype.build = function (verbose) {
  58493. if (verbose === void 0) { verbose = false; }
  58494. this._buildWasSuccessful = false;
  58495. var engine = this.getScene().getEngine();
  58496. if (this._vertexOutputNodes.length === 0) {
  58497. throw "You must define at least one vertexOutputNode";
  58498. }
  58499. if (this._fragmentOutputNodes.length === 0) {
  58500. throw "You must define at least one fragmentOutputNode";
  58501. }
  58502. // Compilation state
  58503. this._vertexCompilationState = new _nodeMaterialBuildState__WEBPACK_IMPORTED_MODULE_5__["NodeMaterialBuildState"]();
  58504. this._vertexCompilationState.supportUniformBuffers = engine.supportsUniformBuffers;
  58505. this._vertexCompilationState.target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Vertex;
  58506. this._fragmentCompilationState = new _nodeMaterialBuildState__WEBPACK_IMPORTED_MODULE_5__["NodeMaterialBuildState"]();
  58507. this._fragmentCompilationState.supportUniformBuffers = engine.supportsUniformBuffers;
  58508. this._fragmentCompilationState.target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_8__["NodeMaterialBlockTargets"].Fragment;
  58509. // Shared data
  58510. this._sharedData = new _nodeMaterialBuildStateSharedData__WEBPACK_IMPORTED_MODULE_9__["NodeMaterialBuildStateSharedData"]();
  58511. this._vertexCompilationState.sharedData = this._sharedData;
  58512. this._fragmentCompilationState.sharedData = this._sharedData;
  58513. this._sharedData.buildId = this._buildId;
  58514. this._sharedData.emitComments = this._options.emitComments;
  58515. this._sharedData.verbose = verbose;
  58516. // Initialize blocks
  58517. var vertexNodes = [];
  58518. var fragmentNodes = [];
  58519. for (var _i = 0, _a = this._vertexOutputNodes; _i < _a.length; _i++) {
  58520. var vertexOutputNode = _a[_i];
  58521. vertexNodes.push(vertexOutputNode);
  58522. this._initializeBlock(vertexOutputNode, this._vertexCompilationState, fragmentNodes);
  58523. }
  58524. for (var _b = 0, _c = this._fragmentOutputNodes; _b < _c.length; _b++) {
  58525. var fragmentOutputNode = _c[_b];
  58526. fragmentNodes.push(fragmentOutputNode);
  58527. this._initializeBlock(fragmentOutputNode, this._fragmentCompilationState, vertexNodes);
  58528. }
  58529. // Optimize
  58530. this.optimize();
  58531. // Vertex
  58532. for (var _d = 0, vertexNodes_1 = vertexNodes; _d < vertexNodes_1.length; _d++) {
  58533. var vertexOutputNode = vertexNodes_1[_d];
  58534. vertexOutputNode.build(this._vertexCompilationState);
  58535. }
  58536. // Fragment
  58537. this._fragmentCompilationState._vertexState = this._vertexCompilationState;
  58538. for (var _e = 0, fragmentNodes_1 = fragmentNodes; _e < fragmentNodes_1.length; _e++) {
  58539. var fragmentOutputNode = fragmentNodes_1[_e];
  58540. this._resetDualBlocks(fragmentOutputNode, this._buildId - 1);
  58541. }
  58542. for (var _f = 0, fragmentNodes_2 = fragmentNodes; _f < fragmentNodes_2.length; _f++) {
  58543. var fragmentOutputNode = fragmentNodes_2[_f];
  58544. fragmentOutputNode.build(this._fragmentCompilationState);
  58545. }
  58546. // Finalize
  58547. this._vertexCompilationState.finalize(this._vertexCompilationState);
  58548. this._fragmentCompilationState.finalize(this._fragmentCompilationState);
  58549. this._buildId++;
  58550. // Errors
  58551. this._sharedData.emitErrors();
  58552. if (verbose) {
  58553. console.log("Vertex shader:");
  58554. console.log(this._vertexCompilationState.compilationString);
  58555. console.log("Fragment shader:");
  58556. console.log(this._fragmentCompilationState.compilationString);
  58557. }
  58558. this._buildWasSuccessful = true;
  58559. this.onBuildObservable.notifyObservers(this);
  58560. this._markAllSubMeshesAsAllDirty();
  58561. };
  58562. /**
  58563. * Runs an otpimization phase to try to improve the shader code
  58564. */
  58565. NodeMaterial.prototype.optimize = function () {
  58566. for (var _i = 0, _a = this._optimizers; _i < _a.length; _i++) {
  58567. var optimizer = _a[_i];
  58568. optimizer.optimize(this._vertexOutputNodes, this._fragmentOutputNodes);
  58569. }
  58570. };
  58571. NodeMaterial.prototype._prepareDefinesForAttributes = function (mesh, defines) {
  58572. if (!defines._areAttributesDirty) {
  58573. return;
  58574. }
  58575. defines["NORMAL"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_11__["VertexBuffer"].NormalKind);
  58576. defines["TANGENT"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_11__["VertexBuffer"].TangentKind);
  58577. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_11__["VertexBuffer"].UVKind);
  58578. };
  58579. /**
  58580. * Get if the submesh is ready to be used and all its information available.
  58581. * Child classes can use it to update shaders
  58582. * @param mesh defines the mesh to check
  58583. * @param subMesh defines which submesh to check
  58584. * @param useInstances specifies that instances should be used
  58585. * @returns a boolean indicating that the submesh is ready or not
  58586. */
  58587. NodeMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  58588. var _this = this;
  58589. if (useInstances === void 0) { useInstances = false; }
  58590. if (!this._buildWasSuccessful) {
  58591. return false;
  58592. }
  58593. if (subMesh.effect && this.isFrozen) {
  58594. if (this._wasPreviouslyReady) {
  58595. return true;
  58596. }
  58597. }
  58598. if (!subMesh._materialDefines) {
  58599. subMesh._materialDefines = new NodeMaterialDefines();
  58600. }
  58601. var scene = this.getScene();
  58602. var defines = subMesh._materialDefines;
  58603. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  58604. if (defines._renderId === scene.getRenderId()) {
  58605. return true;
  58606. }
  58607. }
  58608. var engine = scene.getEngine();
  58609. this._prepareDefinesForAttributes(mesh, defines);
  58610. // Check if blocks are ready
  58611. if (this._sharedData.blockingBlocks.some(function (b) { return !b.isReady(mesh, _this, defines, useInstances); })) {
  58612. return false;
  58613. }
  58614. // Shared defines
  58615. this._sharedData.blocksWithDefines.forEach(function (b) {
  58616. b.initializeDefines(mesh, _this, defines, useInstances);
  58617. });
  58618. this._sharedData.blocksWithDefines.forEach(function (b) {
  58619. b.prepareDefines(mesh, _this, defines, useInstances);
  58620. });
  58621. // Need to recompile?
  58622. if (defines.isDirty) {
  58623. defines.markAsProcessed();
  58624. // Repeatable content generators
  58625. this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString;
  58626. this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString;
  58627. this._sharedData.repeatableContentBlocks.forEach(function (b) {
  58628. b.replaceRepeatableContent(_this._vertexCompilationState, _this._fragmentCompilationState, mesh, defines);
  58629. });
  58630. // Uniforms
  58631. this._sharedData.dynamicUniformBlocks.forEach(function (b) {
  58632. b.updateUniformsAndSamples(_this._vertexCompilationState, _this, defines);
  58633. });
  58634. var mergedUniforms_1 = this._vertexCompilationState.uniforms;
  58635. this._fragmentCompilationState.uniforms.forEach(function (u) {
  58636. var index = mergedUniforms_1.indexOf(u);
  58637. if (index === -1) {
  58638. mergedUniforms_1.push(u);
  58639. }
  58640. });
  58641. // Uniform buffers
  58642. var mergedUniformBuffers_1 = this._vertexCompilationState.uniformBuffers;
  58643. this._fragmentCompilationState.uniformBuffers.forEach(function (u) {
  58644. var index = mergedUniformBuffers_1.indexOf(u);
  58645. if (index === -1) {
  58646. mergedUniformBuffers_1.push(u);
  58647. }
  58648. });
  58649. // Samplers
  58650. var mergedSamplers_1 = this._vertexCompilationState.samplers;
  58651. this._fragmentCompilationState.samplers.forEach(function (s) {
  58652. var index = mergedSamplers_1.indexOf(s);
  58653. if (index === -1) {
  58654. mergedSamplers_1.push(s);
  58655. }
  58656. });
  58657. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  58658. this._sharedData.blocksWithFallbacks.forEach(function (b) {
  58659. b.provideFallbacks(mesh, fallbacks);
  58660. });
  58661. var previousEffect = subMesh.effect;
  58662. // Compilation
  58663. var join = defines.toString();
  58664. var effect = engine.createEffect({
  58665. vertex: "nodeMaterial" + this._buildId,
  58666. fragment: "nodeMaterial" + this._buildId,
  58667. vertexSource: this._vertexCompilationState.compilationString,
  58668. fragmentSource: this._fragmentCompilationState.compilationString
  58669. }, {
  58670. attributes: this._vertexCompilationState.attributes,
  58671. uniformsNames: mergedUniforms_1,
  58672. uniformBuffersNames: mergedUniformBuffers_1,
  58673. samplers: mergedSamplers_1,
  58674. defines: join,
  58675. fallbacks: fallbacks,
  58676. onCompiled: this.onCompiled,
  58677. onError: this.onError,
  58678. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  58679. }, engine);
  58680. if (effect) {
  58681. // Use previous effect while new one is compiling
  58682. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  58683. effect = previousEffect;
  58684. defines.markAsUnprocessed();
  58685. }
  58686. else {
  58687. scene.resetCachedMaterial();
  58688. subMesh.setEffect(effect, defines);
  58689. }
  58690. }
  58691. }
  58692. if (!subMesh.effect || !subMesh.effect.isReady()) {
  58693. return false;
  58694. }
  58695. defines._renderId = scene.getRenderId();
  58696. this._wasPreviouslyReady = true;
  58697. return true;
  58698. };
  58699. Object.defineProperty(NodeMaterial.prototype, "compiledShaders", {
  58700. /**
  58701. * Get a string representing the shaders built by the current node graph
  58702. */
  58703. get: function () {
  58704. return "// Vertex shader\r\n" + this._vertexCompilationState.compilationString + "\r\n\r\n// Fragment shader\r\n" + this._fragmentCompilationState.compilationString;
  58705. },
  58706. enumerable: true,
  58707. configurable: true
  58708. });
  58709. /**
  58710. * Binds the world matrix to the material
  58711. * @param world defines the world transformation matrix
  58712. */
  58713. NodeMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  58714. var scene = this.getScene();
  58715. if (!this._activeEffect) {
  58716. return;
  58717. }
  58718. var hints = this._sharedData.hints;
  58719. if (hints.needWorldViewMatrix) {
  58720. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  58721. }
  58722. if (hints.needWorldViewProjectionMatrix) {
  58723. world.multiplyToRef(scene.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
  58724. }
  58725. // Connection points
  58726. for (var _i = 0, _a = this._sharedData.inputBlocks; _i < _a.length; _i++) {
  58727. var inputBlock = _a[_i];
  58728. inputBlock._transmitWorld(this._activeEffect, world, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix);
  58729. }
  58730. };
  58731. /**
  58732. * Binds the submesh to this material by preparing the effect and shader to draw
  58733. * @param world defines the world transformation matrix
  58734. * @param mesh defines the mesh containing the submesh
  58735. * @param subMesh defines the submesh to bind the material to
  58736. */
  58737. NodeMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  58738. var scene = this.getScene();
  58739. var effect = subMesh.effect;
  58740. if (!effect) {
  58741. return;
  58742. }
  58743. this._activeEffect = effect;
  58744. // Matrices
  58745. this.bindOnlyWorldMatrix(world);
  58746. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  58747. if (mustRebind) {
  58748. var sharedData = this._sharedData;
  58749. if (effect && scene.getCachedMaterial() !== this) {
  58750. // Bindable blocks
  58751. for (var _i = 0, _a = sharedData.bindableBlocks; _i < _a.length; _i++) {
  58752. var block = _a[_i];
  58753. block.bind(effect, this, mesh);
  58754. }
  58755. // Connection points
  58756. for (var _b = 0, _c = sharedData.inputBlocks; _b < _c.length; _b++) {
  58757. var inputBlock = _c[_b];
  58758. inputBlock._transmit(effect, scene);
  58759. }
  58760. }
  58761. }
  58762. this._afterBind(mesh, this._activeEffect);
  58763. };
  58764. /**
  58765. * Gets the active textures from the material
  58766. * @returns an array of textures
  58767. */
  58768. NodeMaterial.prototype.getActiveTextures = function () {
  58769. var activeTextures = _super.prototype.getActiveTextures.call(this);
  58770. activeTextures.push.apply(activeTextures, this._sharedData.textureBlocks.filter(function (tb) { return tb.texture; }).map(function (tb) { return tb.texture; }));
  58771. return activeTextures;
  58772. };
  58773. /**
  58774. * Specifies if the material uses a texture
  58775. * @param texture defines the texture to check against the material
  58776. * @returns a boolean specifying if the material uses the texture
  58777. */
  58778. NodeMaterial.prototype.hasTexture = function (texture) {
  58779. if (_super.prototype.hasTexture.call(this, texture)) {
  58780. return true;
  58781. }
  58782. for (var _i = 0, _a = this._sharedData.textureBlocks; _i < _a.length; _i++) {
  58783. var t = _a[_i];
  58784. if (t.texture === texture) {
  58785. return true;
  58786. }
  58787. }
  58788. return false;
  58789. };
  58790. /**
  58791. * Disposes the material
  58792. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58793. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58794. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58795. */
  58796. NodeMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  58797. if (forceDisposeTextures) {
  58798. for (var _i = 0, _a = this._sharedData.textureBlocks.filter(function (tb) { return tb.texture; }).map(function (tb) { return tb.texture; }); _i < _a.length; _i++) {
  58799. var texture = _a[_i];
  58800. texture.dispose();
  58801. }
  58802. }
  58803. this.onBuildObservable.clear();
  58804. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  58805. };
  58806. /** Creates the node editor window. */
  58807. NodeMaterial.prototype._createNodeEditor = function () {
  58808. this.BJSNODEMATERIALEDITOR = this.BJSNODEMATERIALEDITOR || this._getGlobalNodeMaterialEditor();
  58809. this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
  58810. nodeMaterial: this
  58811. });
  58812. };
  58813. /**
  58814. * Launch the node material editor
  58815. * @param config Define the configuration of the editor
  58816. * @return a promise fulfilled when the node editor is visible
  58817. */
  58818. NodeMaterial.prototype.edit = function (config) {
  58819. var _this = this;
  58820. return new Promise(function (resolve, reject) {
  58821. if (typeof _this.BJSNODEMATERIALEDITOR == 'undefined') {
  58822. var editorUrl = config && config.editorURL ? config.editorURL : NodeMaterial.EditorURL;
  58823. // Load editor and add it to the DOM
  58824. _Misc_tools__WEBPACK_IMPORTED_MODULE_12__["Tools"].LoadScript(editorUrl, function () {
  58825. _this._createNodeEditor();
  58826. resolve();
  58827. });
  58828. }
  58829. else {
  58830. // Otherwise creates the editor
  58831. _this._createNodeEditor();
  58832. resolve();
  58833. }
  58834. });
  58835. };
  58836. /**
  58837. * Clear the current material
  58838. */
  58839. NodeMaterial.prototype.clear = function () {
  58840. this._vertexOutputNodes = [];
  58841. this._fragmentOutputNodes = [];
  58842. };
  58843. /**
  58844. * Clear the current material and set it to a default state
  58845. */
  58846. NodeMaterial.prototype.setToDefault = function () {
  58847. this.clear();
  58848. var positionInput = new _Blocks_Input_inputBlock__WEBPACK_IMPORTED_MODULE_16__["InputBlock"]("position");
  58849. positionInput.setAsAttribute("position");
  58850. var worldInput = new _Blocks_Input_inputBlock__WEBPACK_IMPORTED_MODULE_16__["InputBlock"]("world");
  58851. worldInput.setAsWellKnownValue(BABYLON.NodeMaterialWellKnownValues.World);
  58852. var worldPos = new _Blocks_transformBlock__WEBPACK_IMPORTED_MODULE_13__["TransformBlock"]("worldPos");
  58853. positionInput.connectTo(worldPos);
  58854. worldInput.connectTo(worldPos);
  58855. var viewProjectionInput = new _Blocks_Input_inputBlock__WEBPACK_IMPORTED_MODULE_16__["InputBlock"]("viewProjection");
  58856. viewProjectionInput.setAsWellKnownValue(BABYLON.NodeMaterialWellKnownValues.ViewProjection);
  58857. var worldPosdMultipliedByViewProjection = new _Blocks_transformBlock__WEBPACK_IMPORTED_MODULE_13__["TransformBlock"]("worldPos * viewProjectionTransform");
  58858. worldPos.connectTo(worldPosdMultipliedByViewProjection);
  58859. viewProjectionInput.connectTo(worldPosdMultipliedByViewProjection);
  58860. var vertexOutput = new _Blocks_Vertex_vertexOutputBlock__WEBPACK_IMPORTED_MODULE_14__["VertexOutputBlock"]("vertexOutput");
  58861. worldPosdMultipliedByViewProjection.connectTo(vertexOutput);
  58862. // Pixel
  58863. var pixelColor = new _Blocks_Input_inputBlock__WEBPACK_IMPORTED_MODULE_16__["InputBlock"]("color");
  58864. pixelColor.value = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.8, 0.8, 0.8, 1);
  58865. var pixelOutput = new _Blocks_Fragment_fragmentOutputBlock__WEBPACK_IMPORTED_MODULE_15__["FragmentOutputBlock"]("pixelOutput");
  58866. pixelColor.connectTo(pixelOutput);
  58867. // Add to nodes
  58868. this.addOutputNode(vertexOutput);
  58869. this.addOutputNode(pixelOutput);
  58870. };
  58871. NodeMaterial.prototype._gatherBlocks = function (rootNode, list) {
  58872. if (list.indexOf(rootNode) !== -1) {
  58873. return;
  58874. }
  58875. list.push(rootNode);
  58876. for (var _i = 0, _a = rootNode.inputs; _i < _a.length; _i++) {
  58877. var input = _a[_i];
  58878. var connectedPoint = input.connectedPoint;
  58879. if (connectedPoint) {
  58880. var block = connectedPoint.ownerBlock;
  58881. if (block !== rootNode) {
  58882. this._gatherBlocks(block, list);
  58883. }
  58884. }
  58885. }
  58886. };
  58887. /**
  58888. * Serializes this material in a JSON representation
  58889. * @returns the serialized material object
  58890. */
  58891. NodeMaterial.prototype.serialize = function () {
  58892. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].Serialize(this);
  58893. serializationObject.customType = "BABYLON.NodeMaterial";
  58894. serializationObject.outputNodes = [];
  58895. var blocks = [];
  58896. // Outputs
  58897. for (var _i = 0, _a = this._vertexOutputNodes; _i < _a.length; _i++) {
  58898. var outputNode = _a[_i];
  58899. this._gatherBlocks(outputNode, blocks);
  58900. serializationObject.outputNodes.push(outputNode.uniqueId);
  58901. }
  58902. for (var _b = 0, _c = this._fragmentOutputNodes; _b < _c.length; _b++) {
  58903. var outputNode = _c[_b];
  58904. this._gatherBlocks(outputNode, blocks);
  58905. serializationObject.outputNodes.push(outputNode.uniqueId);
  58906. }
  58907. // Blocks
  58908. serializationObject.blocks = [];
  58909. for (var _d = 0, blocks_1 = blocks; _d < blocks_1.length; _d++) {
  58910. var block = blocks_1[_d];
  58911. serializationObject.blocks.push(block.serialize());
  58912. }
  58913. return serializationObject;
  58914. };
  58915. /**
  58916. * Clear the current graph and load a new one from a serialization object
  58917. * @param source defines the JSON representation of the material
  58918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58919. */
  58920. NodeMaterial.prototype.loadFromSerialization = function (source, rootUrl) {
  58921. if (rootUrl === void 0) { rootUrl = ""; }
  58922. this.clear();
  58923. var map = {};
  58924. // Create blocks
  58925. for (var _i = 0, _a = source.blocks; _i < _a.length; _i++) {
  58926. var parsedBlock = _a[_i];
  58927. var blockType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_17__["_TypeStore"].GetClass(parsedBlock.customType);
  58928. if (blockType) {
  58929. var block = new blockType();
  58930. block._deserialize(parsedBlock, this.getScene(), rootUrl);
  58931. map[parsedBlock.id] = block;
  58932. }
  58933. }
  58934. // Connections
  58935. // Play them in reverse to make sure types are defined
  58936. for (var blockIndex = source.blocks.length - 1; blockIndex >= 0; blockIndex--) {
  58937. var parsedBlock_1 = source.blocks[blockIndex];
  58938. var block = map[parsedBlock_1.id];
  58939. for (var _b = 0, _c = parsedBlock_1.inputs; _b < _c.length; _b++) {
  58940. var input = _c[_b];
  58941. if (!input.targetBlockId) {
  58942. continue;
  58943. }
  58944. var inputPoint = block.getInputByName(input.inputName);
  58945. var targetBlock = map[input.targetBlockId];
  58946. var outputPoint = targetBlock.getOutputByName(input.targetConnectionName);
  58947. if (inputPoint && outputPoint) {
  58948. outputPoint.connectTo(inputPoint);
  58949. }
  58950. }
  58951. }
  58952. // Outputs
  58953. for (var _d = 0, _e = source.outputNodes; _d < _e.length; _d++) {
  58954. var outputNodeId = _e[_d];
  58955. this.addOutputNode(map[outputNodeId]);
  58956. }
  58957. };
  58958. /**
  58959. * Creates a node material from parsed material data
  58960. * @param source defines the JSON representation of the material
  58961. * @param scene defines the hosting scene
  58962. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58963. * @returns a new node material
  58964. */
  58965. NodeMaterial.Parse = function (source, scene, rootUrl) {
  58966. if (rootUrl === void 0) { rootUrl = ""; }
  58967. var nodeMaterial = _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].Parse(function () { return new NodeMaterial(source.name, scene); }, source, scene, rootUrl);
  58968. nodeMaterial.loadFromSerialization(source, rootUrl);
  58969. return nodeMaterial;
  58970. };
  58971. /** Define the URl to load node editor script */
  58972. NodeMaterial.EditorURL = "https://unpkg.com/babylonjs-node-editor@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.nodeEditor.js";
  58973. return NodeMaterial;
  58974. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  58975. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_17__["_TypeStore"].RegisteredTypes["BABYLON.NodeMaterial"] = NodeMaterial;
  58976. /***/ }),
  58977. /***/ "./Materials/Node/nodeMaterialBlock.ts":
  58978. /*!*********************************************!*\
  58979. !*** ./Materials/Node/nodeMaterialBlock.ts ***!
  58980. \*********************************************/
  58981. /*! exports provided: NodeMaterialBlock */
  58982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58983. "use strict";
  58984. __webpack_require__.r(__webpack_exports__);
  58985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlock", function() { return NodeMaterialBlock; });
  58986. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  58987. /* harmony import */ var _nodeMaterialBlockConnectionPoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodeMaterialBlockConnectionPoint */ "./Materials/Node/nodeMaterialBlockConnectionPoint.ts");
  58988. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  58989. /* harmony import */ var _Misc_uniqueIdGenerator__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/uniqueIdGenerator */ "./Misc/uniqueIdGenerator.ts");
  58990. /**
  58991. * Defines a block that can be used inside a node based material
  58992. */
  58993. var NodeMaterialBlock = /** @class */ (function () {
  58994. /**
  58995. * Creates a new NodeMaterialBlock
  58996. * @param name defines the block name
  58997. * @param target defines the target of that block (Vertex by default)
  58998. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58999. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59000. */
  59001. function NodeMaterialBlock(name, target, isFinalMerger, isInput) {
  59002. if (target === void 0) { target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Vertex; }
  59003. if (isFinalMerger === void 0) { isFinalMerger = false; }
  59004. if (isInput === void 0) { isInput = false; }
  59005. this._isFinalMerger = false;
  59006. this._isInput = false;
  59007. /** @hidden */
  59008. this._inputs = new Array();
  59009. /** @hidden */
  59010. this._outputs = new Array();
  59011. this.name = name;
  59012. this._target = target;
  59013. this._isFinalMerger = isFinalMerger;
  59014. this._isInput = isInput;
  59015. this.uniqueId = _Misc_uniqueIdGenerator__WEBPACK_IMPORTED_MODULE_3__["UniqueIdGenerator"].UniqueId;
  59016. }
  59017. Object.defineProperty(NodeMaterialBlock.prototype, "isFinalMerger", {
  59018. /**
  59019. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59020. */
  59021. get: function () {
  59022. return this._isFinalMerger;
  59023. },
  59024. enumerable: true,
  59025. configurable: true
  59026. });
  59027. Object.defineProperty(NodeMaterialBlock.prototype, "isInput", {
  59028. /**
  59029. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59030. */
  59031. get: function () {
  59032. return this._isInput;
  59033. },
  59034. enumerable: true,
  59035. configurable: true
  59036. });
  59037. Object.defineProperty(NodeMaterialBlock.prototype, "buildId", {
  59038. /**
  59039. * Gets or sets the build Id
  59040. */
  59041. get: function () {
  59042. return this._buildId;
  59043. },
  59044. set: function (value) {
  59045. this._buildId = value;
  59046. },
  59047. enumerable: true,
  59048. configurable: true
  59049. });
  59050. Object.defineProperty(NodeMaterialBlock.prototype, "target", {
  59051. /**
  59052. * Gets or sets the target of the block
  59053. */
  59054. get: function () {
  59055. return this._target;
  59056. },
  59057. set: function (value) {
  59058. if ((this._target & value) !== 0) {
  59059. return;
  59060. }
  59061. this._target = value;
  59062. },
  59063. enumerable: true,
  59064. configurable: true
  59065. });
  59066. Object.defineProperty(NodeMaterialBlock.prototype, "inputs", {
  59067. /**
  59068. * Gets the list of input points
  59069. */
  59070. get: function () {
  59071. return this._inputs;
  59072. },
  59073. enumerable: true,
  59074. configurable: true
  59075. });
  59076. Object.defineProperty(NodeMaterialBlock.prototype, "outputs", {
  59077. /** Gets the list of output points */
  59078. get: function () {
  59079. return this._outputs;
  59080. },
  59081. enumerable: true,
  59082. configurable: true
  59083. });
  59084. /**
  59085. * Find an input by its name
  59086. * @param name defines the name of the input to look for
  59087. * @returns the input or null if not found
  59088. */
  59089. NodeMaterialBlock.prototype.getInputByName = function (name) {
  59090. var filter = this._inputs.filter(function (e) { return e.name === name; });
  59091. if (filter.length) {
  59092. return filter[0];
  59093. }
  59094. return null;
  59095. };
  59096. /**
  59097. * Find an output by its name
  59098. * @param name defines the name of the outputto look for
  59099. * @returns the output or null if not found
  59100. */
  59101. NodeMaterialBlock.prototype.getOutputByName = function (name) {
  59102. var filter = this._outputs.filter(function (e) { return e.name === name; });
  59103. if (filter.length) {
  59104. return filter[0];
  59105. }
  59106. return null;
  59107. };
  59108. /**
  59109. * Initialize the block and prepare the context for build
  59110. * @param state defines the state that will be used for the build
  59111. */
  59112. NodeMaterialBlock.prototype.initialize = function (state) {
  59113. // Do nothing
  59114. };
  59115. /**
  59116. * Bind data to effect. Will only be called for blocks with isBindable === true
  59117. * @param effect defines the effect to bind data to
  59118. * @param nodeMaterial defines the hosting NodeMaterial
  59119. * @param mesh defines the mesh that will be rendered
  59120. */
  59121. NodeMaterialBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
  59122. // Do nothing
  59123. };
  59124. NodeMaterialBlock.prototype._declareOutput = function (output, state) {
  59125. return state._getGLType(output.type) + " " + output.associatedVariableName;
  59126. };
  59127. NodeMaterialBlock.prototype._writeVariable = function (currentPoint) {
  59128. var connectionPoint = currentPoint.connectedPoint;
  59129. if (connectionPoint) {
  59130. return "" + currentPoint.associatedVariableName + (connectionPoint.swizzle ? "." + connectionPoint.swizzle : "");
  59131. }
  59132. return "0.";
  59133. };
  59134. NodeMaterialBlock.prototype._writeFloat = function (value) {
  59135. var stringVersion = value.toString();
  59136. if (stringVersion.indexOf(".") === -1) {
  59137. stringVersion += ".0";
  59138. }
  59139. return "" + stringVersion;
  59140. };
  59141. /**
  59142. * Gets the current class name e.g. "NodeMaterialBlock"
  59143. * @returns the class name
  59144. */
  59145. NodeMaterialBlock.prototype.getClassName = function () {
  59146. return "NodeMaterialBlock";
  59147. };
  59148. /**
  59149. * Register a new input. Must be called inside a block constructor
  59150. * @param name defines the connection point name
  59151. * @param type defines the connection point type
  59152. * @param isOptional defines a boolean indicating that this input can be omitted
  59153. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  59154. * @returns the current block
  59155. */
  59156. NodeMaterialBlock.prototype.registerInput = function (name, type, isOptional, target) {
  59157. if (isOptional === void 0) { isOptional = false; }
  59158. var point = new _nodeMaterialBlockConnectionPoint__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialConnectionPoint"](name, this);
  59159. point.type = type;
  59160. point.isOptional = isOptional;
  59161. if (target) {
  59162. point.target = target;
  59163. }
  59164. this._inputs.push(point);
  59165. return this;
  59166. };
  59167. /**
  59168. * Register a new output. Must be called inside a block constructor
  59169. * @param name defines the connection point name
  59170. * @param type defines the connection point type
  59171. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  59172. * @returns the current block
  59173. */
  59174. NodeMaterialBlock.prototype.registerOutput = function (name, type, target) {
  59175. var point = new _nodeMaterialBlockConnectionPoint__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialConnectionPoint"](name, this);
  59176. point.type = type;
  59177. if (target) {
  59178. point.target = target;
  59179. }
  59180. this._outputs.push(point);
  59181. return this;
  59182. };
  59183. /**
  59184. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59185. * @param forOutput defines an optional connection point to check compatibility with
  59186. * @returns the first available input or null
  59187. */
  59188. NodeMaterialBlock.prototype.getFirstAvailableInput = function (forOutput) {
  59189. if (forOutput === void 0) { forOutput = null; }
  59190. for (var _i = 0, _a = this._inputs; _i < _a.length; _i++) {
  59191. var input = _a[_i];
  59192. if (!input.connectedPoint) {
  59193. if (!forOutput || (forOutput.type & input.type) !== 0 || input.type === _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].AutoDetect) {
  59194. return input;
  59195. }
  59196. }
  59197. }
  59198. return null;
  59199. };
  59200. /**
  59201. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59202. * @param forBlock defines an optional block to check compatibility with
  59203. * @returns the first available input or null
  59204. */
  59205. NodeMaterialBlock.prototype.getFirstAvailableOutput = function (forBlock) {
  59206. if (forBlock === void 0) { forBlock = null; }
  59207. for (var _i = 0, _a = this._outputs; _i < _a.length; _i++) {
  59208. var output = _a[_i];
  59209. if (!forBlock || !forBlock.target || forBlock.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Neutral || (forBlock.target & output.target) !== 0) {
  59210. return output;
  59211. }
  59212. }
  59213. return null;
  59214. };
  59215. /**
  59216. * Connect current block with another block
  59217. * @param other defines the block to connect with
  59218. * @param options define the various options to help pick the right connections
  59219. * @returns the current block
  59220. */
  59221. NodeMaterialBlock.prototype.connectTo = function (other, options) {
  59222. if (this._outputs.length === 0) {
  59223. return;
  59224. }
  59225. var output = options && options.output ? this.getOutputByName(options.output) : this.getFirstAvailableOutput(other);
  59226. var input = options && options.input ? other.getInputByName(options.input) : other.getFirstAvailableInput(output);
  59227. if (output && input) {
  59228. output.swizzle = options ? options.outputSwizzle || "" : "";
  59229. output.connectTo(input);
  59230. }
  59231. else {
  59232. throw "Unable to find a compatible match";
  59233. }
  59234. return this;
  59235. };
  59236. NodeMaterialBlock.prototype._buildBlock = function (state) {
  59237. // Empty. Must be defined by child nodes
  59238. };
  59239. /**
  59240. * Add uniforms, samplers and uniform buffers at compilation time
  59241. * @param state defines the state to update
  59242. * @param nodeMaterial defines the node material requesting the update
  59243. * @param defines defines the material defines to update
  59244. */
  59245. NodeMaterialBlock.prototype.updateUniformsAndSamples = function (state, nodeMaterial, defines) {
  59246. // Do nothing
  59247. };
  59248. /**
  59249. * Add potential fallbacks if shader compilation fails
  59250. * @param mesh defines the mesh to be rendered
  59251. * @param fallbacks defines the current prioritized list of fallbacks
  59252. */
  59253. NodeMaterialBlock.prototype.provideFallbacks = function (mesh, fallbacks) {
  59254. // Do nothing
  59255. };
  59256. /**
  59257. * Update defines for shader compilation
  59258. * @param mesh defines the mesh to be rendered
  59259. * @param nodeMaterial defines the node material requesting the update
  59260. * @param defines defines the material defines to update
  59261. * @param useInstances specifies that instances should be used
  59262. */
  59263. NodeMaterialBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines, useInstances) {
  59264. if (useInstances === void 0) { useInstances = false; }
  59265. // Do nothing
  59266. };
  59267. /**
  59268. * Initialize defines for shader compilation
  59269. * @param mesh defines the mesh to be rendered
  59270. * @param nodeMaterial defines the node material requesting the update
  59271. * @param defines defines the material defines to be prepared
  59272. * @param useInstances specifies that instances should be used
  59273. */
  59274. NodeMaterialBlock.prototype.initializeDefines = function (mesh, nodeMaterial, defines, useInstances) {
  59275. if (useInstances === void 0) { useInstances = false; }
  59276. // Do nothing
  59277. };
  59278. /**
  59279. * Lets the block try to connect some inputs automatically
  59280. */
  59281. NodeMaterialBlock.prototype.autoConfigure = function () {
  59282. // Do nothing
  59283. };
  59284. /**
  59285. * Function called when a block is declared as repeatable content generator
  59286. * @param vertexShaderState defines the current compilation state for the vertex shader
  59287. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59288. * @param mesh defines the mesh to be rendered
  59289. * @param defines defines the material defines to update
  59290. */
  59291. NodeMaterialBlock.prototype.replaceRepeatableContent = function (vertexShaderState, fragmentShaderState, mesh, defines) {
  59292. // Do nothing
  59293. };
  59294. /**
  59295. * Checks if the block is ready
  59296. * @param mesh defines the mesh to be rendered
  59297. * @param nodeMaterial defines the node material requesting the update
  59298. * @param defines defines the material defines to update
  59299. * @param useInstances specifies that instances should be used
  59300. * @returns true if the block is ready
  59301. */
  59302. NodeMaterialBlock.prototype.isReady = function (mesh, nodeMaterial, defines, useInstances) {
  59303. if (useInstances === void 0) { useInstances = false; }
  59304. return true;
  59305. };
  59306. NodeMaterialBlock.prototype._processBuild = function (block, state, input) {
  59307. block.build(state);
  59308. if (state._vertexState && (block.target & this.target) === 0) { // context switch! We need a varying
  59309. if ((!block.isInput && state.target !== block._buildTarget) // block was already emitted by vertex shader
  59310. || (block.isInput && block.isAttribute) // block is an attribute
  59311. ) {
  59312. var connectedPoint = input.connectedPoint;
  59313. state._vertexState._emitVaryingFromString("v_" + connectedPoint.associatedVariableName, state._getGLType(connectedPoint.type));
  59314. state._vertexState.compilationString += "v_" + connectedPoint.associatedVariableName + " = " + connectedPoint.associatedVariableName + ";\r\n";
  59315. input.associatedVariableName = "v_" + connectedPoint.associatedVariableName;
  59316. input._enforceAssociatedVariableName = true;
  59317. }
  59318. }
  59319. };
  59320. /**
  59321. * Compile the current node and generate the shader code
  59322. * @param state defines the current compilation state (uniforms, samplers, current string)
  59323. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  59324. * @returns true if already built
  59325. */
  59326. NodeMaterialBlock.prototype.build = function (state, contextSwitched) {
  59327. if (contextSwitched === void 0) { contextSwitched = false; }
  59328. if (this._buildId === state.sharedData.buildId) {
  59329. return true;
  59330. }
  59331. // Check if "parent" blocks are compiled
  59332. for (var _i = 0, _a = this._inputs; _i < _a.length; _i++) {
  59333. var input = _a[_i];
  59334. if (!input.connectedPoint) {
  59335. if (!input.isOptional) { // Emit a warning
  59336. state.sharedData.checks.notConnectedNonOptionalInputs.push(input);
  59337. }
  59338. continue;
  59339. }
  59340. if (this.target !== _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Neutral) {
  59341. if ((input.target & this.target) === 0) {
  59342. continue;
  59343. }
  59344. if ((input.target & state.target) === 0) {
  59345. continue;
  59346. }
  59347. }
  59348. var block = input.connectedPoint.ownerBlock;
  59349. if (block && block !== this) {
  59350. this._processBuild(block, state, input);
  59351. }
  59352. }
  59353. if (this._buildId === state.sharedData.buildId) {
  59354. return true; // Need to check again as inputs can be connected multiple time to this endpoint
  59355. }
  59356. // Logs
  59357. if (state.sharedData.verbose) {
  59358. console.log((state.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Vertex ? "Vertex shader" : "Fragment shader") + ": Building " + this.name + " [" + this.getClassName() + "]");
  59359. }
  59360. if (!this.isInput) {
  59361. /** Prepare outputs */
  59362. for (var _b = 0, _c = this._outputs; _b < _c.length; _b++) {
  59363. var output = _c[_b];
  59364. if (this.target !== _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Neutral) {
  59365. if ((output.target & this.target) === 0) {
  59366. continue;
  59367. }
  59368. if ((output.target & state.target) === 0) {
  59369. continue;
  59370. }
  59371. }
  59372. if (!output.associatedVariableName) {
  59373. output.associatedVariableName = state._getFreeVariableName(output.name);
  59374. }
  59375. }
  59376. }
  59377. // Checks final outputs
  59378. if (this.isFinalMerger) {
  59379. switch (state.target) {
  59380. case _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Vertex:
  59381. state.sharedData.checks.emitVertex = true;
  59382. break;
  59383. case _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_2__["NodeMaterialBlockTargets"].Fragment:
  59384. state.sharedData.checks.emitFragment = true;
  59385. break;
  59386. }
  59387. }
  59388. if (!this.isInput && state.sharedData.emitComments) {
  59389. state.compilationString += "\r\n//" + this.name + "\r\n";
  59390. }
  59391. this._buildBlock(state);
  59392. this._buildId = state.sharedData.buildId;
  59393. this._buildTarget = state.target;
  59394. // Compile connected blocks
  59395. for (var _d = 0, _e = this._outputs; _d < _e.length; _d++) {
  59396. var output = _e[_d];
  59397. if ((output.target & state.target) === 0) {
  59398. continue;
  59399. }
  59400. for (var _f = 0, _g = output.endpoints; _f < _g.length; _f++) {
  59401. var endpoint = _g[_f];
  59402. var block = endpoint.ownerBlock;
  59403. if (block && (block.target & state.target) !== 0) {
  59404. this._processBuild(block, state, endpoint);
  59405. }
  59406. }
  59407. }
  59408. return false;
  59409. };
  59410. /**
  59411. * Serializes this block in a JSON representation
  59412. * @returns the serialized block object
  59413. */
  59414. NodeMaterialBlock.prototype.serialize = function () {
  59415. var serializationObject = {};
  59416. serializationObject.customType = "BABYLON." + this.getClassName();
  59417. serializationObject.id = this.uniqueId;
  59418. serializationObject.name = this.name;
  59419. serializationObject.inputs = [];
  59420. for (var _i = 0, _a = this.inputs; _i < _a.length; _i++) {
  59421. var input = _a[_i];
  59422. serializationObject.inputs.push(input.serialize());
  59423. }
  59424. return serializationObject;
  59425. };
  59426. /** @hidden */
  59427. NodeMaterialBlock.prototype._deserialize = function (serializationObject, scene, rootUrl) {
  59428. this.name = serializationObject.name;
  59429. };
  59430. return NodeMaterialBlock;
  59431. }());
  59432. /***/ }),
  59433. /***/ "./Materials/Node/nodeMaterialBlockConnectionPoint.ts":
  59434. /*!************************************************************!*\
  59435. !*** ./Materials/Node/nodeMaterialBlockConnectionPoint.ts ***!
  59436. \************************************************************/
  59437. /*! exports provided: NodeMaterialConnectionPoint */
  59438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59439. "use strict";
  59440. __webpack_require__.r(__webpack_exports__);
  59441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialConnectionPoint", function() { return NodeMaterialConnectionPoint; });
  59442. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  59443. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  59444. /**
  59445. * Defines a connection point for a block
  59446. */
  59447. var NodeMaterialConnectionPoint = /** @class */ (function () {
  59448. /**
  59449. * Creates a new connection point
  59450. * @param name defines the connection point name
  59451. * @param ownerBlock defines the block hosting this connection point
  59452. */
  59453. function NodeMaterialConnectionPoint(name, ownerBlock) {
  59454. /** @hidden */
  59455. this._connectedPoint = null;
  59456. this._endpoints = new Array();
  59457. /** @hidden */
  59458. this._typeConnectionSource = null;
  59459. this._type = _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Float;
  59460. /** @hidden */
  59461. this._enforceAssociatedVariableName = false;
  59462. /** Gets or sets the target of that connection point */
  59463. this.target = _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlockTargets"].VertexAndFragment;
  59464. this._ownerBlock = ownerBlock;
  59465. this.name = name;
  59466. }
  59467. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "associatedVariableName", {
  59468. /**
  59469. * Gets or sets the associated variable name in the shader
  59470. */
  59471. get: function () {
  59472. if (this._ownerBlock.isInput) {
  59473. return this._ownerBlock.associatedVariableName;
  59474. }
  59475. if (!this._enforceAssociatedVariableName && this._connectedPoint) {
  59476. return this._connectedPoint.associatedVariableName;
  59477. }
  59478. return this._associatedVariableName;
  59479. },
  59480. set: function (value) {
  59481. this._associatedVariableName = value;
  59482. },
  59483. enumerable: true,
  59484. configurable: true
  59485. });
  59486. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "type", {
  59487. /**
  59488. * Gets or sets the connection point type (default is float)
  59489. */
  59490. get: function () {
  59491. if (this._type === _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].AutoDetect) {
  59492. if (this._ownerBlock.isInput) {
  59493. return this._ownerBlock.type;
  59494. }
  59495. if (this._connectedPoint) {
  59496. return this._connectedPoint.type;
  59497. }
  59498. }
  59499. if (this._type === _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].BasedOnInput && this._typeConnectionSource) {
  59500. return this._typeConnectionSource.type;
  59501. }
  59502. return this._type;
  59503. },
  59504. set: function (value) {
  59505. this._type = value;
  59506. },
  59507. enumerable: true,
  59508. configurable: true
  59509. });
  59510. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "isConnected", {
  59511. /**
  59512. * Gets a boolean indicating that the current point is connected
  59513. */
  59514. get: function () {
  59515. return this.connectedPoint !== null;
  59516. },
  59517. enumerable: true,
  59518. configurable: true
  59519. });
  59520. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "isConnectedToInput", {
  59521. /**
  59522. * Gets a boolean indicating that the current point is connected to an input block
  59523. */
  59524. get: function () {
  59525. return this.connectedPoint !== null && this.connectedPoint.ownerBlock.isInput;
  59526. },
  59527. enumerable: true,
  59528. configurable: true
  59529. });
  59530. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "connectInputBlock", {
  59531. /**
  59532. * Gets a the connected input block (if any)
  59533. */
  59534. get: function () {
  59535. if (!this.isConnectedToInput) {
  59536. return null;
  59537. }
  59538. return this.connectedPoint.ownerBlock;
  59539. },
  59540. enumerable: true,
  59541. configurable: true
  59542. });
  59543. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "connectedPoint", {
  59544. /** Get the other side of the connection (if any) */
  59545. get: function () {
  59546. return this._connectedPoint;
  59547. },
  59548. enumerable: true,
  59549. configurable: true
  59550. });
  59551. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "ownerBlock", {
  59552. /** Get the block that owns this connection point */
  59553. get: function () {
  59554. return this._ownerBlock;
  59555. },
  59556. enumerable: true,
  59557. configurable: true
  59558. });
  59559. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "sourceBlock", {
  59560. /** Get the block connected on the other side of this connection (if any) */
  59561. get: function () {
  59562. if (!this._connectedPoint) {
  59563. return null;
  59564. }
  59565. return this._connectedPoint.ownerBlock;
  59566. },
  59567. enumerable: true,
  59568. configurable: true
  59569. });
  59570. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "connectedBlocks", {
  59571. /** Get the block connected on the endpoints of this connection (if any) */
  59572. get: function () {
  59573. if (this._endpoints.length === 0) {
  59574. return [];
  59575. }
  59576. return this._endpoints.map(function (e) { return e.ownerBlock; });
  59577. },
  59578. enumerable: true,
  59579. configurable: true
  59580. });
  59581. Object.defineProperty(NodeMaterialConnectionPoint.prototype, "endpoints", {
  59582. /** Gets the list of connected endpoints */
  59583. get: function () {
  59584. return this, this._endpoints;
  59585. },
  59586. enumerable: true,
  59587. configurable: true
  59588. });
  59589. /**
  59590. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59591. * @returns the class name
  59592. */
  59593. NodeMaterialConnectionPoint.prototype.getClassName = function () {
  59594. return "NodeMaterialConnectionPoint";
  59595. };
  59596. /**
  59597. * Gets an boolean indicating if the current point can be connected to another point
  59598. * @param connectionPoint defines the other connection point
  59599. * @returns true if the connection is possible
  59600. */
  59601. NodeMaterialConnectionPoint.prototype.canConnectTo = function (connectionPoint) {
  59602. if ((this.type & connectionPoint.type) === 0 && connectionPoint.type !== _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].AutoDetect) {
  59603. var fail = true;
  59604. // Check swizzle
  59605. if (this.swizzle) {
  59606. var swizzleLength = this.swizzle.length;
  59607. var connectionLength = NodeMaterialConnectionPoint._GetTypeLength(connectionPoint.type);
  59608. if (swizzleLength === connectionLength) {
  59609. fail = false;
  59610. }
  59611. }
  59612. return !fail;
  59613. }
  59614. return true;
  59615. };
  59616. /**
  59617. * Connect this point to another connection point
  59618. * @param connectionPoint defines the other connection point
  59619. * @returns the current connection point
  59620. */
  59621. NodeMaterialConnectionPoint.prototype.connectTo = function (connectionPoint) {
  59622. if (!this.canConnectTo(connectionPoint)) {
  59623. throw "Cannot connect two different connection types.";
  59624. }
  59625. this._endpoints.push(connectionPoint);
  59626. connectionPoint._connectedPoint = this;
  59627. this._enforceAssociatedVariableName = false;
  59628. return this;
  59629. };
  59630. /**
  59631. * Disconnect this point from one of his endpoint
  59632. * @param endpoint defines the other connection point
  59633. * @returns the current connection point
  59634. */
  59635. NodeMaterialConnectionPoint.prototype.disconnectFrom = function (endpoint) {
  59636. var index = this._endpoints.indexOf(endpoint);
  59637. if (index === -1) {
  59638. return this;
  59639. }
  59640. this._endpoints.splice(index, 1);
  59641. endpoint._connectedPoint = null;
  59642. this._enforceAssociatedVariableName = false;
  59643. return this;
  59644. };
  59645. /**
  59646. * Serializes this point in a JSON representation
  59647. * @returns the serialized point object
  59648. */
  59649. NodeMaterialConnectionPoint.prototype.serialize = function () {
  59650. var serializationObject = {};
  59651. serializationObject.name = this.name;
  59652. serializationObject.swizzle = this.swizzle;
  59653. if (this.connectedPoint) {
  59654. serializationObject.inputName = this.name;
  59655. serializationObject.targetBlockId = this.connectedPoint.ownerBlock.uniqueId;
  59656. serializationObject.targetConnectionName = this.connectedPoint.name;
  59657. }
  59658. return serializationObject;
  59659. };
  59660. // Statics
  59661. NodeMaterialConnectionPoint._GetTypeLength = function (type) {
  59662. switch (type) {
  59663. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Float:
  59664. return 1;
  59665. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector2:
  59666. return 2;
  59667. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector3:
  59668. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Color3:
  59669. return 3;
  59670. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector4:
  59671. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Color4:
  59672. return 3;
  59673. }
  59674. return -1;
  59675. };
  59676. return NodeMaterialConnectionPoint;
  59677. }());
  59678. /***/ }),
  59679. /***/ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts":
  59680. /*!*****************************************************************!*\
  59681. !*** ./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts ***!
  59682. \*****************************************************************/
  59683. /*! exports provided: NodeMaterialBlockConnectionPointTypes */
  59684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59685. "use strict";
  59686. __webpack_require__.r(__webpack_exports__);
  59687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockConnectionPointTypes", function() { return NodeMaterialBlockConnectionPointTypes; });
  59688. /**
  59689. * Defines the kind of connection point for node based material
  59690. */
  59691. var NodeMaterialBlockConnectionPointTypes;
  59692. (function (NodeMaterialBlockConnectionPointTypes) {
  59693. /** Float */
  59694. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Float"] = 1] = "Float";
  59695. /** Int */
  59696. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Int"] = 2] = "Int";
  59697. /** Vector2 */
  59698. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector2"] = 4] = "Vector2";
  59699. /** Vector3 */
  59700. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector3"] = 8] = "Vector3";
  59701. /** Vector4 */
  59702. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector4"] = 16] = "Vector4";
  59703. /** Color3 */
  59704. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Color3"] = 32] = "Color3";
  59705. /** Color4 */
  59706. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Color4"] = 64] = "Color4";
  59707. /** Matrix */
  59708. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Matrix"] = 128] = "Matrix";
  59709. /** Vector3 or Color3 */
  59710. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector3OrColor3"] = 40] = "Vector3OrColor3";
  59711. /** Vector3 or Vector4 */
  59712. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector3OrVector4"] = 24] = "Vector3OrVector4";
  59713. /** Vector4 or Color4 */
  59714. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector4OrColor4"] = 80] = "Vector4OrColor4";
  59715. /** Color3 or Color4 */
  59716. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Color3OrColor4"] = 96] = "Color3OrColor4";
  59717. /** Vector2 or Color3 or Color4 */
  59718. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector2OrColor3OrColor4"] = 100] = "Vector2OrColor3OrColor4";
  59719. /** Vector3 or Color3 or Color4 or Vector4 */
  59720. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector3OrColor3OrVector4OrColor4"] = 120] = "Vector3OrColor3OrVector4OrColor4";
  59721. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  59722. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["Vector2OrVector3OrColor3OrVector4OrColor4"] = 124] = "Vector2OrVector3OrColor3OrVector4OrColor4";
  59723. /** Detect type based on connection */
  59724. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["AutoDetect"] = 1024] = "AutoDetect";
  59725. /** Output type that will be defined by input type */
  59726. NodeMaterialBlockConnectionPointTypes[NodeMaterialBlockConnectionPointTypes["BasedOnInput"] = 2048] = "BasedOnInput";
  59727. })(NodeMaterialBlockConnectionPointTypes || (NodeMaterialBlockConnectionPointTypes = {}));
  59728. /***/ }),
  59729. /***/ "./Materials/Node/nodeMaterialBlockTargets.ts":
  59730. /*!****************************************************!*\
  59731. !*** ./Materials/Node/nodeMaterialBlockTargets.ts ***!
  59732. \****************************************************/
  59733. /*! exports provided: NodeMaterialBlockTargets */
  59734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59735. "use strict";
  59736. __webpack_require__.r(__webpack_exports__);
  59737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockTargets", function() { return NodeMaterialBlockTargets; });
  59738. /**
  59739. * Enum used to define the target of a block
  59740. */
  59741. var NodeMaterialBlockTargets;
  59742. (function (NodeMaterialBlockTargets) {
  59743. /** Vertex shader */
  59744. NodeMaterialBlockTargets[NodeMaterialBlockTargets["Vertex"] = 1] = "Vertex";
  59745. /** Fragment shader */
  59746. NodeMaterialBlockTargets[NodeMaterialBlockTargets["Fragment"] = 2] = "Fragment";
  59747. /** Neutral */
  59748. NodeMaterialBlockTargets[NodeMaterialBlockTargets["Neutral"] = 4] = "Neutral";
  59749. /** Vertex and Fragment */
  59750. NodeMaterialBlockTargets[NodeMaterialBlockTargets["VertexAndFragment"] = 3] = "VertexAndFragment";
  59751. })(NodeMaterialBlockTargets || (NodeMaterialBlockTargets = {}));
  59752. /***/ }),
  59753. /***/ "./Materials/Node/nodeMaterialBuildState.ts":
  59754. /*!**************************************************!*\
  59755. !*** ./Materials/Node/nodeMaterialBuildState.ts ***!
  59756. \**************************************************/
  59757. /*! exports provided: NodeMaterialBuildState */
  59758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59759. "use strict";
  59760. __webpack_require__.r(__webpack_exports__);
  59761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBuildState", function() { return NodeMaterialBuildState; });
  59762. /* harmony import */ var _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./nodeMaterialBlockConnectionPointTypes */ "./Materials/Node/nodeMaterialBlockConnectionPointTypes.ts");
  59763. /* harmony import */ var _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodeMaterialBlockTargets */ "./Materials/Node/nodeMaterialBlockTargets.ts");
  59764. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../effect */ "./Materials/effect.ts");
  59765. /**
  59766. * Class used to store node based material build state
  59767. */
  59768. var NodeMaterialBuildState = /** @class */ (function () {
  59769. function NodeMaterialBuildState() {
  59770. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  59771. this.supportUniformBuffers = false;
  59772. /**
  59773. * Gets the list of emitted attributes
  59774. */
  59775. this.attributes = new Array();
  59776. /**
  59777. * Gets the list of emitted uniforms
  59778. */
  59779. this.uniforms = new Array();
  59780. /**
  59781. * Gets the list of emitted uniform buffers
  59782. */
  59783. this.uniformBuffers = new Array();
  59784. /**
  59785. * Gets the list of emitted samplers
  59786. */
  59787. this.samplers = new Array();
  59788. /**
  59789. * Gets the list of emitted functions
  59790. */
  59791. this.functions = {};
  59792. /**
  59793. * Gets the list of emitted counters
  59794. */
  59795. this.counters = {};
  59796. /** @hidden */
  59797. this._attributeDeclaration = "";
  59798. /** @hidden */
  59799. this._uniformDeclaration = "";
  59800. /** @hidden */
  59801. this._samplerDeclaration = "";
  59802. /** @hidden */
  59803. this._varyingTransfer = "";
  59804. this._repeatableContentAnchorIndex = 0;
  59805. /** @hidden */
  59806. this._builtCompilationString = "";
  59807. /**
  59808. * Gets the emitted compilation strings
  59809. */
  59810. this.compilationString = "";
  59811. }
  59812. /**
  59813. * Finalize the compilation strings
  59814. * @param state defines the current compilation state
  59815. */
  59816. NodeMaterialBuildState.prototype.finalize = function (state) {
  59817. var emitComments = state.sharedData.emitComments;
  59818. var isFragmentMode = (this.target === _nodeMaterialBlockTargets__WEBPACK_IMPORTED_MODULE_1__["NodeMaterialBlockTargets"].Fragment);
  59819. this.compilationString = "\r\n" + (emitComments ? "//Entry point\r\n" : "") + "void main(void) {\r\n" + this.compilationString;
  59820. var functionCode = "";
  59821. for (var functionName in this.functions) {
  59822. functionCode += this.functions[functionName] + "\r\n";
  59823. }
  59824. this.compilationString = "\r\n" + functionCode + "\r\n" + this.compilationString;
  59825. if (!isFragmentMode && this._varyingTransfer) {
  59826. this.compilationString = this.compilationString + "\r\n" + this._varyingTransfer;
  59827. }
  59828. this.compilationString = this.compilationString + "\r\n}";
  59829. if (this.sharedData.varyingDeclaration) {
  59830. this.compilationString = "\r\n" + (emitComments ? "//Varyings\r\n" : "") + this.sharedData.varyingDeclaration + "\r\n" + this.compilationString;
  59831. }
  59832. if (this._samplerDeclaration) {
  59833. this.compilationString = "\r\n" + (emitComments ? "//Samplers\r\n" : "") + this._samplerDeclaration + "\r\n" + this.compilationString;
  59834. }
  59835. if (this._uniformDeclaration) {
  59836. this.compilationString = "\r\n" + (emitComments ? "//Uniforms\r\n" : "") + this._uniformDeclaration + "\r\n" + this.compilationString;
  59837. }
  59838. if (this._attributeDeclaration && !isFragmentMode) {
  59839. this.compilationString = "\r\n" + (emitComments ? "//Attributes\r\n" : "") + this._attributeDeclaration + "\r\n" + this.compilationString;
  59840. }
  59841. this._builtCompilationString = this.compilationString;
  59842. };
  59843. Object.defineProperty(NodeMaterialBuildState.prototype, "_repeatableContentAnchor", {
  59844. /** @hidden */
  59845. get: function () {
  59846. return "###___ANCHOR" + this._repeatableContentAnchorIndex++ + "___###";
  59847. },
  59848. enumerable: true,
  59849. configurable: true
  59850. });
  59851. /** @hidden */
  59852. NodeMaterialBuildState.prototype._getFreeVariableName = function (prefix) {
  59853. if (this.sharedData.variableNames[prefix] === undefined) {
  59854. this.sharedData.variableNames[prefix] = 0;
  59855. // Check reserved words
  59856. if (prefix === "output" || prefix === "texture") {
  59857. return prefix + this.sharedData.variableNames[prefix];
  59858. }
  59859. return prefix;
  59860. }
  59861. else {
  59862. this.sharedData.variableNames[prefix]++;
  59863. }
  59864. return prefix + this.sharedData.variableNames[prefix];
  59865. };
  59866. /** @hidden */
  59867. NodeMaterialBuildState.prototype._getFreeDefineName = function (prefix) {
  59868. if (this.sharedData.defineNames[prefix] === undefined) {
  59869. this.sharedData.defineNames[prefix] = 0;
  59870. }
  59871. else {
  59872. this.sharedData.defineNames[prefix]++;
  59873. }
  59874. return prefix + this.sharedData.defineNames[prefix];
  59875. };
  59876. /** @hidden */
  59877. NodeMaterialBuildState.prototype._excludeVariableName = function (name) {
  59878. this.sharedData.variableNames[name] = 0;
  59879. };
  59880. /** @hidden */
  59881. NodeMaterialBuildState.prototype._getGLType = function (type) {
  59882. switch (type) {
  59883. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Float:
  59884. return "float";
  59885. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Int:
  59886. return "int";
  59887. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector2:
  59888. return "vec2";
  59889. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Color3:
  59890. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector3:
  59891. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector3OrColor3:
  59892. return "vec3";
  59893. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Color4:
  59894. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector4:
  59895. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Vector4OrColor4:
  59896. return "vec4";
  59897. case _nodeMaterialBlockConnectionPointTypes__WEBPACK_IMPORTED_MODULE_0__["NodeMaterialBlockConnectionPointTypes"].Matrix:
  59898. return "mat4";
  59899. }
  59900. return "";
  59901. };
  59902. /** @hidden */
  59903. NodeMaterialBuildState.prototype._emitFunction = function (name, code, comments) {
  59904. if (this.functions[name]) {
  59905. return;
  59906. }
  59907. if (this.sharedData.emitComments) {
  59908. code = comments + "\r\n" + code;
  59909. }
  59910. this.functions[name] = code;
  59911. };
  59912. /** @hidden */
  59913. NodeMaterialBuildState.prototype._emitCodeFromInclude = function (includeName, comments, options) {
  59914. if (options && options.repeatKey) {
  59915. return "#include<" + includeName + ">[0.." + options.repeatKey + "]\r\n";
  59916. }
  59917. var code = _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"].IncludesShadersStore[includeName] + "\r\n";
  59918. if (this.sharedData.emitComments) {
  59919. code = comments + "\r\n" + code;
  59920. }
  59921. if (!options) {
  59922. return code;
  59923. }
  59924. if (options.replaceStrings) {
  59925. for (var index = 0; index < options.replaceStrings.length; index++) {
  59926. var replaceString = options.replaceStrings[index];
  59927. code = code.replace(replaceString.search, replaceString.replace);
  59928. }
  59929. }
  59930. return code;
  59931. };
  59932. /** @hidden */
  59933. NodeMaterialBuildState.prototype._emitFunctionFromInclude = function (includeName, comments, options, storeKey) {
  59934. if (storeKey === void 0) { storeKey = ""; }
  59935. var key = includeName + storeKey;
  59936. if (this.functions[key]) {
  59937. return;
  59938. }
  59939. if (!options || (!options.removeAttributes && !options.removeUniforms && !options.removeVaryings && !options.removeIfDef && !options.replaceStrings)) {
  59940. if (options && options.repeatKey) {
  59941. this.functions[key] = "#include<" + includeName + ">[0.." + options.repeatKey + "]\r\n";
  59942. }
  59943. else {
  59944. this.functions[key] = "#include<" + includeName + ">\r\n";
  59945. }
  59946. if (this.sharedData.emitComments) {
  59947. this.functions[key] = comments + "\r\n" + this.functions[key];
  59948. }
  59949. return;
  59950. }
  59951. this.functions[key] = _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"].IncludesShadersStore[includeName];
  59952. if (this.sharedData.emitComments) {
  59953. this.functions[key] = comments + "\r\n" + this.functions[key];
  59954. }
  59955. if (options.removeIfDef) {
  59956. this.functions[key] = this.functions[key].replace(/^\s*?#ifdef.+$/gm, "");
  59957. this.functions[key] = this.functions[key].replace(/^\s*?#endif.*$/gm, "");
  59958. this.functions[key] = this.functions[key].replace(/^\s*?#else.*$/gm, "");
  59959. this.functions[key] = this.functions[key].replace(/^\s*?#elif.*$/gm, "");
  59960. }
  59961. if (options.removeAttributes) {
  59962. this.functions[key] = this.functions[key].replace(/^\s*?attribute.+$/gm, "");
  59963. }
  59964. if (options.removeUniforms) {
  59965. this.functions[key] = this.functions[key].replace(/^\s*?uniform.+$/gm, "");
  59966. }
  59967. if (options.removeVaryings) {
  59968. this.functions[key] = this.functions[key].replace(/^\s*?varying.+$/gm, "");
  59969. }
  59970. if (options.replaceStrings) {
  59971. for (var index = 0; index < options.replaceStrings.length; index++) {
  59972. var replaceString = options.replaceStrings[index];
  59973. this.functions[key] = this.functions[key].replace(replaceString.search, replaceString.replace);
  59974. }
  59975. }
  59976. };
  59977. /** @hidden */
  59978. NodeMaterialBuildState.prototype._emitVaryingFromString = function (name, type, define, notDefine) {
  59979. if (define === void 0) { define = ""; }
  59980. if (notDefine === void 0) { notDefine = false; }
  59981. if (this.sharedData.varyings.indexOf(name) !== -1) {
  59982. return;
  59983. }
  59984. this.sharedData.varyings.push(name);
  59985. if (define) {
  59986. this.sharedData.varyingDeclaration += (notDefine ? "#ifndef" : "#ifdef") + " " + define + "\r\n";
  59987. }
  59988. this.sharedData.varyingDeclaration += "varying " + type + " " + name + ";\r\n";
  59989. if (define) {
  59990. this.sharedData.varyingDeclaration += "#endif\r\n";
  59991. }
  59992. };
  59993. /** @hidden */
  59994. NodeMaterialBuildState.prototype._emitUniformFromString = function (name, type, define, notDefine) {
  59995. if (define === void 0) { define = ""; }
  59996. if (notDefine === void 0) { notDefine = false; }
  59997. if (this.uniforms.indexOf(name) !== -1) {
  59998. return;
  59999. }
  60000. this.uniforms.push(name);
  60001. if (define) {
  60002. this._uniformDeclaration += (notDefine ? "#ifndef" : "#ifdef") + " " + define + "\r\n";
  60003. }
  60004. this._uniformDeclaration += "uniform " + type + " " + name + ";\r\n";
  60005. if (define) {
  60006. this._uniformDeclaration += "#endif\r\n";
  60007. }
  60008. };
  60009. return NodeMaterialBuildState;
  60010. }());
  60011. /***/ }),
  60012. /***/ "./Materials/Node/nodeMaterialBuildStateSharedData.ts":
  60013. /*!************************************************************!*\
  60014. !*** ./Materials/Node/nodeMaterialBuildStateSharedData.ts ***!
  60015. \************************************************************/
  60016. /*! exports provided: NodeMaterialBuildStateSharedData */
  60017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60018. "use strict";
  60019. __webpack_require__.r(__webpack_exports__);
  60020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBuildStateSharedData", function() { return NodeMaterialBuildStateSharedData; });
  60021. /**
  60022. * Class used to store shared data between 2 NodeMaterialBuildState
  60023. */
  60024. var NodeMaterialBuildStateSharedData = /** @class */ (function () {
  60025. /** Creates a new shared data */
  60026. function NodeMaterialBuildStateSharedData() {
  60027. /**
  60028. * Gets the list of emitted varyings
  60029. */
  60030. this.varyings = new Array();
  60031. /**
  60032. * Gets the varying declaration string
  60033. */
  60034. this.varyingDeclaration = "";
  60035. /**
  60036. * Input blocks
  60037. */
  60038. this.inputBlocks = new Array();
  60039. /**
  60040. * Input blocks
  60041. */
  60042. this.textureBlocks = new Array();
  60043. /**
  60044. * Bindable blocks (Blocks that need to set data to the effect)
  60045. */
  60046. this.bindableBlocks = new Array();
  60047. /**
  60048. * List of blocks that can provide a compilation fallback
  60049. */
  60050. this.blocksWithFallbacks = new Array();
  60051. /**
  60052. * List of blocks that can provide a define update
  60053. */
  60054. this.blocksWithDefines = new Array();
  60055. /**
  60056. * List of blocks that can provide a repeatable content
  60057. */
  60058. this.repeatableContentBlocks = new Array();
  60059. /**
  60060. * List of blocks that can provide a dynamic list of uniforms
  60061. */
  60062. this.dynamicUniformBlocks = new Array();
  60063. /**
  60064. * List of blocks that can block the isReady function for the material
  60065. */
  60066. this.blockingBlocks = new Array();
  60067. /** List of emitted variables */
  60068. this.variableNames = {};
  60069. /** List of emitted defines */
  60070. this.defineNames = {};
  60071. /**
  60072. * Gets the compilation hints emitted at compilation time
  60073. */
  60074. this.hints = {
  60075. needWorldViewMatrix: false,
  60076. needWorldViewProjectionMatrix: false,
  60077. needAlphaBlending: false,
  60078. needAlphaTesting: false
  60079. };
  60080. /**
  60081. * List of compilation checks
  60082. */
  60083. this.checks = {
  60084. emitVertex: false,
  60085. emitFragment: false,
  60086. notConnectedNonOptionalInputs: new Array()
  60087. };
  60088. // Exclude usual attributes from free variable names
  60089. this.variableNames["position"] = 0;
  60090. this.variableNames["normal"] = 0;
  60091. this.variableNames["tangent"] = 0;
  60092. this.variableNames["uv"] = 0;
  60093. this.variableNames["uv2"] = 0;
  60094. this.variableNames["uv3"] = 0;
  60095. this.variableNames["uv4"] = 0;
  60096. this.variableNames["uv4"] = 0;
  60097. this.variableNames["uv5"] = 0;
  60098. this.variableNames["uv6"] = 0;
  60099. this.variableNames["color"] = 0;
  60100. this.variableNames["matricesIndices"] = 0;
  60101. this.variableNames["matricesWeights"] = 0;
  60102. this.variableNames["matricesIndicesExtra"] = 0;
  60103. this.variableNames["matricesWeightsExtra"] = 0;
  60104. this.variableNames["diffuseBase"] = 0;
  60105. this.variableNames["specularBase"] = 0;
  60106. // Exclude defines
  60107. this.defineNames["MAINUV0"] = 0;
  60108. this.defineNames["MAINUV1"] = 0;
  60109. this.defineNames["MAINUV2"] = 0;
  60110. this.defineNames["MAINUV3"] = 0;
  60111. this.defineNames["MAINUV4"] = 0;
  60112. this.defineNames["MAINUV5"] = 0;
  60113. this.defineNames["MAINUV6"] = 0;
  60114. this.defineNames["MAINUV7"] = 0;
  60115. }
  60116. /**
  60117. * Emits console errors and exceptions if there is a failing check
  60118. */
  60119. NodeMaterialBuildStateSharedData.prototype.emitErrors = function () {
  60120. var errorMessage = "";
  60121. if (!this.checks.emitVertex) {
  60122. errorMessage += "NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r\n";
  60123. }
  60124. if (!this.checks.emitFragment) {
  60125. errorMessage += "NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r\n";
  60126. }
  60127. for (var _i = 0, _a = this.checks.notConnectedNonOptionalInputs; _i < _a.length; _i++) {
  60128. var notConnectedInput = _a[_i];
  60129. errorMessage += "input " + notConnectedInput.name + " from block " + notConnectedInput.ownerBlock.name + "[" + notConnectedInput.ownerBlock.getClassName() + "] is not connected and is not optional.\r\n";
  60130. }
  60131. if (errorMessage) {
  60132. throw "Build of NodeMaterial failed:\r\n" + errorMessage;
  60133. }
  60134. };
  60135. return NodeMaterialBuildStateSharedData;
  60136. }());
  60137. /***/ }),
  60138. /***/ "./Materials/Node/nodeMaterialWellKnownValues.ts":
  60139. /*!*******************************************************!*\
  60140. !*** ./Materials/Node/nodeMaterialWellKnownValues.ts ***!
  60141. \*******************************************************/
  60142. /*! exports provided: NodeMaterialWellKnownValues */
  60143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60144. "use strict";
  60145. __webpack_require__.r(__webpack_exports__);
  60146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialWellKnownValues", function() { return NodeMaterialWellKnownValues; });
  60147. /**
  60148. * Enum used to define well known values e.g. values automatically provided by the system
  60149. */
  60150. var NodeMaterialWellKnownValues;
  60151. (function (NodeMaterialWellKnownValues) {
  60152. /** World */
  60153. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["World"] = 1] = "World";
  60154. /** View */
  60155. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["View"] = 2] = "View";
  60156. /** Projection */
  60157. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["Projection"] = 3] = "Projection";
  60158. /** ViewProjection */
  60159. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["ViewProjection"] = 4] = "ViewProjection";
  60160. /** WorldView */
  60161. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["WorldView"] = 5] = "WorldView";
  60162. /** WorldViewProjection */
  60163. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["WorldViewProjection"] = 6] = "WorldViewProjection";
  60164. /** CameraPosition */
  60165. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["CameraPosition"] = 7] = "CameraPosition";
  60166. /** Fog Color */
  60167. NodeMaterialWellKnownValues[NodeMaterialWellKnownValues["FogColor"] = 8] = "FogColor";
  60168. })(NodeMaterialWellKnownValues || (NodeMaterialWellKnownValues = {}));
  60169. /***/ }),
  60170. /***/ "./Materials/PBR/index.ts":
  60171. /*!********************************!*\
  60172. !*** ./Materials/PBR/index.ts ***!
  60173. \********************************/
  60174. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  60175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60176. "use strict";
  60177. __webpack_require__.r(__webpack_exports__);
  60178. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  60179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  60180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  60181. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  60182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  60183. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  60184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  60185. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  60186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  60187. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  60188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  60189. /***/ }),
  60190. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  60191. /*!******************************************************!*\
  60192. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  60193. \******************************************************/
  60194. /*! exports provided: PBRAnisotropicConfiguration */
  60195. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60196. "use strict";
  60197. __webpack_require__.r(__webpack_exports__);
  60198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  60199. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60200. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60201. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  60202. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  60203. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  60204. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  60205. /**
  60206. * Define the code related to the anisotropic parameters of the pbr material.
  60207. */
  60208. var PBRAnisotropicConfiguration = /** @class */ (function () {
  60209. /**
  60210. * Instantiate a new istance of anisotropy configuration.
  60211. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  60212. */
  60213. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  60214. this._isEnabled = false;
  60215. /**
  60216. * Defines if the anisotropy is enabled in the material.
  60217. */
  60218. this.isEnabled = false;
  60219. /**
  60220. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  60221. */
  60222. this.intensity = 1;
  60223. /**
  60224. * Defines if the effect is along the tangents, bitangents or in between.
  60225. * By default, the effect is "strectching" the highlights along the tangents.
  60226. */
  60227. this.direction = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  60228. this._texture = null;
  60229. /**
  60230. * Stores the anisotropy values in a texture.
  60231. * rg is direction (like normal from -1 to 1)
  60232. * b is a intensity
  60233. */
  60234. this.texture = null;
  60235. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  60236. }
  60237. /** @hidden */
  60238. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  60239. this._internalMarkAllSubMeshesAsTexturesDirty();
  60240. };
  60241. /**
  60242. * Specifies that the submesh is ready to be used.
  60243. * @param defines the list of "defines" to update.
  60244. * @param scene defines the scene the material belongs to.
  60245. * @returns - boolean indicating that the submesh is ready or not.
  60246. */
  60247. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  60248. if (defines._areTexturesDirty) {
  60249. if (scene.texturesEnabled) {
  60250. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  60251. if (!this._texture.isReadyOrNotBlocking()) {
  60252. return false;
  60253. }
  60254. }
  60255. }
  60256. }
  60257. return true;
  60258. };
  60259. /**
  60260. * Checks to see if a texture is used in the material.
  60261. * @param defines the list of "defines" to update.
  60262. * @param mesh the mesh we are preparing the defines for.
  60263. * @param scene defines the scene the material belongs to.
  60264. */
  60265. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  60266. if (this._isEnabled) {
  60267. defines.ANISOTROPIC = this._isEnabled;
  60268. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  60269. defines._needUVs = true;
  60270. defines.MAINUV1 = true;
  60271. }
  60272. if (defines._areTexturesDirty) {
  60273. if (scene.texturesEnabled) {
  60274. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  60275. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  60276. }
  60277. else {
  60278. defines.ANISOTROPIC_TEXTURE = false;
  60279. }
  60280. }
  60281. }
  60282. }
  60283. else {
  60284. defines.ANISOTROPIC = false;
  60285. defines.ANISOTROPIC_TEXTURE = false;
  60286. }
  60287. };
  60288. /**
  60289. * Binds the material data.
  60290. * @param uniformBuffer defines the Uniform buffer to fill in.
  60291. * @param scene defines the scene the material belongs to.
  60292. * @param isFrozen defines wether the material is frozen or not.
  60293. */
  60294. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  60295. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  60296. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  60297. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  60298. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  60299. }
  60300. // Anisotropy
  60301. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  60302. }
  60303. // Textures
  60304. if (scene.texturesEnabled) {
  60305. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  60306. uniformBuffer.setTexture("anisotropySampler", this._texture);
  60307. }
  60308. }
  60309. };
  60310. /**
  60311. * Checks to see if a texture is used in the material.
  60312. * @param texture - Base texture to use.
  60313. * @returns - Boolean specifying if a texture is used in the material.
  60314. */
  60315. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  60316. if (this._texture === texture) {
  60317. return true;
  60318. }
  60319. return false;
  60320. };
  60321. /**
  60322. * Returns an array of the actively used textures.
  60323. * @param activeTextures Array of BaseTextures
  60324. */
  60325. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  60326. if (this._texture) {
  60327. activeTextures.push(this._texture);
  60328. }
  60329. };
  60330. /**
  60331. * Returns the animatable textures.
  60332. * @param animatables Array of animatable textures.
  60333. */
  60334. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  60335. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  60336. animatables.push(this._texture);
  60337. }
  60338. };
  60339. /**
  60340. * Disposes the resources of the material.
  60341. * @param forceDisposeTextures - Forces the disposal of all textures.
  60342. */
  60343. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  60344. if (forceDisposeTextures) {
  60345. if (this._texture) {
  60346. this._texture.dispose();
  60347. }
  60348. }
  60349. };
  60350. /**
  60351. * Get the current class name of the texture useful for serialization or dynamic coding.
  60352. * @returns "PBRAnisotropicConfiguration"
  60353. */
  60354. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  60355. return "PBRAnisotropicConfiguration";
  60356. };
  60357. /**
  60358. * Add fallbacks to the effect fallbacks list.
  60359. * @param defines defines the Base texture to use.
  60360. * @param fallbacks defines the current fallback list.
  60361. * @param currentRank defines the current fallback rank.
  60362. * @returns the new fallback rank.
  60363. */
  60364. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  60365. if (defines.ANISOTROPIC) {
  60366. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  60367. }
  60368. return currentRank;
  60369. };
  60370. /**
  60371. * Add the required uniforms to the current list.
  60372. * @param uniforms defines the current uniform list.
  60373. */
  60374. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  60375. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  60376. };
  60377. /**
  60378. * Add the required uniforms to the current buffer.
  60379. * @param uniformBuffer defines the current uniform buffer.
  60380. */
  60381. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  60382. uniformBuffer.addUniform("vAnisotropy", 3);
  60383. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  60384. uniformBuffer.addUniform("anisotropyMatrix", 16);
  60385. };
  60386. /**
  60387. * Add the required samplers to the current list.
  60388. * @param samplers defines the current sampler list.
  60389. */
  60390. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  60391. samplers.push("anisotropySampler");
  60392. };
  60393. /**
  60394. * Makes a duplicate of the current configuration into another one.
  60395. * @param anisotropicConfiguration define the config where to copy the info
  60396. */
  60397. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  60398. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  60399. };
  60400. /**
  60401. * Serializes this anisotropy configuration.
  60402. * @returns - An object with the serialized config.
  60403. */
  60404. PBRAnisotropicConfiguration.prototype.serialize = function () {
  60405. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60406. };
  60407. /**
  60408. * Parses a anisotropy Configuration from a serialized object.
  60409. * @param source - Serialized object.
  60410. * @param scene Defines the scene we are parsing for
  60411. * @param rootUrl Defines the rootUrl to load from
  60412. */
  60413. PBRAnisotropicConfiguration.prototype.parse = function (source, scene, rootUrl) {
  60414. var _this = this;
  60415. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, scene, rootUrl);
  60416. };
  60417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  60419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  60420. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  60421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60423. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  60424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  60426. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  60427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  60429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  60430. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  60431. return PBRAnisotropicConfiguration;
  60432. }());
  60433. /***/ }),
  60434. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  60435. /*!***********************************************!*\
  60436. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  60437. \***********************************************/
  60438. /*! exports provided: PBRBRDFConfiguration */
  60439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60440. "use strict";
  60441. __webpack_require__.r(__webpack_exports__);
  60442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  60443. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60444. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60445. /**
  60446. * Define the code related to the BRDF parameters of the pbr material.
  60447. */
  60448. var PBRBRDFConfiguration = /** @class */ (function () {
  60449. /**
  60450. * Instantiate a new istance of clear coat configuration.
  60451. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  60452. */
  60453. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  60454. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  60455. /**
  60456. * Defines if the material uses energy conservation.
  60457. */
  60458. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  60459. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  60460. /**
  60461. * LEGACY Mode set to false
  60462. * Defines if the material uses height smith correlated visibility term.
  60463. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  60464. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  60465. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  60466. * Not relying on height correlated will also disable energy conservation.
  60467. */
  60468. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  60469. this._useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;
  60470. /**
  60471. * LEGACY Mode set to false
  60472. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  60473. * diffuse part of the IBL.
  60474. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  60475. * to the ground truth.
  60476. */
  60477. this.useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;
  60478. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  60479. }
  60480. /** @hidden */
  60481. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  60482. this._internalMarkAllSubMeshesAsMiscDirty();
  60483. };
  60484. /**
  60485. * Checks to see if a texture is used in the material.
  60486. * @param defines the list of "defines" to update.
  60487. */
  60488. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  60489. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  60490. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  60491. defines.SPHERICAL_HARMONICS = this._useSphericalHarmonics;
  60492. };
  60493. /**
  60494. * Get the current class name of the texture useful for serialization or dynamic coding.
  60495. * @returns "PBRClearCoatConfiguration"
  60496. */
  60497. PBRBRDFConfiguration.prototype.getClassName = function () {
  60498. return "PBRBRDFConfiguration";
  60499. };
  60500. /**
  60501. * Makes a duplicate of the current configuration into another one.
  60502. * @param brdfConfiguration define the config where to copy the info
  60503. */
  60504. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  60505. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  60506. };
  60507. /**
  60508. * Serializes this BRDF configuration.
  60509. * @returns - An object with the serialized config.
  60510. */
  60511. PBRBRDFConfiguration.prototype.serialize = function () {
  60512. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60513. };
  60514. /**
  60515. * Parses a anisotropy Configuration from a serialized object.
  60516. * @param source - Serialized object.
  60517. * @param scene Defines the scene we are parsing for
  60518. * @param rootUrl Defines the rootUrl to load from
  60519. */
  60520. PBRBRDFConfiguration.prototype.parse = function (source, scene, rootUrl) {
  60521. var _this = this;
  60522. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, scene, rootUrl);
  60523. };
  60524. /**
  60525. * Default value used for the energy conservation.
  60526. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  60527. */
  60528. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  60529. /**
  60530. * Default value used for the Smith Visibility Height Correlated mode.
  60531. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  60532. */
  60533. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  60534. /**
  60535. * Default value used for the IBL diffuse part.
  60536. * This can help switching back to the polynomials mode globally which is a tiny bit
  60537. * less GPU intensive at the drawback of a lower quality.
  60538. */
  60539. PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS = true;
  60540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  60542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  60543. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  60544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  60546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  60547. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  60548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  60550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  60551. ], PBRBRDFConfiguration.prototype, "useSphericalHarmonics", void 0);
  60552. return PBRBRDFConfiguration;
  60553. }());
  60554. /***/ }),
  60555. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  60556. /*!******************************************!*\
  60557. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  60558. \******************************************/
  60559. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial */
  60560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60561. "use strict";
  60562. __webpack_require__.r(__webpack_exports__);
  60563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return PBRMaterialDefines; });
  60564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  60565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60566. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60567. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  60568. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  60569. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  60570. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  60571. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  60572. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  60573. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  60574. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  60575. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  60576. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  60577. /* harmony import */ var _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./pbrSubSurfaceConfiguration */ "./Materials/PBR/pbrSubSurfaceConfiguration.ts");
  60578. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  60579. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  60580. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  60581. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  60582. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  60583. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  60584. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60585. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  60586. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60587. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  60588. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  60589. /**
  60590. * Manages the defines for the PBR Material.
  60591. * @hidden
  60592. */
  60593. var PBRMaterialDefines = /** @class */ (function (_super) {
  60594. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  60595. /**
  60596. * Initializes the PBR Material defines.
  60597. */
  60598. function PBRMaterialDefines() {
  60599. var _this = _super.call(this) || this;
  60600. _this.PBR = true;
  60601. _this.MAINUV1 = false;
  60602. _this.MAINUV2 = false;
  60603. _this.UV1 = false;
  60604. _this.UV2 = false;
  60605. _this.ALBEDO = false;
  60606. _this.ALBEDODIRECTUV = 0;
  60607. _this.VERTEXCOLOR = false;
  60608. _this.AMBIENT = false;
  60609. _this.AMBIENTDIRECTUV = 0;
  60610. _this.AMBIENTINGRAYSCALE = false;
  60611. _this.OPACITY = false;
  60612. _this.VERTEXALPHA = false;
  60613. _this.OPACITYDIRECTUV = 0;
  60614. _this.OPACITYRGB = false;
  60615. _this.ALPHATEST = false;
  60616. _this.DEPTHPREPASS = false;
  60617. _this.ALPHABLEND = false;
  60618. _this.ALPHAFROMALBEDO = false;
  60619. _this.ALPHATESTVALUE = "0.5";
  60620. _this.SPECULAROVERALPHA = false;
  60621. _this.RADIANCEOVERALPHA = false;
  60622. _this.ALPHAFRESNEL = false;
  60623. _this.LINEARALPHAFRESNEL = false;
  60624. _this.PREMULTIPLYALPHA = false;
  60625. _this.EMISSIVE = false;
  60626. _this.EMISSIVEDIRECTUV = 0;
  60627. _this.REFLECTIVITY = false;
  60628. _this.REFLECTIVITYDIRECTUV = 0;
  60629. _this.SPECULARTERM = false;
  60630. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  60631. _this.MICROSURFACEAUTOMATIC = false;
  60632. _this.LODBASEDMICROSFURACE = false;
  60633. _this.MICROSURFACEMAP = false;
  60634. _this.MICROSURFACEMAPDIRECTUV = 0;
  60635. _this.METALLICWORKFLOW = false;
  60636. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  60637. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  60638. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  60639. _this.AOSTOREINMETALMAPRED = false;
  60640. _this.ENVIRONMENTBRDF = false;
  60641. _this.ENVIRONMENTBRDF_RGBD = false;
  60642. _this.NORMAL = false;
  60643. _this.TANGENT = false;
  60644. _this.BUMP = false;
  60645. _this.BUMPDIRECTUV = 0;
  60646. _this.OBJECTSPACE_NORMALMAP = false;
  60647. _this.PARALLAX = false;
  60648. _this.PARALLAXOCCLUSION = false;
  60649. _this.NORMALXYSCALE = true;
  60650. _this.LIGHTMAP = false;
  60651. _this.LIGHTMAPDIRECTUV = 0;
  60652. _this.USELIGHTMAPASSHADOWMAP = false;
  60653. _this.GAMMALIGHTMAP = false;
  60654. _this.REFLECTION = false;
  60655. _this.REFLECTIONMAP_3D = false;
  60656. _this.REFLECTIONMAP_SPHERICAL = false;
  60657. _this.REFLECTIONMAP_PLANAR = false;
  60658. _this.REFLECTIONMAP_CUBIC = false;
  60659. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  60660. _this.REFLECTIONMAP_PROJECTION = false;
  60661. _this.REFLECTIONMAP_SKYBOX = false;
  60662. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  60663. _this.REFLECTIONMAP_EXPLICIT = false;
  60664. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  60665. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  60666. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  60667. _this.INVERTCUBICMAP = false;
  60668. _this.USESPHERICALFROMREFLECTIONMAP = false;
  60669. _this.USEIRRADIANCEMAP = false;
  60670. _this.SPHERICAL_HARMONICS = false;
  60671. _this.USESPHERICALINVERTEX = false;
  60672. _this.REFLECTIONMAP_OPPOSITEZ = false;
  60673. _this.LODINREFLECTIONALPHA = false;
  60674. _this.GAMMAREFLECTION = false;
  60675. _this.RGBDREFLECTION = false;
  60676. _this.LINEARSPECULARREFLECTION = false;
  60677. _this.RADIANCEOCCLUSION = false;
  60678. _this.HORIZONOCCLUSION = false;
  60679. _this.INSTANCES = false;
  60680. _this.NUM_BONE_INFLUENCERS = 0;
  60681. _this.BonesPerMesh = 0;
  60682. _this.BONETEXTURE = false;
  60683. _this.NONUNIFORMSCALING = false;
  60684. _this.MORPHTARGETS = false;
  60685. _this.MORPHTARGETS_NORMAL = false;
  60686. _this.MORPHTARGETS_TANGENT = false;
  60687. _this.MORPHTARGETS_UV = false;
  60688. _this.NUM_MORPH_INFLUENCERS = 0;
  60689. _this.IMAGEPROCESSING = false;
  60690. _this.VIGNETTE = false;
  60691. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  60692. _this.VIGNETTEBLENDMODEOPAQUE = false;
  60693. _this.TONEMAPPING = false;
  60694. _this.TONEMAPPING_ACES = false;
  60695. _this.CONTRAST = false;
  60696. _this.COLORCURVES = false;
  60697. _this.COLORGRADING = false;
  60698. _this.COLORGRADING3D = false;
  60699. _this.SAMPLER3DGREENDEPTH = false;
  60700. _this.SAMPLER3DBGRMAP = false;
  60701. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  60702. _this.EXPOSURE = false;
  60703. _this.MULTIVIEW = false;
  60704. _this.USEPHYSICALLIGHTFALLOFF = false;
  60705. _this.USEGLTFLIGHTFALLOFF = false;
  60706. _this.TWOSIDEDLIGHTING = false;
  60707. _this.SHADOWFLOAT = false;
  60708. _this.CLIPPLANE = false;
  60709. _this.CLIPPLANE2 = false;
  60710. _this.CLIPPLANE3 = false;
  60711. _this.CLIPPLANE4 = false;
  60712. _this.POINTSIZE = false;
  60713. _this.FOG = false;
  60714. _this.LOGARITHMICDEPTH = false;
  60715. _this.FORCENORMALFORWARD = false;
  60716. _this.SPECULARAA = false;
  60717. _this.CLEARCOAT = false;
  60718. _this.CLEARCOAT_DEFAULTIOR = false;
  60719. _this.CLEARCOAT_TEXTURE = false;
  60720. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  60721. _this.CLEARCOAT_BUMP = false;
  60722. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  60723. _this.CLEARCOAT_TINT = false;
  60724. _this.CLEARCOAT_TINT_TEXTURE = false;
  60725. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  60726. _this.ANISOTROPIC = false;
  60727. _this.ANISOTROPIC_TEXTURE = false;
  60728. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  60729. _this.BRDF_V_HEIGHT_CORRELATED = false;
  60730. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  60731. _this.SHEEN = false;
  60732. _this.SHEEN_TEXTURE = false;
  60733. _this.SHEEN_TEXTUREDIRECTUV = 0;
  60734. _this.SHEEN_LINKWITHALBEDO = false;
  60735. _this.SUBSURFACE = false;
  60736. _this.SS_REFRACTION = false;
  60737. _this.SS_TRANSLUCENCY = false;
  60738. _this.SS_SCATERRING = false;
  60739. _this.SS_THICKNESSANDMASK_TEXTURE = false;
  60740. _this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0;
  60741. _this.SS_REFRACTIONMAP_3D = false;
  60742. _this.SS_REFRACTIONMAP_OPPOSITEZ = false;
  60743. _this.SS_LODINREFRACTIONALPHA = false;
  60744. _this.SS_GAMMAREFRACTION = false;
  60745. _this.SS_RGBDREFRACTION = false;
  60746. _this.SS_LINEARSPECULARREFRACTION = false;
  60747. _this.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  60748. _this.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  60749. _this.UNLIT = false;
  60750. _this.DEBUGMODE = 0;
  60751. _this.rebuild();
  60752. return _this;
  60753. }
  60754. /**
  60755. * Resets the PBR Material defines.
  60756. */
  60757. PBRMaterialDefines.prototype.reset = function () {
  60758. _super.prototype.reset.call(this);
  60759. this.ALPHATESTVALUE = "0.5";
  60760. this.PBR = true;
  60761. };
  60762. return PBRMaterialDefines;
  60763. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_16__["MaterialDefines"]));
  60764. /**
  60765. * The Physically based material base class of BJS.
  60766. *
  60767. * This offers the main features of a standard PBR material.
  60768. * For more information, please refer to the documentation :
  60769. * https://doc.babylonjs.com/how_to/physically_based_rendering
  60770. */
  60771. var PBRBaseMaterial = /** @class */ (function (_super) {
  60772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  60773. /**
  60774. * Instantiates a new PBRMaterial instance.
  60775. *
  60776. * @param name The material name
  60777. * @param scene The scene the material will be use in.
  60778. */
  60779. function PBRBaseMaterial(name, scene) {
  60780. var _this = _super.call(this, name, scene) || this;
  60781. /**
  60782. * Intensity of the direct lights e.g. the four lights available in your scene.
  60783. * This impacts both the direct diffuse and specular highlights.
  60784. */
  60785. _this._directIntensity = 1.0;
  60786. /**
  60787. * Intensity of the emissive part of the material.
  60788. * This helps controlling the emissive effect without modifying the emissive color.
  60789. */
  60790. _this._emissiveIntensity = 1.0;
  60791. /**
  60792. * Intensity of the environment e.g. how much the environment will light the object
  60793. * either through harmonics for rough material or through the refelction for shiny ones.
  60794. */
  60795. _this._environmentIntensity = 1.0;
  60796. /**
  60797. * This is a special control allowing the reduction of the specular highlights coming from the
  60798. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  60799. */
  60800. _this._specularIntensity = 1.0;
  60801. /**
  60802. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  60803. */
  60804. _this._lightingInfos = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  60805. /**
  60806. * Debug Control allowing disabling the bump map on this material.
  60807. */
  60808. _this._disableBumpMap = false;
  60809. /**
  60810. * AKA Diffuse Texture in standard nomenclature.
  60811. */
  60812. _this._albedoTexture = null;
  60813. /**
  60814. * AKA Occlusion Texture in other nomenclature.
  60815. */
  60816. _this._ambientTexture = null;
  60817. /**
  60818. * AKA Occlusion Texture Intensity in other nomenclature.
  60819. */
  60820. _this._ambientTextureStrength = 1.0;
  60821. /**
  60822. * Defines how much the AO map is occluding the analytical lights (point spot...).
  60823. * 1 means it completely occludes it
  60824. * 0 mean it has no impact
  60825. */
  60826. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  60827. /**
  60828. * Stores the alpha values in a texture.
  60829. */
  60830. _this._opacityTexture = null;
  60831. /**
  60832. * Stores the reflection values in a texture.
  60833. */
  60834. _this._reflectionTexture = null;
  60835. /**
  60836. * Stores the emissive values in a texture.
  60837. */
  60838. _this._emissiveTexture = null;
  60839. /**
  60840. * AKA Specular texture in other nomenclature.
  60841. */
  60842. _this._reflectivityTexture = null;
  60843. /**
  60844. * Used to switch from specular/glossiness to metallic/roughness workflow.
  60845. */
  60846. _this._metallicTexture = null;
  60847. /**
  60848. * Specifies the metallic scalar of the metallic/roughness workflow.
  60849. * Can also be used to scale the metalness values of the metallic texture.
  60850. */
  60851. _this._metallic = null;
  60852. /**
  60853. * Specifies the roughness scalar of the metallic/roughness workflow.
  60854. * Can also be used to scale the roughness values of the metallic texture.
  60855. */
  60856. _this._roughness = null;
  60857. /**
  60858. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  60859. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  60860. */
  60861. _this._microSurfaceTexture = null;
  60862. /**
  60863. * Stores surface normal data used to displace a mesh in a texture.
  60864. */
  60865. _this._bumpTexture = null;
  60866. /**
  60867. * Stores the pre-calculated light information of a mesh in a texture.
  60868. */
  60869. _this._lightmapTexture = null;
  60870. /**
  60871. * The color of a material in ambient lighting.
  60872. */
  60873. _this._ambientColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"](0, 0, 0);
  60874. /**
  60875. * AKA Diffuse Color in other nomenclature.
  60876. */
  60877. _this._albedoColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"](1, 1, 1);
  60878. /**
  60879. * AKA Specular Color in other nomenclature.
  60880. */
  60881. _this._reflectivityColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"](1, 1, 1);
  60882. /**
  60883. * The color applied when light is reflected from a material.
  60884. */
  60885. _this._reflectionColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"](1, 1, 1);
  60886. /**
  60887. * The color applied when light is emitted from a material.
  60888. */
  60889. _this._emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"](0, 0, 0);
  60890. /**
  60891. * AKA Glossiness in other nomenclature.
  60892. */
  60893. _this._microSurface = 0.9;
  60894. /**
  60895. * Specifies that the material will use the light map as a show map.
  60896. */
  60897. _this._useLightmapAsShadowmap = false;
  60898. /**
  60899. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60900. * makes the reflect vector face the model (under horizon).
  60901. */
  60902. _this._useHorizonOcclusion = true;
  60903. /**
  60904. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60905. * too much the area relying on ambient texture to define their ambient occlusion.
  60906. */
  60907. _this._useRadianceOcclusion = true;
  60908. /**
  60909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  60910. */
  60911. _this._useAlphaFromAlbedoTexture = false;
  60912. /**
  60913. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  60914. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  60915. */
  60916. _this._useSpecularOverAlpha = true;
  60917. /**
  60918. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  60919. */
  60920. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  60921. /**
  60922. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  60923. */
  60924. _this._useRoughnessFromMetallicTextureAlpha = true;
  60925. /**
  60926. * Specifies if the metallic texture contains the roughness information in its green channel.
  60927. */
  60928. _this._useRoughnessFromMetallicTextureGreen = false;
  60929. /**
  60930. * Specifies if the metallic texture contains the metallness information in its blue channel.
  60931. */
  60932. _this._useMetallnessFromMetallicTextureBlue = false;
  60933. /**
  60934. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60935. */
  60936. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  60937. /**
  60938. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60939. */
  60940. _this._useAmbientInGrayScale = false;
  60941. /**
  60942. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60943. * The material will try to infer what glossiness each pixel should be.
  60944. */
  60945. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  60946. /**
  60947. * Defines the falloff type used in this material.
  60948. * It by default is Physical.
  60949. */
  60950. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  60951. /**
  60952. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60953. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60954. */
  60955. _this._useRadianceOverAlpha = true;
  60956. /**
  60957. * Allows using an object space normal map (instead of tangent space).
  60958. */
  60959. _this._useObjectSpaceNormalMap = false;
  60960. /**
  60961. * Allows using the bump map in parallax mode.
  60962. */
  60963. _this._useParallax = false;
  60964. /**
  60965. * Allows using the bump map in parallax occlusion mode.
  60966. */
  60967. _this._useParallaxOcclusion = false;
  60968. /**
  60969. * Controls the scale bias of the parallax mode.
  60970. */
  60971. _this._parallaxScaleBias = 0.05;
  60972. /**
  60973. * If sets to true, disables all the lights affecting the material.
  60974. */
  60975. _this._disableLighting = false;
  60976. /**
  60977. * Number of Simultaneous lights allowed on the material.
  60978. */
  60979. _this._maxSimultaneousLights = 4;
  60980. /**
  60981. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  60982. */
  60983. _this._invertNormalMapX = false;
  60984. /**
  60985. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  60986. */
  60987. _this._invertNormalMapY = false;
  60988. /**
  60989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60990. */
  60991. _this._twoSidedLighting = false;
  60992. /**
  60993. * Defines the alpha limits in alpha test mode.
  60994. */
  60995. _this._alphaCutOff = 0.4;
  60996. /**
  60997. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  60998. */
  60999. _this._forceAlphaTest = false;
  61000. /**
  61001. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  61002. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  61003. */
  61004. _this._useAlphaFresnel = false;
  61005. /**
  61006. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  61007. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  61008. */
  61009. _this._useLinearAlphaFresnel = false;
  61010. /**
  61011. * The transparency mode of the material.
  61012. */
  61013. _this._transparencyMode = null;
  61014. /**
  61015. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  61016. * from cos thetav and roughness:
  61017. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  61018. */
  61019. _this._environmentBRDFTexture = null;
  61020. /**
  61021. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  61022. */
  61023. _this._forceIrradianceInFragment = false;
  61024. /**
  61025. * Force normal to face away from face.
  61026. */
  61027. _this._forceNormalForward = false;
  61028. /**
  61029. * Enables specular anti aliasing in the PBR shader.
  61030. * It will both interacts on the Geometry for analytical and IBL lighting.
  61031. * It also prefilter the roughness map based on the bump values.
  61032. */
  61033. _this._enableSpecularAntiAliasing = false;
  61034. /**
  61035. * Keep track of the image processing observer to allow dispose and replace.
  61036. */
  61037. _this._imageProcessingObserver = null;
  61038. /**
  61039. * Stores the available render targets.
  61040. */
  61041. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  61042. /**
  61043. * Sets the global ambient color for the material used in lighting calculations.
  61044. */
  61045. _this._globalAmbientColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"](0, 0, 0);
  61046. /**
  61047. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  61048. */
  61049. _this._useLogarithmicDepth = false;
  61050. /**
  61051. * If set to true, no lighting calculations will be applied.
  61052. */
  61053. _this._unlit = false;
  61054. _this._debugMode = 0;
  61055. /**
  61056. * @hidden
  61057. * This is reserved for the inspector.
  61058. * Defines the material debug mode.
  61059. * It helps seeing only some components of the material while troubleshooting.
  61060. */
  61061. _this.debugMode = 0;
  61062. /**
  61063. * @hidden
  61064. * This is reserved for the inspector.
  61065. * Specify from where on screen the debug mode should start.
  61066. * The value goes from -1 (full screen) to 1 (not visible)
  61067. * It helps with side by side comparison against the final render
  61068. * This defaults to -1
  61069. */
  61070. _this.debugLimit = -1;
  61071. /**
  61072. * @hidden
  61073. * This is reserved for the inspector.
  61074. * As the default viewing range might not be enough (if the ambient is really small for instance)
  61075. * You can use the factor to better multiply the final value.
  61076. */
  61077. _this.debugFactor = 1;
  61078. /**
  61079. * Defines the clear coat layer parameters for the material.
  61080. */
  61081. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  61082. /**
  61083. * Defines the anisotropic parameters for the material.
  61084. */
  61085. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  61086. /**
  61087. * Defines the BRDF parameters for the material.
  61088. */
  61089. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  61090. /**
  61091. * Defines the Sheen parameters for the material.
  61092. */
  61093. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  61094. /**
  61095. * Defines the SubSurface parameters for the material.
  61096. */
  61097. _this.subSurface = new _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  61098. // Setup the default processing configuration to the scene.
  61099. _this._attachImageProcessingConfiguration(null);
  61100. _this.getRenderTargetTextures = function () {
  61101. _this._renderTargets.reset();
  61102. if (_materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  61103. _this._renderTargets.push(_this._reflectionTexture);
  61104. }
  61105. _this.subSurface.fillRenderTargetTextures(_this._renderTargets);
  61106. return _this._renderTargets;
  61107. };
  61108. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  61109. return _this;
  61110. }
  61111. /**
  61112. * Attaches a new image processing configuration to the PBR Material.
  61113. * @param configuration
  61114. */
  61115. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  61116. var _this = this;
  61117. if (configuration === this._imageProcessingConfiguration) {
  61118. return;
  61119. }
  61120. // Detaches observer.
  61121. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  61122. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  61123. }
  61124. // Pick the scene configuration if needed.
  61125. if (!configuration) {
  61126. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  61127. }
  61128. else {
  61129. this._imageProcessingConfiguration = configuration;
  61130. }
  61131. // Attaches observer.
  61132. if (this._imageProcessingConfiguration) {
  61133. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  61134. _this._markAllSubMeshesAsImageProcessingDirty();
  61135. });
  61136. }
  61137. };
  61138. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  61139. /**
  61140. * Gets a boolean indicating that current material needs to register RTT
  61141. */
  61142. get: function () {
  61143. if (_materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  61144. return true;
  61145. }
  61146. return this.subSurface.hasRenderTargetTextures();
  61147. },
  61148. enumerable: true,
  61149. configurable: true
  61150. });
  61151. /**
  61152. * Gets the name of the material class.
  61153. */
  61154. PBRBaseMaterial.prototype.getClassName = function () {
  61155. return "PBRBaseMaterial";
  61156. };
  61157. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  61158. /**
  61159. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  61160. */
  61161. get: function () {
  61162. return this._useLogarithmicDepth;
  61163. },
  61164. /**
  61165. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  61166. */
  61167. set: function (value) {
  61168. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  61169. },
  61170. enumerable: true,
  61171. configurable: true
  61172. });
  61173. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  61174. /**
  61175. * Gets the current transparency mode.
  61176. */
  61177. get: function () {
  61178. return this._transparencyMode;
  61179. },
  61180. /**
  61181. * Sets the transparency mode of the material.
  61182. *
  61183. * | Value | Type | Description |
  61184. * | ----- | ----------------------------------- | ----------- |
  61185. * | 0 | OPAQUE | |
  61186. * | 1 | ALPHATEST | |
  61187. * | 2 | ALPHABLEND | |
  61188. * | 3 | ALPHATESTANDBLEND | |
  61189. *
  61190. */
  61191. set: function (value) {
  61192. if (this._transparencyMode === value) {
  61193. return;
  61194. }
  61195. this._transparencyMode = value;
  61196. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  61197. this._markAllSubMeshesAsTexturesAndMiscDirty();
  61198. },
  61199. enumerable: true,
  61200. configurable: true
  61201. });
  61202. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  61203. /**
  61204. * Returns true if alpha blending should be disabled.
  61205. */
  61206. get: function () {
  61207. return (this.subSurface.disableAlphaBlending ||
  61208. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  61209. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  61210. },
  61211. enumerable: true,
  61212. configurable: true
  61213. });
  61214. /**
  61215. * Specifies whether or not this material should be rendered in alpha blend mode.
  61216. */
  61217. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  61218. if (this._disableAlphaBlending) {
  61219. return false;
  61220. }
  61221. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  61222. };
  61223. /**
  61224. * Specifies if the mesh will require alpha blending.
  61225. * @param mesh - BJS mesh.
  61226. */
  61227. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  61228. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  61229. return false;
  61230. }
  61231. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  61232. };
  61233. /**
  61234. * Specifies whether or not this material should be rendered in alpha test mode.
  61235. */
  61236. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  61237. if (this._forceAlphaTest) {
  61238. return true;
  61239. }
  61240. if (this.subSurface.disableAlphaBlending) {
  61241. return false;
  61242. }
  61243. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  61244. };
  61245. /**
  61246. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  61247. */
  61248. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  61249. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  61250. };
  61251. /**
  61252. * Gets the texture used for the alpha test.
  61253. */
  61254. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  61255. return this._albedoTexture;
  61256. };
  61257. /**
  61258. * Specifies that the submesh is ready to be used.
  61259. * @param mesh - BJS mesh.
  61260. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  61261. * @param useInstances - Specifies that instances should be used.
  61262. * @returns - boolean indicating that the submesh is ready or not.
  61263. */
  61264. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  61265. if (subMesh.effect && this.isFrozen) {
  61266. if (this._wasPreviouslyReady) {
  61267. return true;
  61268. }
  61269. }
  61270. if (!subMesh._materialDefines) {
  61271. subMesh._materialDefines = new PBRMaterialDefines();
  61272. }
  61273. var defines = subMesh._materialDefines;
  61274. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  61275. if (defines._renderId === this.getScene().getRenderId()) {
  61276. return true;
  61277. }
  61278. }
  61279. var scene = this.getScene();
  61280. var engine = scene.getEngine();
  61281. if (defines._areTexturesDirty) {
  61282. if (scene.texturesEnabled) {
  61283. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].DiffuseTextureEnabled) {
  61284. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  61285. return false;
  61286. }
  61287. }
  61288. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].AmbientTextureEnabled) {
  61289. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  61290. return false;
  61291. }
  61292. }
  61293. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].OpacityTextureEnabled) {
  61294. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  61295. return false;
  61296. }
  61297. }
  61298. var reflectionTexture = this._getReflectionTexture();
  61299. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled) {
  61300. if (!reflectionTexture.isReadyOrNotBlocking()) {
  61301. return false;
  61302. }
  61303. if (reflectionTexture.irradianceTexture && !reflectionTexture.irradianceTexture.isReadyOrNotBlocking()) {
  61304. return false;
  61305. }
  61306. }
  61307. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].LightmapTextureEnabled) {
  61308. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  61309. return false;
  61310. }
  61311. }
  61312. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].EmissiveTextureEnabled) {
  61313. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  61314. return false;
  61315. }
  61316. }
  61317. if (_materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].SpecularTextureEnabled) {
  61318. if (this._metallicTexture) {
  61319. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  61320. return false;
  61321. }
  61322. }
  61323. else if (this._reflectivityTexture) {
  61324. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  61325. return false;
  61326. }
  61327. }
  61328. if (this._microSurfaceTexture) {
  61329. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  61330. return false;
  61331. }
  61332. }
  61333. }
  61334. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  61335. // Bump texture cannot be not blocking.
  61336. if (!this._bumpTexture.isReady()) {
  61337. return false;
  61338. }
  61339. }
  61340. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled) {
  61341. // This is blocking.
  61342. if (!this._environmentBRDFTexture.isReady()) {
  61343. return false;
  61344. }
  61345. }
  61346. }
  61347. }
  61348. if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
  61349. !this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
  61350. !this.sheen.isReadyForSubMesh(defines, scene) ||
  61351. !this.anisotropy.isReadyForSubMesh(defines, scene)) {
  61352. return false;
  61353. }
  61354. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  61355. if (!this._imageProcessingConfiguration.isReady()) {
  61356. return false;
  61357. }
  61358. }
  61359. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  61360. mesh.createNormals(true);
  61361. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  61362. }
  61363. var previousEffect = subMesh.effect;
  61364. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  61365. if (effect) {
  61366. // Use previous effect while new one is compiling
  61367. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  61368. effect = previousEffect;
  61369. defines.markAsUnprocessed();
  61370. }
  61371. else {
  61372. scene.resetCachedMaterial();
  61373. subMesh.setEffect(effect, defines);
  61374. this.buildUniformLayout();
  61375. }
  61376. }
  61377. if (!subMesh.effect || !subMesh.effect.isReady()) {
  61378. return false;
  61379. }
  61380. defines._renderId = scene.getRenderId();
  61381. this._wasPreviouslyReady = true;
  61382. return true;
  61383. };
  61384. /**
  61385. * Specifies if the material uses metallic roughness workflow.
  61386. * @returns boolean specifiying if the material uses metallic roughness workflow.
  61387. */
  61388. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  61389. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  61390. return true;
  61391. }
  61392. return false;
  61393. };
  61394. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  61395. if (onCompiled === void 0) { onCompiled = null; }
  61396. if (onError === void 0) { onError = null; }
  61397. if (useInstances === void 0) { useInstances = null; }
  61398. if (useClipPlane === void 0) { useClipPlane = null; }
  61399. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  61400. if (!defines.isDirty) {
  61401. return null;
  61402. }
  61403. defines.markAsProcessed();
  61404. var scene = this.getScene();
  61405. var engine = scene.getEngine();
  61406. // Fallbacks
  61407. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_15__["EffectFallbacks"]();
  61408. var fallbackRank = 0;
  61409. if (defines.USESPHERICALINVERTEX) {
  61410. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  61411. }
  61412. if (defines.FOG) {
  61413. fallbacks.addFallback(fallbackRank, "FOG");
  61414. }
  61415. if (defines.SPECULARAA) {
  61416. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  61417. }
  61418. if (defines.POINTSIZE) {
  61419. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  61420. }
  61421. if (defines.LOGARITHMICDEPTH) {
  61422. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  61423. }
  61424. if (defines.PARALLAX) {
  61425. fallbacks.addFallback(fallbackRank, "PARALLAX");
  61426. }
  61427. if (defines.PARALLAXOCCLUSION) {
  61428. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  61429. }
  61430. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  61431. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  61432. fallbackRank = _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  61433. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  61434. if (defines.ENVIRONMENTBRDF) {
  61435. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  61436. }
  61437. if (defines.TANGENT) {
  61438. fallbacks.addFallback(fallbackRank++, "TANGENT");
  61439. }
  61440. if (defines.BUMP) {
  61441. fallbacks.addFallback(fallbackRank++, "BUMP");
  61442. }
  61443. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  61444. if (defines.SPECULARTERM) {
  61445. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  61446. }
  61447. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  61448. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  61449. }
  61450. if (defines.USEIRRADIANCEMAP) {
  61451. fallbacks.addFallback(fallbackRank++, "USEIRRADIANCEMAP");
  61452. }
  61453. if (defines.LIGHTMAP) {
  61454. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  61455. }
  61456. if (defines.NORMAL) {
  61457. fallbacks.addFallback(fallbackRank++, "NORMAL");
  61458. }
  61459. if (defines.AMBIENT) {
  61460. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  61461. }
  61462. if (defines.EMISSIVE) {
  61463. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  61464. }
  61465. if (defines.VERTEXCOLOR) {
  61466. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  61467. }
  61468. if (defines.MORPHTARGETS) {
  61469. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  61470. }
  61471. if (defines.MULTIVIEW) {
  61472. fallbacks.addFallback(0, "MULTIVIEW");
  61473. }
  61474. //Attributes
  61475. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  61476. if (defines.NORMAL) {
  61477. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  61478. }
  61479. if (defines.TANGENT) {
  61480. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  61481. }
  61482. if (defines.UV1) {
  61483. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  61484. }
  61485. if (defines.UV2) {
  61486. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  61487. }
  61488. if (defines.VERTEXCOLOR) {
  61489. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  61490. }
  61491. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  61492. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  61493. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  61494. var shaderName = "pbr";
  61495. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  61496. "vFogInfos", "vFogColor", "pointSize",
  61497. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  61498. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos",
  61499. "mBones",
  61500. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
  61501. "vLightingIntensity",
  61502. "logarithmicDepthConstant",
  61503. "vSphericalX", "vSphericalY", "vSphericalZ",
  61504. "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ",
  61505. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  61506. "vSphericalL00",
  61507. "vSphericalL1_1", "vSphericalL10", "vSphericalL11",
  61508. "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22",
  61509. "vReflectionMicrosurfaceInfos",
  61510. "vTangentSpaceParams", "boneTextureWidth",
  61511. "vDebugMode"
  61512. ];
  61513. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  61514. "bumpSampler", "lightmapSampler", "opacitySampler",
  61515. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler",
  61516. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  61517. var uniformBuffers = ["Material", "Scene"];
  61518. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddUniforms(uniforms);
  61519. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddSamplers(samplers);
  61520. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  61521. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  61522. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  61523. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  61524. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  61525. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  61526. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_14__["ImageProcessingConfiguration"]) {
  61527. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_14__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  61528. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_14__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  61529. }
  61530. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareUniformsAndSamplersList({
  61531. uniformsNames: uniforms,
  61532. uniformBuffersNames: uniformBuffers,
  61533. samplers: samplers,
  61534. defines: defines,
  61535. maxSimultaneousLights: this._maxSimultaneousLights
  61536. });
  61537. if (this.customShaderNameResolve) {
  61538. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  61539. }
  61540. var join = defines.toString();
  61541. return engine.createEffect(shaderName, {
  61542. attributes: attribs,
  61543. uniformsNames: uniforms,
  61544. uniformBuffersNames: uniformBuffers,
  61545. samplers: samplers,
  61546. defines: join,
  61547. fallbacks: fallbacks,
  61548. onCompiled: onCompiled,
  61549. onError: onError,
  61550. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  61551. }, engine);
  61552. };
  61553. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  61554. if (useInstances === void 0) { useInstances = null; }
  61555. if (useClipPlane === void 0) { useClipPlane = null; }
  61556. var scene = this.getScene();
  61557. var engine = scene.getEngine();
  61558. // Lights
  61559. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  61560. defines._needNormals = true;
  61561. // Multiview
  61562. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  61563. // Textures
  61564. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  61565. if (defines._areTexturesDirty) {
  61566. defines._needUVs = false;
  61567. if (scene.texturesEnabled) {
  61568. if (scene.getEngine().getCaps().textureLOD) {
  61569. defines.LODBASEDMICROSFURACE = true;
  61570. }
  61571. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].DiffuseTextureEnabled) {
  61572. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  61573. }
  61574. else {
  61575. defines.ALBEDO = false;
  61576. }
  61577. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].AmbientTextureEnabled) {
  61578. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  61579. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  61580. }
  61581. else {
  61582. defines.AMBIENT = false;
  61583. }
  61584. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].OpacityTextureEnabled) {
  61585. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  61586. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  61587. }
  61588. else {
  61589. defines.OPACITY = false;
  61590. }
  61591. var reflectionTexture = this._getReflectionTexture();
  61592. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled) {
  61593. defines.REFLECTION = true;
  61594. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  61595. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  61596. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  61597. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  61598. defines.LINEARSPECULARREFLECTION = reflectionTexture.linearSpecularLOD;
  61599. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].INVCUBIC_MODE) {
  61600. defines.INVERTCUBICMAP = true;
  61601. }
  61602. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  61603. defines.REFLECTIONMAP_CUBIC = false;
  61604. defines.REFLECTIONMAP_EXPLICIT = false;
  61605. defines.REFLECTIONMAP_PLANAR = false;
  61606. defines.REFLECTIONMAP_PROJECTION = false;
  61607. defines.REFLECTIONMAP_SKYBOX = false;
  61608. defines.REFLECTIONMAP_SPHERICAL = false;
  61609. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  61610. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  61611. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  61612. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  61613. switch (reflectionTexture.coordinatesMode) {
  61614. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].EXPLICIT_MODE:
  61615. defines.REFLECTIONMAP_EXPLICIT = true;
  61616. break;
  61617. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].PLANAR_MODE:
  61618. defines.REFLECTIONMAP_PLANAR = true;
  61619. break;
  61620. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].PROJECTION_MODE:
  61621. defines.REFLECTIONMAP_PROJECTION = true;
  61622. break;
  61623. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].SKYBOX_MODE:
  61624. defines.REFLECTIONMAP_SKYBOX = true;
  61625. break;
  61626. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].SPHERICAL_MODE:
  61627. defines.REFLECTIONMAP_SPHERICAL = true;
  61628. break;
  61629. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].EQUIRECTANGULAR_MODE:
  61630. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  61631. break;
  61632. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  61633. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  61634. break;
  61635. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  61636. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  61637. break;
  61638. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].CUBIC_MODE:
  61639. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].INVCUBIC_MODE:
  61640. default:
  61641. defines.REFLECTIONMAP_CUBIC = true;
  61642. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  61643. break;
  61644. }
  61645. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_19__["Texture"].SKYBOX_MODE) {
  61646. if (reflectionTexture.irradianceTexture) {
  61647. defines.USEIRRADIANCEMAP = true;
  61648. defines.USESPHERICALFROMREFLECTIONMAP = false;
  61649. }
  61650. else if (reflectionTexture.sphericalPolynomial) {
  61651. defines.USESPHERICALFROMREFLECTIONMAP = true;
  61652. defines.USEIRRADIANCEMAP = false;
  61653. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  61654. defines.USESPHERICALINVERTEX = false;
  61655. }
  61656. else {
  61657. defines.USESPHERICALINVERTEX = true;
  61658. }
  61659. }
  61660. }
  61661. else {
  61662. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  61663. }
  61664. }
  61665. else {
  61666. defines.REFLECTION = false;
  61667. defines.REFLECTIONMAP_3D = false;
  61668. defines.REFLECTIONMAP_SPHERICAL = false;
  61669. defines.REFLECTIONMAP_PLANAR = false;
  61670. defines.REFLECTIONMAP_CUBIC = false;
  61671. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  61672. defines.REFLECTIONMAP_PROJECTION = false;
  61673. defines.REFLECTIONMAP_SKYBOX = false;
  61674. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  61675. defines.REFLECTIONMAP_EXPLICIT = false;
  61676. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  61677. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  61678. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  61679. defines.INVERTCUBICMAP = false;
  61680. defines.USESPHERICALFROMREFLECTIONMAP = false;
  61681. defines.USEIRRADIANCEMAP = false;
  61682. defines.USESPHERICALINVERTEX = false;
  61683. defines.REFLECTIONMAP_OPPOSITEZ = false;
  61684. defines.LODINREFLECTIONALPHA = false;
  61685. defines.GAMMAREFLECTION = false;
  61686. defines.RGBDREFLECTION = false;
  61687. defines.LINEARSPECULARREFLECTION = false;
  61688. }
  61689. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].LightmapTextureEnabled) {
  61690. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  61691. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  61692. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  61693. }
  61694. else {
  61695. defines.LIGHTMAP = false;
  61696. }
  61697. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].EmissiveTextureEnabled) {
  61698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  61699. }
  61700. else {
  61701. defines.EMISSIVE = false;
  61702. }
  61703. if (_materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].SpecularTextureEnabled) {
  61704. if (this._metallicTexture) {
  61705. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  61706. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  61707. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  61708. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  61709. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  61710. }
  61711. else if (this._reflectivityTexture) {
  61712. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  61713. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  61714. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  61715. }
  61716. else {
  61717. defines.REFLECTIVITY = false;
  61718. }
  61719. if (this._microSurfaceTexture) {
  61720. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  61721. }
  61722. else {
  61723. defines.MICROSURFACEMAP = false;
  61724. }
  61725. }
  61726. else {
  61727. defines.REFLECTIVITY = false;
  61728. defines.MICROSURFACEMAP = false;
  61729. }
  61730. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  61731. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  61732. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].DiffuseTextureEnabled) {
  61733. defines.PARALLAX = true;
  61734. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  61735. }
  61736. else {
  61737. defines.PARALLAX = false;
  61738. }
  61739. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  61740. }
  61741. else {
  61742. defines.BUMP = false;
  61743. }
  61744. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled) {
  61745. defines.ENVIRONMENTBRDF = true;
  61746. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  61747. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  61748. }
  61749. else {
  61750. defines.ENVIRONMENTBRDF = false;
  61751. defines.ENVIRONMENTBRDF_RGBD = false;
  61752. }
  61753. if (this._shouldUseAlphaFromAlbedoTexture()) {
  61754. defines.ALPHAFROMALBEDO = true;
  61755. }
  61756. else {
  61757. defines.ALPHAFROMALBEDO = false;
  61758. }
  61759. }
  61760. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  61761. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  61762. defines.USEPHYSICALLIGHTFALLOFF = false;
  61763. defines.USEGLTFLIGHTFALLOFF = false;
  61764. }
  61765. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  61766. defines.USEPHYSICALLIGHTFALLOFF = false;
  61767. defines.USEGLTFLIGHTFALLOFF = true;
  61768. }
  61769. else {
  61770. defines.USEPHYSICALLIGHTFALLOFF = true;
  61771. defines.USEGLTFLIGHTFALLOFF = false;
  61772. }
  61773. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  61774. if (!this.backFaceCulling && this._twoSidedLighting) {
  61775. defines.TWOSIDEDLIGHTING = true;
  61776. }
  61777. else {
  61778. defines.TWOSIDEDLIGHTING = false;
  61779. }
  61780. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  61781. }
  61782. if (defines._areTexturesDirty || defines._areMiscDirty) {
  61783. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  61784. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  61785. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  61786. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  61787. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  61788. }
  61789. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  61790. this._imageProcessingConfiguration.prepareDefines(defines);
  61791. }
  61792. defines.FORCENORMALFORWARD = this._forceNormalForward;
  61793. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  61794. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  61795. // Misc.
  61796. if (defines._areMiscDirty) {
  61797. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  61798. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  61799. defines.DEBUGMODE = this._debugMode;
  61800. }
  61801. // External config
  61802. this.subSurface.prepareDefines(defines, scene);
  61803. this.clearCoat.prepareDefines(defines, scene);
  61804. this.anisotropy.prepareDefines(defines, mesh, scene);
  61805. this.brdf.prepareDefines(defines);
  61806. this.sheen.prepareDefines(defines, scene);
  61807. // Values that need to be evaluated on every frame
  61808. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  61809. // Attribs
  61810. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  61811. };
  61812. /**
  61813. * Force shader compilation
  61814. */
  61815. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  61816. var _this = this;
  61817. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  61818. var defines = new PBRMaterialDefines();
  61819. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  61820. if (effect.isReady()) {
  61821. if (onCompiled) {
  61822. onCompiled(this);
  61823. }
  61824. }
  61825. else {
  61826. effect.onCompileObservable.add(function () {
  61827. if (onCompiled) {
  61828. onCompiled(_this);
  61829. }
  61830. });
  61831. }
  61832. };
  61833. /**
  61834. * Initializes the uniform buffer layout for the shader.
  61835. */
  61836. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  61837. // Order is important !
  61838. var ubo = this._uniformBuffer;
  61839. ubo.addUniform("vAlbedoInfos", 2);
  61840. ubo.addUniform("vAmbientInfos", 4);
  61841. ubo.addUniform("vOpacityInfos", 2);
  61842. ubo.addUniform("vEmissiveInfos", 2);
  61843. ubo.addUniform("vLightmapInfos", 2);
  61844. ubo.addUniform("vReflectivityInfos", 3);
  61845. ubo.addUniform("vMicroSurfaceSamplerInfos", 2);
  61846. ubo.addUniform("vReflectionInfos", 2);
  61847. ubo.addUniform("vReflectionPosition", 3);
  61848. ubo.addUniform("vReflectionSize", 3);
  61849. ubo.addUniform("vBumpInfos", 3);
  61850. ubo.addUniform("albedoMatrix", 16);
  61851. ubo.addUniform("ambientMatrix", 16);
  61852. ubo.addUniform("opacityMatrix", 16);
  61853. ubo.addUniform("emissiveMatrix", 16);
  61854. ubo.addUniform("lightmapMatrix", 16);
  61855. ubo.addUniform("reflectivityMatrix", 16);
  61856. ubo.addUniform("microSurfaceSamplerMatrix", 16);
  61857. ubo.addUniform("bumpMatrix", 16);
  61858. ubo.addUniform("vTangentSpaceParams", 2);
  61859. ubo.addUniform("reflectionMatrix", 16);
  61860. ubo.addUniform("vReflectionColor", 3);
  61861. ubo.addUniform("vAlbedoColor", 4);
  61862. ubo.addUniform("vLightingIntensity", 4);
  61863. ubo.addUniform("vReflectionMicrosurfaceInfos", 3);
  61864. ubo.addUniform("pointSize", 1);
  61865. ubo.addUniform("vReflectivityColor", 4);
  61866. ubo.addUniform("vEmissiveColor", 3);
  61867. ubo.addUniform("visibility", 1);
  61868. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(ubo);
  61869. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(ubo);
  61870. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(ubo);
  61871. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].PrepareUniformBuffer(ubo);
  61872. ubo.create();
  61873. };
  61874. /**
  61875. * Unbinds the material from the mesh
  61876. */
  61877. PBRBaseMaterial.prototype.unbind = function () {
  61878. if (this._activeEffect) {
  61879. var needFlag = false;
  61880. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  61881. this._activeEffect.setTexture("reflection2DSampler", null);
  61882. needFlag = true;
  61883. }
  61884. if (this.subSurface.unbind(this._activeEffect)) {
  61885. needFlag = true;
  61886. }
  61887. if (needFlag) {
  61888. this._markAllSubMeshesAsTexturesDirty();
  61889. }
  61890. }
  61891. _super.prototype.unbind.call(this);
  61892. };
  61893. /**
  61894. * Binds the submesh data.
  61895. * @param world - The world matrix.
  61896. * @param mesh - The BJS mesh.
  61897. * @param subMesh - A submesh of the BJS mesh.
  61898. */
  61899. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  61900. var scene = this.getScene();
  61901. var defines = subMesh._materialDefines;
  61902. if (!defines) {
  61903. return;
  61904. }
  61905. var effect = subMesh.effect;
  61906. if (!effect) {
  61907. return;
  61908. }
  61909. this._activeEffect = effect;
  61910. // Matrices
  61911. if (!defines.INSTANCES) {
  61912. this.bindOnlyWorldMatrix(world);
  61913. }
  61914. // Normal Matrix
  61915. if (defines.OBJECTSPACE_NORMALMAP) {
  61916. world.toNormalMatrix(this._normalMatrix);
  61917. this.bindOnlyNormalMatrix(this._normalMatrix);
  61918. }
  61919. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  61920. // Bones
  61921. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  61922. var reflectionTexture = null;
  61923. var ubo = this._uniformBuffer;
  61924. if (mustRebind) {
  61925. var engine = scene.getEngine();
  61926. ubo.bindToEffect(effect, "Material");
  61927. this.bindViewProjection(effect);
  61928. reflectionTexture = this._getReflectionTexture();
  61929. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  61930. // Texture uniforms
  61931. if (scene.texturesEnabled) {
  61932. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].DiffuseTextureEnabled) {
  61933. ubo.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  61934. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, ubo, "albedo");
  61935. }
  61936. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].AmbientTextureEnabled) {
  61937. ubo.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  61938. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  61939. }
  61940. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].OpacityTextureEnabled) {
  61941. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  61942. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  61943. }
  61944. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled) {
  61945. ubo.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  61946. ubo.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  61947. if (reflectionTexture.boundingBoxSize) {
  61948. var cubeTexture = reflectionTexture;
  61949. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  61950. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  61951. }
  61952. if (!defines.USEIRRADIANCEMAP) {
  61953. var polynomials = reflectionTexture.sphericalPolynomial;
  61954. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  61955. if (defines.SPHERICAL_HARMONICS) {
  61956. var preScaledHarmonics = polynomials.preScaledHarmonics;
  61957. this._activeEffect.setVector3("vSphericalL00", preScaledHarmonics.l00);
  61958. this._activeEffect.setVector3("vSphericalL1_1", preScaledHarmonics.l1_1);
  61959. this._activeEffect.setVector3("vSphericalL10", preScaledHarmonics.l10);
  61960. this._activeEffect.setVector3("vSphericalL11", preScaledHarmonics.l11);
  61961. this._activeEffect.setVector3("vSphericalL2_2", preScaledHarmonics.l2_2);
  61962. this._activeEffect.setVector3("vSphericalL2_1", preScaledHarmonics.l2_1);
  61963. this._activeEffect.setVector3("vSphericalL20", preScaledHarmonics.l20);
  61964. this._activeEffect.setVector3("vSphericalL21", preScaledHarmonics.l21);
  61965. this._activeEffect.setVector3("vSphericalL22", preScaledHarmonics.l22);
  61966. }
  61967. else {
  61968. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  61969. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  61970. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  61971. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  61972. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  61973. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  61974. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  61975. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  61976. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  61977. }
  61978. }
  61979. }
  61980. ubo.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  61981. }
  61982. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].EmissiveTextureEnabled) {
  61983. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  61984. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  61985. }
  61986. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].LightmapTextureEnabled) {
  61987. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  61988. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  61989. }
  61990. if (_materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].SpecularTextureEnabled) {
  61991. if (this._metallicTexture) {
  61992. ubo.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  61993. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, ubo, "reflectivity");
  61994. }
  61995. else if (this._reflectivityTexture) {
  61996. ubo.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  61997. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, ubo, "reflectivity");
  61998. }
  61999. if (this._microSurfaceTexture) {
  62000. ubo.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  62001. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, ubo, "microSurfaceSampler");
  62002. }
  62003. }
  62004. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  62005. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  62006. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  62007. if (scene._mirroredCameraPosition) {
  62008. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  62009. }
  62010. else {
  62011. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  62012. }
  62013. }
  62014. }
  62015. // Point size
  62016. if (this.pointsCloud) {
  62017. ubo.updateFloat("pointSize", this.pointSize);
  62018. }
  62019. // Colors
  62020. if (defines.METALLICWORKFLOW) {
  62021. _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["TmpColors"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  62022. _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["TmpColors"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  62023. ubo.updateColor4("vReflectivityColor", _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["TmpColors"].Color3[0], 0);
  62024. }
  62025. else {
  62026. ubo.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  62027. }
  62028. ubo.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math_color__WEBPACK_IMPORTED_MODULE_13__["Color3"].BlackReadOnly);
  62029. ubo.updateColor3("vReflectionColor", this._reflectionColor);
  62030. if (!defines.SS_REFRACTION && this.subSurface.linkRefractionWithTransparency) {
  62031. ubo.updateColor4("vAlbedoColor", this._albedoColor, 1);
  62032. }
  62033. else {
  62034. ubo.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  62035. }
  62036. // Visibility
  62037. ubo.updateFloat("visibility", mesh.visibility);
  62038. // Misc
  62039. this._lightingInfos.x = this._directIntensity;
  62040. this._lightingInfos.y = this._emissiveIntensity;
  62041. this._lightingInfos.z = this._environmentIntensity;
  62042. this._lightingInfos.w = this._specularIntensity;
  62043. ubo.updateVector4("vLightingIntensity", this._lightingInfos);
  62044. }
  62045. // Textures
  62046. if (scene.texturesEnabled) {
  62047. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].DiffuseTextureEnabled) {
  62048. ubo.setTexture("albedoSampler", this._albedoTexture);
  62049. }
  62050. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].AmbientTextureEnabled) {
  62051. ubo.setTexture("ambientSampler", this._ambientTexture);
  62052. }
  62053. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].OpacityTextureEnabled) {
  62054. ubo.setTexture("opacitySampler", this._opacityTexture);
  62055. }
  62056. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].ReflectionTextureEnabled) {
  62057. if (defines.LODBASEDMICROSFURACE) {
  62058. ubo.setTexture("reflectionSampler", reflectionTexture);
  62059. }
  62060. else {
  62061. ubo.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  62062. ubo.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  62063. ubo.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  62064. }
  62065. if (defines.USEIRRADIANCEMAP) {
  62066. ubo.setTexture("irradianceSampler", reflectionTexture.irradianceTexture);
  62067. }
  62068. }
  62069. if (defines.ENVIRONMENTBRDF) {
  62070. ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  62071. }
  62072. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].EmissiveTextureEnabled) {
  62073. ubo.setTexture("emissiveSampler", this._emissiveTexture);
  62074. }
  62075. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].LightmapTextureEnabled) {
  62076. ubo.setTexture("lightmapSampler", this._lightmapTexture);
  62077. }
  62078. if (_materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].SpecularTextureEnabled) {
  62079. if (this._metallicTexture) {
  62080. ubo.setTexture("reflectivitySampler", this._metallicTexture);
  62081. }
  62082. else if (this._reflectivityTexture) {
  62083. ubo.setTexture("reflectivitySampler", this._reflectivityTexture);
  62084. }
  62085. if (this._microSurfaceTexture) {
  62086. ubo.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  62087. }
  62088. }
  62089. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_20__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  62090. ubo.setTexture("bumpSampler", this._bumpTexture);
  62091. }
  62092. }
  62093. this.subSurface.bindForSubMesh(ubo, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE);
  62094. this.clearCoat.bindForSubMesh(ubo, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  62095. this.anisotropy.bindForSubMesh(ubo, scene, this.isFrozen);
  62096. this.sheen.bindForSubMesh(ubo, scene, this.isFrozen);
  62097. // Clip plane
  62098. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  62099. // Colors
  62100. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  62101. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  62102. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  62103. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  62104. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  62105. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  62106. }
  62107. if (mustRebind || !this.isFrozen) {
  62108. // Lights
  62109. if (scene.lightsEnabled && !this._disableLighting) {
  62110. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  62111. }
  62112. // View
  62113. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  62114. this.bindView(effect);
  62115. }
  62116. // Fog
  62117. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  62118. // Morph targets
  62119. if (defines.NUM_MORPH_INFLUENCERS) {
  62120. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  62121. }
  62122. // image processing
  62123. this._imageProcessingConfiguration.bind(this._activeEffect);
  62124. // Log. depth
  62125. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_18__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  62126. }
  62127. ubo.update();
  62128. this._afterBind(mesh, this._activeEffect);
  62129. };
  62130. /**
  62131. * Returns the animatable textures.
  62132. * @returns - Array of animatable textures.
  62133. */
  62134. PBRBaseMaterial.prototype.getAnimatables = function () {
  62135. var results = [];
  62136. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  62137. results.push(this._albedoTexture);
  62138. }
  62139. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  62140. results.push(this._ambientTexture);
  62141. }
  62142. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  62143. results.push(this._opacityTexture);
  62144. }
  62145. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  62146. results.push(this._reflectionTexture);
  62147. }
  62148. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  62149. results.push(this._emissiveTexture);
  62150. }
  62151. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  62152. results.push(this._metallicTexture);
  62153. }
  62154. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  62155. results.push(this._reflectivityTexture);
  62156. }
  62157. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  62158. results.push(this._bumpTexture);
  62159. }
  62160. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  62161. results.push(this._lightmapTexture);
  62162. }
  62163. this.subSurface.getAnimatables(results);
  62164. this.clearCoat.getAnimatables(results);
  62165. this.sheen.getAnimatables(results);
  62166. this.anisotropy.getAnimatables(results);
  62167. return results;
  62168. };
  62169. /**
  62170. * Returns the texture used for reflections.
  62171. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  62172. */
  62173. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  62174. if (this._reflectionTexture) {
  62175. return this._reflectionTexture;
  62176. }
  62177. return this.getScene().environmentTexture;
  62178. };
  62179. /**
  62180. * Returns an array of the actively used textures.
  62181. * @returns - Array of BaseTextures
  62182. */
  62183. PBRBaseMaterial.prototype.getActiveTextures = function () {
  62184. var activeTextures = _super.prototype.getActiveTextures.call(this);
  62185. if (this._albedoTexture) {
  62186. activeTextures.push(this._albedoTexture);
  62187. }
  62188. if (this._ambientTexture) {
  62189. activeTextures.push(this._ambientTexture);
  62190. }
  62191. if (this._opacityTexture) {
  62192. activeTextures.push(this._opacityTexture);
  62193. }
  62194. if (this._reflectionTexture) {
  62195. activeTextures.push(this._reflectionTexture);
  62196. }
  62197. if (this._emissiveTexture) {
  62198. activeTextures.push(this._emissiveTexture);
  62199. }
  62200. if (this._reflectivityTexture) {
  62201. activeTextures.push(this._reflectivityTexture);
  62202. }
  62203. if (this._metallicTexture) {
  62204. activeTextures.push(this._metallicTexture);
  62205. }
  62206. if (this._microSurfaceTexture) {
  62207. activeTextures.push(this._microSurfaceTexture);
  62208. }
  62209. if (this._bumpTexture) {
  62210. activeTextures.push(this._bumpTexture);
  62211. }
  62212. if (this._lightmapTexture) {
  62213. activeTextures.push(this._lightmapTexture);
  62214. }
  62215. this.subSurface.getActiveTextures(activeTextures);
  62216. this.clearCoat.getActiveTextures(activeTextures);
  62217. this.sheen.getActiveTextures(activeTextures);
  62218. this.anisotropy.getActiveTextures(activeTextures);
  62219. return activeTextures;
  62220. };
  62221. /**
  62222. * Checks to see if a texture is used in the material.
  62223. * @param texture - Base texture to use.
  62224. * @returns - Boolean specifying if a texture is used in the material.
  62225. */
  62226. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  62227. if (_super.prototype.hasTexture.call(this, texture)) {
  62228. return true;
  62229. }
  62230. if (this._albedoTexture === texture) {
  62231. return true;
  62232. }
  62233. if (this._ambientTexture === texture) {
  62234. return true;
  62235. }
  62236. if (this._opacityTexture === texture) {
  62237. return true;
  62238. }
  62239. if (this._reflectionTexture === texture) {
  62240. return true;
  62241. }
  62242. if (this._reflectivityTexture === texture) {
  62243. return true;
  62244. }
  62245. if (this._metallicTexture === texture) {
  62246. return true;
  62247. }
  62248. if (this._microSurfaceTexture === texture) {
  62249. return true;
  62250. }
  62251. if (this._bumpTexture === texture) {
  62252. return true;
  62253. }
  62254. if (this._lightmapTexture === texture) {
  62255. return true;
  62256. }
  62257. return this.subSurface.hasTexture(texture) ||
  62258. this.clearCoat.hasTexture(texture) ||
  62259. this.sheen.hasTexture(texture) ||
  62260. this.anisotropy.hasTexture(texture);
  62261. };
  62262. /**
  62263. * Disposes the resources of the material.
  62264. * @param forceDisposeEffect - Forces the disposal of effects.
  62265. * @param forceDisposeTextures - Forces the disposal of all textures.
  62266. */
  62267. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  62268. if (forceDisposeTextures) {
  62269. if (this._albedoTexture) {
  62270. this._albedoTexture.dispose();
  62271. }
  62272. if (this._ambientTexture) {
  62273. this._ambientTexture.dispose();
  62274. }
  62275. if (this._opacityTexture) {
  62276. this._opacityTexture.dispose();
  62277. }
  62278. if (this._reflectionTexture) {
  62279. this._reflectionTexture.dispose();
  62280. }
  62281. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  62282. this._environmentBRDFTexture.dispose();
  62283. }
  62284. if (this._emissiveTexture) {
  62285. this._emissiveTexture.dispose();
  62286. }
  62287. if (this._metallicTexture) {
  62288. this._metallicTexture.dispose();
  62289. }
  62290. if (this._reflectivityTexture) {
  62291. this._reflectivityTexture.dispose();
  62292. }
  62293. if (this._bumpTexture) {
  62294. this._bumpTexture.dispose();
  62295. }
  62296. if (this._lightmapTexture) {
  62297. this._lightmapTexture.dispose();
  62298. }
  62299. }
  62300. this.subSurface.dispose(forceDisposeTextures);
  62301. this.clearCoat.dispose(forceDisposeTextures);
  62302. this.sheen.dispose(forceDisposeTextures);
  62303. this.anisotropy.dispose(forceDisposeTextures);
  62304. this._renderTargets.dispose();
  62305. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  62306. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  62307. }
  62308. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  62309. };
  62310. /**
  62311. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  62312. */
  62313. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  62314. /**
  62315. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  62316. */
  62317. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  62318. /**
  62319. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  62320. */
  62321. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  62322. /**
  62323. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  62324. * They are also discarded below the alpha cutoff threshold to improve performances.
  62325. */
  62326. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  62327. /**
  62328. * Defines the default value of how much AO map is occluding the analytical lights
  62329. * (point spot...).
  62330. */
  62331. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  62332. /**
  62333. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  62334. */
  62335. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  62336. /**
  62337. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  62338. * to enhance interoperability with other engines.
  62339. */
  62340. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  62341. /**
  62342. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  62343. * to enhance interoperability with other materials.
  62344. */
  62345. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  62346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  62348. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  62349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  62351. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  62352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62354. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  62355. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62357. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  62358. return PBRBaseMaterial;
  62359. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_17__["PushMaterial"]));
  62360. /***/ }),
  62361. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  62362. /*!************************************************!*\
  62363. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  62364. \************************************************/
  62365. /*! exports provided: PBRBaseSimpleMaterial */
  62366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62367. "use strict";
  62368. __webpack_require__.r(__webpack_exports__);
  62369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  62370. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62371. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  62372. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  62373. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  62374. /**
  62375. * The Physically based simple base material of BJS.
  62376. *
  62377. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62378. * It is used as the base class for both the specGloss and metalRough conventions.
  62379. */
  62380. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  62381. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  62382. /**
  62383. * Instantiates a new PBRMaterial instance.
  62384. *
  62385. * @param name The material name
  62386. * @param scene The scene the material will be use in.
  62387. */
  62388. function PBRBaseSimpleMaterial(name, scene) {
  62389. var _this = _super.call(this, name, scene) || this;
  62390. /**
  62391. * Number of Simultaneous lights allowed on the material.
  62392. */
  62393. _this.maxSimultaneousLights = 4;
  62394. /**
  62395. * If sets to true, disables all the lights affecting the material.
  62396. */
  62397. _this.disableLighting = false;
  62398. /**
  62399. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62400. */
  62401. _this.invertNormalMapX = false;
  62402. /**
  62403. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62404. */
  62405. _this.invertNormalMapY = false;
  62406. /**
  62407. * Emissivie color used to self-illuminate the model.
  62408. */
  62409. _this.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  62410. /**
  62411. * Occlusion Channel Strenght.
  62412. */
  62413. _this.occlusionStrength = 1.0;
  62414. /**
  62415. * If true, the light map contains occlusion information instead of lighting info.
  62416. */
  62417. _this.useLightmapAsShadowmap = false;
  62418. _this._useAlphaFromAlbedoTexture = true;
  62419. _this._useAmbientInGrayScale = true;
  62420. return _this;
  62421. }
  62422. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  62423. /**
  62424. * Gets the current double sided mode.
  62425. */
  62426. get: function () {
  62427. return this._twoSidedLighting;
  62428. },
  62429. /**
  62430. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62431. */
  62432. set: function (value) {
  62433. if (this._twoSidedLighting === value) {
  62434. return;
  62435. }
  62436. this._twoSidedLighting = value;
  62437. this.backFaceCulling = !value;
  62438. this._markAllSubMeshesAsTexturesDirty();
  62439. },
  62440. enumerable: true,
  62441. configurable: true
  62442. });
  62443. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  62444. return "PBRBaseSimpleMaterial";
  62445. };
  62446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  62449. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  62450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  62453. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  62454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  62457. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  62458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62461. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  62462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62465. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  62466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  62469. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  62470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  62472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62473. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  62474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62477. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  62478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  62481. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  62482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  62485. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  62486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62488. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  62489. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  62490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62492. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  62493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  62496. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  62497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62500. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  62501. return PBRBaseSimpleMaterial;
  62502. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  62503. /***/ }),
  62504. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  62505. /*!****************************************************!*\
  62506. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  62507. \****************************************************/
  62508. /*! exports provided: PBRClearCoatConfiguration */
  62509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62510. "use strict";
  62511. __webpack_require__.r(__webpack_exports__);
  62512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  62513. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62514. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  62515. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  62516. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  62517. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  62518. /**
  62519. * Define the code related to the clear coat parameters of the pbr material.
  62520. */
  62521. var PBRClearCoatConfiguration = /** @class */ (function () {
  62522. /**
  62523. * Instantiate a new istance of clear coat configuration.
  62524. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  62525. */
  62526. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  62527. this._isEnabled = false;
  62528. /**
  62529. * Defines if the clear coat is enabled in the material.
  62530. */
  62531. this.isEnabled = false;
  62532. /**
  62533. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  62534. */
  62535. this.intensity = 1;
  62536. /**
  62537. * Defines the clear coat layer roughness.
  62538. */
  62539. this.roughness = 0;
  62540. this._indexOfRefraction = PBRClearCoatConfiguration._DefaultIndexOfRefraction;
  62541. /**
  62542. * Defines the index of refraction of the clear coat.
  62543. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  62544. * The default fits with a polyurethane material.
  62545. * Changing the default value is more performance intensive.
  62546. */
  62547. this.indexOfRefraction = PBRClearCoatConfiguration._DefaultIndexOfRefraction;
  62548. this._texture = null;
  62549. /**
  62550. * Stores the clear coat values in a texture.
  62551. */
  62552. this.texture = null;
  62553. this._bumpTexture = null;
  62554. /**
  62555. * Define the clear coat specific bump texture.
  62556. */
  62557. this.bumpTexture = null;
  62558. this._isTintEnabled = false;
  62559. /**
  62560. * Defines if the clear coat tint is enabled in the material.
  62561. */
  62562. this.isTintEnabled = false;
  62563. /**
  62564. * Defines the clear coat tint of the material.
  62565. * This is only use if tint is enabled
  62566. */
  62567. this.tintColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  62568. /**
  62569. * Defines the distance at which the tint color should be found in the
  62570. * clear coat media.
  62571. * This is only use if tint is enabled
  62572. */
  62573. this.tintColorAtDistance = 1;
  62574. /**
  62575. * Defines the clear coat layer thickness.
  62576. * This is only use if tint is enabled
  62577. */
  62578. this.tintThickness = 1;
  62579. this._tintTexture = null;
  62580. /**
  62581. * Stores the clear tint values in a texture.
  62582. * rgb is tint
  62583. * a is a thickness factor
  62584. */
  62585. this.tintTexture = null;
  62586. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  62587. }
  62588. /** @hidden */
  62589. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62590. this._internalMarkAllSubMeshesAsTexturesDirty();
  62591. };
  62592. /**
  62593. * Gets wehter the submesh is ready to be used or not.
  62594. * @param defines the list of "defines" to update.
  62595. * @param scene defines the scene the material belongs to.
  62596. * @param engine defines the engine the material belongs to.
  62597. * @param disableBumpMap defines wether the material disables bump or not.
  62598. * @returns - boolean indicating that the submesh is ready or not.
  62599. */
  62600. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  62601. if (defines._areTexturesDirty) {
  62602. if (scene.texturesEnabled) {
  62603. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  62604. if (!this._texture.isReadyOrNotBlocking()) {
  62605. return false;
  62606. }
  62607. }
  62608. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  62609. // Bump texture cannot be not blocking.
  62610. if (!this._bumpTexture.isReady()) {
  62611. return false;
  62612. }
  62613. }
  62614. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  62615. if (!this._tintTexture.isReadyOrNotBlocking()) {
  62616. return false;
  62617. }
  62618. }
  62619. }
  62620. }
  62621. return true;
  62622. };
  62623. /**
  62624. * Checks to see if a texture is used in the material.
  62625. * @param defines the list of "defines" to update.
  62626. * @param scene defines the scene to the material belongs to.
  62627. */
  62628. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  62629. if (this._isEnabled) {
  62630. defines.CLEARCOAT = true;
  62631. if (defines._areTexturesDirty) {
  62632. if (scene.texturesEnabled) {
  62633. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  62634. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  62635. }
  62636. else {
  62637. defines.CLEARCOAT_TEXTURE = false;
  62638. }
  62639. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  62640. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  62641. }
  62642. else {
  62643. defines.CLEARCOAT_BUMP = false;
  62644. }
  62645. defines.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === PBRClearCoatConfiguration._DefaultIndexOfRefraction;
  62646. if (this._isTintEnabled) {
  62647. defines.CLEARCOAT_TINT = true;
  62648. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  62649. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  62650. }
  62651. else {
  62652. defines.CLEARCOAT_TINT_TEXTURE = false;
  62653. }
  62654. }
  62655. else {
  62656. defines.CLEARCOAT_TINT = false;
  62657. defines.CLEARCOAT_TINT_TEXTURE = false;
  62658. }
  62659. }
  62660. }
  62661. }
  62662. else {
  62663. defines.CLEARCOAT = false;
  62664. defines.CLEARCOAT_TEXTURE = false;
  62665. defines.CLEARCOAT_BUMP = false;
  62666. defines.CLEARCOAT_TINT = false;
  62667. defines.CLEARCOAT_TINT_TEXTURE = false;
  62668. }
  62669. };
  62670. /**
  62671. * Binds the material data.
  62672. * @param uniformBuffer defines the Uniform buffer to fill in.
  62673. * @param scene defines the scene the material belongs to.
  62674. * @param engine defines the engine the material belongs to.
  62675. * @param disableBumpMap defines wether the material disables bump or not.
  62676. * @param isFrozen defines wether the material is frozen or not.
  62677. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  62678. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  62679. */
  62680. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  62681. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  62682. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  62683. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  62684. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  62685. }
  62686. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  62687. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  62688. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  62689. if (scene._mirroredCameraPosition) {
  62690. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  62691. }
  62692. else {
  62693. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  62694. }
  62695. }
  62696. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  62697. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  62698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  62699. }
  62700. // Clear Coat General params
  62701. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  62702. // Clear Coat Refraction params
  62703. var a = 1 - this._indexOfRefraction;
  62704. var b = 1 + this._indexOfRefraction;
  62705. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  62706. var eta = 1 / this._indexOfRefraction;
  62707. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  62708. if (this._isTintEnabled) {
  62709. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  62710. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  62711. }
  62712. }
  62713. // Textures
  62714. if (scene.texturesEnabled) {
  62715. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  62716. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  62717. }
  62718. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  62719. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  62720. }
  62721. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  62722. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  62723. }
  62724. }
  62725. };
  62726. /**
  62727. * Checks to see if a texture is used in the material.
  62728. * @param texture - Base texture to use.
  62729. * @returns - Boolean specifying if a texture is used in the material.
  62730. */
  62731. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  62732. if (this._texture === texture) {
  62733. return true;
  62734. }
  62735. if (this._bumpTexture === texture) {
  62736. return true;
  62737. }
  62738. if (this._tintTexture === texture) {
  62739. return true;
  62740. }
  62741. return false;
  62742. };
  62743. /**
  62744. * Returns an array of the actively used textures.
  62745. * @param activeTextures Array of BaseTextures
  62746. */
  62747. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  62748. if (this._texture) {
  62749. activeTextures.push(this._texture);
  62750. }
  62751. if (this._bumpTexture) {
  62752. activeTextures.push(this._bumpTexture);
  62753. }
  62754. if (this._tintTexture) {
  62755. activeTextures.push(this._tintTexture);
  62756. }
  62757. };
  62758. /**
  62759. * Returns the animatable textures.
  62760. * @param animatables Array of animatable textures.
  62761. */
  62762. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  62763. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  62764. animatables.push(this._texture);
  62765. }
  62766. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  62767. animatables.push(this._bumpTexture);
  62768. }
  62769. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  62770. animatables.push(this._tintTexture);
  62771. }
  62772. };
  62773. /**
  62774. * Disposes the resources of the material.
  62775. * @param forceDisposeTextures - Forces the disposal of all textures.
  62776. */
  62777. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  62778. if (forceDisposeTextures) {
  62779. if (this._texture) {
  62780. this._texture.dispose();
  62781. }
  62782. if (this._bumpTexture) {
  62783. this._bumpTexture.dispose();
  62784. }
  62785. if (this._tintTexture) {
  62786. this._tintTexture.dispose();
  62787. }
  62788. }
  62789. };
  62790. /**
  62791. * Get the current class name of the texture useful for serialization or dynamic coding.
  62792. * @returns "PBRClearCoatConfiguration"
  62793. */
  62794. PBRClearCoatConfiguration.prototype.getClassName = function () {
  62795. return "PBRClearCoatConfiguration";
  62796. };
  62797. /**
  62798. * Add fallbacks to the effect fallbacks list.
  62799. * @param defines defines the Base texture to use.
  62800. * @param fallbacks defines the current fallback list.
  62801. * @param currentRank defines the current fallback rank.
  62802. * @returns the new fallback rank.
  62803. */
  62804. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  62805. if (defines.CLEARCOAT_BUMP) {
  62806. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  62807. }
  62808. if (defines.CLEARCOAT_TINT) {
  62809. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  62810. }
  62811. if (defines.CLEARCOAT) {
  62812. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  62813. }
  62814. return currentRank;
  62815. };
  62816. /**
  62817. * Add the required uniforms to the current list.
  62818. * @param uniforms defines the current uniform list.
  62819. */
  62820. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  62821. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  62822. };
  62823. /**
  62824. * Add the required samplers to the current list.
  62825. * @param samplers defines the current sampler list.
  62826. */
  62827. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  62828. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  62829. };
  62830. /**
  62831. * Add the required uniforms to the current buffer.
  62832. * @param uniformBuffer defines the current uniform buffer.
  62833. */
  62834. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  62835. uniformBuffer.addUniform("vClearCoatParams", 2);
  62836. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  62837. uniformBuffer.addUniform("vClearCoatInfos", 2);
  62838. uniformBuffer.addUniform("clearCoatMatrix", 16);
  62839. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  62840. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  62841. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  62842. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  62843. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  62844. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  62845. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  62846. };
  62847. /**
  62848. * Makes a duplicate of the current configuration into another one.
  62849. * @param clearCoatConfiguration define the config where to copy the info
  62850. */
  62851. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  62852. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  62853. };
  62854. /**
  62855. * Serializes this clear coat configuration.
  62856. * @returns - An object with the serialized config.
  62857. */
  62858. PBRClearCoatConfiguration.prototype.serialize = function () {
  62859. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62860. };
  62861. /**
  62862. * Parses a anisotropy Configuration from a serialized object.
  62863. * @param source - Serialized object.
  62864. * @param scene Defines the scene we are parsing for
  62865. * @param rootUrl Defines the rootUrl to load from
  62866. */
  62867. PBRClearCoatConfiguration.prototype.parse = function (source, scene, rootUrl) {
  62868. var _this = this;
  62869. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, scene, rootUrl);
  62870. };
  62871. /**
  62872. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  62873. * The default fits with a polyurethane material.
  62874. */
  62875. PBRClearCoatConfiguration._DefaultIndexOfRefraction = 1.5;
  62876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62879. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  62880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62882. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  62883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62885. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  62886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62889. ], PBRClearCoatConfiguration.prototype, "indexOfRefraction", void 0);
  62890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62893. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  62894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62897. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  62898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  62900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62901. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  62902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  62904. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  62905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62907. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  62908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62910. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  62911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  62913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  62914. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  62915. return PBRClearCoatConfiguration;
  62916. }());
  62917. /***/ }),
  62918. /***/ "./Materials/PBR/pbrMaterial.ts":
  62919. /*!**************************************!*\
  62920. !*** ./Materials/PBR/pbrMaterial.ts ***!
  62921. \**************************************/
  62922. /*! exports provided: PBRMaterial */
  62923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62924. "use strict";
  62925. __webpack_require__.r(__webpack_exports__);
  62926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  62927. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62928. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  62929. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  62930. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  62931. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  62932. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  62933. /**
  62934. * The Physically based material of BJS.
  62935. *
  62936. * This offers the main features of a standard PBR material.
  62937. * For more information, please refer to the documentation :
  62938. * https://doc.babylonjs.com/how_to/physically_based_rendering
  62939. */
  62940. var PBRMaterial = /** @class */ (function (_super) {
  62941. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  62942. /**
  62943. * Instantiates a new PBRMaterial instance.
  62944. *
  62945. * @param name The material name
  62946. * @param scene The scene the material will be use in.
  62947. */
  62948. function PBRMaterial(name, scene) {
  62949. var _this = _super.call(this, name, scene) || this;
  62950. /**
  62951. * Intensity of the direct lights e.g. the four lights available in your scene.
  62952. * This impacts both the direct diffuse and specular highlights.
  62953. */
  62954. _this.directIntensity = 1.0;
  62955. /**
  62956. * Intensity of the emissive part of the material.
  62957. * This helps controlling the emissive effect without modifying the emissive color.
  62958. */
  62959. _this.emissiveIntensity = 1.0;
  62960. /**
  62961. * Intensity of the environment e.g. how much the environment will light the object
  62962. * either through harmonics for rough material or through the refelction for shiny ones.
  62963. */
  62964. _this.environmentIntensity = 1.0;
  62965. /**
  62966. * This is a special control allowing the reduction of the specular highlights coming from the
  62967. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62968. */
  62969. _this.specularIntensity = 1.0;
  62970. /**
  62971. * Debug Control allowing disabling the bump map on this material.
  62972. */
  62973. _this.disableBumpMap = false;
  62974. /**
  62975. * AKA Occlusion Texture Intensity in other nomenclature.
  62976. */
  62977. _this.ambientTextureStrength = 1.0;
  62978. /**
  62979. * Defines how much the AO map is occluding the analytical lights (point spot...).
  62980. * 1 means it completely occludes it
  62981. * 0 mean it has no impact
  62982. */
  62983. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  62984. /**
  62985. * The color of a material in ambient lighting.
  62986. */
  62987. _this.ambientColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  62988. /**
  62989. * AKA Diffuse Color in other nomenclature.
  62990. */
  62991. _this.albedoColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  62992. /**
  62993. * AKA Specular Color in other nomenclature.
  62994. */
  62995. _this.reflectivityColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  62996. /**
  62997. * The color reflected from the material.
  62998. */
  62999. _this.reflectionColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  63000. /**
  63001. * The color emitted from the material.
  63002. */
  63003. _this.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  63004. /**
  63005. * AKA Glossiness in other nomenclature.
  63006. */
  63007. _this.microSurface = 1.0;
  63008. /**
  63009. * If true, the light map contains occlusion information instead of lighting info.
  63010. */
  63011. _this.useLightmapAsShadowmap = false;
  63012. /**
  63013. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63014. */
  63015. _this.useAlphaFromAlbedoTexture = false;
  63016. /**
  63017. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  63018. */
  63019. _this.forceAlphaTest = false;
  63020. /**
  63021. * Defines the alpha limits in alpha test mode.
  63022. */
  63023. _this.alphaCutOff = 0.4;
  63024. /**
  63025. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  63026. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63027. */
  63028. _this.useSpecularOverAlpha = true;
  63029. /**
  63030. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  63031. */
  63032. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  63033. /**
  63034. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63035. */
  63036. _this.useRoughnessFromMetallicTextureAlpha = true;
  63037. /**
  63038. * Specifies if the metallic texture contains the roughness information in its green channel.
  63039. */
  63040. _this.useRoughnessFromMetallicTextureGreen = false;
  63041. /**
  63042. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63043. */
  63044. _this.useMetallnessFromMetallicTextureBlue = false;
  63045. /**
  63046. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63047. */
  63048. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  63049. /**
  63050. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63051. */
  63052. _this.useAmbientInGrayScale = false;
  63053. /**
  63054. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  63055. * The material will try to infer what glossiness each pixel should be.
  63056. */
  63057. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  63058. /**
  63059. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  63060. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63061. */
  63062. _this.useRadianceOverAlpha = true;
  63063. /**
  63064. * Allows using an object space normal map (instead of tangent space).
  63065. */
  63066. _this.useObjectSpaceNormalMap = false;
  63067. /**
  63068. * Allows using the bump map in parallax mode.
  63069. */
  63070. _this.useParallax = false;
  63071. /**
  63072. * Allows using the bump map in parallax occlusion mode.
  63073. */
  63074. _this.useParallaxOcclusion = false;
  63075. /**
  63076. * Controls the scale bias of the parallax mode.
  63077. */
  63078. _this.parallaxScaleBias = 0.05;
  63079. /**
  63080. * If sets to true, disables all the lights affecting the material.
  63081. */
  63082. _this.disableLighting = false;
  63083. /**
  63084. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63085. */
  63086. _this.forceIrradianceInFragment = false;
  63087. /**
  63088. * Number of Simultaneous lights allowed on the material.
  63089. */
  63090. _this.maxSimultaneousLights = 4;
  63091. /**
  63092. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63093. */
  63094. _this.invertNormalMapX = false;
  63095. /**
  63096. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63097. */
  63098. _this.invertNormalMapY = false;
  63099. /**
  63100. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63101. */
  63102. _this.twoSidedLighting = false;
  63103. /**
  63104. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  63105. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  63106. */
  63107. _this.useAlphaFresnel = false;
  63108. /**
  63109. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  63110. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  63111. */
  63112. _this.useLinearAlphaFresnel = false;
  63113. /**
  63114. * Let user defines the brdf lookup texture used for IBL.
  63115. * A default 8bit version is embedded but you could point at :
  63116. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  63117. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  63118. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  63119. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  63120. */
  63121. _this.environmentBRDFTexture = null;
  63122. /**
  63123. * Force normal to face away from face.
  63124. */
  63125. _this.forceNormalForward = false;
  63126. /**
  63127. * Enables specular anti aliasing in the PBR shader.
  63128. * It will both interacts on the Geometry for analytical and IBL lighting.
  63129. * It also prefilter the roughness map based on the bump values.
  63130. */
  63131. _this.enableSpecularAntiAliasing = false;
  63132. /**
  63133. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63134. * makes the reflect vector face the model (under horizon).
  63135. */
  63136. _this.useHorizonOcclusion = true;
  63137. /**
  63138. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63139. * too much the area relying on ambient texture to define their ambient occlusion.
  63140. */
  63141. _this.useRadianceOcclusion = true;
  63142. /**
  63143. * If set to true, no lighting calculations will be applied.
  63144. */
  63145. _this.unlit = false;
  63146. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  63147. return _this;
  63148. }
  63149. Object.defineProperty(PBRMaterial.prototype, "refractionTexture", {
  63150. /**
  63151. * Stores the refracted light information in a texture.
  63152. */
  63153. get: function () {
  63154. return this.subSurface.refractionTexture;
  63155. },
  63156. set: function (value) {
  63157. this.subSurface.refractionTexture = value;
  63158. if (value) {
  63159. this.subSurface.isRefractionEnabled = true;
  63160. }
  63161. else if (!this.subSurface.linkRefractionWithTransparency) {
  63162. this.subSurface.isRefractionEnabled = false;
  63163. }
  63164. },
  63165. enumerable: true,
  63166. configurable: true
  63167. });
  63168. Object.defineProperty(PBRMaterial.prototype, "indexOfRefraction", {
  63169. /**
  63170. * source material index of refraction (IOR)' / 'destination material IOR.
  63171. */
  63172. get: function () {
  63173. return 1 / this.subSurface.indexOfRefraction;
  63174. },
  63175. set: function (value) {
  63176. this.subSurface.indexOfRefraction = 1 / value;
  63177. },
  63178. enumerable: true,
  63179. configurable: true
  63180. });
  63181. Object.defineProperty(PBRMaterial.prototype, "invertRefractionY", {
  63182. /**
  63183. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  63184. */
  63185. get: function () {
  63186. return this.subSurface.invertRefractionY;
  63187. },
  63188. set: function (value) {
  63189. this.subSurface.invertRefractionY = value;
  63190. },
  63191. enumerable: true,
  63192. configurable: true
  63193. });
  63194. Object.defineProperty(PBRMaterial.prototype, "linkRefractionWithTransparency", {
  63195. /**
  63196. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  63197. * Materials half opaque for instance using refraction could benefit from this control.
  63198. */
  63199. get: function () {
  63200. return this.subSurface.linkRefractionWithTransparency;
  63201. },
  63202. set: function (value) {
  63203. this.subSurface.linkRefractionWithTransparency = value;
  63204. if (value) {
  63205. this.subSurface.isRefractionEnabled = true;
  63206. }
  63207. },
  63208. enumerable: true,
  63209. configurable: true
  63210. });
  63211. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  63212. /**
  63213. * BJS is using an harcoded light falloff based on a manually sets up range.
  63214. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  63215. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  63216. */
  63217. get: function () {
  63218. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  63219. },
  63220. /**
  63221. * BJS is using an harcoded light falloff based on a manually sets up range.
  63222. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  63223. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  63224. */
  63225. set: function (value) {
  63226. if (value !== this.usePhysicalLightFalloff) {
  63227. // Ensure the effect will be rebuilt.
  63228. this._markAllSubMeshesAsTexturesDirty();
  63229. if (value) {
  63230. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  63231. }
  63232. else {
  63233. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  63234. }
  63235. }
  63236. },
  63237. enumerable: true,
  63238. configurable: true
  63239. });
  63240. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  63241. /**
  63242. * In order to support the falloff compatibility with gltf, a special mode has been added
  63243. * to reproduce the gltf light falloff.
  63244. */
  63245. get: function () {
  63246. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  63247. },
  63248. /**
  63249. * In order to support the falloff compatibility with gltf, a special mode has been added
  63250. * to reproduce the gltf light falloff.
  63251. */
  63252. set: function (value) {
  63253. if (value !== this.useGLTFLightFalloff) {
  63254. // Ensure the effect will be rebuilt.
  63255. this._markAllSubMeshesAsTexturesDirty();
  63256. if (value) {
  63257. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  63258. }
  63259. else {
  63260. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  63261. }
  63262. }
  63263. },
  63264. enumerable: true,
  63265. configurable: true
  63266. });
  63267. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  63268. /**
  63269. * Gets the image processing configuration used either in this material.
  63270. */
  63271. get: function () {
  63272. return this._imageProcessingConfiguration;
  63273. },
  63274. /**
  63275. * Sets the Default image processing configuration used either in the this material.
  63276. *
  63277. * If sets to null, the scene one is in use.
  63278. */
  63279. set: function (value) {
  63280. this._attachImageProcessingConfiguration(value);
  63281. // Ensure the effect will be rebuilt.
  63282. this._markAllSubMeshesAsTexturesDirty();
  63283. },
  63284. enumerable: true,
  63285. configurable: true
  63286. });
  63287. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  63288. /**
  63289. * Gets wether the color curves effect is enabled.
  63290. */
  63291. get: function () {
  63292. return this.imageProcessingConfiguration.colorCurvesEnabled;
  63293. },
  63294. /**
  63295. * Sets wether the color curves effect is enabled.
  63296. */
  63297. set: function (value) {
  63298. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  63299. },
  63300. enumerable: true,
  63301. configurable: true
  63302. });
  63303. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  63304. /**
  63305. * Gets wether the color grading effect is enabled.
  63306. */
  63307. get: function () {
  63308. return this.imageProcessingConfiguration.colorGradingEnabled;
  63309. },
  63310. /**
  63311. * Gets wether the color grading effect is enabled.
  63312. */
  63313. set: function (value) {
  63314. this.imageProcessingConfiguration.colorGradingEnabled = value;
  63315. },
  63316. enumerable: true,
  63317. configurable: true
  63318. });
  63319. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  63320. /**
  63321. * Gets wether tonemapping is enabled or not.
  63322. */
  63323. get: function () {
  63324. return this._imageProcessingConfiguration.toneMappingEnabled;
  63325. },
  63326. /**
  63327. * Sets wether tonemapping is enabled or not
  63328. */
  63329. set: function (value) {
  63330. this._imageProcessingConfiguration.toneMappingEnabled = value;
  63331. },
  63332. enumerable: true,
  63333. configurable: true
  63334. });
  63335. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  63336. /**
  63337. * The camera exposure used on this material.
  63338. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  63339. * This corresponds to a photographic exposure.
  63340. */
  63341. get: function () {
  63342. return this._imageProcessingConfiguration.exposure;
  63343. },
  63344. /**
  63345. * The camera exposure used on this material.
  63346. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  63347. * This corresponds to a photographic exposure.
  63348. */
  63349. set: function (value) {
  63350. this._imageProcessingConfiguration.exposure = value;
  63351. },
  63352. enumerable: true,
  63353. configurable: true
  63354. });
  63355. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  63356. /**
  63357. * Gets The camera contrast used on this material.
  63358. */
  63359. get: function () {
  63360. return this._imageProcessingConfiguration.contrast;
  63361. },
  63362. /**
  63363. * Sets The camera contrast used on this material.
  63364. */
  63365. set: function (value) {
  63366. this._imageProcessingConfiguration.contrast = value;
  63367. },
  63368. enumerable: true,
  63369. configurable: true
  63370. });
  63371. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  63372. /**
  63373. * Gets the Color Grading 2D Lookup Texture.
  63374. */
  63375. get: function () {
  63376. return this._imageProcessingConfiguration.colorGradingTexture;
  63377. },
  63378. /**
  63379. * Sets the Color Grading 2D Lookup Texture.
  63380. */
  63381. set: function (value) {
  63382. this._imageProcessingConfiguration.colorGradingTexture = value;
  63383. },
  63384. enumerable: true,
  63385. configurable: true
  63386. });
  63387. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  63388. /**
  63389. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  63390. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  63391. * 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;
  63392. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  63393. */
  63394. get: function () {
  63395. return this._imageProcessingConfiguration.colorCurves;
  63396. },
  63397. /**
  63398. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  63399. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  63400. * 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;
  63401. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  63402. */
  63403. set: function (value) {
  63404. this._imageProcessingConfiguration.colorCurves = value;
  63405. },
  63406. enumerable: true,
  63407. configurable: true
  63408. });
  63409. /**
  63410. * Returns the name of this material class.
  63411. */
  63412. PBRMaterial.prototype.getClassName = function () {
  63413. return "PBRMaterial";
  63414. };
  63415. /**
  63416. * Makes a duplicate of the current material.
  63417. * @param name - name to use for the new material.
  63418. */
  63419. PBRMaterial.prototype.clone = function (name) {
  63420. var _this = this;
  63421. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  63422. clone.id = name;
  63423. clone.name = name;
  63424. this.clearCoat.copyTo(clone.clearCoat);
  63425. this.anisotropy.copyTo(clone.anisotropy);
  63426. this.brdf.copyTo(clone.brdf);
  63427. this.sheen.copyTo(clone.sheen);
  63428. return clone;
  63429. };
  63430. /**
  63431. * Serializes this PBR Material.
  63432. * @returns - An object with the serialized material.
  63433. */
  63434. PBRMaterial.prototype.serialize = function () {
  63435. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63436. serializationObject.customType = "BABYLON.PBRMaterial";
  63437. serializationObject.clearCoat = this.clearCoat.serialize();
  63438. serializationObject.anisotropy = this.anisotropy.serialize();
  63439. serializationObject.brdf = this.brdf.serialize();
  63440. serializationObject.sheen = this.sheen.serialize();
  63441. serializationObject.subSurface = this.subSurface.serialize();
  63442. return serializationObject;
  63443. };
  63444. // Statics
  63445. /**
  63446. * Parses a PBR Material from a serialized object.
  63447. * @param source - Serialized object.
  63448. * @param scene - BJS scene instance.
  63449. * @param rootUrl - url for the scene object
  63450. * @returns - PBRMaterial
  63451. */
  63452. PBRMaterial.Parse = function (source, scene, rootUrl) {
  63453. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  63454. if (source.clearCoat) {
  63455. material.clearCoat.parse(source.clearCoat, scene, rootUrl);
  63456. }
  63457. if (source.anisotropy) {
  63458. material.anisotropy.parse(source.anisotropy, scene, rootUrl);
  63459. }
  63460. if (source.brdf) {
  63461. material.brdf.parse(source.brdf, scene, rootUrl);
  63462. }
  63463. if (source.sheen) {
  63464. material.sheen.parse(source.sheen, scene, rootUrl);
  63465. }
  63466. if (source.subSurface) {
  63467. material.subSurface.parse(source.subSurface, scene, rootUrl);
  63468. }
  63469. return material;
  63470. };
  63471. /**
  63472. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  63473. */
  63474. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  63475. /**
  63476. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  63477. */
  63478. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  63479. /**
  63480. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  63481. */
  63482. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  63483. /**
  63484. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  63485. * They are also discarded below the alpha cutoff threshold to improve performances.
  63486. */
  63487. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  63488. /**
  63489. * Defines the default value of how much AO map is occluding the analytical lights
  63490. * (point spot...).
  63491. */
  63492. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  63493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63496. ], PBRMaterial.prototype, "directIntensity", void 0);
  63497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63500. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  63501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63503. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63504. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  63505. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63506. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63508. ], PBRMaterial.prototype, "specularIntensity", void 0);
  63509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63512. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  63513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63516. ], PBRMaterial.prototype, "albedoTexture", void 0);
  63517. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63518. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63520. ], PBRMaterial.prototype, "ambientTexture", void 0);
  63521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63524. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  63525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63528. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  63529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  63532. ], PBRMaterial.prototype, "opacityTexture", void 0);
  63533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63536. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  63537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63540. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  63541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63544. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  63545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63548. ], PBRMaterial.prototype, "metallicTexture", void 0);
  63549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63552. ], PBRMaterial.prototype, "metallic", void 0);
  63553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63556. ], PBRMaterial.prototype, "roughness", void 0);
  63557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63560. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  63561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63564. ], PBRMaterial.prototype, "bumpTexture", void 0);
  63565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  63568. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  63569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  63571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63572. ], PBRMaterial.prototype, "ambientColor", void 0);
  63573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  63575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63576. ], PBRMaterial.prototype, "albedoColor", void 0);
  63577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  63579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63580. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  63581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  63583. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63584. ], PBRMaterial.prototype, "reflectionColor", void 0);
  63585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63586. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  63587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63588. ], PBRMaterial.prototype, "emissiveColor", void 0);
  63589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63592. ], PBRMaterial.prototype, "microSurface", void 0);
  63593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63596. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  63597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  63600. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  63601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  63604. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  63605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  63608. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  63609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63612. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  63613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63616. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  63617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63620. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  63621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63624. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  63625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63628. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  63629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63632. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  63633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63636. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  63637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63640. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  63641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63643. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  63644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63646. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  63647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63650. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  63651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63654. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  63655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63658. ], PBRMaterial.prototype, "useParallax", void 0);
  63659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63662. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  63663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63666. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  63667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  63670. ], PBRMaterial.prototype, "disableLighting", void 0);
  63671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63674. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  63675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  63678. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  63679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63682. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  63683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63686. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  63687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63690. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  63691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63694. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  63695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63698. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  63699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63702. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  63703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63706. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  63707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63710. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  63711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63714. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  63715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63718. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  63719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  63722. ], PBRMaterial.prototype, "unlit", void 0);
  63723. return PBRMaterial;
  63724. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  63725. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  63726. /***/ }),
  63727. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  63728. /*!*******************************************************!*\
  63729. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  63730. \*******************************************************/
  63731. /*! exports provided: PBRMetallicRoughnessMaterial */
  63732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63733. "use strict";
  63734. __webpack_require__.r(__webpack_exports__);
  63735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  63736. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63737. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  63738. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  63739. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  63740. /**
  63741. * The PBR material of BJS following the metal roughness convention.
  63742. *
  63743. * This fits to the PBR convention in the GLTF definition:
  63744. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63745. */
  63746. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  63747. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  63748. /**
  63749. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63750. *
  63751. * @param name The material name
  63752. * @param scene The scene the material will be use in.
  63753. */
  63754. function PBRMetallicRoughnessMaterial(name, scene) {
  63755. var _this = _super.call(this, name, scene) || this;
  63756. _this._useRoughnessFromMetallicTextureAlpha = false;
  63757. _this._useRoughnessFromMetallicTextureGreen = true;
  63758. _this._useMetallnessFromMetallicTextureBlue = true;
  63759. _this.metallic = 1.0;
  63760. _this.roughness = 1.0;
  63761. return _this;
  63762. }
  63763. /**
  63764. * Return the currrent class name of the material.
  63765. */
  63766. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  63767. return "PBRMetallicRoughnessMaterial";
  63768. };
  63769. /**
  63770. * Makes a duplicate of the current material.
  63771. * @param name - name to use for the new material.
  63772. */
  63773. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  63774. var _this = this;
  63775. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  63776. clone.id = name;
  63777. clone.name = name;
  63778. this.clearCoat.copyTo(clone.clearCoat);
  63779. this.anisotropy.copyTo(clone.anisotropy);
  63780. this.brdf.copyTo(clone.brdf);
  63781. this.sheen.copyTo(clone.sheen);
  63782. return clone;
  63783. };
  63784. /**
  63785. * Serialize the material to a parsable JSON object.
  63786. */
  63787. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  63788. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63789. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  63790. serializationObject.clearCoat = this.clearCoat.serialize();
  63791. serializationObject.anisotropy = this.anisotropy.serialize();
  63792. serializationObject.brdf = this.brdf.serialize();
  63793. serializationObject.sheen = this.sheen.serialize();
  63794. serializationObject.subSurface = this.subSurface.serialize();
  63795. return serializationObject;
  63796. };
  63797. /**
  63798. * Parses a JSON object correponding to the serialize function.
  63799. */
  63800. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  63801. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  63802. if (source.clearCoat) {
  63803. material.clearCoat.parse(source.clearCoat, scene, rootUrl);
  63804. }
  63805. if (source.anisotropy) {
  63806. material.anisotropy.parse(source.anisotropy, scene, rootUrl);
  63807. }
  63808. if (source.brdf) {
  63809. material.brdf.parse(source.brdf, scene, rootUrl);
  63810. }
  63811. if (source.sheen) {
  63812. material.sheen.parse(source.sheen, scene, rootUrl);
  63813. }
  63814. if (source.subSurface) {
  63815. material.subSurface.parse(source.subSurface, scene, rootUrl);
  63816. }
  63817. return material;
  63818. };
  63819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  63821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  63822. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  63823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  63826. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  63827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63830. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  63831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  63833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  63834. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  63835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  63837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  63838. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  63839. return PBRMetallicRoughnessMaterial;
  63840. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  63841. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  63842. /***/ }),
  63843. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  63844. /*!************************************************!*\
  63845. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  63846. \************************************************/
  63847. /*! exports provided: PBRSheenConfiguration */
  63848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63849. "use strict";
  63850. __webpack_require__.r(__webpack_exports__);
  63851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  63852. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63853. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  63854. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  63855. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  63856. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  63857. /**
  63858. * Define the code related to the Sheen parameters of the pbr material.
  63859. */
  63860. var PBRSheenConfiguration = /** @class */ (function () {
  63861. /**
  63862. * Instantiate a new istance of clear coat configuration.
  63863. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  63864. */
  63865. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  63866. this._isEnabled = false;
  63867. /**
  63868. * Defines if the material uses sheen.
  63869. */
  63870. this.isEnabled = false;
  63871. this._linkSheenWithAlbedo = false;
  63872. /**
  63873. * Defines if the sheen is linked to the sheen color.
  63874. */
  63875. this.linkSheenWithAlbedo = false;
  63876. /**
  63877. * Defines the sheen intensity.
  63878. */
  63879. this.intensity = 1;
  63880. /**
  63881. * Defines the sheen color.
  63882. */
  63883. this.color = _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  63884. this._texture = null;
  63885. /**
  63886. * Stores the sheen tint values in a texture.
  63887. * rgb is tint
  63888. * a is a intensity
  63889. */
  63890. this.texture = null;
  63891. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  63892. }
  63893. /** @hidden */
  63894. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  63895. this._internalMarkAllSubMeshesAsTexturesDirty();
  63896. };
  63897. /**
  63898. * Specifies that the submesh is ready to be used.
  63899. * @param defines the list of "defines" to update.
  63900. * @param scene defines the scene the material belongs to.
  63901. * @returns - boolean indicating that the submesh is ready or not.
  63902. */
  63903. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  63904. if (defines._areTexturesDirty) {
  63905. if (scene.texturesEnabled) {
  63906. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  63907. if (!this._texture.isReadyOrNotBlocking()) {
  63908. return false;
  63909. }
  63910. }
  63911. }
  63912. }
  63913. return true;
  63914. };
  63915. /**
  63916. * Checks to see if a texture is used in the material.
  63917. * @param defines the list of "defines" to update.
  63918. * @param scene defines the scene the material belongs to.
  63919. */
  63920. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  63921. if (this._isEnabled) {
  63922. defines.SHEEN = this._isEnabled;
  63923. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  63924. if (defines._areTexturesDirty) {
  63925. if (scene.texturesEnabled) {
  63926. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  63927. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  63928. }
  63929. else {
  63930. defines.SHEEN_TEXTURE = false;
  63931. }
  63932. }
  63933. }
  63934. }
  63935. else {
  63936. defines.SHEEN = false;
  63937. defines.SHEEN_TEXTURE = false;
  63938. defines.SHEEN_LINKWITHALBEDO = false;
  63939. }
  63940. };
  63941. /**
  63942. * Binds the material data.
  63943. * @param uniformBuffer defines the Uniform buffer to fill in.
  63944. * @param scene defines the scene the material belongs to.
  63945. * @param isFrozen defines wether the material is frozen or not.
  63946. */
  63947. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  63948. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  63949. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  63950. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  63951. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  63952. }
  63953. // Sheen
  63954. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  63955. }
  63956. // Textures
  63957. if (scene.texturesEnabled) {
  63958. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  63959. uniformBuffer.setTexture("sheenSampler", this._texture);
  63960. }
  63961. }
  63962. };
  63963. /**
  63964. * Checks to see if a texture is used in the material.
  63965. * @param texture - Base texture to use.
  63966. * @returns - Boolean specifying if a texture is used in the material.
  63967. */
  63968. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  63969. if (this._texture === texture) {
  63970. return true;
  63971. }
  63972. return false;
  63973. };
  63974. /**
  63975. * Returns an array of the actively used textures.
  63976. * @param activeTextures Array of BaseTextures
  63977. */
  63978. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  63979. if (this._texture) {
  63980. activeTextures.push(this._texture);
  63981. }
  63982. };
  63983. /**
  63984. * Returns the animatable textures.
  63985. * @param animatables Array of animatable textures.
  63986. */
  63987. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  63988. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  63989. animatables.push(this._texture);
  63990. }
  63991. };
  63992. /**
  63993. * Disposes the resources of the material.
  63994. * @param forceDisposeTextures - Forces the disposal of all textures.
  63995. */
  63996. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  63997. if (forceDisposeTextures) {
  63998. if (this._texture) {
  63999. this._texture.dispose();
  64000. }
  64001. }
  64002. };
  64003. /**
  64004. * Get the current class name of the texture useful for serialization or dynamic coding.
  64005. * @returns "PBRSheenConfiguration"
  64006. */
  64007. PBRSheenConfiguration.prototype.getClassName = function () {
  64008. return "PBRSheenConfiguration";
  64009. };
  64010. /**
  64011. * Add fallbacks to the effect fallbacks list.
  64012. * @param defines defines the Base texture to use.
  64013. * @param fallbacks defines the current fallback list.
  64014. * @param currentRank defines the current fallback rank.
  64015. * @returns the new fallback rank.
  64016. */
  64017. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  64018. if (defines.SHEEN) {
  64019. fallbacks.addFallback(currentRank++, "SHEEN");
  64020. }
  64021. return currentRank;
  64022. };
  64023. /**
  64024. * Add the required uniforms to the current list.
  64025. * @param uniforms defines the current uniform list.
  64026. */
  64027. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  64028. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  64029. };
  64030. /**
  64031. * Add the required uniforms to the current buffer.
  64032. * @param uniformBuffer defines the current uniform buffer.
  64033. */
  64034. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  64035. uniformBuffer.addUniform("vSheenColor", 4);
  64036. uniformBuffer.addUniform("vSheenInfos", 2);
  64037. uniformBuffer.addUniform("sheenMatrix", 16);
  64038. };
  64039. /**
  64040. * Add the required samplers to the current list.
  64041. * @param samplers defines the current sampler list.
  64042. */
  64043. PBRSheenConfiguration.AddSamplers = function (samplers) {
  64044. samplers.push("sheenSampler");
  64045. };
  64046. /**
  64047. * Makes a duplicate of the current configuration into another one.
  64048. * @param sheenConfiguration define the config where to copy the info
  64049. */
  64050. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  64051. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  64052. };
  64053. /**
  64054. * Serializes this BRDF configuration.
  64055. * @returns - An object with the serialized config.
  64056. */
  64057. PBRSheenConfiguration.prototype.serialize = function () {
  64058. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64059. };
  64060. /**
  64061. * Parses a anisotropy Configuration from a serialized object.
  64062. * @param source - Serialized object.
  64063. * @param scene Defines the scene we are parsing for
  64064. * @param rootUrl Defines the rootUrl to load from
  64065. */
  64066. PBRSheenConfiguration.prototype.parse = function (source, scene, rootUrl) {
  64067. var _this = this;
  64068. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, scene, rootUrl);
  64069. };
  64070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64073. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  64074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64077. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  64078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64080. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  64081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  64083. ], PBRSheenConfiguration.prototype, "color", void 0);
  64084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  64086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64087. ], PBRSheenConfiguration.prototype, "texture", void 0);
  64088. return PBRSheenConfiguration;
  64089. }());
  64090. /***/ }),
  64091. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  64092. /*!********************************************************!*\
  64093. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  64094. \********************************************************/
  64095. /*! exports provided: PBRSpecularGlossinessMaterial */
  64096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64097. "use strict";
  64098. __webpack_require__.r(__webpack_exports__);
  64099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  64100. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64101. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  64102. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  64103. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  64104. /**
  64105. * The PBR material of BJS following the specular glossiness convention.
  64106. *
  64107. * This fits to the PBR convention in the GLTF definition:
  64108. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64109. */
  64110. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  64111. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  64112. /**
  64113. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64114. *
  64115. * @param name The material name
  64116. * @param scene The scene the material will be use in.
  64117. */
  64118. function PBRSpecularGlossinessMaterial(name, scene) {
  64119. var _this = _super.call(this, name, scene) || this;
  64120. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  64121. return _this;
  64122. }
  64123. /**
  64124. * Return the currrent class name of the material.
  64125. */
  64126. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  64127. return "PBRSpecularGlossinessMaterial";
  64128. };
  64129. /**
  64130. * Makes a duplicate of the current material.
  64131. * @param name - name to use for the new material.
  64132. */
  64133. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  64134. var _this = this;
  64135. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  64136. clone.id = name;
  64137. clone.name = name;
  64138. this.clearCoat.copyTo(clone.clearCoat);
  64139. this.anisotropy.copyTo(clone.anisotropy);
  64140. this.brdf.copyTo(clone.brdf);
  64141. this.sheen.copyTo(clone.sheen);
  64142. return clone;
  64143. };
  64144. /**
  64145. * Serialize the material to a parsable JSON object.
  64146. */
  64147. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  64148. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64149. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  64150. serializationObject.clearCoat = this.clearCoat.serialize();
  64151. serializationObject.anisotropy = this.anisotropy.serialize();
  64152. serializationObject.brdf = this.brdf.serialize();
  64153. serializationObject.sheen = this.sheen.serialize();
  64154. serializationObject.subSurface = this.subSurface.serialize();
  64155. return serializationObject;
  64156. };
  64157. /**
  64158. * Parses a JSON object correponding to the serialize function.
  64159. */
  64160. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  64161. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  64162. if (source.clearCoat) {
  64163. material.clearCoat.parse(source.clearCoat, scene, rootUrl);
  64164. }
  64165. if (source.anisotropy) {
  64166. material.anisotropy.parse(source.anisotropy, scene, rootUrl);
  64167. }
  64168. if (source.brdf) {
  64169. material.brdf.parse(source.brdf, scene, rootUrl);
  64170. }
  64171. if (source.sheen) {
  64172. material.sheen.parse(source.sheen, scene, rootUrl);
  64173. }
  64174. if (source.subSurface) {
  64175. material.subSurface.parse(source.subSurface, scene, rootUrl);
  64176. }
  64177. return material;
  64178. };
  64179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  64181. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  64182. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  64183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  64185. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  64186. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  64187. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  64189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  64190. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  64191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  64194. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  64195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  64197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  64198. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  64199. return PBRSpecularGlossinessMaterial;
  64200. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  64201. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  64202. /***/ }),
  64203. /***/ "./Materials/PBR/pbrSubSurfaceConfiguration.ts":
  64204. /*!*****************************************************!*\
  64205. !*** ./Materials/PBR/pbrSubSurfaceConfiguration.ts ***!
  64206. \*****************************************************/
  64207. /*! exports provided: PBRSubSurfaceConfiguration */
  64208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64209. "use strict";
  64210. __webpack_require__.r(__webpack_exports__);
  64211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSubSurfaceConfiguration", function() { return PBRSubSurfaceConfiguration; });
  64212. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64213. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  64214. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  64215. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  64216. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  64217. /**
  64218. * Define the code related to the sub surface parameters of the pbr material.
  64219. */
  64220. var PBRSubSurfaceConfiguration = /** @class */ (function () {
  64221. /**
  64222. * Instantiate a new istance of sub surface configuration.
  64223. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  64224. */
  64225. function PBRSubSurfaceConfiguration(markAllSubMeshesAsTexturesDirty) {
  64226. this._isRefractionEnabled = false;
  64227. /**
  64228. * Defines if the refraction is enabled in the material.
  64229. */
  64230. this.isRefractionEnabled = false;
  64231. this._isTranslucencyEnabled = false;
  64232. /**
  64233. * Defines if the translucency is enabled in the material.
  64234. */
  64235. this.isTranslucencyEnabled = false;
  64236. this._isScatteringEnabled = false;
  64237. // /**
  64238. // * Defines if the sub surface scattering is enabled in the material.
  64239. // */
  64240. // @serialize()
  64241. // @expandToProperty("_markAllSubMeshesAsTexturesDirty")
  64242. // public isScatteringEnabled = false;
  64243. /**
  64244. * Defines the refraction intensity of the material.
  64245. * The refraction when enabled replaces the Diffuse part of the material.
  64246. * The intensity helps transitionning between diffuse and refraction.
  64247. */
  64248. this.refractionIntensity = 1;
  64249. /**
  64250. * Defines the translucency intensity of the material.
  64251. * When translucency has been enabled, this defines how much of the "translucency"
  64252. * is addded to the diffuse part of the material.
  64253. */
  64254. this.translucencyIntensity = 1;
  64255. /**
  64256. * Defines the scattering intensity of the material.
  64257. * When scattering has been enabled, this defines how much of the "scattered light"
  64258. * is addded to the diffuse part of the material.
  64259. */
  64260. this.scatteringIntensity = 1;
  64261. this._thicknessTexture = null;
  64262. /**
  64263. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  64264. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  64265. * 0 would mean minimumThickness
  64266. * 1 would mean maximumThickness
  64267. * The other channels might be use as a mask to vary the different effects intensity.
  64268. */
  64269. this.thicknessTexture = null;
  64270. this._refractionTexture = null;
  64271. /**
  64272. * Defines the texture to use for refraction.
  64273. */
  64274. this.refractionTexture = null;
  64275. this._indexOfRefraction = 1;
  64276. /**
  64277. * Defines the index of refraction used in the material.
  64278. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  64279. */
  64280. this.indexOfRefraction = 1;
  64281. this._invertRefractionY = false;
  64282. /**
  64283. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  64284. */
  64285. this.invertRefractionY = false;
  64286. this._linkRefractionWithTransparency = false;
  64287. /**
  64288. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  64289. * Materials half opaque for instance using refraction could benefit from this control.
  64290. */
  64291. this.linkRefractionWithTransparency = false;
  64292. /**
  64293. * Defines the minimum thickness stored in the thickness map.
  64294. * If no thickness map is defined, this value will be used to simulate thickness.
  64295. */
  64296. this.minimumThickness = 0;
  64297. /**
  64298. * Defines the maximum thickness stored in the thickness map.
  64299. */
  64300. this.maximumThickness = 1;
  64301. /**
  64302. * Defines the volume tint of the material.
  64303. * This is used for both translucency and scattering.
  64304. */
  64305. this.tintColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  64306. /**
  64307. * Defines the distance at which the tint color should be found in the media.
  64308. * This is used for refraction only.
  64309. */
  64310. this.tintColorAtDistance = 1;
  64311. /**
  64312. * Defines how far each channel transmit through the media.
  64313. * It is defined as a color to simplify it selection.
  64314. */
  64315. this.diffusionDistance = _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  64316. this._useMaskFromThicknessTexture = false;
  64317. /**
  64318. * Stores the intensity of the different subsurface effects in the thickness texture.
  64319. * * the green channel is the translucency intensity.
  64320. * * the blue channel is the scattering intensity.
  64321. * * the alpha channel is the refraction intensity.
  64322. */
  64323. this.useMaskFromThicknessTexture = false;
  64324. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  64325. }
  64326. /** @hidden */
  64327. PBRSubSurfaceConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  64328. this._internalMarkAllSubMeshesAsTexturesDirty();
  64329. };
  64330. /**
  64331. * Gets wehter the submesh is ready to be used or not.
  64332. * @param defines the list of "defines" to update.
  64333. * @param scene defines the scene the material belongs to.
  64334. * @returns - boolean indicating that the submesh is ready or not.
  64335. */
  64336. PBRSubSurfaceConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  64337. if (defines._areTexturesDirty) {
  64338. if (scene.texturesEnabled) {
  64339. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  64340. if (!this._thicknessTexture.isReadyOrNotBlocking()) {
  64341. return false;
  64342. }
  64343. }
  64344. var refractionTexture = this._getRefractionTexture(scene);
  64345. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  64346. if (!refractionTexture.isReadyOrNotBlocking()) {
  64347. return false;
  64348. }
  64349. }
  64350. }
  64351. }
  64352. return true;
  64353. };
  64354. /**
  64355. * Checks to see if a texture is used in the material.
  64356. * @param defines the list of "defines" to update.
  64357. * @param scene defines the scene to the material belongs to.
  64358. */
  64359. PBRSubSurfaceConfiguration.prototype.prepareDefines = function (defines, scene) {
  64360. if (defines._areTexturesDirty) {
  64361. defines.SUBSURFACE = false;
  64362. defines.SS_TRANSLUCENCY = this._isTranslucencyEnabled;
  64363. defines.SS_SCATERRING = this._isScatteringEnabled;
  64364. defines.SS_THICKNESSANDMASK_TEXTURE = false;
  64365. defines.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  64366. defines.SS_REFRACTION = false;
  64367. defines.SS_REFRACTIONMAP_3D = false;
  64368. defines.SS_GAMMAREFRACTION = false;
  64369. defines.SS_RGBDREFRACTION = false;
  64370. defines.SS_LINEARSPECULARREFRACTION = false;
  64371. defines.SS_REFRACTIONMAP_OPPOSITEZ = false;
  64372. defines.SS_LODINREFRACTIONALPHA = false;
  64373. defines.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  64374. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  64375. defines.SUBSURFACE = true;
  64376. if (defines._areTexturesDirty) {
  64377. if (scene.texturesEnabled) {
  64378. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  64379. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._thicknessTexture, defines, "SS_THICKNESSANDMASK_TEXTURE");
  64380. }
  64381. }
  64382. }
  64383. defines.SS_MASK_FROM_THICKNESS_TEXTURE = this._useMaskFromThicknessTexture;
  64384. }
  64385. if (this._isRefractionEnabled) {
  64386. if (scene.texturesEnabled) {
  64387. var refractionTexture = this._getRefractionTexture(scene);
  64388. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  64389. defines.SS_REFRACTION = true;
  64390. defines.SS_REFRACTIONMAP_3D = refractionTexture.isCube;
  64391. defines.SS_GAMMAREFRACTION = refractionTexture.gammaSpace;
  64392. defines.SS_RGBDREFRACTION = refractionTexture.isRGBD;
  64393. defines.SS_LINEARSPECULARREFRACTION = refractionTexture.linearSpecularLOD;
  64394. defines.SS_REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  64395. defines.SS_LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  64396. defines.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency;
  64397. }
  64398. }
  64399. }
  64400. }
  64401. };
  64402. /**
  64403. * Binds the material data.
  64404. * @param uniformBuffer defines the Uniform buffer to fill in.
  64405. * @param scene defines the scene the material belongs to.
  64406. * @param engine defines the engine the material belongs to.
  64407. * @param isFrozen defines wether the material is frozen or not.
  64408. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  64409. */
  64410. PBRSubSurfaceConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, isFrozen, lodBasedMicrosurface) {
  64411. var refractionTexture = this._getRefractionTexture(scene);
  64412. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  64413. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  64414. uniformBuffer.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level);
  64415. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._thicknessTexture, uniformBuffer, "thickness");
  64416. }
  64417. uniformBuffer.updateFloat2("vThicknessParam", this.minimumThickness, this.maximumThickness - this.minimumThickness);
  64418. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  64419. uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  64420. var depth = 1.0;
  64421. if (!refractionTexture.isCube) {
  64422. if (refractionTexture.depth) {
  64423. depth = refractionTexture.depth;
  64424. }
  64425. }
  64426. uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, 1 / this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  64427. uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  64428. }
  64429. uniformBuffer.updateColor3("vDiffusionDistance", this.diffusionDistance);
  64430. uniformBuffer.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, this.tintColorAtDistance);
  64431. uniformBuffer.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, this.scatteringIntensity);
  64432. }
  64433. // Textures
  64434. if (scene.texturesEnabled) {
  64435. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  64436. uniformBuffer.setTexture("thicknessSampler", this._thicknessTexture);
  64437. }
  64438. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  64439. if (lodBasedMicrosurface) {
  64440. uniformBuffer.setTexture("refractionSampler", refractionTexture);
  64441. }
  64442. else {
  64443. uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  64444. uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  64445. uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  64446. }
  64447. }
  64448. }
  64449. };
  64450. /**
  64451. * Unbinds the material from the mesh.
  64452. * @param activeEffect defines the effect that should be unbound from.
  64453. * @returns true if unbound, otherwise false
  64454. */
  64455. PBRSubSurfaceConfiguration.prototype.unbind = function (activeEffect) {
  64456. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  64457. activeEffect.setTexture("refractionSampler", null);
  64458. return true;
  64459. }
  64460. return false;
  64461. };
  64462. /**
  64463. * Returns the texture used for refraction or null if none is used.
  64464. * @param scene defines the scene the material belongs to.
  64465. * @returns - Refraction texture if present. If no refraction texture and refraction
  64466. * is linked with transparency, returns environment texture. Otherwise, returns null.
  64467. */
  64468. PBRSubSurfaceConfiguration.prototype._getRefractionTexture = function (scene) {
  64469. if (this._refractionTexture) {
  64470. return this._refractionTexture;
  64471. }
  64472. if (this._isRefractionEnabled) {
  64473. return scene.environmentTexture;
  64474. }
  64475. return null;
  64476. };
  64477. Object.defineProperty(PBRSubSurfaceConfiguration.prototype, "disableAlphaBlending", {
  64478. /**
  64479. * Returns true if alpha blending should be disabled.
  64480. */
  64481. get: function () {
  64482. return this.isRefractionEnabled && this._linkRefractionWithTransparency;
  64483. },
  64484. enumerable: true,
  64485. configurable: true
  64486. });
  64487. /**
  64488. * Fills the list of render target textures.
  64489. * @param renderTargets the list of render targets to update
  64490. */
  64491. PBRSubSurfaceConfiguration.prototype.fillRenderTargetTextures = function (renderTargets) {
  64492. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  64493. renderTargets.push(this._refractionTexture);
  64494. }
  64495. };
  64496. /**
  64497. * Checks to see if a texture is used in the material.
  64498. * @param texture - Base texture to use.
  64499. * @returns - Boolean specifying if a texture is used in the material.
  64500. */
  64501. PBRSubSurfaceConfiguration.prototype.hasTexture = function (texture) {
  64502. if (this._thicknessTexture === texture) {
  64503. return true;
  64504. }
  64505. if (this._refractionTexture === texture) {
  64506. return true;
  64507. }
  64508. return false;
  64509. };
  64510. /**
  64511. * Gets a boolean indicating that current material needs to register RTT
  64512. * @returns true if this uses a render target otherwise false.
  64513. */
  64514. PBRSubSurfaceConfiguration.prototype.hasRenderTargetTextures = function () {
  64515. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  64516. return true;
  64517. }
  64518. return false;
  64519. };
  64520. /**
  64521. * Returns an array of the actively used textures.
  64522. * @param activeTextures Array of BaseTextures
  64523. */
  64524. PBRSubSurfaceConfiguration.prototype.getActiveTextures = function (activeTextures) {
  64525. if (this._thicknessTexture) {
  64526. activeTextures.push(this._thicknessTexture);
  64527. }
  64528. if (this._refractionTexture) {
  64529. activeTextures.push(this._refractionTexture);
  64530. }
  64531. };
  64532. /**
  64533. * Returns the animatable textures.
  64534. * @param animatables Array of animatable textures.
  64535. */
  64536. PBRSubSurfaceConfiguration.prototype.getAnimatables = function (animatables) {
  64537. if (this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0) {
  64538. animatables.push(this._thicknessTexture);
  64539. }
  64540. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  64541. animatables.push(this._refractionTexture);
  64542. }
  64543. };
  64544. /**
  64545. * Disposes the resources of the material.
  64546. * @param forceDisposeTextures - Forces the disposal of all textures.
  64547. */
  64548. PBRSubSurfaceConfiguration.prototype.dispose = function (forceDisposeTextures) {
  64549. if (forceDisposeTextures) {
  64550. if (this._thicknessTexture) {
  64551. this._thicknessTexture.dispose();
  64552. }
  64553. if (this._refractionTexture) {
  64554. this._refractionTexture.dispose();
  64555. }
  64556. }
  64557. };
  64558. /**
  64559. * Get the current class name of the texture useful for serialization or dynamic coding.
  64560. * @returns "PBRSubSurfaceConfiguration"
  64561. */
  64562. PBRSubSurfaceConfiguration.prototype.getClassName = function () {
  64563. return "PBRSubSurfaceConfiguration";
  64564. };
  64565. /**
  64566. * Add fallbacks to the effect fallbacks list.
  64567. * @param defines defines the Base texture to use.
  64568. * @param fallbacks defines the current fallback list.
  64569. * @param currentRank defines the current fallback rank.
  64570. * @returns the new fallback rank.
  64571. */
  64572. PBRSubSurfaceConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  64573. if (defines.SS_SCATERRING) {
  64574. fallbacks.addFallback(currentRank++, "SS_SCATERRING");
  64575. }
  64576. if (defines.SS_TRANSLUCENCY) {
  64577. fallbacks.addFallback(currentRank++, "SS_TRANSLUCENCY");
  64578. }
  64579. return currentRank;
  64580. };
  64581. /**
  64582. * Add the required uniforms to the current list.
  64583. * @param uniforms defines the current uniform list.
  64584. */
  64585. PBRSubSurfaceConfiguration.AddUniforms = function (uniforms) {
  64586. uniforms.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionInfos", "vThicknessInfos", "vThicknessParam", "refractionMatrix", "thicknessMatrix");
  64587. };
  64588. /**
  64589. * Add the required samplers to the current list.
  64590. * @param samplers defines the current sampler list.
  64591. */
  64592. PBRSubSurfaceConfiguration.AddSamplers = function (samplers) {
  64593. samplers.push("thicknessSampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
  64594. };
  64595. /**
  64596. * Add the required uniforms to the current buffer.
  64597. * @param uniformBuffer defines the current uniform buffer.
  64598. */
  64599. PBRSubSurfaceConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  64600. uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  64601. uniformBuffer.addUniform("vRefractionInfos", 4);
  64602. uniformBuffer.addUniform("refractionMatrix", 16);
  64603. uniformBuffer.addUniform("vThicknessInfos", 2);
  64604. uniformBuffer.addUniform("thicknessMatrix", 16);
  64605. uniformBuffer.addUniform("vThicknessParam", 2);
  64606. uniformBuffer.addUniform("vDiffusionDistance", 3);
  64607. uniformBuffer.addUniform("vTintColor", 4);
  64608. uniformBuffer.addUniform("vSubSurfaceIntensity", 3);
  64609. };
  64610. /**
  64611. * Makes a duplicate of the current configuration into another one.
  64612. * @param configuration define the config where to copy the info
  64613. */
  64614. PBRSubSurfaceConfiguration.prototype.copyTo = function (configuration) {
  64615. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return configuration; }, this);
  64616. };
  64617. /**
  64618. * Serializes this Sub Surface configuration.
  64619. * @returns - An object with the serialized config.
  64620. */
  64621. PBRSubSurfaceConfiguration.prototype.serialize = function () {
  64622. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64623. };
  64624. /**
  64625. * Parses a anisotropy Configuration from a serialized object.
  64626. * @param source - Serialized object.
  64627. * @param scene Defines the scene we are parsing for
  64628. * @param rootUrl Defines the rootUrl to load from
  64629. */
  64630. PBRSubSurfaceConfiguration.prototype.parse = function (source, scene, rootUrl) {
  64631. var _this = this;
  64632. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, scene, rootUrl);
  64633. };
  64634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64637. ], PBRSubSurfaceConfiguration.prototype, "isRefractionEnabled", void 0);
  64638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64641. ], PBRSubSurfaceConfiguration.prototype, "isTranslucencyEnabled", void 0);
  64642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64644. ], PBRSubSurfaceConfiguration.prototype, "refractionIntensity", void 0);
  64645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64647. ], PBRSubSurfaceConfiguration.prototype, "translucencyIntensity", void 0);
  64648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64650. ], PBRSubSurfaceConfiguration.prototype, "scatteringIntensity", void 0);
  64651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  64653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64654. ], PBRSubSurfaceConfiguration.prototype, "thicknessTexture", void 0);
  64655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  64657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64658. ], PBRSubSurfaceConfiguration.prototype, "refractionTexture", void 0);
  64659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64662. ], PBRSubSurfaceConfiguration.prototype, "indexOfRefraction", void 0);
  64663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64666. ], PBRSubSurfaceConfiguration.prototype, "invertRefractionY", void 0);
  64667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64670. ], PBRSubSurfaceConfiguration.prototype, "linkRefractionWithTransparency", void 0);
  64671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64673. ], PBRSubSurfaceConfiguration.prototype, "minimumThickness", void 0);
  64674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64676. ], PBRSubSurfaceConfiguration.prototype, "maximumThickness", void 0);
  64677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  64679. ], PBRSubSurfaceConfiguration.prototype, "tintColor", void 0);
  64680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64682. ], PBRSubSurfaceConfiguration.prototype, "tintColorAtDistance", void 0);
  64683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  64685. ], PBRSubSurfaceConfiguration.prototype, "diffusionDistance", void 0);
  64686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  64688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  64689. ], PBRSubSurfaceConfiguration.prototype, "useMaskFromThicknessTexture", void 0);
  64690. return PBRSubSurfaceConfiguration;
  64691. }());
  64692. /***/ }),
  64693. /***/ "./Materials/Textures/Loaders/basisTextureLoader.ts":
  64694. /*!**********************************************************!*\
  64695. !*** ./Materials/Textures/Loaders/basisTextureLoader.ts ***!
  64696. \**********************************************************/
  64697. /*! exports provided: _BasisTextureLoader */
  64698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64699. "use strict";
  64700. __webpack_require__.r(__webpack_exports__);
  64701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BasisTextureLoader", function() { return _BasisTextureLoader; });
  64702. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  64703. /* harmony import */ var _Misc_basis__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/basis */ "./Misc/basis.ts");
  64704. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  64705. /**
  64706. * Loader for .basis file format
  64707. */
  64708. var _BasisTextureLoader = /** @class */ (function () {
  64709. function _BasisTextureLoader() {
  64710. /**
  64711. * Defines whether the loader supports cascade loading the different faces.
  64712. */
  64713. this.supportCascades = true;
  64714. }
  64715. /**
  64716. * This returns if the loader support the current file information.
  64717. * @param extension defines the file extension of the file being loaded
  64718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64719. * @param fallback defines the fallback internal texture if any
  64720. * @param isBase64 defines whether the texture is encoded as a base64
  64721. * @param isBuffer defines whether the texture data are stored as a buffer
  64722. * @returns true if the loader can load the specified file
  64723. */
  64724. _BasisTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  64725. return extension.indexOf(".basis") === 0;
  64726. };
  64727. /**
  64728. * Transform the url before loading if required.
  64729. * @param rootUrl the url of the texture
  64730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64731. * @returns the transformed texture
  64732. */
  64733. _BasisTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  64734. return rootUrl;
  64735. };
  64736. /**
  64737. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  64738. * @param rootUrl the url of the texture
  64739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64740. * @returns the fallback texture
  64741. */
  64742. _BasisTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  64743. return null;
  64744. };
  64745. /**
  64746. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  64747. * @param data contains the texture data
  64748. * @param texture defines the BabylonJS internal texture
  64749. * @param createPolynomials will be true if polynomials have been requested
  64750. * @param onLoad defines the callback to trigger once the texture is ready
  64751. * @param onError defines the callback to trigger in case of error
  64752. */
  64753. _BasisTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  64754. if (Array.isArray(data)) {
  64755. return;
  64756. }
  64757. var caps = texture.getEngine().getCaps();
  64758. var transcodeConfig = {
  64759. supportedCompressionFormats: {
  64760. etc1: caps.etc1 ? true : false,
  64761. s3tc: caps.s3tc ? true : false,
  64762. pvrtc: caps.pvrtc ? true : false,
  64763. etc2: caps.etc2 ? true : false
  64764. }
  64765. };
  64766. _Misc_basis__WEBPACK_IMPORTED_MODULE_1__["BasisTools"].TranscodeAsync(data, transcodeConfig).then(function (result) {
  64767. var hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;
  64768. _Misc_basis__WEBPACK_IMPORTED_MODULE_1__["BasisTools"].LoadTextureFromTranscodeResult(texture, result);
  64769. texture.getEngine()._setCubeMapTextureParams(hasMipmap);
  64770. texture.isReady = true;
  64771. }).catch(function (err) {
  64772. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Warn("Failed to transcode Basis file, transcoding may not be supported on this device");
  64773. texture.isReady = true;
  64774. });
  64775. };
  64776. /**
  64777. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  64778. * @param data contains the texture data
  64779. * @param texture defines the BabylonJS internal texture
  64780. * @param callback defines the method to call once ready to upload
  64781. */
  64782. _BasisTextureLoader.prototype.loadData = function (data, texture, callback) {
  64783. var caps = texture.getEngine().getCaps();
  64784. var transcodeConfig = {
  64785. supportedCompressionFormats: {
  64786. etc1: caps.etc1 ? true : false,
  64787. s3tc: caps.s3tc ? true : false,
  64788. pvrtc: caps.pvrtc ? true : false,
  64789. etc2: caps.etc2 ? true : false
  64790. }
  64791. };
  64792. _Misc_basis__WEBPACK_IMPORTED_MODULE_1__["BasisTools"].TranscodeAsync(data, transcodeConfig).then(function (result) {
  64793. var rootImage = result.fileInfo.images[0].levels[0];
  64794. var hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;
  64795. callback(rootImage.width, rootImage.height, hasMipmap, result.format !== -1, function () {
  64796. _Misc_basis__WEBPACK_IMPORTED_MODULE_1__["BasisTools"].LoadTextureFromTranscodeResult(texture, result);
  64797. });
  64798. }).catch(function (err) {
  64799. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Warn("Failed to transcode Basis file, transcoding may not be supported on this device");
  64800. callback(0, 0, false, false, function () {
  64801. });
  64802. });
  64803. };
  64804. return _BasisTextureLoader;
  64805. }());
  64806. // Register the loader.
  64807. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"]._TextureLoaders.push(new _BasisTextureLoader());
  64808. /***/ }),
  64809. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  64810. /*!********************************************************!*\
  64811. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  64812. \********************************************************/
  64813. /*! exports provided: _DDSTextureLoader */
  64814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64815. "use strict";
  64816. __webpack_require__.r(__webpack_exports__);
  64817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  64818. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  64819. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  64820. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  64821. /**
  64822. * Implementation of the DDS Texture Loader.
  64823. * @hidden
  64824. */
  64825. var _DDSTextureLoader = /** @class */ (function () {
  64826. function _DDSTextureLoader() {
  64827. /**
  64828. * Defines wether the loader supports cascade loading the different faces.
  64829. */
  64830. this.supportCascades = true;
  64831. }
  64832. /**
  64833. * This returns if the loader support the current file information.
  64834. * @param extension defines the file extension of the file being loaded
  64835. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64836. * @param fallback defines the fallback internal texture if any
  64837. * @param isBase64 defines whether the texture is encoded as a base64
  64838. * @param isBuffer defines whether the texture data are stored as a buffer
  64839. * @returns true if the loader can load the specified file
  64840. */
  64841. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  64842. return extension.indexOf(".dds") === 0;
  64843. };
  64844. /**
  64845. * Transform the url before loading if required.
  64846. * @param rootUrl the url of the texture
  64847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64848. * @returns the transformed texture
  64849. */
  64850. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  64851. return rootUrl;
  64852. };
  64853. /**
  64854. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  64855. * @param rootUrl the url of the texture
  64856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64857. * @returns the fallback texture
  64858. */
  64859. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  64860. return null;
  64861. };
  64862. /**
  64863. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  64864. * @param data contains the texture data
  64865. * @param texture defines the BabylonJS internal texture
  64866. * @param createPolynomials will be true if polynomials have been requested
  64867. * @param onLoad defines the callback to trigger once the texture is ready
  64868. * @param onError defines the callback to trigger in case of error
  64869. */
  64870. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  64871. var engine = texture.getEngine();
  64872. var info;
  64873. var loadMipmap = false;
  64874. if (Array.isArray(imgs)) {
  64875. for (var index = 0; index < imgs.length; index++) {
  64876. var data_1 = imgs[index];
  64877. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  64878. texture.width = info.width;
  64879. texture.height = info.height;
  64880. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  64881. engine._unpackFlipY(info.isCompressed);
  64882. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  64883. if (!info.isFourCC && info.mipmapCount === 1) {
  64884. engine.generateMipMapsForCubemap(texture);
  64885. }
  64886. }
  64887. }
  64888. else {
  64889. var data = imgs;
  64890. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  64891. texture.width = info.width;
  64892. texture.height = info.height;
  64893. if (createPolynomials) {
  64894. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  64895. }
  64896. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  64897. engine._unpackFlipY(info.isCompressed);
  64898. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  64899. if (!info.isFourCC && info.mipmapCount === 1) {
  64900. engine.generateMipMapsForCubemap(texture);
  64901. }
  64902. }
  64903. engine._setCubeMapTextureParams(loadMipmap);
  64904. texture.isReady = true;
  64905. if (onLoad) {
  64906. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  64907. }
  64908. };
  64909. /**
  64910. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  64911. * @param data contains the texture data
  64912. * @param texture defines the BabylonJS internal texture
  64913. * @param callback defines the method to call once ready to upload
  64914. */
  64915. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  64916. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  64917. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  64918. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  64919. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  64920. });
  64921. };
  64922. return _DDSTextureLoader;
  64923. }());
  64924. // Register the loader.
  64925. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  64926. /***/ }),
  64927. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  64928. /*!********************************************************!*\
  64929. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  64930. \********************************************************/
  64931. /*! exports provided: _ENVTextureLoader */
  64932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64933. "use strict";
  64934. __webpack_require__.r(__webpack_exports__);
  64935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  64936. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  64937. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  64938. /**
  64939. * Implementation of the ENV Texture Loader.
  64940. * @hidden
  64941. */
  64942. var _ENVTextureLoader = /** @class */ (function () {
  64943. function _ENVTextureLoader() {
  64944. /**
  64945. * Defines wether the loader supports cascade loading the different faces.
  64946. */
  64947. this.supportCascades = false;
  64948. }
  64949. /**
  64950. * This returns if the loader support the current file information.
  64951. * @param extension defines the file extension of the file being loaded
  64952. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64953. * @param fallback defines the fallback internal texture if any
  64954. * @param isBase64 defines whether the texture is encoded as a base64
  64955. * @param isBuffer defines whether the texture data are stored as a buffer
  64956. * @returns true if the loader can load the specified file
  64957. */
  64958. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  64959. return extension.indexOf(".env") === 0;
  64960. };
  64961. /**
  64962. * Transform the url before loading if required.
  64963. * @param rootUrl the url of the texture
  64964. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64965. * @returns the transformed texture
  64966. */
  64967. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  64968. return rootUrl;
  64969. };
  64970. /**
  64971. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  64972. * @param rootUrl the url of the texture
  64973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  64974. * @returns the fallback texture
  64975. */
  64976. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  64977. return null;
  64978. };
  64979. /**
  64980. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  64981. * @param data contains the texture data
  64982. * @param texture defines the BabylonJS internal texture
  64983. * @param createPolynomials will be true if polynomials have been requested
  64984. * @param onLoad defines the callback to trigger once the texture is ready
  64985. * @param onError defines the callback to trigger in case of error
  64986. */
  64987. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  64988. if (Array.isArray(data)) {
  64989. return;
  64990. }
  64991. data = data;
  64992. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  64993. if (info) {
  64994. texture.width = info.width;
  64995. texture.height = info.width;
  64996. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  64997. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  64998. texture.isReady = true;
  64999. if (onLoad) {
  65000. onLoad();
  65001. }
  65002. });
  65003. }
  65004. else if (onError) {
  65005. onError("Can not parse the environment file", null);
  65006. }
  65007. };
  65008. /**
  65009. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  65010. * @param data contains the texture data
  65011. * @param texture defines the BabylonJS internal texture
  65012. * @param callback defines the method to call once ready to upload
  65013. */
  65014. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  65015. throw ".env not supported in 2d.";
  65016. };
  65017. return _ENVTextureLoader;
  65018. }());
  65019. // Register the loader.
  65020. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  65021. /***/ }),
  65022. /***/ "./Materials/Textures/Loaders/index.ts":
  65023. /*!*********************************************!*\
  65024. !*** ./Materials/Textures/Loaders/index.ts ***!
  65025. \*********************************************/
  65026. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, _BasisTextureLoader */
  65027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65028. "use strict";
  65029. __webpack_require__.r(__webpack_exports__);
  65030. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  65031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  65032. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  65033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  65034. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  65035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  65036. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  65037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  65038. /* harmony import */ var _basisTextureLoader__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./basisTextureLoader */ "./Materials/Textures/Loaders/basisTextureLoader.ts");
  65039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BasisTextureLoader", function() { return _basisTextureLoader__WEBPACK_IMPORTED_MODULE_4__["_BasisTextureLoader"]; });
  65040. /***/ }),
  65041. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  65042. /*!********************************************************!*\
  65043. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  65044. \********************************************************/
  65045. /*! exports provided: _KTXTextureLoader */
  65046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65047. "use strict";
  65048. __webpack_require__.r(__webpack_exports__);
  65049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  65050. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  65051. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  65052. /**
  65053. * Implementation of the KTX Texture Loader.
  65054. * @hidden
  65055. */
  65056. var _KTXTextureLoader = /** @class */ (function () {
  65057. function _KTXTextureLoader() {
  65058. /**
  65059. * Defines wether the loader supports cascade loading the different faces.
  65060. */
  65061. this.supportCascades = false;
  65062. }
  65063. /**
  65064. * This returns if the loader support the current file information.
  65065. * @param extension defines the file extension of the file being loaded
  65066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  65067. * @param fallback defines the fallback internal texture if any
  65068. * @param isBase64 defines whether the texture is encoded as a base64
  65069. * @param isBuffer defines whether the texture data are stored as a buffer
  65070. * @returns true if the loader can load the specified file
  65071. */
  65072. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  65073. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  65074. return true;
  65075. }
  65076. return false;
  65077. };
  65078. /**
  65079. * Transform the url before loading if required.
  65080. * @param rootUrl the url of the texture
  65081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  65082. * @returns the transformed texture
  65083. */
  65084. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  65085. var lastDot = rootUrl.lastIndexOf('.');
  65086. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  65087. // Already transformed
  65088. return rootUrl;
  65089. }
  65090. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  65091. };
  65092. /**
  65093. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  65094. * @param rootUrl the url of the texture
  65095. * @param textureFormatInUse defines the current compressed format in use iun the engine
  65096. * @returns the fallback texture
  65097. */
  65098. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  65099. // remove the format appended to the rootUrl in the original createCubeTexture call.
  65100. var exp = new RegExp("" + textureFormatInUse + "$");
  65101. return rootUrl.replace(exp, "");
  65102. };
  65103. /**
  65104. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  65105. * @param data contains the texture data
  65106. * @param texture defines the BabylonJS internal texture
  65107. * @param createPolynomials will be true if polynomials have been requested
  65108. * @param onLoad defines the callback to trigger once the texture is ready
  65109. * @param onError defines the callback to trigger in case of error
  65110. */
  65111. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  65112. if (Array.isArray(data)) {
  65113. return;
  65114. }
  65115. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  65116. texture._invertVScale = !texture.invertY;
  65117. var engine = texture.getEngine();
  65118. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  65119. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  65120. engine._unpackFlipY(true);
  65121. ktx.uploadLevels(texture, texture.generateMipMaps);
  65122. texture.width = ktx.pixelWidth;
  65123. texture.height = ktx.pixelHeight;
  65124. engine._setCubeMapTextureParams(loadMipmap);
  65125. texture.isReady = true;
  65126. };
  65127. /**
  65128. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  65129. * @param data contains the texture data
  65130. * @param texture defines the BabylonJS internal texture
  65131. * @param callback defines the method to call once ready to upload
  65132. */
  65133. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  65134. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  65135. texture._invertVScale = !texture.invertY;
  65136. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  65137. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  65138. ktx.uploadLevels(texture, texture.generateMipMaps);
  65139. }, ktx.isInvalid);
  65140. };
  65141. return _KTXTextureLoader;
  65142. }());
  65143. // Register the loader.
  65144. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  65145. /***/ }),
  65146. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  65147. /*!********************************************************!*\
  65148. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  65149. \********************************************************/
  65150. /*! exports provided: _TGATextureLoader */
  65151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65152. "use strict";
  65153. __webpack_require__.r(__webpack_exports__);
  65154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  65155. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  65156. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  65157. /**
  65158. * Implementation of the TGA Texture Loader.
  65159. * @hidden
  65160. */
  65161. var _TGATextureLoader = /** @class */ (function () {
  65162. function _TGATextureLoader() {
  65163. /**
  65164. * Defines wether the loader supports cascade loading the different faces.
  65165. */
  65166. this.supportCascades = false;
  65167. }
  65168. /**
  65169. * This returns if the loader support the current file information.
  65170. * @param extension defines the file extension of the file being loaded
  65171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  65172. * @param fallback defines the fallback internal texture if any
  65173. * @param isBase64 defines whether the texture is encoded as a base64
  65174. * @param isBuffer defines whether the texture data are stored as a buffer
  65175. * @returns true if the loader can load the specified file
  65176. */
  65177. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  65178. return extension.indexOf(".tga") === 0;
  65179. };
  65180. /**
  65181. * Transform the url before loading if required.
  65182. * @param rootUrl the url of the texture
  65183. * @param textureFormatInUse defines the current compressed format in use iun the engine
  65184. * @returns the transformed texture
  65185. */
  65186. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  65187. return rootUrl;
  65188. };
  65189. /**
  65190. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  65191. * @param rootUrl the url of the texture
  65192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  65193. * @returns the fallback texture
  65194. */
  65195. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  65196. return null;
  65197. };
  65198. /**
  65199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  65200. * @param data contains the texture data
  65201. * @param texture defines the BabylonJS internal texture
  65202. * @param createPolynomials will be true if polynomials have been requested
  65203. * @param onLoad defines the callback to trigger once the texture is ready
  65204. * @param onError defines the callback to trigger in case of error
  65205. */
  65206. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  65207. throw ".env not supported in Cube.";
  65208. };
  65209. /**
  65210. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  65211. * @param data contains the texture data
  65212. * @param texture defines the BabylonJS internal texture
  65213. * @param callback defines the method to call once ready to upload
  65214. */
  65215. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  65216. var uintData = new Uint8Array(data);
  65217. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  65218. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  65219. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  65220. });
  65221. };
  65222. return _TGATextureLoader;
  65223. }());
  65224. // Register the loader.
  65225. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  65226. /***/ }),
  65227. /***/ "./Materials/Textures/MultiviewRenderTarget.ts":
  65228. /*!*****************************************************!*\
  65229. !*** ./Materials/Textures/MultiviewRenderTarget.ts ***!
  65230. \*****************************************************/
  65231. /*! exports provided: MultiviewRenderTarget */
  65232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65233. "use strict";
  65234. __webpack_require__.r(__webpack_exports__);
  65235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  65236. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65237. /* harmony import */ var _Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  65238. /* harmony import */ var _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  65239. /**
  65240. * Renders to multiple views with a single draw call
  65241. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  65242. */
  65243. var MultiviewRenderTarget = /** @class */ (function (_super) {
  65244. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  65245. /**
  65246. * Creates a multiview render target
  65247. * @param scene scene used with the render target
  65248. * @param size the size of the render target (used for each view)
  65249. */
  65250. function MultiviewRenderTarget(scene, size) {
  65251. if (size === void 0) { size = 512; }
  65252. 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;
  65253. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  65254. internalTexture.isMultiview = true;
  65255. _this._texture = internalTexture;
  65256. return _this;
  65257. }
  65258. /**
  65259. * @hidden
  65260. * @param faceIndex the face index, if its a cube texture
  65261. */
  65262. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  65263. if (faceIndex === void 0) { faceIndex = 0; }
  65264. if (!this._texture) {
  65265. return;
  65266. }
  65267. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  65268. };
  65269. /**
  65270. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  65271. * @returns the view count
  65272. */
  65273. MultiviewRenderTarget.prototype.getViewCount = function () {
  65274. return 2;
  65275. };
  65276. return MultiviewRenderTarget;
  65277. }(_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]));
  65278. /***/ }),
  65279. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  65280. /*!*******************************************************************!*\
  65281. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  65282. \*******************************************************************/
  65283. /*! exports provided: CustomProceduralTexture */
  65284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65285. "use strict";
  65286. __webpack_require__.r(__webpack_exports__);
  65287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  65288. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65289. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  65290. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math.vector */ "./Maths/math.vector.ts");
  65291. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math.color */ "./Maths/math.color.ts");
  65292. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65293. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  65294. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  65295. /**
  65296. * 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.
  65297. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65298. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65299. */
  65300. var CustomProceduralTexture = /** @class */ (function (_super) {
  65301. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  65302. /**
  65303. * Instantiates a new Custom Procedural Texture.
  65304. * 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.
  65305. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65306. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65307. * @param name Define the name of the texture
  65308. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65309. * @param size Define the size of the texture to create
  65310. * @param scene Define the scene the texture belongs to
  65311. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65312. * @param generateMipMaps Define if the texture should creates mip maps or not
  65313. */
  65314. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  65315. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  65316. _this._animate = true;
  65317. _this._time = 0;
  65318. _this._texturePath = texturePath;
  65319. //Try to load json
  65320. _this._loadJson(texturePath);
  65321. _this.refreshRate = 1;
  65322. return _this;
  65323. }
  65324. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  65325. var _this = this;
  65326. var noConfigFile = function () {
  65327. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  65328. try {
  65329. _this.setFragment(_this._texturePath);
  65330. }
  65331. catch (ex) {
  65332. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  65333. }
  65334. };
  65335. var configFileUrl = jsonUrl + "/config.json";
  65336. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_6__["WebRequest"]();
  65337. xhr.open("GET", configFileUrl);
  65338. xhr.addEventListener("load", function () {
  65339. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  65340. try {
  65341. _this._config = JSON.parse(xhr.response);
  65342. _this.updateShaderUniforms();
  65343. _this.updateTextures();
  65344. _this.setFragment(_this._texturePath + "/custom");
  65345. _this._animate = _this._config.animate;
  65346. _this.refreshRate = _this._config.refreshrate;
  65347. }
  65348. catch (ex) {
  65349. noConfigFile();
  65350. }
  65351. }
  65352. else {
  65353. noConfigFile();
  65354. }
  65355. }, false);
  65356. xhr.addEventListener("error", function () {
  65357. noConfigFile();
  65358. }, false);
  65359. try {
  65360. xhr.send();
  65361. }
  65362. catch (ex) {
  65363. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  65364. }
  65365. };
  65366. /**
  65367. * Is the texture ready to be used ? (rendered at least once)
  65368. * @returns true if ready, otherwise, false.
  65369. */
  65370. CustomProceduralTexture.prototype.isReady = function () {
  65371. if (!_super.prototype.isReady.call(this)) {
  65372. return false;
  65373. }
  65374. for (var name in this._textures) {
  65375. var texture = this._textures[name];
  65376. if (!texture.isReady()) {
  65377. return false;
  65378. }
  65379. }
  65380. return true;
  65381. };
  65382. /**
  65383. * Render the texture to its associated render target.
  65384. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65385. */
  65386. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  65387. var scene = this.getScene();
  65388. if (this._animate && scene) {
  65389. this._time += scene.getAnimationRatio() * 0.03;
  65390. this.updateShaderUniforms();
  65391. }
  65392. _super.prototype.render.call(this, useCameraPostProcess);
  65393. };
  65394. /**
  65395. * Update the list of dependant textures samplers in the shader.
  65396. */
  65397. CustomProceduralTexture.prototype.updateTextures = function () {
  65398. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  65399. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  65400. }
  65401. };
  65402. /**
  65403. * Update the uniform values of the procedural texture in the shader.
  65404. */
  65405. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  65406. if (this._config) {
  65407. for (var j = 0; j < this._config.uniforms.length; j++) {
  65408. var uniform = this._config.uniforms[j];
  65409. switch (uniform.type) {
  65410. case "float":
  65411. this.setFloat(uniform.name, uniform.value);
  65412. break;
  65413. case "color3":
  65414. this.setColor3(uniform.name, new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  65415. break;
  65416. case "color4":
  65417. this.setColor4(uniform.name, new _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  65418. break;
  65419. case "vector2":
  65420. this.setVector2(uniform.name, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  65421. break;
  65422. case "vector3":
  65423. this.setVector3(uniform.name, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  65424. break;
  65425. }
  65426. }
  65427. }
  65428. this.setFloat("time", this._time);
  65429. };
  65430. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  65431. /**
  65432. * Define if the texture animates or not.
  65433. */
  65434. get: function () {
  65435. return this._animate;
  65436. },
  65437. set: function (value) {
  65438. this._animate = value;
  65439. },
  65440. enumerable: true,
  65441. configurable: true
  65442. });
  65443. return CustomProceduralTexture;
  65444. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  65445. /***/ }),
  65446. /***/ "./Materials/Textures/Procedurals/index.ts":
  65447. /*!*************************************************!*\
  65448. !*** ./Materials/Textures/Procedurals/index.ts ***!
  65449. \*************************************************/
  65450. /*! exports provided: CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  65451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65452. "use strict";
  65453. __webpack_require__.r(__webpack_exports__);
  65454. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  65455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  65456. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  65457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  65458. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  65459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  65460. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  65461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  65462. /***/ }),
  65463. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  65464. /*!******************************************************************!*\
  65465. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  65466. \******************************************************************/
  65467. /*! exports provided: NoiseProceduralTexture */
  65468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65469. "use strict";
  65470. __webpack_require__.r(__webpack_exports__);
  65471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  65472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65473. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  65474. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  65475. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  65476. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  65477. /**
  65478. * Class used to generate noise procedural textures
  65479. */
  65480. var NoiseProceduralTexture = /** @class */ (function (_super) {
  65481. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  65482. /**
  65483. * Creates a new NoiseProceduralTexture
  65484. * @param name defines the name fo the texture
  65485. * @param size defines the size of the texture (default is 256)
  65486. * @param scene defines the hosting scene
  65487. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65488. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65489. */
  65490. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  65491. if (size === void 0) { size = 256; }
  65492. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  65493. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  65494. _this._time = 0;
  65495. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65496. _this.brightness = 0.2;
  65497. /** Defines the number of octaves to process */
  65498. _this.octaves = 3;
  65499. /** Defines the level of persistence (0.8 by default) */
  65500. _this.persistence = 0.8;
  65501. /** Gets or sets animation speed factor (default is 1) */
  65502. _this.animationSpeedFactor = 1;
  65503. _this.autoClear = false;
  65504. _this._updateShaderUniforms();
  65505. return _this;
  65506. }
  65507. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  65508. var scene = this.getScene();
  65509. if (!scene) {
  65510. return;
  65511. }
  65512. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  65513. this.setFloat("brightness", this.brightness);
  65514. this.setFloat("persistence", this.persistence);
  65515. this.setFloat("timeScale", this._time);
  65516. };
  65517. NoiseProceduralTexture.prototype._getDefines = function () {
  65518. return "#define OCTAVES " + (this.octaves | 0);
  65519. };
  65520. /** Generate the current state of the procedural texture */
  65521. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  65522. this._updateShaderUniforms();
  65523. _super.prototype.render.call(this, useCameraPostProcess);
  65524. };
  65525. /**
  65526. * Serializes this noise procedural texture
  65527. * @returns a serialized noise procedural texture object
  65528. */
  65529. NoiseProceduralTexture.prototype.serialize = function () {
  65530. var serializationObject = {};
  65531. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  65532. serializationObject.brightness = this.brightness;
  65533. serializationObject.octaves = this.octaves;
  65534. serializationObject.persistence = this.persistence;
  65535. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  65536. serializationObject.size = this.getSize().width;
  65537. serializationObject.generateMipMaps = this._generateMipMaps;
  65538. return serializationObject;
  65539. };
  65540. /**
  65541. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65542. * @param parsedTexture defines parsed texture data
  65543. * @param scene defines the current scene
  65544. * @param rootUrl defines the root URL containing noise procedural texture information
  65545. * @returns a parsed NoiseProceduralTexture
  65546. */
  65547. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  65548. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  65549. texture.brightness = parsedTexture.brightness;
  65550. texture.octaves = parsedTexture.octaves;
  65551. texture.persistence = parsedTexture.persistence;
  65552. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  65553. return texture;
  65554. };
  65555. return NoiseProceduralTexture;
  65556. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  65557. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  65558. /***/ }),
  65559. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  65560. /*!*************************************************************!*\
  65561. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  65562. \*************************************************************/
  65563. /*! exports provided: ProceduralTexture */
  65564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65565. "use strict";
  65566. __webpack_require__.r(__webpack_exports__);
  65567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  65568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65569. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  65570. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  65571. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  65572. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  65573. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  65574. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65575. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  65576. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  65577. /* harmony import */ var _Engines_Extensions_engine_renderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/Extensions/engine.renderTarget */ "./Engines/Extensions/engine.renderTarget.ts");
  65578. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  65579. /**
  65580. * 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.
  65581. * This is the base class of any Procedural texture and contains most of the shareable code.
  65582. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  65583. */
  65584. var ProceduralTexture = /** @class */ (function (_super) {
  65585. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  65586. /**
  65587. * Instantiates a new procedural texture.
  65588. * 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.
  65589. * This is the base class of any Procedural texture and contains most of the shareable code.
  65590. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  65591. * @param name Define the name of the texture
  65592. * @param size Define the size of the texture to create
  65593. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  65594. * @param scene Define the scene the texture belongs to
  65595. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65596. * @param generateMipMaps Define if the texture should creates mip maps or not
  65597. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  65598. */
  65599. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  65600. if (fallbackTexture === void 0) { fallbackTexture = null; }
  65601. if (generateMipMaps === void 0) { generateMipMaps = true; }
  65602. if (isCube === void 0) { isCube = false; }
  65603. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  65604. _this.isCube = isCube;
  65605. /**
  65606. * Define if the texture is enabled or not (disabled texture will not render)
  65607. */
  65608. _this.isEnabled = true;
  65609. /**
  65610. * Define if the texture must be cleared before rendering (default is true)
  65611. */
  65612. _this.autoClear = true;
  65613. /**
  65614. * Event raised when the texture is generated
  65615. */
  65616. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  65617. /** @hidden */
  65618. _this._textures = {};
  65619. _this._currentRefreshId = -1;
  65620. _this._refreshRate = 1;
  65621. _this._vertexBuffers = {};
  65622. _this._uniforms = new Array();
  65623. _this._samplers = new Array();
  65624. _this._floats = {};
  65625. _this._ints = {};
  65626. _this._floatsArrays = {};
  65627. _this._colors3 = {};
  65628. _this._colors4 = {};
  65629. _this._vectors2 = {};
  65630. _this._vectors3 = {};
  65631. _this._matrices = {};
  65632. _this._fallbackTextureUsed = false;
  65633. _this._cachedDefines = "";
  65634. _this._contentUpdateId = -1;
  65635. scene = _this.getScene();
  65636. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  65637. if (!component) {
  65638. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  65639. scene._addComponent(component);
  65640. }
  65641. scene.proceduralTextures.push(_this);
  65642. _this._engine = scene.getEngine();
  65643. _this.name = name;
  65644. _this.isRenderTarget = true;
  65645. _this._size = size;
  65646. _this._generateMipMaps = generateMipMaps;
  65647. _this.setFragment(fragment);
  65648. _this._fallbackTexture = fallbackTexture;
  65649. if (isCube) {
  65650. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  65651. _this.setFloat("face", 0);
  65652. }
  65653. else {
  65654. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  65655. }
  65656. // VBO
  65657. var vertices = [];
  65658. vertices.push(1, 1);
  65659. vertices.push(-1, 1);
  65660. vertices.push(-1, -1);
  65661. vertices.push(1, -1);
  65662. _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);
  65663. _this._createIndexBuffer();
  65664. return _this;
  65665. }
  65666. /**
  65667. * The effect that is created when initializing the post process.
  65668. * @returns The created effect corresponding the the postprocess.
  65669. */
  65670. ProceduralTexture.prototype.getEffect = function () {
  65671. return this._effect;
  65672. };
  65673. /**
  65674. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  65675. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  65676. */
  65677. ProceduralTexture.prototype.getContent = function () {
  65678. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  65679. return this._contentData;
  65680. }
  65681. this._contentData = this.readPixels(0, 0, this._contentData);
  65682. this._contentUpdateId = this._currentRefreshId;
  65683. return this._contentData;
  65684. };
  65685. ProceduralTexture.prototype._createIndexBuffer = function () {
  65686. var engine = this._engine;
  65687. // Indices
  65688. var indices = [];
  65689. indices.push(0);
  65690. indices.push(1);
  65691. indices.push(2);
  65692. indices.push(0);
  65693. indices.push(2);
  65694. indices.push(3);
  65695. this._indexBuffer = engine.createIndexBuffer(indices);
  65696. };
  65697. /** @hidden */
  65698. ProceduralTexture.prototype._rebuild = function () {
  65699. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  65700. if (vb) {
  65701. vb._rebuild();
  65702. }
  65703. this._createIndexBuffer();
  65704. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  65705. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  65706. }
  65707. };
  65708. /**
  65709. * Resets the texture in order to recreate its associated resources.
  65710. * This can be called in case of context loss
  65711. */
  65712. ProceduralTexture.prototype.reset = function () {
  65713. if (this._effect === undefined) {
  65714. return;
  65715. }
  65716. this._effect.dispose();
  65717. };
  65718. ProceduralTexture.prototype._getDefines = function () {
  65719. return "";
  65720. };
  65721. /**
  65722. * Is the texture ready to be used ? (rendered at least once)
  65723. * @returns true if ready, otherwise, false.
  65724. */
  65725. ProceduralTexture.prototype.isReady = function () {
  65726. var _this = this;
  65727. var engine = this._engine;
  65728. var shaders;
  65729. if (!this._fragment) {
  65730. return false;
  65731. }
  65732. if (this._fallbackTextureUsed) {
  65733. return true;
  65734. }
  65735. var defines = this._getDefines();
  65736. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  65737. return true;
  65738. }
  65739. if (this._fragment.fragmentElement !== undefined) {
  65740. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  65741. }
  65742. else {
  65743. shaders = { vertex: "procedural", fragment: this._fragment };
  65744. }
  65745. this._cachedDefines = defines;
  65746. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  65747. _this.releaseInternalTexture();
  65748. if (_this._fallbackTexture) {
  65749. _this._texture = _this._fallbackTexture._texture;
  65750. if (_this._texture) {
  65751. _this._texture.incrementReferences();
  65752. }
  65753. }
  65754. _this._fallbackTextureUsed = true;
  65755. });
  65756. return this._effect.isReady();
  65757. };
  65758. /**
  65759. * Resets the refresh counter of the texture and start bak from scratch.
  65760. * Could be useful to regenerate the texture if it is setup to render only once.
  65761. */
  65762. ProceduralTexture.prototype.resetRefreshCounter = function () {
  65763. this._currentRefreshId = -1;
  65764. };
  65765. /**
  65766. * Set the fragment shader to use in order to render the texture.
  65767. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  65768. */
  65769. ProceduralTexture.prototype.setFragment = function (fragment) {
  65770. this._fragment = fragment;
  65771. };
  65772. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  65773. /**
  65774. * Define the refresh rate of the texture or the rendering frequency.
  65775. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  65776. */
  65777. get: function () {
  65778. return this._refreshRate;
  65779. },
  65780. set: function (value) {
  65781. this._refreshRate = value;
  65782. this.resetRefreshCounter();
  65783. },
  65784. enumerable: true,
  65785. configurable: true
  65786. });
  65787. /** @hidden */
  65788. ProceduralTexture.prototype._shouldRender = function () {
  65789. if (!this.isEnabled || !this.isReady() || !this._texture) {
  65790. if (this._texture) {
  65791. this._texture.isReady = false;
  65792. }
  65793. return false;
  65794. }
  65795. if (this._fallbackTextureUsed) {
  65796. return false;
  65797. }
  65798. if (this._currentRefreshId === -1) { // At least render once
  65799. this._currentRefreshId = 1;
  65800. return true;
  65801. }
  65802. if (this.refreshRate === this._currentRefreshId) {
  65803. this._currentRefreshId = 1;
  65804. return true;
  65805. }
  65806. this._currentRefreshId++;
  65807. return false;
  65808. };
  65809. /**
  65810. * Get the size the texture is rendering at.
  65811. * @returns the size (texture is always squared)
  65812. */
  65813. ProceduralTexture.prototype.getRenderSize = function () {
  65814. return this._size;
  65815. };
  65816. /**
  65817. * Resize the texture to new value.
  65818. * @param size Define the new size the texture should have
  65819. * @param generateMipMaps Define whether the new texture should create mip maps
  65820. */
  65821. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  65822. if (this._fallbackTextureUsed) {
  65823. return;
  65824. }
  65825. this.releaseInternalTexture();
  65826. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  65827. // Update properties
  65828. this._size = size;
  65829. this._generateMipMaps = generateMipMaps;
  65830. };
  65831. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  65832. if (this._uniforms.indexOf(uniformName) === -1) {
  65833. this._uniforms.push(uniformName);
  65834. }
  65835. };
  65836. /**
  65837. * Set a texture in the shader program used to render.
  65838. * @param name Define the name of the uniform samplers as defined in the shader
  65839. * @param texture Define the texture to bind to this sampler
  65840. * @return the texture itself allowing "fluent" like uniform updates
  65841. */
  65842. ProceduralTexture.prototype.setTexture = function (name, texture) {
  65843. if (this._samplers.indexOf(name) === -1) {
  65844. this._samplers.push(name);
  65845. }
  65846. this._textures[name] = texture;
  65847. return this;
  65848. };
  65849. /**
  65850. * Set a float in the shader.
  65851. * @param name Define the name of the uniform as defined in the shader
  65852. * @param value Define the value to give to the uniform
  65853. * @return the texture itself allowing "fluent" like uniform updates
  65854. */
  65855. ProceduralTexture.prototype.setFloat = function (name, value) {
  65856. this._checkUniform(name);
  65857. this._floats[name] = value;
  65858. return this;
  65859. };
  65860. /**
  65861. * Set a int in the shader.
  65862. * @param name Define the name of the uniform as defined in the shader
  65863. * @param value Define the value to give to the uniform
  65864. * @return the texture itself allowing "fluent" like uniform updates
  65865. */
  65866. ProceduralTexture.prototype.setInt = function (name, value) {
  65867. this._checkUniform(name);
  65868. this._ints[name] = value;
  65869. return this;
  65870. };
  65871. /**
  65872. * Set an array of floats in the shader.
  65873. * @param name Define the name of the uniform as defined in the shader
  65874. * @param value Define the value to give to the uniform
  65875. * @return the texture itself allowing "fluent" like uniform updates
  65876. */
  65877. ProceduralTexture.prototype.setFloats = function (name, value) {
  65878. this._checkUniform(name);
  65879. this._floatsArrays[name] = value;
  65880. return this;
  65881. };
  65882. /**
  65883. * Set a vec3 in the shader from a Color3.
  65884. * @param name Define the name of the uniform as defined in the shader
  65885. * @param value Define the value to give to the uniform
  65886. * @return the texture itself allowing "fluent" like uniform updates
  65887. */
  65888. ProceduralTexture.prototype.setColor3 = function (name, value) {
  65889. this._checkUniform(name);
  65890. this._colors3[name] = value;
  65891. return this;
  65892. };
  65893. /**
  65894. * Set a vec4 in the shader from a Color4.
  65895. * @param name Define the name of the uniform as defined in the shader
  65896. * @param value Define the value to give to the uniform
  65897. * @return the texture itself allowing "fluent" like uniform updates
  65898. */
  65899. ProceduralTexture.prototype.setColor4 = function (name, value) {
  65900. this._checkUniform(name);
  65901. this._colors4[name] = value;
  65902. return this;
  65903. };
  65904. /**
  65905. * Set a vec2 in the shader from a Vector2.
  65906. * @param name Define the name of the uniform as defined in the shader
  65907. * @param value Define the value to give to the uniform
  65908. * @return the texture itself allowing "fluent" like uniform updates
  65909. */
  65910. ProceduralTexture.prototype.setVector2 = function (name, value) {
  65911. this._checkUniform(name);
  65912. this._vectors2[name] = value;
  65913. return this;
  65914. };
  65915. /**
  65916. * Set a vec3 in the shader from a Vector3.
  65917. * @param name Define the name of the uniform as defined in the shader
  65918. * @param value Define the value to give to the uniform
  65919. * @return the texture itself allowing "fluent" like uniform updates
  65920. */
  65921. ProceduralTexture.prototype.setVector3 = function (name, value) {
  65922. this._checkUniform(name);
  65923. this._vectors3[name] = value;
  65924. return this;
  65925. };
  65926. /**
  65927. * Set a mat4 in the shader from a MAtrix.
  65928. * @param name Define the name of the uniform as defined in the shader
  65929. * @param value Define the value to give to the uniform
  65930. * @return the texture itself allowing "fluent" like uniform updates
  65931. */
  65932. ProceduralTexture.prototype.setMatrix = function (name, value) {
  65933. this._checkUniform(name);
  65934. this._matrices[name] = value;
  65935. return this;
  65936. };
  65937. /**
  65938. * Render the texture to its associated render target.
  65939. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65940. */
  65941. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  65942. var scene = this.getScene();
  65943. if (!scene) {
  65944. return;
  65945. }
  65946. var engine = this._engine;
  65947. // Render
  65948. engine.enableEffect(this._effect);
  65949. engine.setState(false);
  65950. // Texture
  65951. for (var name in this._textures) {
  65952. this._effect.setTexture(name, this._textures[name]);
  65953. }
  65954. // Float
  65955. for (name in this._ints) {
  65956. this._effect.setInt(name, this._ints[name]);
  65957. }
  65958. // Float
  65959. for (name in this._floats) {
  65960. this._effect.setFloat(name, this._floats[name]);
  65961. }
  65962. // Floats
  65963. for (name in this._floatsArrays) {
  65964. this._effect.setArray(name, this._floatsArrays[name]);
  65965. }
  65966. // Color3
  65967. for (name in this._colors3) {
  65968. this._effect.setColor3(name, this._colors3[name]);
  65969. }
  65970. // Color4
  65971. for (name in this._colors4) {
  65972. var color = this._colors4[name];
  65973. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  65974. }
  65975. // Vector2
  65976. for (name in this._vectors2) {
  65977. this._effect.setVector2(name, this._vectors2[name]);
  65978. }
  65979. // Vector3
  65980. for (name in this._vectors3) {
  65981. this._effect.setVector3(name, this._vectors3[name]);
  65982. }
  65983. // Matrix
  65984. for (name in this._matrices) {
  65985. this._effect.setMatrix(name, this._matrices[name]);
  65986. }
  65987. if (!this._texture) {
  65988. return;
  65989. }
  65990. if (this.isCube) {
  65991. for (var face = 0; face < 6; face++) {
  65992. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  65993. // VBOs
  65994. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  65995. this._effect.setFloat("face", face);
  65996. // Clear
  65997. if (this.autoClear) {
  65998. engine.clear(scene.clearColor, true, false, false);
  65999. }
  66000. // Draw order
  66001. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  66002. // Mipmaps
  66003. if (face === 5) {
  66004. engine.generateMipMapsForCubemap(this._texture);
  66005. }
  66006. }
  66007. }
  66008. else {
  66009. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  66010. // VBOs
  66011. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  66012. // Clear
  66013. if (this.autoClear) {
  66014. engine.clear(scene.clearColor, true, false, false);
  66015. }
  66016. // Draw order
  66017. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  66018. }
  66019. // Unbind
  66020. engine.unBindFramebuffer(this._texture, this.isCube);
  66021. if (this.onGenerated) {
  66022. this.onGenerated();
  66023. }
  66024. this.onGeneratedObservable.notifyObservers(this);
  66025. };
  66026. /**
  66027. * Clone the texture.
  66028. * @returns the cloned texture
  66029. */
  66030. ProceduralTexture.prototype.clone = function () {
  66031. var textureSize = this.getSize();
  66032. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  66033. // Base texture
  66034. newTexture.hasAlpha = this.hasAlpha;
  66035. newTexture.level = this.level;
  66036. // RenderTarget Texture
  66037. newTexture.coordinatesMode = this.coordinatesMode;
  66038. return newTexture;
  66039. };
  66040. /**
  66041. * Dispose the texture and release its asoociated resources.
  66042. */
  66043. ProceduralTexture.prototype.dispose = function () {
  66044. var scene = this.getScene();
  66045. if (!scene) {
  66046. return;
  66047. }
  66048. var index = scene.proceduralTextures.indexOf(this);
  66049. if (index >= 0) {
  66050. scene.proceduralTextures.splice(index, 1);
  66051. }
  66052. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  66053. if (vertexBuffer) {
  66054. vertexBuffer.dispose();
  66055. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  66056. }
  66057. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  66058. this._indexBuffer = null;
  66059. }
  66060. _super.prototype.dispose.call(this);
  66061. };
  66062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66064. ], ProceduralTexture.prototype, "isEnabled", void 0);
  66065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66067. ], ProceduralTexture.prototype, "autoClear", void 0);
  66068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66070. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  66071. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66073. ], ProceduralTexture.prototype, "_size", void 0);
  66074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66076. ], ProceduralTexture.prototype, "refreshRate", null);
  66077. return ProceduralTexture;
  66078. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  66079. /***/ }),
  66080. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  66081. /*!***************************************************************************!*\
  66082. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  66083. \***************************************************************************/
  66084. /*! exports provided: ProceduralTextureSceneComponent */
  66085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66086. "use strict";
  66087. __webpack_require__.r(__webpack_exports__);
  66088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  66089. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  66090. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  66091. /**
  66092. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  66093. * in a given scene.
  66094. */
  66095. var ProceduralTextureSceneComponent = /** @class */ (function () {
  66096. /**
  66097. * Creates a new instance of the component for the given scene
  66098. * @param scene Defines the scene to register the component in
  66099. */
  66100. function ProceduralTextureSceneComponent(scene) {
  66101. /**
  66102. * The component name helpfull to identify the component in the list of scene components.
  66103. */
  66104. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  66105. this.scene = scene;
  66106. this.scene.proceduralTextures = new Array();
  66107. }
  66108. /**
  66109. * Registers the component in a given scene
  66110. */
  66111. ProceduralTextureSceneComponent.prototype.register = function () {
  66112. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  66113. };
  66114. /**
  66115. * Rebuilds the elements related to this component in case of
  66116. * context lost for instance.
  66117. */
  66118. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  66119. // Nothing to do here.
  66120. };
  66121. /**
  66122. * Disposes the component and the associated ressources.
  66123. */
  66124. ProceduralTextureSceneComponent.prototype.dispose = function () {
  66125. // Nothing to do here.
  66126. };
  66127. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  66128. if (this.scene.proceduralTexturesEnabled) {
  66129. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  66130. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  66131. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  66132. if (proceduralTexture._shouldRender()) {
  66133. proceduralTexture.render();
  66134. }
  66135. }
  66136. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  66137. }
  66138. };
  66139. return ProceduralTextureSceneComponent;
  66140. }());
  66141. /***/ }),
  66142. /***/ "./Materials/Textures/baseTexture.ts":
  66143. /*!*******************************************!*\
  66144. !*** ./Materials/Textures/baseTexture.ts ***!
  66145. \*******************************************/
  66146. /*! exports provided: BaseTexture */
  66147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66148. "use strict";
  66149. __webpack_require__.r(__webpack_exports__);
  66150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  66151. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66152. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  66153. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  66154. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  66155. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  66156. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  66157. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  66158. /* harmony import */ var _Misc_guid__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/guid */ "./Misc/guid.ts");
  66159. /* harmony import */ var _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Maths/math.size */ "./Maths/math.size.ts");
  66160. /**
  66161. * Base class of all the textures in babylon.
  66162. * It groups all the common properties the materials, post process, lights... might need
  66163. * in order to make a correct use of the texture.
  66164. */
  66165. var BaseTexture = /** @class */ (function () {
  66166. /**
  66167. * Instantiates a new BaseTexture.
  66168. * Base class of all the textures in babylon.
  66169. * It groups all the common properties the materials, post process, lights... might need
  66170. * in order to make a correct use of the texture.
  66171. * @param scene Define the scene the texture blongs to
  66172. */
  66173. function BaseTexture(scene) {
  66174. /**
  66175. * Gets or sets an object used to store user defined information.
  66176. */
  66177. this.metadata = null;
  66178. /**
  66179. * For internal use only. Please do not use.
  66180. */
  66181. this.reservedDataStore = null;
  66182. this._hasAlpha = false;
  66183. /**
  66184. * Defines if the alpha value should be determined via the rgb values.
  66185. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66186. */
  66187. this.getAlphaFromRGB = false;
  66188. /**
  66189. * Intensity or strength of the texture.
  66190. * It is commonly used by materials to fine tune the intensity of the texture
  66191. */
  66192. this.level = 1;
  66193. /**
  66194. * Define the UV chanel to use starting from 0 and defaulting to 0.
  66195. * This is part of the texture as textures usually maps to one uv set.
  66196. */
  66197. this.coordinatesIndex = 0;
  66198. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  66199. /**
  66200. * | Value | Type | Description |
  66201. * | ----- | ------------------ | ----------- |
  66202. * | 0 | CLAMP_ADDRESSMODE | |
  66203. * | 1 | WRAP_ADDRESSMODE | |
  66204. * | 2 | MIRROR_ADDRESSMODE | |
  66205. */
  66206. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  66207. /**
  66208. * | Value | Type | Description |
  66209. * | ----- | ------------------ | ----------- |
  66210. * | 0 | CLAMP_ADDRESSMODE | |
  66211. * | 1 | WRAP_ADDRESSMODE | |
  66212. * | 2 | MIRROR_ADDRESSMODE | |
  66213. */
  66214. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  66215. /**
  66216. * | Value | Type | Description |
  66217. * | ----- | ------------------ | ----------- |
  66218. * | 0 | CLAMP_ADDRESSMODE | |
  66219. * | 1 | WRAP_ADDRESSMODE | |
  66220. * | 2 | MIRROR_ADDRESSMODE | |
  66221. */
  66222. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  66223. /**
  66224. * With compliant hardware and browser (supporting anisotropic filtering)
  66225. * this defines the level of anisotropic filtering in the texture.
  66226. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  66227. */
  66228. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  66229. /**
  66230. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  66231. * HDR texture are usually stored in linear space.
  66232. * This only impacts the PBR and Background materials
  66233. */
  66234. this.gammaSpace = true;
  66235. /**
  66236. * Is Z inverted in the texture (useful in a cube texture).
  66237. */
  66238. this.invertZ = false;
  66239. /**
  66240. * @hidden
  66241. */
  66242. this.lodLevelInAlpha = false;
  66243. /**
  66244. * Define if the texture is a render target.
  66245. */
  66246. this.isRenderTarget = false;
  66247. /**
  66248. * Define the list of animation attached to the texture.
  66249. */
  66250. this.animations = new Array();
  66251. /**
  66252. * An event triggered when the texture is disposed.
  66253. */
  66254. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  66255. this._onDisposeObserver = null;
  66256. /**
  66257. * Define the current state of the loading sequence when in delayed load mode.
  66258. */
  66259. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  66260. this._scene = null;
  66261. /** @hidden */
  66262. this._texture = null;
  66263. this._uid = null;
  66264. this._cachedSize = _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__["Size"].Zero();
  66265. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  66266. if (this._scene) {
  66267. this.uniqueId = this._scene.getUniqueId();
  66268. this._scene.addTexture(this);
  66269. }
  66270. this._uid = null;
  66271. }
  66272. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  66273. get: function () {
  66274. return this._hasAlpha;
  66275. },
  66276. /**
  66277. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  66278. */
  66279. set: function (value) {
  66280. if (this._hasAlpha === value) {
  66281. return;
  66282. }
  66283. this._hasAlpha = value;
  66284. if (this._scene) {
  66285. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_MiscDirtyFlag);
  66286. }
  66287. },
  66288. enumerable: true,
  66289. configurable: true
  66290. });
  66291. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  66292. get: function () {
  66293. return this._coordinatesMode;
  66294. },
  66295. /**
  66296. * How a texture is mapped.
  66297. *
  66298. * | Value | Type | Description |
  66299. * | ----- | ----------------------------------- | ----------- |
  66300. * | 0 | EXPLICIT_MODE | |
  66301. * | 1 | SPHERICAL_MODE | |
  66302. * | 2 | PLANAR_MODE | |
  66303. * | 3 | CUBIC_MODE | |
  66304. * | 4 | PROJECTION_MODE | |
  66305. * | 5 | SKYBOX_MODE | |
  66306. * | 6 | INVCUBIC_MODE | |
  66307. * | 7 | EQUIRECTANGULAR_MODE | |
  66308. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  66309. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  66310. */
  66311. set: function (value) {
  66312. if (this._coordinatesMode === value) {
  66313. return;
  66314. }
  66315. this._coordinatesMode = value;
  66316. if (this._scene) {
  66317. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  66318. }
  66319. },
  66320. enumerable: true,
  66321. configurable: true
  66322. });
  66323. Object.defineProperty(BaseTexture.prototype, "isCube", {
  66324. /**
  66325. * Define if the texture is a cube texture or if false a 2d texture.
  66326. */
  66327. get: function () {
  66328. if (!this._texture) {
  66329. return false;
  66330. }
  66331. return this._texture.isCube;
  66332. },
  66333. set: function (value) {
  66334. if (!this._texture) {
  66335. return;
  66336. }
  66337. this._texture.isCube = value;
  66338. },
  66339. enumerable: true,
  66340. configurable: true
  66341. });
  66342. Object.defineProperty(BaseTexture.prototype, "is3D", {
  66343. /**
  66344. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  66345. */
  66346. get: function () {
  66347. if (!this._texture) {
  66348. return false;
  66349. }
  66350. return this._texture.is3D;
  66351. },
  66352. set: function (value) {
  66353. if (!this._texture) {
  66354. return;
  66355. }
  66356. this._texture.is3D = value;
  66357. },
  66358. enumerable: true,
  66359. configurable: true
  66360. });
  66361. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  66362. /**
  66363. * Gets whether or not the texture contains RGBD data.
  66364. */
  66365. get: function () {
  66366. return this._texture != null && this._texture._isRGBD;
  66367. },
  66368. enumerable: true,
  66369. configurable: true
  66370. });
  66371. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  66372. /**
  66373. * Are mip maps generated for this texture or not.
  66374. */
  66375. get: function () {
  66376. return false;
  66377. },
  66378. enumerable: true,
  66379. configurable: true
  66380. });
  66381. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  66382. /**
  66383. * With prefiltered texture, defined the offset used during the prefiltering steps.
  66384. */
  66385. get: function () {
  66386. if (this._texture) {
  66387. return this._texture._lodGenerationOffset;
  66388. }
  66389. return 0.0;
  66390. },
  66391. set: function (value) {
  66392. if (this._texture) {
  66393. this._texture._lodGenerationOffset = value;
  66394. }
  66395. },
  66396. enumerable: true,
  66397. configurable: true
  66398. });
  66399. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  66400. /**
  66401. * With prefiltered texture, defined the scale used during the prefiltering steps.
  66402. */
  66403. get: function () {
  66404. if (this._texture) {
  66405. return this._texture._lodGenerationScale;
  66406. }
  66407. return 0.0;
  66408. },
  66409. set: function (value) {
  66410. if (this._texture) {
  66411. this._texture._lodGenerationScale = value;
  66412. }
  66413. },
  66414. enumerable: true,
  66415. configurable: true
  66416. });
  66417. Object.defineProperty(BaseTexture.prototype, "linearSpecularLOD", {
  66418. /**
  66419. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  66420. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  66421. * average roughness values.
  66422. */
  66423. get: function () {
  66424. if (this._texture) {
  66425. return this._texture._linearSpecularLOD;
  66426. }
  66427. return false;
  66428. },
  66429. set: function (value) {
  66430. if (this._texture) {
  66431. this._texture._linearSpecularLOD = value;
  66432. }
  66433. },
  66434. enumerable: true,
  66435. configurable: true
  66436. });
  66437. Object.defineProperty(BaseTexture.prototype, "irradianceTexture", {
  66438. /**
  66439. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  66440. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  66441. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  66442. */
  66443. get: function () {
  66444. if (this._texture) {
  66445. return this._texture._irradianceTexture;
  66446. }
  66447. return null;
  66448. },
  66449. set: function (value) {
  66450. if (this._texture) {
  66451. this._texture._irradianceTexture = value;
  66452. }
  66453. },
  66454. enumerable: true,
  66455. configurable: true
  66456. });
  66457. Object.defineProperty(BaseTexture.prototype, "uid", {
  66458. /**
  66459. * Define the unique id of the texture in the scene.
  66460. */
  66461. get: function () {
  66462. if (!this._uid) {
  66463. this._uid = _Misc_guid__WEBPACK_IMPORTED_MODULE_7__["GUID"].RandomId();
  66464. }
  66465. return this._uid;
  66466. },
  66467. enumerable: true,
  66468. configurable: true
  66469. });
  66470. /**
  66471. * Return a string representation of the texture.
  66472. * @returns the texture as a string
  66473. */
  66474. BaseTexture.prototype.toString = function () {
  66475. return this.name;
  66476. };
  66477. /**
  66478. * Get the class name of the texture.
  66479. * @returns "BaseTexture"
  66480. */
  66481. BaseTexture.prototype.getClassName = function () {
  66482. return "BaseTexture";
  66483. };
  66484. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  66485. /**
  66486. * Callback triggered when the texture has been disposed.
  66487. * Kept for back compatibility, you can use the onDisposeObservable instead.
  66488. */
  66489. set: function (callback) {
  66490. if (this._onDisposeObserver) {
  66491. this.onDisposeObservable.remove(this._onDisposeObserver);
  66492. }
  66493. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  66494. },
  66495. enumerable: true,
  66496. configurable: true
  66497. });
  66498. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  66499. /**
  66500. * Define if the texture is preventinga material to render or not.
  66501. * If not and the texture is not ready, the engine will use a default black texture instead.
  66502. */
  66503. get: function () {
  66504. return true;
  66505. },
  66506. enumerable: true,
  66507. configurable: true
  66508. });
  66509. /**
  66510. * Get the scene the texture belongs to.
  66511. * @returns the scene or null if undefined
  66512. */
  66513. BaseTexture.prototype.getScene = function () {
  66514. return this._scene;
  66515. };
  66516. /**
  66517. * Get the texture transform matrix used to offset tile the texture for istance.
  66518. * @returns the transformation matrix
  66519. */
  66520. BaseTexture.prototype.getTextureMatrix = function () {
  66521. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityReadOnly;
  66522. };
  66523. /**
  66524. * Get the texture reflection matrix used to rotate/transform the reflection.
  66525. * @returns the reflection matrix
  66526. */
  66527. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  66528. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityReadOnly;
  66529. };
  66530. /**
  66531. * Get the underlying lower level texture from Babylon.
  66532. * @returns the insternal texture
  66533. */
  66534. BaseTexture.prototype.getInternalTexture = function () {
  66535. return this._texture;
  66536. };
  66537. /**
  66538. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  66539. * @returns true if ready or not blocking
  66540. */
  66541. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  66542. return !this.isBlocking || this.isReady();
  66543. };
  66544. /**
  66545. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  66546. * @returns true if fully ready
  66547. */
  66548. BaseTexture.prototype.isReady = function () {
  66549. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  66550. this.delayLoad();
  66551. return false;
  66552. }
  66553. if (this._texture) {
  66554. return this._texture.isReady;
  66555. }
  66556. return false;
  66557. };
  66558. /**
  66559. * Get the size of the texture.
  66560. * @returns the texture size.
  66561. */
  66562. BaseTexture.prototype.getSize = function () {
  66563. if (this._texture) {
  66564. if (this._texture.width) {
  66565. this._cachedSize.width = this._texture.width;
  66566. this._cachedSize.height = this._texture.height;
  66567. return this._cachedSize;
  66568. }
  66569. if (this._texture._size) {
  66570. this._cachedSize.width = this._texture._size;
  66571. this._cachedSize.height = this._texture._size;
  66572. return this._cachedSize;
  66573. }
  66574. }
  66575. return this._cachedSize;
  66576. };
  66577. /**
  66578. * Get the base size of the texture.
  66579. * It can be different from the size if the texture has been resized for POT for instance
  66580. * @returns the base size
  66581. */
  66582. BaseTexture.prototype.getBaseSize = function () {
  66583. if (!this.isReady() || !this._texture) {
  66584. return _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__["Size"].Zero();
  66585. }
  66586. if (this._texture._size) {
  66587. return new _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__["Size"](this._texture._size, this._texture._size);
  66588. }
  66589. return new _Maths_math_size__WEBPACK_IMPORTED_MODULE_8__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  66590. };
  66591. /**
  66592. * Update the sampling mode of the texture.
  66593. * Default is Trilinear mode.
  66594. *
  66595. * | Value | Type | Description |
  66596. * | ----- | ------------------ | ----------- |
  66597. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  66598. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  66599. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  66600. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  66601. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  66602. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  66603. * | 7 | NEAREST_LINEAR | |
  66604. * | 8 | NEAREST_NEAREST | |
  66605. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  66606. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  66607. * | 11 | LINEAR_LINEAR | |
  66608. * | 12 | LINEAR_NEAREST | |
  66609. *
  66610. * > _mag_: magnification filter (close to the viewer)
  66611. * > _min_: minification filter (far from the viewer)
  66612. * > _mip_: filter used between mip map levels
  66613. *@param samplingMode Define the new sampling mode of the texture
  66614. */
  66615. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  66616. if (!this._texture) {
  66617. return;
  66618. }
  66619. var scene = this.getScene();
  66620. if (!scene) {
  66621. return;
  66622. }
  66623. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  66624. };
  66625. /**
  66626. * Scales the texture if is `canRescale()`
  66627. * @param ratio the resize factor we want to use to rescale
  66628. */
  66629. BaseTexture.prototype.scale = function (ratio) {
  66630. };
  66631. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  66632. /**
  66633. * Get if the texture can rescale.
  66634. */
  66635. get: function () {
  66636. return false;
  66637. },
  66638. enumerable: true,
  66639. configurable: true
  66640. });
  66641. /** @hidden */
  66642. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  66643. if (!this._scene) {
  66644. return null;
  66645. }
  66646. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  66647. for (var index = 0; index < texturesCache.length; index++) {
  66648. var texturesCacheEntry = texturesCache[index];
  66649. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  66650. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  66651. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  66652. texturesCacheEntry.incrementReferences();
  66653. return texturesCacheEntry;
  66654. }
  66655. }
  66656. }
  66657. }
  66658. return null;
  66659. };
  66660. /** @hidden */
  66661. BaseTexture.prototype._rebuild = function () {
  66662. };
  66663. /**
  66664. * Triggers the load sequence in delayed load mode.
  66665. */
  66666. BaseTexture.prototype.delayLoad = function () {
  66667. };
  66668. /**
  66669. * Clones the texture.
  66670. * @returns the cloned texture
  66671. */
  66672. BaseTexture.prototype.clone = function () {
  66673. return null;
  66674. };
  66675. Object.defineProperty(BaseTexture.prototype, "textureType", {
  66676. /**
  66677. * Get the texture underlying type (INT, FLOAT...)
  66678. */
  66679. get: function () {
  66680. if (!this._texture) {
  66681. return _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  66682. }
  66683. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  66684. },
  66685. enumerable: true,
  66686. configurable: true
  66687. });
  66688. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  66689. /**
  66690. * Get the texture underlying format (RGB, RGBA...)
  66691. */
  66692. get: function () {
  66693. if (!this._texture) {
  66694. return _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  66695. }
  66696. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  66697. },
  66698. enumerable: true,
  66699. configurable: true
  66700. });
  66701. /**
  66702. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  66703. * This will returns an RGBA array buffer containing either in values (0-255) or
  66704. * float values (0-1) depending of the underlying buffer type.
  66705. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  66706. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  66707. * @param buffer defines a user defined buffer to fill with data (can be null)
  66708. * @returns The Array buffer containing the pixels data.
  66709. */
  66710. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  66711. if (faceIndex === void 0) { faceIndex = 0; }
  66712. if (level === void 0) { level = 0; }
  66713. if (buffer === void 0) { buffer = null; }
  66714. if (!this._texture) {
  66715. return null;
  66716. }
  66717. var size = this.getSize();
  66718. var width = size.width;
  66719. var height = size.height;
  66720. var scene = this.getScene();
  66721. if (!scene) {
  66722. return null;
  66723. }
  66724. var engine = scene.getEngine();
  66725. if (level != 0) {
  66726. width = width / Math.pow(2, level);
  66727. height = height / Math.pow(2, level);
  66728. width = Math.round(width);
  66729. height = Math.round(height);
  66730. }
  66731. if (this._texture.isCube) {
  66732. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  66733. }
  66734. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  66735. };
  66736. /**
  66737. * Release and destroy the underlying lower level texture aka internalTexture.
  66738. */
  66739. BaseTexture.prototype.releaseInternalTexture = function () {
  66740. if (this._texture) {
  66741. this._texture.dispose();
  66742. this._texture = null;
  66743. }
  66744. };
  66745. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  66746. /**
  66747. * Get the polynomial representation of the texture data.
  66748. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  66749. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  66750. */
  66751. get: function () {
  66752. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  66753. return null;
  66754. }
  66755. if (!this._texture._sphericalPolynomial) {
  66756. this._texture._sphericalPolynomial =
  66757. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  66758. }
  66759. return this._texture._sphericalPolynomial;
  66760. },
  66761. set: function (value) {
  66762. if (this._texture) {
  66763. this._texture._sphericalPolynomial = value;
  66764. }
  66765. },
  66766. enumerable: true,
  66767. configurable: true
  66768. });
  66769. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  66770. /** @hidden */
  66771. get: function () {
  66772. if (this._texture) {
  66773. return this._texture._lodTextureHigh;
  66774. }
  66775. return null;
  66776. },
  66777. enumerable: true,
  66778. configurable: true
  66779. });
  66780. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  66781. /** @hidden */
  66782. get: function () {
  66783. if (this._texture) {
  66784. return this._texture._lodTextureMid;
  66785. }
  66786. return null;
  66787. },
  66788. enumerable: true,
  66789. configurable: true
  66790. });
  66791. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  66792. /** @hidden */
  66793. get: function () {
  66794. if (this._texture) {
  66795. return this._texture._lodTextureLow;
  66796. }
  66797. return null;
  66798. },
  66799. enumerable: true,
  66800. configurable: true
  66801. });
  66802. /**
  66803. * Dispose the texture and release its associated resources.
  66804. */
  66805. BaseTexture.prototype.dispose = function () {
  66806. if (!this._scene) {
  66807. return;
  66808. }
  66809. // Animations
  66810. if (this._scene.stopAnimation) {
  66811. this._scene.stopAnimation(this);
  66812. }
  66813. // Remove from scene
  66814. this._scene._removePendingData(this);
  66815. var index = this._scene.textures.indexOf(this);
  66816. if (index >= 0) {
  66817. this._scene.textures.splice(index, 1);
  66818. }
  66819. this._scene.onTextureRemovedObservable.notifyObservers(this);
  66820. if (this._texture === undefined) {
  66821. return;
  66822. }
  66823. // Release
  66824. this.releaseInternalTexture();
  66825. // Callback
  66826. this.onDisposeObservable.notifyObservers(this);
  66827. this.onDisposeObservable.clear();
  66828. };
  66829. /**
  66830. * Serialize the texture into a JSON representation that can be parsed later on.
  66831. * @returns the JSON representation of the texture
  66832. */
  66833. BaseTexture.prototype.serialize = function () {
  66834. if (!this.name) {
  66835. return null;
  66836. }
  66837. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66838. // Animations
  66839. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  66840. return serializationObject;
  66841. };
  66842. /**
  66843. * Helper function to be called back once a list of texture contains only ready textures.
  66844. * @param textures Define the list of textures to wait for
  66845. * @param callback Define the callback triggered once the entire list will be ready
  66846. */
  66847. BaseTexture.WhenAllReady = function (textures, callback) {
  66848. var numRemaining = textures.length;
  66849. if (numRemaining === 0) {
  66850. callback();
  66851. return;
  66852. }
  66853. var _loop_1 = function () {
  66854. texture = textures[i];
  66855. if (texture.isReady()) {
  66856. if (--numRemaining === 0) {
  66857. callback();
  66858. }
  66859. }
  66860. else {
  66861. onLoadObservable = texture.onLoadObservable;
  66862. var onLoadCallback_1 = function () {
  66863. onLoadObservable.removeCallback(onLoadCallback_1);
  66864. if (--numRemaining === 0) {
  66865. callback();
  66866. }
  66867. };
  66868. onLoadObservable.add(onLoadCallback_1);
  66869. }
  66870. };
  66871. var texture, onLoadObservable;
  66872. for (var i = 0; i < textures.length; i++) {
  66873. _loop_1();
  66874. }
  66875. };
  66876. /**
  66877. * Default anisotropic filtering level for the application.
  66878. * It is set to 4 as a good tradeoff between perf and quality.
  66879. */
  66880. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  66881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66883. ], BaseTexture.prototype, "uniqueId", void 0);
  66884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66886. ], BaseTexture.prototype, "name", void 0);
  66887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66889. ], BaseTexture.prototype, "metadata", void 0);
  66890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  66892. ], BaseTexture.prototype, "_hasAlpha", void 0);
  66893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66895. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  66896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66898. ], BaseTexture.prototype, "level", void 0);
  66899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66901. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  66902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  66904. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  66905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66907. ], BaseTexture.prototype, "wrapU", void 0);
  66908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66910. ], BaseTexture.prototype, "wrapV", void 0);
  66911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66913. ], BaseTexture.prototype, "wrapR", void 0);
  66914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66916. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  66917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66919. ], BaseTexture.prototype, "isCube", null);
  66920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66922. ], BaseTexture.prototype, "is3D", null);
  66923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66925. ], BaseTexture.prototype, "gammaSpace", void 0);
  66926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66928. ], BaseTexture.prototype, "invertZ", void 0);
  66929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66931. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  66932. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66934. ], BaseTexture.prototype, "lodGenerationOffset", null);
  66935. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66937. ], BaseTexture.prototype, "lodGenerationScale", null);
  66938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66940. ], BaseTexture.prototype, "linearSpecularLOD", null);
  66941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  66943. ], BaseTexture.prototype, "irradianceTexture", null);
  66944. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66945. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66946. ], BaseTexture.prototype, "isRenderTarget", void 0);
  66947. return BaseTexture;
  66948. }());
  66949. /***/ }),
  66950. /***/ "./Materials/Textures/colorGradingTexture.ts":
  66951. /*!***************************************************!*\
  66952. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  66953. \***************************************************/
  66954. /*! exports provided: ColorGradingTexture */
  66955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66956. "use strict";
  66957. __webpack_require__.r(__webpack_exports__);
  66958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  66959. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66960. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  66961. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  66962. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  66963. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  66964. /**
  66965. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66966. * It can help converting any input color in a desired output one. This can then be used to create effects
  66967. * from sepia, black and white to sixties or futuristic rendering...
  66968. *
  66969. * The only supported format is currently 3dl.
  66970. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66971. */
  66972. var ColorGradingTexture = /** @class */ (function (_super) {
  66973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  66974. /**
  66975. * Instantiates a ColorGradingTexture from the following parameters.
  66976. *
  66977. * @param url The location of the color gradind data (currently only supporting 3dl)
  66978. * @param scene The scene the texture will be used in
  66979. */
  66980. function ColorGradingTexture(url, scene) {
  66981. var _this = _super.call(this, scene) || this;
  66982. if (!url) {
  66983. return _this;
  66984. }
  66985. _this._engine = scene.getEngine();
  66986. _this._textureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  66987. _this.name = url;
  66988. _this.url = url;
  66989. _this.hasAlpha = false;
  66990. _this.isCube = false;
  66991. _this.is3D = _this._engine.webGLVersion > 1;
  66992. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  66993. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  66994. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  66995. _this.anisotropicFilteringLevel = 1;
  66996. _this._texture = _this._getFromCache(url, true);
  66997. if (!_this._texture) {
  66998. if (!scene.useDelayedTextureLoading) {
  66999. _this.loadTexture();
  67000. }
  67001. else {
  67002. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  67003. }
  67004. }
  67005. return _this;
  67006. }
  67007. /**
  67008. * Returns the texture matrix used in most of the material.
  67009. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  67010. */
  67011. ColorGradingTexture.prototype.getTextureMatrix = function () {
  67012. return this._textureMatrix;
  67013. };
  67014. /**
  67015. * Occurs when the file being loaded is a .3dl LUT file.
  67016. */
  67017. ColorGradingTexture.prototype.load3dlTexture = function () {
  67018. var engine = this._engine;
  67019. var texture;
  67020. if (engine.webGLVersion === 1) {
  67021. 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);
  67022. }
  67023. else {
  67024. 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);
  67025. }
  67026. this._texture = texture;
  67027. var callback = function (text) {
  67028. if (typeof text !== "string") {
  67029. return;
  67030. }
  67031. var data = null;
  67032. var tempData = null;
  67033. var line;
  67034. var lines = text.split('\n');
  67035. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  67036. var maxColor = 0;
  67037. for (var i = 0; i < lines.length; i++) {
  67038. line = lines[i];
  67039. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  67040. continue;
  67041. }
  67042. if (line.indexOf('#') === 0) {
  67043. continue;
  67044. }
  67045. var words = line.split(" ");
  67046. if (size === 0) {
  67047. // Number of space + one
  67048. size = words.length;
  67049. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  67050. tempData = new Float32Array(size * size * size * 4);
  67051. continue;
  67052. }
  67053. if (size != 0) {
  67054. var r = Math.max(parseInt(words[0]), 0);
  67055. var g = Math.max(parseInt(words[1]), 0);
  67056. var b = Math.max(parseInt(words[2]), 0);
  67057. maxColor = Math.max(r, maxColor);
  67058. maxColor = Math.max(g, maxColor);
  67059. maxColor = Math.max(b, maxColor);
  67060. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  67061. if (tempData) {
  67062. tempData[pixelStorageIndex + 0] = r;
  67063. tempData[pixelStorageIndex + 1] = g;
  67064. tempData[pixelStorageIndex + 2] = b;
  67065. }
  67066. // Keep for reference in case of back compat problems.
  67067. // pixelIndexSlice++;
  67068. // if (pixelIndexSlice % size == 0) {
  67069. // pixelIndexH++;
  67070. // pixelIndexSlice = 0;
  67071. // if (pixelIndexH % size == 0) {
  67072. // pixelIndexW++;
  67073. // pixelIndexH = 0;
  67074. // }
  67075. // }
  67076. pixelIndexH++;
  67077. if (pixelIndexH % size == 0) {
  67078. pixelIndexSlice++;
  67079. pixelIndexH = 0;
  67080. if (pixelIndexSlice % size == 0) {
  67081. pixelIndexW++;
  67082. pixelIndexSlice = 0;
  67083. }
  67084. }
  67085. }
  67086. }
  67087. if (tempData && data) {
  67088. for (var i = 0; i < tempData.length; i++) {
  67089. if (i > 0 && (i + 1) % 4 === 0) {
  67090. data[i] = 255;
  67091. }
  67092. else {
  67093. var value = tempData[i];
  67094. data[i] = (value / maxColor * 255);
  67095. }
  67096. }
  67097. }
  67098. if (texture.is3D) {
  67099. texture.updateSize(size, size, size);
  67100. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  67101. }
  67102. else {
  67103. texture.updateSize(size * size, size);
  67104. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  67105. }
  67106. };
  67107. var scene = this.getScene();
  67108. if (scene) {
  67109. scene._loadFile(this.url, callback);
  67110. }
  67111. else {
  67112. this._engine._loadFile(this.url, callback);
  67113. }
  67114. return this._texture;
  67115. };
  67116. /**
  67117. * Starts the loading process of the texture.
  67118. */
  67119. ColorGradingTexture.prototype.loadTexture = function () {
  67120. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  67121. this.load3dlTexture();
  67122. }
  67123. };
  67124. /**
  67125. * Clones the color gradind texture.
  67126. */
  67127. ColorGradingTexture.prototype.clone = function () {
  67128. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  67129. // Base texture
  67130. newTexture.level = this.level;
  67131. return newTexture;
  67132. };
  67133. /**
  67134. * Called during delayed load for textures.
  67135. */
  67136. ColorGradingTexture.prototype.delayLoad = function () {
  67137. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  67138. return;
  67139. }
  67140. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  67141. this._texture = this._getFromCache(this.url, true);
  67142. if (!this._texture) {
  67143. this.loadTexture();
  67144. }
  67145. };
  67146. /**
  67147. * Parses a color grading texture serialized by Babylon.
  67148. * @param parsedTexture The texture information being parsedTexture
  67149. * @param scene The scene to load the texture in
  67150. * @param rootUrl The root url of the data assets to load
  67151. * @return A color gradind texture
  67152. */
  67153. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  67154. var texture = null;
  67155. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  67156. texture = new ColorGradingTexture(parsedTexture.name, scene);
  67157. texture.name = parsedTexture.name;
  67158. texture.level = parsedTexture.level;
  67159. }
  67160. return texture;
  67161. };
  67162. /**
  67163. * Serializes the LUT texture to json format.
  67164. */
  67165. ColorGradingTexture.prototype.serialize = function () {
  67166. if (!this.name) {
  67167. return null;
  67168. }
  67169. var serializationObject = {};
  67170. serializationObject.name = this.name;
  67171. serializationObject.level = this.level;
  67172. serializationObject.customType = "BABYLON.ColorGradingTexture";
  67173. return serializationObject;
  67174. };
  67175. /**
  67176. * Empty line regex stored for GC.
  67177. */
  67178. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  67179. return ColorGradingTexture;
  67180. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  67181. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  67182. /***/ }),
  67183. /***/ "./Materials/Textures/cubeTexture.ts":
  67184. /*!*******************************************!*\
  67185. !*** ./Materials/Textures/cubeTexture.ts ***!
  67186. \*******************************************/
  67187. /*! exports provided: CubeTexture */
  67188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67189. "use strict";
  67190. __webpack_require__.r(__webpack_exports__);
  67191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  67192. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67193. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  67194. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  67195. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  67196. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  67197. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67198. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  67199. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  67200. /* harmony import */ var _Engines_Extensions_engine_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Engines/Extensions/engine.cubeTexture */ "./Engines/Extensions/engine.cubeTexture.ts");
  67201. /**
  67202. * Class for creating a cube texture
  67203. */
  67204. var CubeTexture = /** @class */ (function (_super) {
  67205. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  67206. /**
  67207. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67208. * as prefiltered data.
  67209. * @param rootUrl defines the url of the texture or the root name of the six images
  67210. * @param scene defines the scene the texture is attached to
  67211. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67212. * @param noMipmap defines if mipmaps should be created or not
  67213. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67214. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67215. * @param onError defines a callback triggered in case of error during load
  67216. * @param format defines the internal format to use for the texture once loaded
  67217. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67218. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67219. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67220. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67221. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67222. * @return the cube texture
  67223. */
  67224. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  67225. if (extensions === void 0) { extensions = null; }
  67226. if (noMipmap === void 0) { noMipmap = false; }
  67227. if (files === void 0) { files = null; }
  67228. if (onLoad === void 0) { onLoad = null; }
  67229. if (onError === void 0) { onError = null; }
  67230. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  67231. if (prefiltered === void 0) { prefiltered = false; }
  67232. if (forcedExtension === void 0) { forcedExtension = null; }
  67233. if (createPolynomials === void 0) { createPolynomials = false; }
  67234. if (lodScale === void 0) { lodScale = 0.8; }
  67235. if (lodOffset === void 0) { lodOffset = 0; }
  67236. var _this = _super.call(this, scene) || this;
  67237. /**
  67238. * Gets or sets the center of the bounding box associated with the cube texture.
  67239. * It must define where the camera used to render the texture was set
  67240. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67241. */
  67242. _this.boundingBoxPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  67243. _this._rotationY = 0;
  67244. /** @hidden */
  67245. _this._prefiltered = false;
  67246. _this.name = rootUrl;
  67247. _this.url = rootUrl;
  67248. _this._noMipmap = noMipmap;
  67249. _this.hasAlpha = false;
  67250. _this._format = format;
  67251. _this.isCube = true;
  67252. _this._textureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  67253. _this._createPolynomials = createPolynomials;
  67254. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  67255. if (!rootUrl && !files) {
  67256. return _this;
  67257. }
  67258. var lastDot = rootUrl.lastIndexOf(".");
  67259. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  67260. var isDDS = (extension === ".dds");
  67261. var isEnv = (extension === ".env");
  67262. if (isEnv) {
  67263. _this.gammaSpace = false;
  67264. _this._prefiltered = false;
  67265. }
  67266. else {
  67267. _this._prefiltered = prefiltered;
  67268. if (prefiltered) {
  67269. _this.gammaSpace = false;
  67270. }
  67271. }
  67272. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  67273. if (!files) {
  67274. if (!isEnv && !isDDS && !extensions) {
  67275. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  67276. }
  67277. files = [];
  67278. if (extensions) {
  67279. for (var index = 0; index < extensions.length; index++) {
  67280. files.push(rootUrl + extensions[index]);
  67281. }
  67282. }
  67283. }
  67284. _this._files = files;
  67285. if (!_this._texture) {
  67286. if (!scene.useDelayedTextureLoading) {
  67287. if (prefiltered) {
  67288. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  67289. }
  67290. else {
  67291. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  67292. }
  67293. }
  67294. else {
  67295. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  67296. }
  67297. }
  67298. else if (onLoad) {
  67299. if (_this._texture.isReady) {
  67300. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  67301. }
  67302. else {
  67303. _this._texture.onLoadedObservable.add(onLoad);
  67304. }
  67305. }
  67306. return _this;
  67307. }
  67308. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  67309. /**
  67310. * Returns the bounding box size
  67311. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67312. */
  67313. get: function () {
  67314. return this._boundingBoxSize;
  67315. },
  67316. /**
  67317. * Gets or sets the size of the bounding box associated with the cube texture
  67318. * When defined, the cubemap will switch to local mode
  67319. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67320. * @example https://www.babylonjs-playground.com/#RNASML
  67321. */
  67322. set: function (value) {
  67323. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  67324. return;
  67325. }
  67326. this._boundingBoxSize = value;
  67327. var scene = this.getScene();
  67328. if (scene) {
  67329. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  67330. }
  67331. },
  67332. enumerable: true,
  67333. configurable: true
  67334. });
  67335. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  67336. /**
  67337. * Gets texture matrix rotation angle around Y axis radians.
  67338. */
  67339. get: function () {
  67340. return this._rotationY;
  67341. },
  67342. /**
  67343. * Sets texture matrix rotation angle around Y axis in radians.
  67344. */
  67345. set: function (value) {
  67346. this._rotationY = value;
  67347. this.setReflectionTextureMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  67348. },
  67349. enumerable: true,
  67350. configurable: true
  67351. });
  67352. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  67353. /**
  67354. * Are mip maps generated for this texture or not.
  67355. */
  67356. get: function () {
  67357. return this._noMipmap;
  67358. },
  67359. enumerable: true,
  67360. configurable: true
  67361. });
  67362. /**
  67363. * Creates a cube texture from an array of image urls
  67364. * @param files defines an array of image urls
  67365. * @param scene defines the hosting scene
  67366. * @param noMipmap specifies if mip maps are not used
  67367. * @returns a cube texture
  67368. */
  67369. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  67370. var rootUrlKey = "";
  67371. files.forEach(function (url) { return rootUrlKey += url; });
  67372. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  67373. };
  67374. /**
  67375. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67376. * @param url defines the url of the prefiltered texture
  67377. * @param scene defines the scene the texture is attached to
  67378. * @param forcedExtension defines the extension of the file if different from the url
  67379. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67380. * @return the prefiltered texture
  67381. */
  67382. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  67383. if (forcedExtension === void 0) { forcedExtension = null; }
  67384. if (createPolynomials === void 0) { createPolynomials = true; }
  67385. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  67386. };
  67387. Object.defineProperty(CubeTexture.prototype, "isPrefiltered", {
  67388. /**
  67389. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  67390. */
  67391. get: function () {
  67392. return this._prefiltered;
  67393. },
  67394. enumerable: true,
  67395. configurable: true
  67396. });
  67397. /**
  67398. * Get the current class name of the texture useful for serialization or dynamic coding.
  67399. * @returns "CubeTexture"
  67400. */
  67401. CubeTexture.prototype.getClassName = function () {
  67402. return "CubeTexture";
  67403. };
  67404. /**
  67405. * Update the url (and optional buffer) of this texture if url was null during construction.
  67406. * @param url the url of the texture
  67407. * @param forcedExtension defines the extension to use
  67408. * @param onLoad callback called when the texture is loaded (defaults to null)
  67409. */
  67410. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  67411. if (this.url) {
  67412. this.releaseInternalTexture();
  67413. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  67414. }
  67415. this.url = url;
  67416. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  67417. this._prefiltered = false;
  67418. if (onLoad) {
  67419. this._delayedOnLoad = onLoad;
  67420. }
  67421. this.delayLoad(forcedExtension);
  67422. };
  67423. /**
  67424. * Delays loading of the cube texture
  67425. * @param forcedExtension defines the extension to use
  67426. */
  67427. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  67428. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  67429. return;
  67430. }
  67431. var scene = this.getScene();
  67432. if (!scene) {
  67433. return;
  67434. }
  67435. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  67436. this._texture = this._getFromCache(this.url, this._noMipmap);
  67437. if (!this._texture) {
  67438. if (this._prefiltered) {
  67439. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  67440. }
  67441. else {
  67442. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, null, this._format, forcedExtension);
  67443. }
  67444. }
  67445. };
  67446. /**
  67447. * Returns the reflection texture matrix
  67448. * @returns the reflection texture matrix
  67449. */
  67450. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  67451. return this._textureMatrix;
  67452. };
  67453. /**
  67454. * Sets the reflection texture matrix
  67455. * @param value Reflection texture matrix
  67456. */
  67457. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  67458. var _this = this;
  67459. if (value.updateFlag === this._textureMatrix.updateFlag) {
  67460. return;
  67461. }
  67462. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  67463. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  67464. }
  67465. this._textureMatrix = value;
  67466. };
  67467. /**
  67468. * Parses text to create a cube texture
  67469. * @param parsedTexture define the serialized text to read from
  67470. * @param scene defines the hosting scene
  67471. * @param rootUrl defines the root url of the cube texture
  67472. * @returns a cube texture
  67473. */
  67474. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  67475. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  67476. var prefiltered = false;
  67477. if (parsedTexture.prefiltered) {
  67478. prefiltered = parsedTexture.prefiltered;
  67479. }
  67480. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  67481. }, parsedTexture, scene);
  67482. // Local Cubemaps
  67483. if (parsedTexture.boundingBoxPosition) {
  67484. texture.boundingBoxPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  67485. }
  67486. if (parsedTexture.boundingBoxSize) {
  67487. texture.boundingBoxSize = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  67488. }
  67489. // Animations
  67490. if (parsedTexture.animations) {
  67491. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  67492. var parsedAnimation = parsedTexture.animations[animationIndex];
  67493. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  67494. if (internalClass) {
  67495. texture.animations.push(internalClass.Parse(parsedAnimation));
  67496. }
  67497. }
  67498. }
  67499. return texture;
  67500. };
  67501. /**
  67502. * Makes a clone, or deep copy, of the cube texture
  67503. * @returns a new cube texture
  67504. */
  67505. CubeTexture.prototype.clone = function () {
  67506. var _this = this;
  67507. var scene = this.getScene();
  67508. var uniqueId = 0;
  67509. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  67510. if (!scene) {
  67511. return _this;
  67512. }
  67513. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  67514. uniqueId = cubeTexture.uniqueId;
  67515. return cubeTexture;
  67516. }, this);
  67517. newCubeTexture.uniqueId = uniqueId;
  67518. return newCubeTexture;
  67519. };
  67520. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67521. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  67522. ], CubeTexture.prototype, "rotationY", null);
  67523. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67524. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  67525. ], CubeTexture.prototype, "_textureMatrix", void 0);
  67526. return CubeTexture;
  67527. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  67528. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  67529. // Some exporters relies on Tools.Instantiate
  67530. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  67531. /***/ }),
  67532. /***/ "./Materials/Textures/dynamicTexture.ts":
  67533. /*!**********************************************!*\
  67534. !*** ./Materials/Textures/dynamicTexture.ts ***!
  67535. \**********************************************/
  67536. /*! exports provided: DynamicTexture */
  67537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67538. "use strict";
  67539. __webpack_require__.r(__webpack_exports__);
  67540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  67541. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67542. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  67543. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67544. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  67545. /**
  67546. * A class extending Texture allowing drawing on a texture
  67547. * @see http://doc.babylonjs.com/how_to/dynamictexture
  67548. */
  67549. var DynamicTexture = /** @class */ (function (_super) {
  67550. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  67551. /**
  67552. * Creates a DynamicTexture
  67553. * @param name defines the name of the texture
  67554. * @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
  67555. * @param scene defines the scene where you want the texture
  67556. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  67557. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67558. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  67559. */
  67560. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  67561. if (scene === void 0) { scene = null; }
  67562. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  67563. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  67564. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  67565. _this.name = name;
  67566. _this._engine = _this.getScene().getEngine();
  67567. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  67568. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  67569. _this._generateMipMaps = generateMipMaps;
  67570. if (options.getContext) {
  67571. _this._canvas = options;
  67572. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  67573. }
  67574. else {
  67575. _this._canvas = document.createElement("canvas");
  67576. if (options.width || options.width === 0) {
  67577. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  67578. }
  67579. else {
  67580. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  67581. }
  67582. }
  67583. var textureSize = _this.getSize();
  67584. _this._canvas.width = textureSize.width;
  67585. _this._canvas.height = textureSize.height;
  67586. _this._context = _this._canvas.getContext("2d");
  67587. return _this;
  67588. }
  67589. /**
  67590. * Get the current class name of the texture useful for serialization or dynamic coding.
  67591. * @returns "DynamicTexture"
  67592. */
  67593. DynamicTexture.prototype.getClassName = function () {
  67594. return "DynamicTexture";
  67595. };
  67596. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  67597. /**
  67598. * Gets the current state of canRescale
  67599. */
  67600. get: function () {
  67601. return true;
  67602. },
  67603. enumerable: true,
  67604. configurable: true
  67605. });
  67606. DynamicTexture.prototype._recreate = function (textureSize) {
  67607. this._canvas.width = textureSize.width;
  67608. this._canvas.height = textureSize.height;
  67609. this.releaseInternalTexture();
  67610. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  67611. };
  67612. /**
  67613. * Scales the texture
  67614. * @param ratio the scale factor to apply to both width and height
  67615. */
  67616. DynamicTexture.prototype.scale = function (ratio) {
  67617. var textureSize = this.getSize();
  67618. textureSize.width *= ratio;
  67619. textureSize.height *= ratio;
  67620. this._recreate(textureSize);
  67621. };
  67622. /**
  67623. * Resizes the texture
  67624. * @param width the new width
  67625. * @param height the new height
  67626. */
  67627. DynamicTexture.prototype.scaleTo = function (width, height) {
  67628. var textureSize = this.getSize();
  67629. textureSize.width = width;
  67630. textureSize.height = height;
  67631. this._recreate(textureSize);
  67632. };
  67633. /**
  67634. * Gets the context of the canvas used by the texture
  67635. * @returns the canvas context of the dynamic texture
  67636. */
  67637. DynamicTexture.prototype.getContext = function () {
  67638. return this._context;
  67639. };
  67640. /**
  67641. * Clears the texture
  67642. */
  67643. DynamicTexture.prototype.clear = function () {
  67644. var size = this.getSize();
  67645. this._context.fillRect(0, 0, size.width, size.height);
  67646. };
  67647. /**
  67648. * Updates the texture
  67649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  67650. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  67651. */
  67652. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  67653. if (premulAlpha === void 0) { premulAlpha = false; }
  67654. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  67655. };
  67656. /**
  67657. * Draws text onto the texture
  67658. * @param text defines the text to be drawn
  67659. * @param x defines the placement of the text from the left
  67660. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  67661. * @param font defines the font to be used with font-style, font-size, font-name
  67662. * @param color defines the color used for the text
  67663. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  67664. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  67665. * @param update defines whether texture is immediately update (default is true)
  67666. */
  67667. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  67668. if (update === void 0) { update = true; }
  67669. var size = this.getSize();
  67670. if (clearColor) {
  67671. this._context.fillStyle = clearColor;
  67672. this._context.fillRect(0, 0, size.width, size.height);
  67673. }
  67674. this._context.font = font;
  67675. if (x === null || x === undefined) {
  67676. var textSize = this._context.measureText(text);
  67677. x = (size.width - textSize.width) / 2;
  67678. }
  67679. if (y === null || y === undefined) {
  67680. var fontSize = parseInt((font.replace(/\D/g, '')));
  67681. y = (size.height / 2) + (fontSize / 3.65);
  67682. }
  67683. this._context.fillStyle = color;
  67684. this._context.fillText(text, x, y);
  67685. if (update) {
  67686. this.update(invertY);
  67687. }
  67688. };
  67689. /**
  67690. * Clones the texture
  67691. * @returns the clone of the texture.
  67692. */
  67693. DynamicTexture.prototype.clone = function () {
  67694. var scene = this.getScene();
  67695. if (!scene) {
  67696. return this;
  67697. }
  67698. var textureSize = this.getSize();
  67699. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  67700. // Base texture
  67701. newTexture.hasAlpha = this.hasAlpha;
  67702. newTexture.level = this.level;
  67703. // Dynamic Texture
  67704. newTexture.wrapU = this.wrapU;
  67705. newTexture.wrapV = this.wrapV;
  67706. return newTexture;
  67707. };
  67708. /**
  67709. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  67710. * @returns a serialized dynamic texture object
  67711. */
  67712. DynamicTexture.prototype.serialize = function () {
  67713. var scene = this.getScene();
  67714. if (scene && !scene.isReady()) {
  67715. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  67716. }
  67717. var serializationObject = _super.prototype.serialize.call(this);
  67718. serializationObject.base64String = this._canvas.toDataURL();
  67719. serializationObject.invertY = this._invertY;
  67720. serializationObject.samplingMode = this.samplingMode;
  67721. return serializationObject;
  67722. };
  67723. /** @hidden */
  67724. DynamicTexture.prototype._rebuild = function () {
  67725. this.update();
  67726. };
  67727. return DynamicTexture;
  67728. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  67729. /***/ }),
  67730. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  67731. /*!**********************************************************!*\
  67732. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  67733. \**********************************************************/
  67734. /*! exports provided: EquiRectangularCubeTexture */
  67735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67736. "use strict";
  67737. __webpack_require__.r(__webpack_exports__);
  67738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  67739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67740. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  67741. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  67742. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  67743. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  67744. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  67745. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  67746. /**
  67747. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  67748. */
  67749. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  67750. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  67751. /**
  67752. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  67753. * @param url The location of the image
  67754. * @param scene The scene the texture will be used in
  67755. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  67756. * @param noMipmap Forces to not generate the mipmap if true
  67757. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67758. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67759. * @param onLoad — defines a callback called when texture is loaded
  67760. * @param onError — defines a callback called if there is an error
  67761. */
  67762. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  67763. if (noMipmap === void 0) { noMipmap = false; }
  67764. if (gammaSpace === void 0) { gammaSpace = true; }
  67765. if (onLoad === void 0) { onLoad = null; }
  67766. if (onError === void 0) { onError = null; }
  67767. var _this = _super.call(this, scene) || this;
  67768. _this._onLoad = null;
  67769. _this._onError = null;
  67770. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  67771. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  67772. if (!url) {
  67773. throw new Error('Image url is not set');
  67774. }
  67775. _this.name = url;
  67776. _this.url = url;
  67777. _this._size = size;
  67778. _this._noMipmap = noMipmap;
  67779. _this.gammaSpace = gammaSpace;
  67780. _this._onLoad = onLoad;
  67781. _this._onError = onError;
  67782. _this.hasAlpha = false;
  67783. _this.isCube = true;
  67784. _this._texture = _this._getFromCache(url, _this._noMipmap);
  67785. if (!_this._texture) {
  67786. if (!scene.useDelayedTextureLoading) {
  67787. _this.loadImage(_this.loadTexture.bind(_this), _this._onError);
  67788. }
  67789. else {
  67790. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  67791. }
  67792. }
  67793. else if (onLoad) {
  67794. if (_this._texture.isReady) {
  67795. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].SetImmediate(function () { return onLoad(); });
  67796. }
  67797. else {
  67798. _this._texture.onLoadedObservable.add(onLoad);
  67799. }
  67800. }
  67801. return _this;
  67802. }
  67803. /**
  67804. * Load the image data, by putting the image on a canvas and extracting its buffer.
  67805. */
  67806. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback, onError) {
  67807. var _this = this;
  67808. var canvas = document.createElement('canvas');
  67809. var image = new Image();
  67810. image.addEventListener('load', function () {
  67811. _this._width = image.width;
  67812. _this._height = image.height;
  67813. canvas.width = _this._width;
  67814. canvas.height = _this._height;
  67815. var ctx = canvas.getContext('2d');
  67816. ctx.drawImage(image, 0, 0);
  67817. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  67818. _this._buffer = imageData.data.buffer;
  67819. canvas.remove();
  67820. loadTextureCallback();
  67821. });
  67822. image.addEventListener('error', function (error) {
  67823. if (onError) {
  67824. onError(_this.getClassName() + " could not be loaded", error);
  67825. }
  67826. });
  67827. image.src = this.url;
  67828. };
  67829. /**
  67830. * Convert the image buffer into a cubemap and create a CubeTexture.
  67831. */
  67832. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  67833. var _this = this;
  67834. var scene = this.getScene();
  67835. var callback = function () {
  67836. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  67837. // Extract the raw linear data.
  67838. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  67839. var results = [];
  67840. // Push each faces.
  67841. for (var i = 0; i < 6; i++) {
  67842. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  67843. results.push(dataFace);
  67844. }
  67845. return results;
  67846. };
  67847. if (!scene) {
  67848. return;
  67849. }
  67850. this._texture = scene
  67851. .getEngine()
  67852. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  67853. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  67854. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  67855. };
  67856. /**
  67857. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  67858. * @param buffer The ArrayBuffer that should be converted.
  67859. * @returns The buffer as Float32Array.
  67860. */
  67861. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  67862. var dataView = new DataView(buffer);
  67863. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  67864. var k = 0;
  67865. for (var i = 0; i < buffer.byteLength; i++) {
  67866. // We drop the transparency channel, because we do not need/want it
  67867. if ((i + 1) % 4 !== 0) {
  67868. floatImageData[k++] = dataView.getUint8(i) / 255;
  67869. }
  67870. }
  67871. return floatImageData;
  67872. };
  67873. /**
  67874. * Get the current class name of the texture useful for serialization or dynamic coding.
  67875. * @returns "EquiRectangularCubeTexture"
  67876. */
  67877. EquiRectangularCubeTexture.prototype.getClassName = function () {
  67878. return "EquiRectangularCubeTexture";
  67879. };
  67880. /**
  67881. * Create a clone of the current EquiRectangularCubeTexture and return it.
  67882. * @returns A clone of the current EquiRectangularCubeTexture.
  67883. */
  67884. EquiRectangularCubeTexture.prototype.clone = function () {
  67885. var scene = this.getScene();
  67886. if (!scene) {
  67887. return this;
  67888. }
  67889. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  67890. // Base texture
  67891. newTexture.level = this.level;
  67892. newTexture.wrapU = this.wrapU;
  67893. newTexture.wrapV = this.wrapV;
  67894. newTexture.coordinatesIndex = this.coordinatesIndex;
  67895. newTexture.coordinatesMode = this.coordinatesMode;
  67896. return newTexture;
  67897. };
  67898. /** The six faces of the cube. */
  67899. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  67900. return EquiRectangularCubeTexture;
  67901. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  67902. /***/ }),
  67903. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  67904. /*!**********************************************!*\
  67905. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  67906. \**********************************************/
  67907. /*! exports provided: HDRCubeTexture */
  67908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67909. "use strict";
  67910. __webpack_require__.r(__webpack_exports__);
  67911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  67912. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67913. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  67914. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  67915. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  67916. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67917. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  67918. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  67919. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  67920. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  67921. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  67922. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  67923. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Maths/math.constants */ "./Maths/math.constants.ts");
  67924. /**
  67925. * This represents a texture coming from an HDR input.
  67926. *
  67927. * The only supported format is currently panorama picture stored in RGBE format.
  67928. * Example of such files can be found on HDRLib: http://hdrlib.com/
  67929. */
  67930. var HDRCubeTexture = /** @class */ (function (_super) {
  67931. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  67932. /**
  67933. * Instantiates an HDRTexture from the following parameters.
  67934. *
  67935. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  67936. * @param scene The scene the texture will be used in
  67937. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  67938. * @param noMipmap Forces to not generate the mipmap if true
  67939. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  67940. * @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)
  67941. * @param reserved Reserved flag for internal use.
  67942. */
  67943. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  67944. if (noMipmap === void 0) { noMipmap = false; }
  67945. if (generateHarmonics === void 0) { generateHarmonics = true; }
  67946. if (gammaSpace === void 0) { gammaSpace = false; }
  67947. if (reserved === void 0) { reserved = false; }
  67948. if (onLoad === void 0) { onLoad = null; }
  67949. if (onError === void 0) { onError = null; }
  67950. var _this = _super.call(this, scene) || this;
  67951. _this._generateHarmonics = true;
  67952. _this._onLoad = null;
  67953. _this._onError = null;
  67954. /**
  67955. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  67956. */
  67957. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  67958. _this._isBlocking = true;
  67959. _this._rotationY = 0;
  67960. /**
  67961. * Gets or sets the center of the bounding box associated with the cube texture
  67962. * It must define where the camera used to render the texture was set
  67963. */
  67964. _this.boundingBoxPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  67965. if (!url) {
  67966. return _this;
  67967. }
  67968. _this.name = url;
  67969. _this.url = url;
  67970. _this.hasAlpha = false;
  67971. _this.isCube = true;
  67972. _this._textureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  67973. _this._onLoad = onLoad;
  67974. _this._onError = onError;
  67975. _this.gammaSpace = gammaSpace;
  67976. _this._noMipmap = noMipmap;
  67977. _this._size = size;
  67978. _this._texture = _this._getFromCache(url, _this._noMipmap);
  67979. if (!_this._texture) {
  67980. if (!scene.useDelayedTextureLoading) {
  67981. _this.loadTexture();
  67982. }
  67983. else {
  67984. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  67985. }
  67986. }
  67987. else if (onLoad) {
  67988. if (_this._texture.isReady) {
  67989. _Misc_tools__WEBPACK_IMPORTED_MODULE_9__["Tools"].SetImmediate(function () { return onLoad(); });
  67990. }
  67991. else {
  67992. _this._texture.onLoadedObservable.add(onLoad);
  67993. }
  67994. }
  67995. return _this;
  67996. }
  67997. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  67998. /**
  67999. * Gets wether or not the texture is blocking during loading.
  68000. */
  68001. get: function () {
  68002. return this._isBlocking;
  68003. },
  68004. /**
  68005. * Sets wether or not the texture is blocking during loading.
  68006. */
  68007. set: function (value) {
  68008. this._isBlocking = value;
  68009. },
  68010. enumerable: true,
  68011. configurable: true
  68012. });
  68013. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  68014. /**
  68015. * Gets texture matrix rotation angle around Y axis radians.
  68016. */
  68017. get: function () {
  68018. return this._rotationY;
  68019. },
  68020. /**
  68021. * Sets texture matrix rotation angle around Y axis in radians.
  68022. */
  68023. set: function (value) {
  68024. this._rotationY = value;
  68025. this.setReflectionTextureMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  68026. },
  68027. enumerable: true,
  68028. configurable: true
  68029. });
  68030. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  68031. get: function () {
  68032. return this._boundingBoxSize;
  68033. },
  68034. /**
  68035. * Gets or sets the size of the bounding box associated with the cube texture
  68036. * When defined, the cubemap will switch to local mode
  68037. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68038. * @example https://www.babylonjs-playground.com/#RNASML
  68039. */
  68040. set: function (value) {
  68041. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  68042. return;
  68043. }
  68044. this._boundingBoxSize = value;
  68045. var scene = this.getScene();
  68046. if (scene) {
  68047. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  68048. }
  68049. },
  68050. enumerable: true,
  68051. configurable: true
  68052. });
  68053. /**
  68054. * Get the current class name of the texture useful for serialization or dynamic coding.
  68055. * @returns "HDRCubeTexture"
  68056. */
  68057. HDRCubeTexture.prototype.getClassName = function () {
  68058. return "HDRCubeTexture";
  68059. };
  68060. /**
  68061. * Occurs when the file is raw .hdr file.
  68062. */
  68063. HDRCubeTexture.prototype.loadTexture = function () {
  68064. var _this = this;
  68065. var callback = function (buffer) {
  68066. _this.lodGenerationOffset = 0.0;
  68067. _this.lodGenerationScale = 0.8;
  68068. var scene = _this.getScene();
  68069. if (!scene) {
  68070. return null;
  68071. }
  68072. // Extract the raw linear data.
  68073. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  68074. // Generate harmonics if needed.
  68075. if (_this._generateHarmonics) {
  68076. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  68077. _this.sphericalPolynomial = sphericalPolynomial;
  68078. }
  68079. var results = [];
  68080. var byteArray = null;
  68081. // Push each faces.
  68082. for (var j = 0; j < 6; j++) {
  68083. // Create uintarray fallback.
  68084. if (!scene.getEngine().getCaps().textureFloat) {
  68085. // 3 channels of 1 bytes per pixel in bytes.
  68086. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  68087. byteArray = new Uint8Array(byteBuffer);
  68088. }
  68089. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  68090. // If special cases.
  68091. if (_this.gammaSpace || byteArray) {
  68092. for (var i = 0; i < _this._size * _this._size; i++) {
  68093. // Put in gamma space if requested.
  68094. if (_this.gammaSpace) {
  68095. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math_constants__WEBPACK_IMPORTED_MODULE_11__["ToGammaSpace"]);
  68096. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math_constants__WEBPACK_IMPORTED_MODULE_11__["ToGammaSpace"]);
  68097. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math_constants__WEBPACK_IMPORTED_MODULE_11__["ToGammaSpace"]);
  68098. }
  68099. // Convert to int texture for fallback.
  68100. if (byteArray) {
  68101. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  68102. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  68103. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  68104. // May use luminance instead if the result is not accurate.
  68105. var max = Math.max(Math.max(r, g), b);
  68106. if (max > 255) {
  68107. var scale = 255 / max;
  68108. r *= scale;
  68109. g *= scale;
  68110. b *= scale;
  68111. }
  68112. byteArray[(i * 3) + 0] = r;
  68113. byteArray[(i * 3) + 1] = g;
  68114. byteArray[(i * 3) + 2] = b;
  68115. }
  68116. }
  68117. }
  68118. if (byteArray) {
  68119. results.push(byteArray);
  68120. }
  68121. else {
  68122. results.push(dataFace);
  68123. }
  68124. }
  68125. return results;
  68126. };
  68127. var scene = this.getScene();
  68128. if (scene) {
  68129. 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);
  68130. }
  68131. };
  68132. HDRCubeTexture.prototype.clone = function () {
  68133. var scene = this.getScene();
  68134. if (!scene) {
  68135. return this;
  68136. }
  68137. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  68138. // Base texture
  68139. newTexture.level = this.level;
  68140. newTexture.wrapU = this.wrapU;
  68141. newTexture.wrapV = this.wrapV;
  68142. newTexture.coordinatesIndex = this.coordinatesIndex;
  68143. newTexture.coordinatesMode = this.coordinatesMode;
  68144. return newTexture;
  68145. };
  68146. // Methods
  68147. HDRCubeTexture.prototype.delayLoad = function () {
  68148. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  68149. return;
  68150. }
  68151. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  68152. this._texture = this._getFromCache(this.url, this._noMipmap);
  68153. if (!this._texture) {
  68154. this.loadTexture();
  68155. }
  68156. };
  68157. /**
  68158. * Get the texture reflection matrix used to rotate/transform the reflection.
  68159. * @returns the reflection matrix
  68160. */
  68161. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  68162. return this._textureMatrix;
  68163. };
  68164. /**
  68165. * Set the texture reflection matrix used to rotate/transform the reflection.
  68166. * @param value Define the reflection matrix to set
  68167. */
  68168. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  68169. var _this = this;
  68170. this._textureMatrix = value;
  68171. if (value.updateFlag === this._textureMatrix.updateFlag) {
  68172. return;
  68173. }
  68174. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  68175. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  68176. }
  68177. };
  68178. /**
  68179. * Parses a JSON representation of an HDR Texture in order to create the texture
  68180. * @param parsedTexture Define the JSON representation
  68181. * @param scene Define the scene the texture should be created in
  68182. * @param rootUrl Define the root url in case we need to load relative dependencies
  68183. * @returns the newly created texture after parsing
  68184. */
  68185. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  68186. var texture = null;
  68187. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  68188. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  68189. texture.name = parsedTexture.name;
  68190. texture.hasAlpha = parsedTexture.hasAlpha;
  68191. texture.level = parsedTexture.level;
  68192. texture.coordinatesMode = parsedTexture.coordinatesMode;
  68193. texture.isBlocking = parsedTexture.isBlocking;
  68194. }
  68195. if (texture) {
  68196. if (parsedTexture.boundingBoxPosition) {
  68197. texture.boundingBoxPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  68198. }
  68199. if (parsedTexture.boundingBoxSize) {
  68200. texture.boundingBoxSize = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  68201. }
  68202. if (parsedTexture.rotationY) {
  68203. texture.rotationY = parsedTexture.rotationY;
  68204. }
  68205. }
  68206. return texture;
  68207. };
  68208. HDRCubeTexture.prototype.serialize = function () {
  68209. if (!this.name) {
  68210. return null;
  68211. }
  68212. var serializationObject = {};
  68213. serializationObject.name = this.name;
  68214. serializationObject.hasAlpha = this.hasAlpha;
  68215. serializationObject.isCube = true;
  68216. serializationObject.level = this.level;
  68217. serializationObject.size = this._size;
  68218. serializationObject.coordinatesMode = this.coordinatesMode;
  68219. serializationObject.useInGammaSpace = this.gammaSpace;
  68220. serializationObject.generateHarmonics = this._generateHarmonics;
  68221. serializationObject.customType = "BABYLON.HDRCubeTexture";
  68222. serializationObject.noMipmap = this._noMipmap;
  68223. serializationObject.isBlocking = this._isBlocking;
  68224. serializationObject.rotationY = this._rotationY;
  68225. return serializationObject;
  68226. };
  68227. HDRCubeTexture._facesMapping = [
  68228. "right",
  68229. "left",
  68230. "up",
  68231. "down",
  68232. "front",
  68233. "back"
  68234. ];
  68235. return HDRCubeTexture;
  68236. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  68237. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  68238. /***/ }),
  68239. /***/ "./Materials/Textures/htmlElementTexture.ts":
  68240. /*!**************************************************!*\
  68241. !*** ./Materials/Textures/htmlElementTexture.ts ***!
  68242. \**************************************************/
  68243. /*! exports provided: HtmlElementTexture */
  68244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68245. "use strict";
  68246. __webpack_require__.r(__webpack_exports__);
  68247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return HtmlElementTexture; });
  68248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68249. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  68250. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  68251. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  68252. /**
  68253. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  68254. * To be as efficient as possible depending on your constraints nothing aside the first upload
  68255. * is automatically managed.
  68256. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  68257. * in your application.
  68258. *
  68259. * As the update is not automatic, you need to call them manually.
  68260. */
  68261. var HtmlElementTexture = /** @class */ (function (_super) {
  68262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HtmlElementTexture, _super);
  68263. /**
  68264. * Instantiates a HtmlElementTexture from the following parameters.
  68265. *
  68266. * @param name Defines the name of the texture
  68267. * @param element Defines the video or canvas the texture is filled with
  68268. * @param options Defines the other none mandatory texture creation options
  68269. */
  68270. function HtmlElementTexture(name, element, options) {
  68271. var _this = _super.call(this, options.scene) || this;
  68272. if (!element || (!options.engine && !options.scene)) {
  68273. return _this;
  68274. }
  68275. options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, HtmlElementTexture.DefaultOptions, options);
  68276. _this._engine = options.engine || options.scene.getEngine();
  68277. _this._generateMipMaps = options.generateMipMaps;
  68278. _this._samplingMode = options.samplingMode;
  68279. _this._textureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  68280. _this.name = name;
  68281. _this.element = element;
  68282. _this._isVideo = (element instanceof HTMLVideoElement);
  68283. _this.anisotropicFilteringLevel = 1;
  68284. _this._createInternalTexture();
  68285. return _this;
  68286. }
  68287. HtmlElementTexture.prototype._createInternalTexture = function () {
  68288. var width = 0;
  68289. var height = 0;
  68290. if (this._isVideo) {
  68291. width = this.element.videoWidth;
  68292. height = this.element.videoHeight;
  68293. }
  68294. else {
  68295. width = this.element.width;
  68296. height = this.element.height;
  68297. }
  68298. this._texture = this._engine.createDynamicTexture(width, height, this._generateMipMaps, this._samplingMode);
  68299. this.update();
  68300. };
  68301. /**
  68302. * Returns the texture matrix used in most of the material.
  68303. */
  68304. HtmlElementTexture.prototype.getTextureMatrix = function () {
  68305. return this._textureMatrix;
  68306. };
  68307. /**
  68308. * Updates the content of the texture.
  68309. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  68310. */
  68311. HtmlElementTexture.prototype.update = function (invertY) {
  68312. if (invertY === void 0) { invertY = null; }
  68313. if (this._texture == null) {
  68314. return;
  68315. }
  68316. if (this._isVideo) {
  68317. var videoElement = this.element;
  68318. if (videoElement.readyState < videoElement.HAVE_CURRENT_DATA) {
  68319. return;
  68320. }
  68321. this._engine.updateVideoTexture(this._texture, videoElement, invertY === null ? true : invertY);
  68322. }
  68323. else {
  68324. var canvasElement = this.element;
  68325. this._engine.updateDynamicTexture(this._texture, canvasElement, invertY === null ? true : invertY, false);
  68326. }
  68327. };
  68328. HtmlElementTexture.DefaultOptions = {
  68329. generateMipMaps: false,
  68330. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  68331. engine: null,
  68332. scene: null
  68333. };
  68334. return HtmlElementTexture;
  68335. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_1__["BaseTexture"]));
  68336. /***/ }),
  68337. /***/ "./Materials/Textures/index.ts":
  68338. /*!*************************************!*\
  68339. !*** ./Materials/Textures/index.ts ***!
  68340. \*************************************/
  68341. /*! exports provided: BaseTexture, CubeTexture, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, _BasisTextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  68342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68343. "use strict";
  68344. __webpack_require__.r(__webpack_exports__);
  68345. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  68346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  68347. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  68348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  68349. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  68350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  68351. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  68352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  68353. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  68354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  68355. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  68356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  68357. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  68358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  68359. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  68360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  68361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  68362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  68363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  68364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BasisTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_BasisTextureLoader"]; });
  68365. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  68366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  68367. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  68368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  68369. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  68370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  68371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  68372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  68373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  68374. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  68375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  68376. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  68377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  68378. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  68379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  68380. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  68381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  68382. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  68383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  68384. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  68385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  68386. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  68387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  68388. /* harmony import */ var _htmlElementTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./htmlElementTexture */ "./Materials/Textures/htmlElementTexture.ts");
  68389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _htmlElementTexture__WEBPACK_IMPORTED_MODULE_18__["HtmlElementTexture"]; });
  68390. /***/ }),
  68391. /***/ "./Materials/Textures/internalTexture.ts":
  68392. /*!***********************************************!*\
  68393. !*** ./Materials/Textures/internalTexture.ts ***!
  68394. \***********************************************/
  68395. /*! exports provided: InternalTexture */
  68396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68397. "use strict";
  68398. __webpack_require__.r(__webpack_exports__);
  68399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  68400. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  68401. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  68402. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  68403. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  68404. /**
  68405. * Class used to store data associated with WebGL texture data for the engine
  68406. * This class should not be used directly
  68407. */
  68408. var InternalTexture = /** @class */ (function () {
  68409. /**
  68410. * Creates a new InternalTexture
  68411. * @param engine defines the engine to use
  68412. * @param dataSource defines the type of data that will be used
  68413. * @param delayAllocation if the texture allocation should be delayed (default: false)
  68414. */
  68415. function InternalTexture(engine, dataSource, delayAllocation) {
  68416. if (delayAllocation === void 0) { delayAllocation = false; }
  68417. /**
  68418. * Defines if the texture is ready
  68419. */
  68420. this.isReady = false;
  68421. /**
  68422. * Defines if the texture is a cube texture
  68423. */
  68424. this.isCube = false;
  68425. /**
  68426. * Defines if the texture contains 3D data
  68427. */
  68428. this.is3D = false;
  68429. /**
  68430. * Defines if the texture contains multiview data
  68431. */
  68432. this.isMultiview = false;
  68433. /**
  68434. * Gets the URL used to load this texture
  68435. */
  68436. this.url = "";
  68437. /**
  68438. * Gets the sampling mode of the texture
  68439. */
  68440. this.samplingMode = -1;
  68441. /**
  68442. * Gets a boolean indicating if the texture needs mipmaps generation
  68443. */
  68444. this.generateMipMaps = false;
  68445. /**
  68446. * Gets the number of samples used by the texture (WebGL2+ only)
  68447. */
  68448. this.samples = 0;
  68449. /**
  68450. * Gets the type of the texture (int, float...)
  68451. */
  68452. this.type = -1;
  68453. /**
  68454. * Gets the format of the texture (RGB, RGBA...)
  68455. */
  68456. this.format = -1;
  68457. /**
  68458. * Observable called when the texture is loaded
  68459. */
  68460. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  68461. /**
  68462. * Gets the width of the texture
  68463. */
  68464. this.width = 0;
  68465. /**
  68466. * Gets the height of the texture
  68467. */
  68468. this.height = 0;
  68469. /**
  68470. * Gets the depth of the texture
  68471. */
  68472. this.depth = 0;
  68473. /**
  68474. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  68475. */
  68476. this.baseWidth = 0;
  68477. /**
  68478. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  68479. */
  68480. this.baseHeight = 0;
  68481. /**
  68482. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  68483. */
  68484. this.baseDepth = 0;
  68485. /**
  68486. * Gets a boolean indicating if the texture is inverted on Y axis
  68487. */
  68488. this.invertY = false;
  68489. // Private
  68490. /** @hidden */
  68491. this._invertVScale = false;
  68492. /** @hidden */
  68493. this._associatedChannel = -1;
  68494. /** @hidden */
  68495. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  68496. /** @hidden */
  68497. this._buffer = null;
  68498. /** @hidden */
  68499. this._bufferView = null;
  68500. /** @hidden */
  68501. this._bufferViewArray = null;
  68502. /** @hidden */
  68503. this._bufferViewArrayArray = null;
  68504. /** @hidden */
  68505. this._size = 0;
  68506. /** @hidden */
  68507. this._extension = "";
  68508. /** @hidden */
  68509. this._files = null;
  68510. /** @hidden */
  68511. this._workingCanvas = null;
  68512. /** @hidden */
  68513. this._workingContext = null;
  68514. /** @hidden */
  68515. this._framebuffer = null;
  68516. /** @hidden */
  68517. this._depthStencilBuffer = null;
  68518. /** @hidden */
  68519. this._MSAAFramebuffer = null;
  68520. /** @hidden */
  68521. this._MSAARenderBuffer = null;
  68522. /** @hidden */
  68523. this._attachments = null;
  68524. /** @hidden */
  68525. this._cachedCoordinatesMode = null;
  68526. /** @hidden */
  68527. this._cachedWrapU = null;
  68528. /** @hidden */
  68529. this._cachedWrapV = null;
  68530. /** @hidden */
  68531. this._cachedWrapR = null;
  68532. /** @hidden */
  68533. this._cachedAnisotropicFilteringLevel = null;
  68534. /** @hidden */
  68535. this._isDisabled = false;
  68536. /** @hidden */
  68537. this._compression = null;
  68538. /** @hidden */
  68539. this._generateStencilBuffer = false;
  68540. /** @hidden */
  68541. this._generateDepthBuffer = false;
  68542. /** @hidden */
  68543. this._comparisonFunction = 0;
  68544. /** @hidden */
  68545. this._sphericalPolynomial = null;
  68546. /** @hidden */
  68547. this._lodGenerationScale = 0;
  68548. /** @hidden */
  68549. this._lodGenerationOffset = 0;
  68550. // Multiview
  68551. /** @hidden */
  68552. this._colorTextureArray = null;
  68553. /** @hidden */
  68554. this._depthStencilTextureArray = null;
  68555. // The following three fields helps sharing generated fixed LODs for texture filtering
  68556. // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.
  68557. // They are at the level of the gl texture to benefit from the cache.
  68558. /** @hidden */
  68559. this._lodTextureHigh = null;
  68560. /** @hidden */
  68561. this._lodTextureMid = null;
  68562. /** @hidden */
  68563. this._lodTextureLow = null;
  68564. /** @hidden */
  68565. this._isRGBD = false;
  68566. /** @hidden */
  68567. this._linearSpecularLOD = false;
  68568. /** @hidden */
  68569. this._irradianceTexture = null;
  68570. /** @hidden */
  68571. this._webGLTexture = null;
  68572. /** @hidden */
  68573. this._references = 1;
  68574. this._engine = engine;
  68575. this._dataSource = dataSource;
  68576. if (!delayAllocation) {
  68577. this._webGLTexture = engine._createTexture();
  68578. }
  68579. }
  68580. /**
  68581. * Gets the Engine the texture belongs to.
  68582. * @returns The babylon engine
  68583. */
  68584. InternalTexture.prototype.getEngine = function () {
  68585. return this._engine;
  68586. };
  68587. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  68588. /**
  68589. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  68590. */
  68591. get: function () {
  68592. return this._dataSource;
  68593. },
  68594. enumerable: true,
  68595. configurable: true
  68596. });
  68597. /**
  68598. * Increments the number of references (ie. the number of Texture that point to it)
  68599. */
  68600. InternalTexture.prototype.incrementReferences = function () {
  68601. this._references++;
  68602. };
  68603. /**
  68604. * Change the size of the texture (not the size of the content)
  68605. * @param width defines the new width
  68606. * @param height defines the new height
  68607. * @param depth defines the new depth (1 by default)
  68608. */
  68609. InternalTexture.prototype.updateSize = function (width, height, depth) {
  68610. if (depth === void 0) { depth = 1; }
  68611. this.width = width;
  68612. this.height = height;
  68613. this.depth = depth;
  68614. this.baseWidth = width;
  68615. this.baseHeight = height;
  68616. this.baseDepth = depth;
  68617. this._size = width * height * depth;
  68618. };
  68619. /** @hidden */
  68620. InternalTexture.prototype._rebuild = function () {
  68621. var _this = this;
  68622. var proxy;
  68623. this.isReady = false;
  68624. this._cachedCoordinatesMode = null;
  68625. this._cachedWrapU = null;
  68626. this._cachedWrapV = null;
  68627. this._cachedAnisotropicFilteringLevel = null;
  68628. switch (this._dataSource) {
  68629. case InternalTexture.DATASOURCE_TEMP:
  68630. return;
  68631. case InternalTexture.DATASOURCE_URL:
  68632. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  68633. proxy._swapAndDie(_this);
  68634. _this.isReady = true;
  68635. }, null, this._buffer, undefined, this.format);
  68636. return;
  68637. case InternalTexture.DATASOURCE_RAW:
  68638. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  68639. proxy._swapAndDie(this);
  68640. this.isReady = true;
  68641. return;
  68642. case InternalTexture.DATASOURCE_RAW3D:
  68643. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  68644. proxy._swapAndDie(this);
  68645. this.isReady = true;
  68646. return;
  68647. case InternalTexture.DATASOURCE_DYNAMIC:
  68648. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  68649. proxy._swapAndDie(this);
  68650. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  68651. // The engine will make sure to update content so no need to flag it as isReady = true
  68652. return;
  68653. case InternalTexture.DATASOURCE_RENDERTARGET:
  68654. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  68655. options.generateDepthBuffer = this._generateDepthBuffer;
  68656. options.generateMipMaps = this.generateMipMaps;
  68657. options.generateStencilBuffer = this._generateStencilBuffer;
  68658. options.samplingMode = this.samplingMode;
  68659. options.type = this.type;
  68660. if (this.isCube) {
  68661. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  68662. }
  68663. else {
  68664. var size = {
  68665. width: this.width,
  68666. height: this.height
  68667. };
  68668. proxy = this._engine.createRenderTargetTexture(size, options);
  68669. }
  68670. proxy._swapAndDie(this);
  68671. this.isReady = true;
  68672. return;
  68673. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  68674. var depthTextureOptions = {
  68675. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  68676. comparisonFunction: this._comparisonFunction,
  68677. generateStencil: this._generateStencilBuffer,
  68678. isCube: this.isCube
  68679. };
  68680. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  68681. proxy._swapAndDie(this);
  68682. this.isReady = true;
  68683. return;
  68684. case InternalTexture.DATASOURCE_CUBE:
  68685. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  68686. proxy._swapAndDie(_this);
  68687. _this.isReady = true;
  68688. }, null, this.format, this._extension);
  68689. return;
  68690. case InternalTexture.DATASOURCE_CUBERAW:
  68691. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  68692. proxy._swapAndDie(this);
  68693. this.isReady = true;
  68694. return;
  68695. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  68696. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  68697. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  68698. proxy._swapAndDie(_this);
  68699. _this.isReady = true;
  68700. });
  68701. return;
  68702. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  68703. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  68704. if (proxy) {
  68705. proxy._swapAndDie(_this);
  68706. }
  68707. _this.isReady = true;
  68708. }, null, this.format, this._extension);
  68709. proxy._sphericalPolynomial = this._sphericalPolynomial;
  68710. return;
  68711. }
  68712. };
  68713. /** @hidden */
  68714. InternalTexture.prototype._swapAndDie = function (target) {
  68715. target._webGLTexture = this._webGLTexture;
  68716. target._isRGBD = this._isRGBD;
  68717. if (this._framebuffer) {
  68718. target._framebuffer = this._framebuffer;
  68719. }
  68720. if (this._depthStencilBuffer) {
  68721. target._depthStencilBuffer = this._depthStencilBuffer;
  68722. }
  68723. if (this._lodTextureHigh) {
  68724. if (target._lodTextureHigh) {
  68725. target._lodTextureHigh.dispose();
  68726. }
  68727. target._lodTextureHigh = this._lodTextureHigh;
  68728. }
  68729. if (this._lodTextureMid) {
  68730. if (target._lodTextureMid) {
  68731. target._lodTextureMid.dispose();
  68732. }
  68733. target._lodTextureMid = this._lodTextureMid;
  68734. }
  68735. if (this._lodTextureLow) {
  68736. if (target._lodTextureLow) {
  68737. target._lodTextureLow.dispose();
  68738. }
  68739. target._lodTextureLow = this._lodTextureLow;
  68740. }
  68741. if (this._irradianceTexture) {
  68742. if (target._irradianceTexture) {
  68743. target._irradianceTexture.dispose();
  68744. }
  68745. target._irradianceTexture = this._irradianceTexture;
  68746. }
  68747. var cache = this._engine.getLoadedTexturesCache();
  68748. var index = cache.indexOf(this);
  68749. if (index !== -1) {
  68750. cache.splice(index, 1);
  68751. }
  68752. var index = cache.indexOf(target);
  68753. if (index === -1) {
  68754. cache.push(target);
  68755. }
  68756. };
  68757. /**
  68758. * Dispose the current allocated resources
  68759. */
  68760. InternalTexture.prototype.dispose = function () {
  68761. if (!this._webGLTexture) {
  68762. return;
  68763. }
  68764. this._references--;
  68765. if (this._references === 0) {
  68766. this._engine._releaseTexture(this);
  68767. this._webGLTexture = null;
  68768. }
  68769. };
  68770. /** @hidden */
  68771. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  68772. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  68773. };
  68774. /**
  68775. * The source of the texture data is unknown
  68776. */
  68777. InternalTexture.DATASOURCE_UNKNOWN = 0;
  68778. /**
  68779. * Texture data comes from an URL
  68780. */
  68781. InternalTexture.DATASOURCE_URL = 1;
  68782. /**
  68783. * Texture data is only used for temporary storage
  68784. */
  68785. InternalTexture.DATASOURCE_TEMP = 2;
  68786. /**
  68787. * Texture data comes from raw data (ArrayBuffer)
  68788. */
  68789. InternalTexture.DATASOURCE_RAW = 3;
  68790. /**
  68791. * Texture content is dynamic (video or dynamic texture)
  68792. */
  68793. InternalTexture.DATASOURCE_DYNAMIC = 4;
  68794. /**
  68795. * Texture content is generated by rendering to it
  68796. */
  68797. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  68798. /**
  68799. * Texture content is part of a multi render target process
  68800. */
  68801. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  68802. /**
  68803. * Texture data comes from a cube data file
  68804. */
  68805. InternalTexture.DATASOURCE_CUBE = 7;
  68806. /**
  68807. * Texture data comes from a raw cube data
  68808. */
  68809. InternalTexture.DATASOURCE_CUBERAW = 8;
  68810. /**
  68811. * Texture data come from a prefiltered cube data file
  68812. */
  68813. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  68814. /**
  68815. * Texture content is raw 3D data
  68816. */
  68817. InternalTexture.DATASOURCE_RAW3D = 10;
  68818. /**
  68819. * Texture content is a depth texture
  68820. */
  68821. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  68822. /**
  68823. * Texture data comes from a raw cube data encoded with RGBD
  68824. */
  68825. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  68826. return InternalTexture;
  68827. }());
  68828. /***/ }),
  68829. /***/ "./Materials/Textures/mirrorTexture.ts":
  68830. /*!*********************************************!*\
  68831. !*** ./Materials/Textures/mirrorTexture.ts ***!
  68832. \*********************************************/
  68833. /*! exports provided: MirrorTexture */
  68834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68835. "use strict";
  68836. __webpack_require__.r(__webpack_exports__);
  68837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  68838. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68839. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  68840. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  68841. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  68842. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  68843. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  68844. /* harmony import */ var _Maths_math_plane__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math.plane */ "./Maths/math.plane.ts");
  68845. /**
  68846. * Mirror texture can be used to simulate the view from a mirror in a scene.
  68847. * It will dynamically be rendered every frame to adapt to the camera point of view.
  68848. * You can then easily use it as a reflectionTexture on a flat surface.
  68849. * In case the surface is not a plane, please consider relying on reflection probes.
  68850. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68851. */
  68852. var MirrorTexture = /** @class */ (function (_super) {
  68853. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  68854. /**
  68855. * Instantiates a Mirror Texture.
  68856. * Mirror texture can be used to simulate the view from a mirror in a scene.
  68857. * It will dynamically be rendered every frame to adapt to the camera point of view.
  68858. * You can then easily use it as a reflectionTexture on a flat surface.
  68859. * In case the surface is not a plane, please consider relying on reflection probes.
  68860. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68861. * @param name
  68862. * @param size
  68863. * @param scene
  68864. * @param generateMipMaps
  68865. * @param type
  68866. * @param samplingMode
  68867. * @param generateDepthBuffer
  68868. */
  68869. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  68870. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  68871. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  68872. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  68873. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  68874. _this.scene = scene;
  68875. /**
  68876. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  68877. * 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.
  68878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68879. */
  68880. _this.mirrorPlane = new _Maths_math_plane__WEBPACK_IMPORTED_MODULE_6__["Plane"](0, 1, 0, 1);
  68881. _this._transformMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  68882. _this._mirrorMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  68883. _this._adaptiveBlurKernel = 0;
  68884. _this._blurKernelX = 0;
  68885. _this._blurKernelY = 0;
  68886. _this._blurRatio = 1.0;
  68887. _this.ignoreCameraViewport = true;
  68888. _this._updateGammaSpace();
  68889. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  68890. _this._updateGammaSpace;
  68891. });
  68892. _this.onBeforeRenderObservable.add(function () {
  68893. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  68894. _this._savedViewMatrix = scene.getViewMatrix();
  68895. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  68896. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  68897. scene.clipPlane = _this.mirrorPlane;
  68898. scene.getEngine().cullBackFaces = false;
  68899. scene._mirroredCameraPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  68900. });
  68901. _this.onAfterRenderObservable.add(function () {
  68902. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  68903. scene.getEngine().cullBackFaces = true;
  68904. scene._mirroredCameraPosition = null;
  68905. scene.clipPlane = null;
  68906. });
  68907. return _this;
  68908. }
  68909. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  68910. get: function () {
  68911. return this._blurRatio;
  68912. },
  68913. /**
  68914. * Define the blur ratio used to blur the reflection if needed.
  68915. */
  68916. set: function (value) {
  68917. if (this._blurRatio === value) {
  68918. return;
  68919. }
  68920. this._blurRatio = value;
  68921. this._preparePostProcesses();
  68922. },
  68923. enumerable: true,
  68924. configurable: true
  68925. });
  68926. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  68927. /**
  68928. * Define the adaptive blur kernel used to blur the reflection if needed.
  68929. * This will autocompute the closest best match for the `blurKernel`
  68930. */
  68931. set: function (value) {
  68932. this._adaptiveBlurKernel = value;
  68933. this._autoComputeBlurKernel();
  68934. },
  68935. enumerable: true,
  68936. configurable: true
  68937. });
  68938. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  68939. /**
  68940. * Define the blur kernel used to blur the reflection if needed.
  68941. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68942. */
  68943. set: function (value) {
  68944. this.blurKernelX = value;
  68945. this.blurKernelY = value;
  68946. },
  68947. enumerable: true,
  68948. configurable: true
  68949. });
  68950. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  68951. get: function () {
  68952. return this._blurKernelX;
  68953. },
  68954. /**
  68955. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  68956. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68957. */
  68958. set: function (value) {
  68959. if (this._blurKernelX === value) {
  68960. return;
  68961. }
  68962. this._blurKernelX = value;
  68963. this._preparePostProcesses();
  68964. },
  68965. enumerable: true,
  68966. configurable: true
  68967. });
  68968. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  68969. get: function () {
  68970. return this._blurKernelY;
  68971. },
  68972. /**
  68973. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  68974. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68975. */
  68976. set: function (value) {
  68977. if (this._blurKernelY === value) {
  68978. return;
  68979. }
  68980. this._blurKernelY = value;
  68981. this._preparePostProcesses();
  68982. },
  68983. enumerable: true,
  68984. configurable: true
  68985. });
  68986. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  68987. var engine = this.getScene().getEngine();
  68988. var dw = this.getRenderWidth() / engine.getRenderWidth();
  68989. var dh = this.getRenderHeight() / engine.getRenderHeight();
  68990. this.blurKernelX = this._adaptiveBlurKernel * dw;
  68991. this.blurKernelY = this._adaptiveBlurKernel * dh;
  68992. };
  68993. MirrorTexture.prototype._onRatioRescale = function () {
  68994. if (this._sizeRatio) {
  68995. this.resize(this._initialSizeParameter);
  68996. if (!this._adaptiveBlurKernel) {
  68997. this._preparePostProcesses();
  68998. }
  68999. }
  69000. if (this._adaptiveBlurKernel) {
  69001. this._autoComputeBlurKernel();
  69002. }
  69003. };
  69004. MirrorTexture.prototype._updateGammaSpace = function () {
  69005. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  69006. };
  69007. MirrorTexture.prototype._preparePostProcesses = function () {
  69008. this.clearPostProcesses(true);
  69009. if (this._blurKernelX && this._blurKernelY) {
  69010. var engine = this.getScene().getEngine();
  69011. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  69012. this._blurX = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]("horizontal blur", new _Maths_math_vector__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);
  69013. this._blurX.autoClear = false;
  69014. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  69015. this._blurX.inputTexture = this._texture;
  69016. }
  69017. else {
  69018. this._blurX.alwaysForcePOT = true;
  69019. }
  69020. this._blurY = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]("vertical blur", new _Maths_math_vector__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);
  69021. this._blurY.autoClear = false;
  69022. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  69023. this.addPostProcess(this._blurX);
  69024. this.addPostProcess(this._blurY);
  69025. }
  69026. else {
  69027. if (this._blurY) {
  69028. this.removePostProcess(this._blurY);
  69029. this._blurY.dispose();
  69030. this._blurY = null;
  69031. }
  69032. if (this._blurX) {
  69033. this.removePostProcess(this._blurX);
  69034. this._blurX.dispose();
  69035. this._blurX = null;
  69036. }
  69037. }
  69038. };
  69039. /**
  69040. * Clone the mirror texture.
  69041. * @returns the cloned texture
  69042. */
  69043. MirrorTexture.prototype.clone = function () {
  69044. var scene = this.getScene();
  69045. if (!scene) {
  69046. return this;
  69047. }
  69048. var textureSize = this.getSize();
  69049. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  69050. // Base texture
  69051. newTexture.hasAlpha = this.hasAlpha;
  69052. newTexture.level = this.level;
  69053. // Mirror Texture
  69054. newTexture.mirrorPlane = this.mirrorPlane.clone();
  69055. if (this.renderList) {
  69056. newTexture.renderList = this.renderList.slice(0);
  69057. }
  69058. return newTexture;
  69059. };
  69060. /**
  69061. * Serialize the texture to a JSON representation you could use in Parse later on
  69062. * @returns the serialized JSON representation
  69063. */
  69064. MirrorTexture.prototype.serialize = function () {
  69065. if (!this.name) {
  69066. return null;
  69067. }
  69068. var serializationObject = _super.prototype.serialize.call(this);
  69069. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  69070. return serializationObject;
  69071. };
  69072. /**
  69073. * Dispose the texture and release its associated resources.
  69074. */
  69075. MirrorTexture.prototype.dispose = function () {
  69076. _super.prototype.dispose.call(this);
  69077. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  69078. };
  69079. return MirrorTexture;
  69080. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  69081. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  69082. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  69083. };
  69084. /***/ }),
  69085. /***/ "./Materials/Textures/multiRenderTarget.ts":
  69086. /*!*************************************************!*\
  69087. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  69088. \*************************************************/
  69089. /*! exports provided: MultiRenderTarget */
  69090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69091. "use strict";
  69092. __webpack_require__.r(__webpack_exports__);
  69093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  69094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69095. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  69096. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  69097. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  69098. /* harmony import */ var _Engines_Extensions_engine_multiRender__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/Extensions/engine.multiRender */ "./Engines/Extensions/engine.multiRender.ts");
  69099. /**
  69100. * A multi render target, like a render target provides the ability to render to a texture.
  69101. * Unlike the render target, it can render to several draw buffers in one draw.
  69102. * This is specially interesting in deferred rendering or for any effects requiring more than
  69103. * just one color from a single pass.
  69104. */
  69105. var MultiRenderTarget = /** @class */ (function (_super) {
  69106. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  69107. /**
  69108. * Instantiate a new multi render target texture.
  69109. * A multi render target, like a render target provides the ability to render to a texture.
  69110. * Unlike the render target, it can render to several draw buffers in one draw.
  69111. * This is specially interesting in deferred rendering or for any effects requiring more than
  69112. * just one color from a single pass.
  69113. * @param name Define the name of the texture
  69114. * @param size Define the size of the buffers to render to
  69115. * @param count Define the number of target we are rendering into
  69116. * @param scene Define the scene the texture belongs to
  69117. * @param options Define the options used to create the multi render target
  69118. */
  69119. function MultiRenderTarget(name, size, count, scene, options) {
  69120. var _this = this;
  69121. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  69122. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  69123. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  69124. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  69125. _this._engine = scene.getEngine();
  69126. if (!_this.isSupported) {
  69127. _this.dispose();
  69128. return;
  69129. }
  69130. var types = [];
  69131. var samplingModes = [];
  69132. for (var i = 0; i < count; i++) {
  69133. if (options && options.types && options.types[i] !== undefined) {
  69134. types.push(options.types[i]);
  69135. }
  69136. else {
  69137. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  69138. }
  69139. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  69140. samplingModes.push(options.samplingModes[i]);
  69141. }
  69142. else {
  69143. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  69144. }
  69145. }
  69146. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  69147. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  69148. _this._size = size;
  69149. _this._multiRenderTargetOptions = {
  69150. samplingModes: samplingModes,
  69151. generateMipMaps: generateMipMaps,
  69152. generateDepthBuffer: generateDepthBuffer,
  69153. generateStencilBuffer: generateStencilBuffer,
  69154. generateDepthTexture: generateDepthTexture,
  69155. types: types,
  69156. textureCount: count
  69157. };
  69158. _this._createInternalTextures();
  69159. _this._createTextures();
  69160. return _this;
  69161. }
  69162. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  69163. /**
  69164. * Get if draw buffers are currently supported by the used hardware and browser.
  69165. */
  69166. get: function () {
  69167. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  69168. },
  69169. enumerable: true,
  69170. configurable: true
  69171. });
  69172. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  69173. /**
  69174. * Get the list of textures generated by the multi render target.
  69175. */
  69176. get: function () {
  69177. return this._textures;
  69178. },
  69179. enumerable: true,
  69180. configurable: true
  69181. });
  69182. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  69183. /**
  69184. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  69185. */
  69186. get: function () {
  69187. return this._textures[this._textures.length - 1];
  69188. },
  69189. enumerable: true,
  69190. configurable: true
  69191. });
  69192. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  69193. /**
  69194. * Set the wrapping mode on U of all the textures we are rendering to.
  69195. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  69196. */
  69197. set: function (wrap) {
  69198. if (this._textures) {
  69199. for (var i = 0; i < this._textures.length; i++) {
  69200. this._textures[i].wrapU = wrap;
  69201. }
  69202. }
  69203. },
  69204. enumerable: true,
  69205. configurable: true
  69206. });
  69207. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  69208. /**
  69209. * Set the wrapping mode on V of all the textures we are rendering to.
  69210. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  69211. */
  69212. set: function (wrap) {
  69213. if (this._textures) {
  69214. for (var i = 0; i < this._textures.length; i++) {
  69215. this._textures[i].wrapV = wrap;
  69216. }
  69217. }
  69218. },
  69219. enumerable: true,
  69220. configurable: true
  69221. });
  69222. /** @hidden */
  69223. MultiRenderTarget.prototype._rebuild = function () {
  69224. this.releaseInternalTextures();
  69225. this._createInternalTextures();
  69226. for (var i = 0; i < this._internalTextures.length; i++) {
  69227. var texture = this._textures[i];
  69228. texture._texture = this._internalTextures[i];
  69229. }
  69230. // Keeps references to frame buffer and stencil/depth buffer
  69231. this._texture = this._internalTextures[0];
  69232. };
  69233. MultiRenderTarget.prototype._createInternalTextures = function () {
  69234. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  69235. };
  69236. MultiRenderTarget.prototype._createTextures = function () {
  69237. this._textures = [];
  69238. for (var i = 0; i < this._internalTextures.length; i++) {
  69239. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  69240. texture._texture = this._internalTextures[i];
  69241. this._textures.push(texture);
  69242. }
  69243. // Keeps references to frame buffer and stencil/depth buffer
  69244. this._texture = this._internalTextures[0];
  69245. };
  69246. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  69247. /**
  69248. * Define the number of samples used if MSAA is enabled.
  69249. */
  69250. get: function () {
  69251. return this._samples;
  69252. },
  69253. set: function (value) {
  69254. if (this._samples === value) {
  69255. return;
  69256. }
  69257. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  69258. },
  69259. enumerable: true,
  69260. configurable: true
  69261. });
  69262. /**
  69263. * Resize all the textures in the multi render target.
  69264. * Be carrefull as it will recreate all the data in the new texture.
  69265. * @param size Define the new size
  69266. */
  69267. MultiRenderTarget.prototype.resize = function (size) {
  69268. this.releaseInternalTextures();
  69269. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  69270. this._createInternalTextures();
  69271. };
  69272. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  69273. var _this = this;
  69274. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  69275. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  69276. });
  69277. };
  69278. /**
  69279. * Dispose the render targets and their associated resources
  69280. */
  69281. MultiRenderTarget.prototype.dispose = function () {
  69282. this.releaseInternalTextures();
  69283. _super.prototype.dispose.call(this);
  69284. };
  69285. /**
  69286. * Release all the underlying texture used as draw buffers.
  69287. */
  69288. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  69289. if (!this._internalTextures) {
  69290. return;
  69291. }
  69292. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  69293. if (this._internalTextures[i] !== undefined) {
  69294. this._internalTextures[i].dispose();
  69295. this._internalTextures.splice(i, 1);
  69296. }
  69297. }
  69298. };
  69299. return MultiRenderTarget;
  69300. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  69301. /***/ }),
  69302. /***/ "./Materials/Textures/rawCubeTexture.ts":
  69303. /*!**********************************************!*\
  69304. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  69305. \**********************************************/
  69306. /*! exports provided: RawCubeTexture */
  69307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69308. "use strict";
  69309. __webpack_require__.r(__webpack_exports__);
  69310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  69311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69312. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  69313. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  69314. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  69315. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  69316. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  69317. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  69318. /**
  69319. * Raw cube texture where the raw buffers are passed in
  69320. */
  69321. var RawCubeTexture = /** @class */ (function (_super) {
  69322. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  69323. /**
  69324. * Creates a cube texture where the raw buffers are passed in.
  69325. * @param scene defines the scene the texture is attached to
  69326. * @param data defines the array of data to use to create each face
  69327. * @param size defines the size of the textures
  69328. * @param format defines the format of the data
  69329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  69330. * @param generateMipMaps defines if the engine should generate the mip levels
  69331. * @param invertY defines if data must be stored with Y axis inverted
  69332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  69333. * @param compression defines the compression used (null by default)
  69334. */
  69335. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  69336. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  69337. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  69338. if (generateMipMaps === void 0) { generateMipMaps = false; }
  69339. if (invertY === void 0) { invertY = false; }
  69340. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69341. if (compression === void 0) { compression = null; }
  69342. var _this = _super.call(this, "", scene) || this;
  69343. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  69344. return _this;
  69345. }
  69346. /**
  69347. * Updates the raw cube texture.
  69348. * @param data defines the data to store
  69349. * @param format defines the data format
  69350. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69351. * @param invertY defines if data must be stored with Y axis inverted
  69352. * @param compression defines the compression used (null by default)
  69353. * @param level defines which level of the texture to update
  69354. */
  69355. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  69356. if (compression === void 0) { compression = null; }
  69357. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  69358. };
  69359. /**
  69360. * Updates a raw cube texture with RGBD encoded data.
  69361. * @param data defines the array of data [mipmap][face] to use to create each face
  69362. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  69363. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  69364. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  69365. * @returns a promsie that resolves when the operation is complete
  69366. */
  69367. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  69368. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  69369. if (lodScale === void 0) { lodScale = 0.8; }
  69370. if (lodOffset === void 0) { lodOffset = 0; }
  69371. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  69372. };
  69373. /**
  69374. * Clones the raw cube texture.
  69375. * @return a new cube texture
  69376. */
  69377. RawCubeTexture.prototype.clone = function () {
  69378. var _this = this;
  69379. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  69380. var scene = _this.getScene();
  69381. var internalTexture = _this._texture;
  69382. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  69383. if (internalTexture.dataSource === _internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  69384. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  69385. }
  69386. return texture;
  69387. }, this);
  69388. };
  69389. /** @hidden */
  69390. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  69391. internalTexture._dataSource = _internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  69392. internalTexture._bufferViewArrayArray = data;
  69393. internalTexture._lodGenerationScale = lodScale;
  69394. internalTexture._lodGenerationOffset = lodOffset;
  69395. internalTexture._sphericalPolynomial = sphericalPolynomial;
  69396. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  69397. internalTexture.isReady = true;
  69398. });
  69399. };
  69400. return RawCubeTexture;
  69401. }(_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  69402. /***/ }),
  69403. /***/ "./Materials/Textures/rawTexture.ts":
  69404. /*!******************************************!*\
  69405. !*** ./Materials/Textures/rawTexture.ts ***!
  69406. \******************************************/
  69407. /*! exports provided: RawTexture */
  69408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69409. "use strict";
  69410. __webpack_require__.r(__webpack_exports__);
  69411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  69412. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69413. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  69414. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  69415. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  69416. /**
  69417. * Raw texture can help creating a texture directly from an array of data.
  69418. * This can be super useful if you either get the data from an uncompressed source or
  69419. * if you wish to create your texture pixel by pixel.
  69420. */
  69421. var RawTexture = /** @class */ (function (_super) {
  69422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  69423. /**
  69424. * Instantiates a new RawTexture.
  69425. * Raw texture can help creating a texture directly from an array of data.
  69426. * This can be super useful if you either get the data from an uncompressed source or
  69427. * if you wish to create your texture pixel by pixel.
  69428. * @param data define the array of data to use to create the texture
  69429. * @param width define the width of the texture
  69430. * @param height define the height of the texture
  69431. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  69432. * @param scene define the scene the texture belongs to
  69433. * @param generateMipMaps define whether mip maps should be generated or not
  69434. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69435. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69436. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  69437. */
  69438. function RawTexture(data, width, height,
  69439. /**
  69440. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  69441. */
  69442. format, scene, generateMipMaps, invertY, samplingMode, type) {
  69443. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69444. if (invertY === void 0) { invertY = false; }
  69445. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69446. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  69447. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  69448. _this.format = format;
  69449. _this._engine = scene.getEngine();
  69450. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  69451. _this.wrapU = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  69452. _this.wrapV = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  69453. return _this;
  69454. }
  69455. /**
  69456. * Updates the texture underlying data.
  69457. * @param data Define the new data of the texture
  69458. */
  69459. RawTexture.prototype.update = function (data) {
  69460. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
  69461. };
  69462. /**
  69463. * Creates a luminance texture from some data.
  69464. * @param data Define the texture data
  69465. * @param width Define the width of the texture
  69466. * @param height Define the height of the texture
  69467. * @param scene Define the scene the texture belongs to
  69468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  69469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69471. * @returns the luminance texture
  69472. */
  69473. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  69474. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69475. if (invertY === void 0) { invertY = false; }
  69476. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69477. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  69478. };
  69479. /**
  69480. * Creates a luminance alpha texture from some data.
  69481. * @param data Define the texture data
  69482. * @param width Define the width of the texture
  69483. * @param height Define the height of the texture
  69484. * @param scene Define the scene the texture belongs to
  69485. * @param generateMipMaps Define whether or not to create mip maps for the texture
  69486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69488. * @returns the luminance alpha texture
  69489. */
  69490. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  69491. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69492. if (invertY === void 0) { invertY = false; }
  69493. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69494. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  69495. };
  69496. /**
  69497. * Creates an alpha texture from some data.
  69498. * @param data Define the texture data
  69499. * @param width Define the width of the texture
  69500. * @param height Define the height of the texture
  69501. * @param scene Define the scene the texture belongs to
  69502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  69503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69505. * @returns the alpha texture
  69506. */
  69507. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  69508. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69509. if (invertY === void 0) { invertY = false; }
  69510. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69511. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  69512. };
  69513. /**
  69514. * Creates a RGB texture from some data.
  69515. * @param data Define the texture data
  69516. * @param width Define the width of the texture
  69517. * @param height Define the height of the texture
  69518. * @param scene Define the scene the texture belongs to
  69519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  69520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69522. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  69523. * @returns the RGB alpha texture
  69524. */
  69525. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  69526. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69527. if (invertY === void 0) { invertY = false; }
  69528. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69529. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  69530. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  69531. };
  69532. /**
  69533. * Creates a RGBA texture from some data.
  69534. * @param data Define the texture data
  69535. * @param width Define the width of the texture
  69536. * @param height Define the height of the texture
  69537. * @param scene Define the scene the texture belongs to
  69538. * @param generateMipMaps Define whether or not to create mip maps for the texture
  69539. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69540. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69541. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  69542. * @returns the RGBA texture
  69543. */
  69544. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  69545. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69546. if (invertY === void 0) { invertY = false; }
  69547. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  69548. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  69549. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  69550. };
  69551. /**
  69552. * Creates a R texture from some data.
  69553. * @param data Define the texture data
  69554. * @param width Define the width of the texture
  69555. * @param height Define the height of the texture
  69556. * @param scene Define the scene the texture belongs to
  69557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  69558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  69559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  69560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  69561. * @returns the R texture
  69562. */
  69563. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  69564. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69565. if (invertY === void 0) { invertY = false; }
  69566. if (samplingMode === void 0) { samplingMode = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  69567. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  69568. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  69569. };
  69570. return RawTexture;
  69571. }(_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  69572. /***/ }),
  69573. /***/ "./Materials/Textures/rawTexture3D.ts":
  69574. /*!********************************************!*\
  69575. !*** ./Materials/Textures/rawTexture3D.ts ***!
  69576. \********************************************/
  69577. /*! exports provided: RawTexture3D */
  69578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69579. "use strict";
  69580. __webpack_require__.r(__webpack_exports__);
  69581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  69582. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69583. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  69584. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  69585. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  69586. /**
  69587. * Class used to store 3D textures containing user data
  69588. */
  69589. var RawTexture3D = /** @class */ (function (_super) {
  69590. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  69591. /**
  69592. * Create a new RawTexture3D
  69593. * @param data defines the data of the texture
  69594. * @param width defines the width of the texture
  69595. * @param height defines the height of the texture
  69596. * @param depth defines the depth of the texture
  69597. * @param format defines the texture format to use
  69598. * @param scene defines the hosting scene
  69599. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69600. * @param invertY defines if texture must be stored with Y axis inverted
  69601. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69603. */
  69604. function RawTexture3D(data, width, height, depth,
  69605. /** Gets or sets the texture format to use */
  69606. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  69607. if (generateMipMaps === void 0) { generateMipMaps = true; }
  69608. if (invertY === void 0) { invertY = false; }
  69609. if (samplingMode === void 0) { samplingMode = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  69610. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  69611. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  69612. _this.format = format;
  69613. _this._engine = scene.getEngine();
  69614. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  69615. _this.is3D = true;
  69616. return _this;
  69617. }
  69618. /**
  69619. * Update the texture with new data
  69620. * @param data defines the data to store in the texture
  69621. */
  69622. RawTexture3D.prototype.update = function (data) {
  69623. if (!this._texture) {
  69624. return;
  69625. }
  69626. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
  69627. };
  69628. return RawTexture3D;
  69629. }(_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  69630. /***/ }),
  69631. /***/ "./Materials/Textures/refractionTexture.ts":
  69632. /*!*************************************************!*\
  69633. !*** ./Materials/Textures/refractionTexture.ts ***!
  69634. \*************************************************/
  69635. /*! exports provided: RefractionTexture */
  69636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69637. "use strict";
  69638. __webpack_require__.r(__webpack_exports__);
  69639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  69640. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69641. /* harmony import */ var _Maths_math_plane__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.plane */ "./Maths/math.plane.ts");
  69642. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  69643. /**
  69644. * Creates a refraction texture used by refraction channel of the standard material.
  69645. * It is like a mirror but to see through a material.
  69646. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69647. */
  69648. var RefractionTexture = /** @class */ (function (_super) {
  69649. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  69650. /**
  69651. * Creates a refraction texture used by refraction channel of the standard material.
  69652. * It is like a mirror but to see through a material.
  69653. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69654. * @param name Define the texture name
  69655. * @param size Define the size of the underlying texture
  69656. * @param scene Define the scene the refraction belongs to
  69657. * @param generateMipMaps Define if we need to generate mips level for the refraction
  69658. */
  69659. function RefractionTexture(name, size, scene, generateMipMaps) {
  69660. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  69661. /**
  69662. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  69663. * 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.
  69664. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69665. */
  69666. _this.refractionPlane = new _Maths_math_plane__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  69667. /**
  69668. * Define how deep under the surface we should see.
  69669. */
  69670. _this.depth = 2.0;
  69671. _this.onBeforeRenderObservable.add(function () {
  69672. scene.clipPlane = _this.refractionPlane;
  69673. });
  69674. _this.onAfterRenderObservable.add(function () {
  69675. scene.clipPlane = null;
  69676. });
  69677. return _this;
  69678. }
  69679. /**
  69680. * Clone the refraction texture.
  69681. * @returns the cloned texture
  69682. */
  69683. RefractionTexture.prototype.clone = function () {
  69684. var scene = this.getScene();
  69685. if (!scene) {
  69686. return this;
  69687. }
  69688. var textureSize = this.getSize();
  69689. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  69690. // Base texture
  69691. newTexture.hasAlpha = this.hasAlpha;
  69692. newTexture.level = this.level;
  69693. // Refraction Texture
  69694. newTexture.refractionPlane = this.refractionPlane.clone();
  69695. if (this.renderList) {
  69696. newTexture.renderList = this.renderList.slice(0);
  69697. }
  69698. newTexture.depth = this.depth;
  69699. return newTexture;
  69700. };
  69701. /**
  69702. * Serialize the texture to a JSON representation you could use in Parse later on
  69703. * @returns the serialized JSON representation
  69704. */
  69705. RefractionTexture.prototype.serialize = function () {
  69706. if (!this.name) {
  69707. return null;
  69708. }
  69709. var serializationObject = _super.prototype.serialize.call(this);
  69710. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  69711. serializationObject.depth = this.depth;
  69712. return serializationObject;
  69713. };
  69714. return RefractionTexture;
  69715. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  69716. /***/ }),
  69717. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  69718. /*!***********************************************************!*\
  69719. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  69720. \***********************************************************/
  69721. /*! exports provided: RenderTargetCreationOptions */
  69722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69723. "use strict";
  69724. __webpack_require__.r(__webpack_exports__);
  69725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  69726. /**
  69727. * Define options used to create a render target texture
  69728. */
  69729. var RenderTargetCreationOptions = /** @class */ (function () {
  69730. function RenderTargetCreationOptions() {
  69731. }
  69732. return RenderTargetCreationOptions;
  69733. }());
  69734. /***/ }),
  69735. /***/ "./Materials/Textures/renderTargetTexture.ts":
  69736. /*!***************************************************!*\
  69737. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  69738. \***************************************************/
  69739. /*! exports provided: RenderTargetTexture */
  69740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69741. "use strict";
  69742. __webpack_require__.r(__webpack_exports__);
  69743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  69744. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69745. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  69746. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  69747. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  69748. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  69749. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  69750. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  69751. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  69752. /* harmony import */ var _Engines_Extensions_engine_renderTarget__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Engines/Extensions/engine.renderTarget */ "./Engines/Extensions/engine.renderTarget.ts");
  69753. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  69754. /**
  69755. * This Helps creating a texture that will be created from a camera in your scene.
  69756. * It is basically a dynamic texture that could be used to create special effects for instance.
  69757. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  69758. */
  69759. var RenderTargetTexture = /** @class */ (function (_super) {
  69760. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  69761. /**
  69762. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  69763. * or used a shadow, depth texture...
  69764. * @param name The friendly name of the texture
  69765. * @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)
  69766. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  69767. * @param generateMipMaps True if mip maps need to be generated after render.
  69768. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  69769. * @param type The type of the buffer in the RTT (int, half float, float...)
  69770. * @param isCube True if a cube texture needs to be created
  69771. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  69772. * @param generateDepthBuffer True to generate a depth buffer
  69773. * @param generateStencilBuffer True to generate a stencil buffer
  69774. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  69775. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  69776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69777. */
  69778. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  69779. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  69780. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  69781. if (isCube === void 0) { isCube = false; }
  69782. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  69783. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  69784. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  69785. if (isMulti === void 0) { isMulti = false; }
  69786. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  69787. if (delayAllocation === void 0) { delayAllocation = false; }
  69788. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  69789. _this.isCube = isCube;
  69790. /**
  69791. * Define if particles should be rendered in your texture.
  69792. */
  69793. _this.renderParticles = true;
  69794. /**
  69795. * Define if sprites should be rendered in your texture.
  69796. */
  69797. _this.renderSprites = false;
  69798. /**
  69799. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  69800. */
  69801. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  69802. /**
  69803. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  69804. */
  69805. _this.ignoreCameraViewport = false;
  69806. /**
  69807. * An event triggered when the texture is unbind.
  69808. */
  69809. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  69810. /**
  69811. * An event triggered when the texture is unbind.
  69812. */
  69813. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  69814. /**
  69815. * An event triggered before rendering the texture
  69816. */
  69817. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  69818. /**
  69819. * An event triggered after rendering the texture
  69820. */
  69821. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  69822. /**
  69823. * An event triggered after the texture clear
  69824. */
  69825. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  69826. _this._currentRefreshId = -1;
  69827. _this._refreshRate = 1;
  69828. _this._samples = 1;
  69829. /**
  69830. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  69831. * It must define where the camera used to render the texture is set
  69832. */
  69833. _this.boundingBoxPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  69834. scene = _this.getScene();
  69835. if (!scene) {
  69836. return _this;
  69837. }
  69838. _this.renderList = new Array();
  69839. _this._engine = scene.getEngine();
  69840. _this.name = name;
  69841. _this.isRenderTarget = true;
  69842. _this._initialSizeParameter = size;
  69843. _this._processSizeParameter(size);
  69844. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  69845. });
  69846. _this._generateMipMaps = generateMipMaps ? true : false;
  69847. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  69848. // Rendering groups
  69849. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  69850. _this._renderingManager._useSceneAutoClearSetup = true;
  69851. if (isMulti) {
  69852. return _this;
  69853. }
  69854. _this._renderTargetOptions = {
  69855. generateMipMaps: generateMipMaps,
  69856. type: type,
  69857. format: format,
  69858. samplingMode: samplingMode,
  69859. generateDepthBuffer: generateDepthBuffer,
  69860. generateStencilBuffer: generateStencilBuffer
  69861. };
  69862. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  69863. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  69864. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  69865. }
  69866. if (!delayAllocation) {
  69867. if (isCube) {
  69868. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  69869. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  69870. _this._textureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  69871. }
  69872. else {
  69873. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  69874. }
  69875. }
  69876. return _this;
  69877. }
  69878. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  69879. /**
  69880. * Use this list to define the list of mesh you want to render.
  69881. */
  69882. get: function () {
  69883. return this._renderList;
  69884. },
  69885. set: function (value) {
  69886. this._renderList = value;
  69887. if (this._renderList) {
  69888. this._hookArray(this._renderList);
  69889. }
  69890. },
  69891. enumerable: true,
  69892. configurable: true
  69893. });
  69894. RenderTargetTexture.prototype._hookArray = function (array) {
  69895. var _this = this;
  69896. var oldPush = array.push;
  69897. array.push = function () {
  69898. var items = [];
  69899. for (var _i = 0; _i < arguments.length; _i++) {
  69900. items[_i] = arguments[_i];
  69901. }
  69902. var wasEmpty = array.length === 0;
  69903. var result = oldPush.apply(array, items);
  69904. if (wasEmpty) {
  69905. _this.getScene().meshes.forEach(function (mesh) {
  69906. mesh._markSubMeshesAsLightDirty();
  69907. });
  69908. }
  69909. return result;
  69910. };
  69911. var oldSplice = array.splice;
  69912. array.splice = function (index, deleteCount) {
  69913. var deleted = oldSplice.apply(array, [index, deleteCount]);
  69914. if (array.length === 0) {
  69915. _this.getScene().meshes.forEach(function (mesh) {
  69916. mesh._markSubMeshesAsLightDirty();
  69917. });
  69918. }
  69919. return deleted;
  69920. };
  69921. };
  69922. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  69923. /**
  69924. * Set a after unbind callback in the texture.
  69925. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  69926. */
  69927. set: function (callback) {
  69928. if (this._onAfterUnbindObserver) {
  69929. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  69930. }
  69931. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  69932. },
  69933. enumerable: true,
  69934. configurable: true
  69935. });
  69936. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  69937. /**
  69938. * Set a before render callback in the texture.
  69939. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  69940. */
  69941. set: function (callback) {
  69942. if (this._onBeforeRenderObserver) {
  69943. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  69944. }
  69945. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  69946. },
  69947. enumerable: true,
  69948. configurable: true
  69949. });
  69950. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  69951. /**
  69952. * Set a after render callback in the texture.
  69953. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  69954. */
  69955. set: function (callback) {
  69956. if (this._onAfterRenderObserver) {
  69957. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  69958. }
  69959. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  69960. },
  69961. enumerable: true,
  69962. configurable: true
  69963. });
  69964. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  69965. /**
  69966. * Set a clear callback in the texture.
  69967. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  69968. */
  69969. set: function (callback) {
  69970. if (this._onClearObserver) {
  69971. this.onClearObservable.remove(this._onClearObserver);
  69972. }
  69973. this._onClearObserver = this.onClearObservable.add(callback);
  69974. },
  69975. enumerable: true,
  69976. configurable: true
  69977. });
  69978. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  69979. /**
  69980. * Gets render target creation options that were used.
  69981. */
  69982. get: function () {
  69983. return this._renderTargetOptions;
  69984. },
  69985. enumerable: true,
  69986. configurable: true
  69987. });
  69988. RenderTargetTexture.prototype._onRatioRescale = function () {
  69989. if (this._sizeRatio) {
  69990. this.resize(this._initialSizeParameter);
  69991. }
  69992. };
  69993. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  69994. get: function () {
  69995. return this._boundingBoxSize;
  69996. },
  69997. /**
  69998. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  69999. * When defined, the cubemap will switch to local mode
  70000. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70001. * @example https://www.babylonjs-playground.com/#RNASML
  70002. */
  70003. set: function (value) {
  70004. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  70005. return;
  70006. }
  70007. this._boundingBoxSize = value;
  70008. var scene = this.getScene();
  70009. if (scene) {
  70010. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  70011. }
  70012. },
  70013. enumerable: true,
  70014. configurable: true
  70015. });
  70016. /**
  70017. * Creates a depth stencil texture.
  70018. * This is only available in WebGL 2 or with the depth texture extension available.
  70019. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  70020. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  70021. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  70022. */
  70023. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  70024. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  70025. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  70026. if (generateStencil === void 0) { generateStencil = false; }
  70027. if (!this.getScene()) {
  70028. return;
  70029. }
  70030. var engine = this.getScene().getEngine();
  70031. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  70032. bilinearFiltering: bilinearFiltering,
  70033. comparisonFunction: comparisonFunction,
  70034. generateStencil: generateStencil,
  70035. isCube: this.isCube
  70036. });
  70037. engine.setFrameBufferDepthStencilTexture(this);
  70038. };
  70039. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  70040. if (size.ratio) {
  70041. this._sizeRatio = size.ratio;
  70042. this._size = {
  70043. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  70044. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  70045. };
  70046. }
  70047. else {
  70048. this._size = size;
  70049. }
  70050. };
  70051. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  70052. /**
  70053. * Define the number of samples to use in case of MSAA.
  70054. * It defaults to one meaning no MSAA has been enabled.
  70055. */
  70056. get: function () {
  70057. return this._samples;
  70058. },
  70059. set: function (value) {
  70060. if (this._samples === value) {
  70061. return;
  70062. }
  70063. var scene = this.getScene();
  70064. if (!scene) {
  70065. return;
  70066. }
  70067. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  70068. },
  70069. enumerable: true,
  70070. configurable: true
  70071. });
  70072. /**
  70073. * Resets the refresh counter of the texture and start bak from scratch.
  70074. * Could be useful to regenerate the texture if it is setup to render only once.
  70075. */
  70076. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  70077. this._currentRefreshId = -1;
  70078. };
  70079. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  70080. /**
  70081. * Define the refresh rate of the texture or the rendering frequency.
  70082. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70083. */
  70084. get: function () {
  70085. return this._refreshRate;
  70086. },
  70087. set: function (value) {
  70088. this._refreshRate = value;
  70089. this.resetRefreshCounter();
  70090. },
  70091. enumerable: true,
  70092. configurable: true
  70093. });
  70094. /**
  70095. * Adds a post process to the render target rendering passes.
  70096. * @param postProcess define the post process to add
  70097. */
  70098. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  70099. if (!this._postProcessManager) {
  70100. var scene = this.getScene();
  70101. if (!scene) {
  70102. return;
  70103. }
  70104. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  70105. this._postProcesses = new Array();
  70106. }
  70107. this._postProcesses.push(postProcess);
  70108. this._postProcesses[0].autoClear = false;
  70109. };
  70110. /**
  70111. * Clear all the post processes attached to the render target
  70112. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  70113. */
  70114. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  70115. if (dispose === void 0) { dispose = false; }
  70116. if (!this._postProcesses) {
  70117. return;
  70118. }
  70119. if (dispose) {
  70120. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  70121. var postProcess = _a[_i];
  70122. postProcess.dispose();
  70123. }
  70124. }
  70125. this._postProcesses = [];
  70126. };
  70127. /**
  70128. * Remove one of the post process from the list of attached post processes to the texture
  70129. * @param postProcess define the post process to remove from the list
  70130. */
  70131. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  70132. if (!this._postProcesses) {
  70133. return;
  70134. }
  70135. var index = this._postProcesses.indexOf(postProcess);
  70136. if (index === -1) {
  70137. return;
  70138. }
  70139. this._postProcesses.splice(index, 1);
  70140. if (this._postProcesses.length > 0) {
  70141. this._postProcesses[0].autoClear = false;
  70142. }
  70143. };
  70144. /** @hidden */
  70145. RenderTargetTexture.prototype._shouldRender = function () {
  70146. if (this._currentRefreshId === -1) { // At least render once
  70147. this._currentRefreshId = 1;
  70148. return true;
  70149. }
  70150. if (this.refreshRate === this._currentRefreshId) {
  70151. this._currentRefreshId = 1;
  70152. return true;
  70153. }
  70154. this._currentRefreshId++;
  70155. return false;
  70156. };
  70157. /**
  70158. * Gets the actual render size of the texture.
  70159. * @returns the width of the render size
  70160. */
  70161. RenderTargetTexture.prototype.getRenderSize = function () {
  70162. return this.getRenderWidth();
  70163. };
  70164. /**
  70165. * Gets the actual render width of the texture.
  70166. * @returns the width of the render size
  70167. */
  70168. RenderTargetTexture.prototype.getRenderWidth = function () {
  70169. if (this._size.width) {
  70170. return this._size.width;
  70171. }
  70172. return this._size;
  70173. };
  70174. /**
  70175. * Gets the actual render height of the texture.
  70176. * @returns the height of the render size
  70177. */
  70178. RenderTargetTexture.prototype.getRenderHeight = function () {
  70179. if (this._size.width) {
  70180. return this._size.height;
  70181. }
  70182. return this._size;
  70183. };
  70184. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  70185. /**
  70186. * Get if the texture can be rescaled or not.
  70187. */
  70188. get: function () {
  70189. return true;
  70190. },
  70191. enumerable: true,
  70192. configurable: true
  70193. });
  70194. /**
  70195. * Resize the texture using a ratio.
  70196. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  70197. */
  70198. RenderTargetTexture.prototype.scale = function (ratio) {
  70199. var newSize = this.getRenderSize() * ratio;
  70200. this.resize(newSize);
  70201. };
  70202. /**
  70203. * Get the texture reflection matrix used to rotate/transform the reflection.
  70204. * @returns the reflection matrix
  70205. */
  70206. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  70207. if (this.isCube) {
  70208. return this._textureMatrix;
  70209. }
  70210. return _super.prototype.getReflectionTextureMatrix.call(this);
  70211. };
  70212. /**
  70213. * Resize the texture to a new desired size.
  70214. * Be carrefull as it will recreate all the data in the new texture.
  70215. * @param size Define the new size. It can be:
  70216. * - a number for squared texture,
  70217. * - an object containing { width: number, height: number }
  70218. * - or an object containing a ratio { ratio: number }
  70219. */
  70220. RenderTargetTexture.prototype.resize = function (size) {
  70221. var wasCube = this.isCube;
  70222. this.releaseInternalTexture();
  70223. var scene = this.getScene();
  70224. if (!scene) {
  70225. return;
  70226. }
  70227. this._processSizeParameter(size);
  70228. if (wasCube) {
  70229. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  70230. }
  70231. else {
  70232. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  70233. }
  70234. };
  70235. /**
  70236. * Renders all the objects from the render list into the texture.
  70237. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  70238. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  70239. */
  70240. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  70241. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  70242. if (dumpForDebug === void 0) { dumpForDebug = false; }
  70243. var scene = this.getScene();
  70244. if (!scene) {
  70245. return;
  70246. }
  70247. var engine = scene.getEngine();
  70248. if (this.useCameraPostProcesses !== undefined) {
  70249. useCameraPostProcess = this.useCameraPostProcesses;
  70250. }
  70251. if (this._waitingRenderList) {
  70252. this.renderList = [];
  70253. for (var index = 0; index < this._waitingRenderList.length; index++) {
  70254. var id = this._waitingRenderList[index];
  70255. var mesh_1 = scene.getMeshByID(id);
  70256. if (mesh_1) {
  70257. this.renderList.push(mesh_1);
  70258. }
  70259. }
  70260. delete this._waitingRenderList;
  70261. }
  70262. // Is predicate defined?
  70263. if (this.renderListPredicate) {
  70264. if (this.renderList) {
  70265. this.renderList.length = 0; // Clear previous renderList
  70266. }
  70267. else {
  70268. this.renderList = [];
  70269. }
  70270. var scene = this.getScene();
  70271. if (!scene) {
  70272. return;
  70273. }
  70274. var sceneMeshes = scene.meshes;
  70275. for (var index = 0; index < sceneMeshes.length; index++) {
  70276. var mesh = sceneMeshes[index];
  70277. if (this.renderListPredicate(mesh)) {
  70278. this.renderList.push(mesh);
  70279. }
  70280. }
  70281. }
  70282. this.onBeforeBindObservable.notifyObservers(this);
  70283. // Set custom projection.
  70284. // Needs to be before binding to prevent changing the aspect ratio.
  70285. var camera;
  70286. if (this.activeCamera) {
  70287. camera = this.activeCamera;
  70288. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  70289. if (this.activeCamera !== scene.activeCamera) {
  70290. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  70291. }
  70292. }
  70293. else {
  70294. camera = scene.activeCamera;
  70295. if (camera) {
  70296. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  70297. }
  70298. }
  70299. // Prepare renderingManager
  70300. this._renderingManager.reset();
  70301. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  70302. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  70303. var sceneRenderId = scene.getRenderId();
  70304. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  70305. var mesh = currentRenderList[meshIndex];
  70306. if (mesh) {
  70307. if (!mesh.isReady(this.refreshRate === 0)) {
  70308. this.resetRefreshCounter();
  70309. continue;
  70310. }
  70311. mesh._preActivateForIntermediateRendering(sceneRenderId);
  70312. var isMasked = void 0;
  70313. if (!this.renderList && camera) {
  70314. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  70315. }
  70316. else {
  70317. isMasked = false;
  70318. }
  70319. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  70320. if (mesh._activate(sceneRenderId, true)) {
  70321. if (!mesh.isAnInstance) {
  70322. mesh._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = false;
  70323. }
  70324. else {
  70325. mesh = mesh.sourceMesh;
  70326. }
  70327. mesh._internalAbstractMeshDataInfo._isActiveIntermediate = true;
  70328. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  70329. var subMesh = mesh.subMeshes[subIndex];
  70330. scene._activeIndices.addCount(subMesh.indexCount, false);
  70331. this._renderingManager.dispatch(subMesh, mesh);
  70332. }
  70333. }
  70334. }
  70335. }
  70336. }
  70337. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  70338. var particleSystem = scene.particleSystems[particleIndex];
  70339. var emitter = particleSystem.emitter;
  70340. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  70341. continue;
  70342. }
  70343. if (currentRenderList.indexOf(emitter) >= 0) {
  70344. this._renderingManager.dispatchParticles(particleSystem);
  70345. }
  70346. }
  70347. if (this.isCube) {
  70348. for (var face = 0; face < 6; face++) {
  70349. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  70350. scene.incrementRenderId();
  70351. scene.resetCachedMaterial();
  70352. }
  70353. }
  70354. else {
  70355. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  70356. }
  70357. this.onAfterUnbindObservable.notifyObservers(this);
  70358. if (scene.activeCamera) {
  70359. // Do not avoid setting uniforms when multiple scenes are active as another camera may have overwrite these
  70360. if (scene.getEngine().scenes.length > 1 || (this.activeCamera && this.activeCamera !== scene.activeCamera)) {
  70361. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  70362. }
  70363. engine.setViewport(scene.activeCamera.viewport);
  70364. }
  70365. scene.resetCachedMaterial();
  70366. };
  70367. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  70368. var minimum = 128;
  70369. var x = renderDimension * scale;
  70370. var curved = _Engines_engine__WEBPACK_IMPORTED_MODULE_9__["Engine"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  70371. // Ensure we don't exceed the render dimension (while staying POT)
  70372. return Math.min(_Engines_engine__WEBPACK_IMPORTED_MODULE_9__["Engine"].FloorPOT(renderDimension), curved);
  70373. };
  70374. /**
  70375. * @hidden
  70376. * @param faceIndex face index to bind to if this is a cubetexture
  70377. */
  70378. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  70379. if (faceIndex === void 0) { faceIndex = 0; }
  70380. var scene = this.getScene();
  70381. if (!scene) {
  70382. return;
  70383. }
  70384. var engine = scene.getEngine();
  70385. if (this._texture) {
  70386. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  70387. }
  70388. };
  70389. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  70390. var _this = this;
  70391. if (!this._texture) {
  70392. return;
  70393. }
  70394. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  70395. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  70396. });
  70397. };
  70398. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  70399. var scene = this.getScene();
  70400. if (!scene) {
  70401. return;
  70402. }
  70403. var engine = scene.getEngine();
  70404. if (!this._texture) {
  70405. return;
  70406. }
  70407. // Bind
  70408. if (this._postProcessManager) {
  70409. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  70410. }
  70411. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  70412. this._bindFrameBuffer(faceIndex);
  70413. }
  70414. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  70415. // Clear
  70416. if (this.onClearObservable.hasObservers()) {
  70417. this.onClearObservable.notifyObservers(engine);
  70418. }
  70419. else {
  70420. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  70421. }
  70422. if (!this._doNotChangeAspectRatio) {
  70423. scene.updateTransformMatrix(true);
  70424. }
  70425. // Before Camera Draw
  70426. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  70427. var step = _a[_i];
  70428. step.action(this);
  70429. }
  70430. // Render
  70431. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  70432. // After Camera Draw
  70433. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  70434. var step = _c[_b];
  70435. step.action(this);
  70436. }
  70437. if (this._postProcessManager) {
  70438. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  70439. }
  70440. else if (useCameraPostProcess) {
  70441. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  70442. }
  70443. if (!this._doNotChangeAspectRatio) {
  70444. scene.updateTransformMatrix(true);
  70445. }
  70446. // Dump ?
  70447. if (dumpForDebug) {
  70448. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  70449. }
  70450. // Unbind
  70451. if (!this.isCube || faceIndex === 5) {
  70452. if (this.isCube) {
  70453. if (faceIndex === 5) {
  70454. engine.generateMipMapsForCubemap(this._texture);
  70455. }
  70456. }
  70457. this.unbindFrameBuffer(engine, faceIndex);
  70458. }
  70459. else {
  70460. this.onAfterRenderObservable.notifyObservers(faceIndex);
  70461. }
  70462. };
  70463. /**
  70464. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  70465. * This allowed control for front to back rendering or reversly depending of the special needs.
  70466. *
  70467. * @param renderingGroupId The rendering group id corresponding to its index
  70468. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  70469. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  70470. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  70471. */
  70472. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  70473. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  70474. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  70475. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  70476. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  70477. };
  70478. /**
  70479. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  70480. *
  70481. * @param renderingGroupId The rendering group id corresponding to its index
  70482. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  70483. */
  70484. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  70485. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  70486. this._renderingManager._useSceneAutoClearSetup = false;
  70487. };
  70488. /**
  70489. * Clones the texture.
  70490. * @returns the cloned texture
  70491. */
  70492. RenderTargetTexture.prototype.clone = function () {
  70493. var textureSize = this.getSize();
  70494. 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);
  70495. // Base texture
  70496. newTexture.hasAlpha = this.hasAlpha;
  70497. newTexture.level = this.level;
  70498. // RenderTarget Texture
  70499. newTexture.coordinatesMode = this.coordinatesMode;
  70500. if (this.renderList) {
  70501. newTexture.renderList = this.renderList.slice(0);
  70502. }
  70503. return newTexture;
  70504. };
  70505. /**
  70506. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  70507. * @returns The JSON representation of the texture
  70508. */
  70509. RenderTargetTexture.prototype.serialize = function () {
  70510. if (!this.name) {
  70511. return null;
  70512. }
  70513. var serializationObject = _super.prototype.serialize.call(this);
  70514. serializationObject.renderTargetSize = this.getRenderSize();
  70515. serializationObject.renderList = [];
  70516. if (this.renderList) {
  70517. for (var index = 0; index < this.renderList.length; index++) {
  70518. serializationObject.renderList.push(this.renderList[index].id);
  70519. }
  70520. }
  70521. return serializationObject;
  70522. };
  70523. /**
  70524. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  70525. */
  70526. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  70527. var objBuffer = this.getInternalTexture();
  70528. var scene = this.getScene();
  70529. if (objBuffer && scene) {
  70530. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  70531. }
  70532. };
  70533. /**
  70534. * Dispose the texture and release its associated resources.
  70535. */
  70536. RenderTargetTexture.prototype.dispose = function () {
  70537. if (this._postProcessManager) {
  70538. this._postProcessManager.dispose();
  70539. this._postProcessManager = null;
  70540. }
  70541. this.clearPostProcesses(true);
  70542. if (this._resizeObserver) {
  70543. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  70544. this._resizeObserver = null;
  70545. }
  70546. this.renderList = null;
  70547. // Remove from custom render targets
  70548. var scene = this.getScene();
  70549. if (!scene) {
  70550. return;
  70551. }
  70552. var index = scene.customRenderTargets.indexOf(this);
  70553. if (index >= 0) {
  70554. scene.customRenderTargets.splice(index, 1);
  70555. }
  70556. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  70557. var camera = _a[_i];
  70558. index = camera.customRenderTargets.indexOf(this);
  70559. if (index >= 0) {
  70560. camera.customRenderTargets.splice(index, 1);
  70561. }
  70562. }
  70563. if (this.depthStencilTexture) {
  70564. this.getScene().getEngine()._releaseTexture(this.depthStencilTexture);
  70565. }
  70566. _super.prototype.dispose.call(this);
  70567. };
  70568. /** @hidden */
  70569. RenderTargetTexture.prototype._rebuild = function () {
  70570. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  70571. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  70572. }
  70573. if (this._postProcessManager) {
  70574. this._postProcessManager._rebuild();
  70575. }
  70576. };
  70577. /**
  70578. * Clear the info related to rendering groups preventing retention point in material dispose.
  70579. */
  70580. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  70581. if (this._renderingManager) {
  70582. this._renderingManager.freeRenderingGroups();
  70583. }
  70584. };
  70585. /**
  70586. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  70587. * @returns the view count
  70588. */
  70589. RenderTargetTexture.prototype.getViewCount = function () {
  70590. return 1;
  70591. };
  70592. /**
  70593. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  70594. */
  70595. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  70596. /**
  70597. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  70598. */
  70599. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  70600. /**
  70601. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  70602. * the central point of your effect and can save a lot of performances.
  70603. */
  70604. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  70605. return RenderTargetTexture;
  70606. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  70607. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  70608. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  70609. };
  70610. /***/ }),
  70611. /***/ "./Materials/Textures/texture.ts":
  70612. /*!***************************************!*\
  70613. !*** ./Materials/Textures/texture.ts ***!
  70614. \***************************************/
  70615. /*! exports provided: Texture */
  70616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70617. "use strict";
  70618. __webpack_require__.r(__webpack_exports__);
  70619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  70620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  70621. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  70622. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  70623. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  70624. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  70625. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  70626. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  70627. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  70628. /* harmony import */ var _Misc_timingTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/timingTools */ "./Misc/timingTools.ts");
  70629. /* harmony import */ var _Misc_instantiationTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/instantiationTools */ "./Misc/instantiationTools.ts");
  70630. /* harmony import */ var _Maths_math_plane__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Maths/math.plane */ "./Maths/math.plane.ts");
  70631. /**
  70632. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  70633. * @see http://doc.babylonjs.com/babylon101/materials#texture
  70634. */
  70635. var Texture = /** @class */ (function (_super) {
  70636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  70637. /**
  70638. * Instantiates a new texture.
  70639. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  70640. * @see http://doc.babylonjs.com/babylon101/materials#texture
  70641. * @param url define the url of the picture to load as a texture
  70642. * @param scene define the scene or engine the texture will belong to
  70643. * @param noMipmap define if the texture will require mip maps or not
  70644. * @param invertY define if the texture needs to be inverted on the y axis during loading
  70645. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  70646. * @param onLoad define a callback triggered when the texture has been loaded
  70647. * @param onError define a callback triggered when an error occurred during the loading session
  70648. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  70649. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  70650. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  70651. */
  70652. function Texture(url, sceneOrEngine, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  70653. if (noMipmap === void 0) { noMipmap = false; }
  70654. if (invertY === void 0) { invertY = true; }
  70655. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  70656. if (onLoad === void 0) { onLoad = null; }
  70657. if (onError === void 0) { onError = null; }
  70658. if (buffer === void 0) { buffer = null; }
  70659. if (deleteBuffer === void 0) { deleteBuffer = false; }
  70660. var _this = _super.call(this, (sceneOrEngine && sceneOrEngine.getClassName() === "Scene") ? sceneOrEngine : null) || this;
  70661. /**
  70662. * Define the url of the texture.
  70663. */
  70664. _this.url = null;
  70665. /**
  70666. * Define an offset on the texture to offset the u coordinates of the UVs
  70667. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  70668. */
  70669. _this.uOffset = 0;
  70670. /**
  70671. * Define an offset on the texture to offset the v coordinates of the UVs
  70672. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  70673. */
  70674. _this.vOffset = 0;
  70675. /**
  70676. * Define an offset on the texture to scale the u coordinates of the UVs
  70677. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  70678. */
  70679. _this.uScale = 1.0;
  70680. /**
  70681. * Define an offset on the texture to scale the v coordinates of the UVs
  70682. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  70683. */
  70684. _this.vScale = 1.0;
  70685. /**
  70686. * Define an offset on the texture to rotate around the u coordinates of the UVs
  70687. * @see http://doc.babylonjs.com/how_to/more_materials
  70688. */
  70689. _this.uAng = 0;
  70690. /**
  70691. * Define an offset on the texture to rotate around the v coordinates of the UVs
  70692. * @see http://doc.babylonjs.com/how_to/more_materials
  70693. */
  70694. _this.vAng = 0;
  70695. /**
  70696. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  70697. * @see http://doc.babylonjs.com/how_to/more_materials
  70698. */
  70699. _this.wAng = 0;
  70700. /**
  70701. * Defines the center of rotation (U)
  70702. */
  70703. _this.uRotationCenter = 0.5;
  70704. /**
  70705. * Defines the center of rotation (V)
  70706. */
  70707. _this.vRotationCenter = 0.5;
  70708. /**
  70709. * Defines the center of rotation (W)
  70710. */
  70711. _this.wRotationCenter = 0.5;
  70712. /**
  70713. * List of inspectable custom properties (used by the Inspector)
  70714. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70715. */
  70716. _this.inspectableCustomProperties = null;
  70717. _this._noMipmap = false;
  70718. /** @hidden */
  70719. _this._invertY = false;
  70720. _this._rowGenerationMatrix = null;
  70721. _this._cachedTextureMatrix = null;
  70722. _this._projectionModeMatrix = null;
  70723. _this._t0 = null;
  70724. _this._t1 = null;
  70725. _this._t2 = null;
  70726. _this._cachedUOffset = -1;
  70727. _this._cachedVOffset = -1;
  70728. _this._cachedUScale = 0;
  70729. _this._cachedVScale = 0;
  70730. _this._cachedUAng = -1;
  70731. _this._cachedVAng = -1;
  70732. _this._cachedWAng = -1;
  70733. _this._cachedProjectionMatrixId = -1;
  70734. _this._cachedCoordinatesMode = -1;
  70735. /** @hidden */
  70736. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  70737. /** @hidden */
  70738. _this._buffer = null;
  70739. _this._deleteBuffer = false;
  70740. _this._format = null;
  70741. _this._delayedOnLoad = null;
  70742. _this._delayedOnError = null;
  70743. /**
  70744. * Observable triggered once the texture has been loaded.
  70745. */
  70746. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  70747. _this._isBlocking = true;
  70748. _this.name = url || "";
  70749. _this.url = url;
  70750. _this._noMipmap = noMipmap;
  70751. _this._invertY = invertY;
  70752. _this._initialSamplingMode = samplingMode;
  70753. _this._buffer = buffer;
  70754. _this._deleteBuffer = deleteBuffer;
  70755. if (format) {
  70756. _this._format = format;
  70757. }
  70758. var scene = _this.getScene();
  70759. var engine = (sceneOrEngine && sceneOrEngine.getCaps) ? sceneOrEngine : (scene ? scene.getEngine() : null);
  70760. if (!engine) {
  70761. return _this;
  70762. }
  70763. engine.onBeforeTextureInitObservable.notifyObservers(_this);
  70764. var load = function () {
  70765. if (_this._texture) {
  70766. if (_this._texture._invertVScale) {
  70767. _this.vScale *= -1;
  70768. _this.vOffset += 1;
  70769. }
  70770. // Update texutre to match internal texture's wrapping
  70771. if (_this._texture._cachedWrapU !== null) {
  70772. _this.wrapU = _this._texture._cachedWrapU;
  70773. _this._texture._cachedWrapU = null;
  70774. }
  70775. if (_this._texture._cachedWrapV !== null) {
  70776. _this.wrapV = _this._texture._cachedWrapV;
  70777. _this._texture._cachedWrapV = null;
  70778. }
  70779. if (_this._texture._cachedWrapR !== null) {
  70780. _this.wrapR = _this._texture._cachedWrapR;
  70781. _this._texture._cachedWrapR = null;
  70782. }
  70783. }
  70784. if (_this.onLoadObservable.hasObservers()) {
  70785. _this.onLoadObservable.notifyObservers(_this);
  70786. }
  70787. if (onLoad) {
  70788. onLoad();
  70789. }
  70790. if (!_this.isBlocking && scene) {
  70791. scene.resetCachedMaterial();
  70792. }
  70793. };
  70794. if (!_this.url) {
  70795. _this._delayedOnLoad = load;
  70796. _this._delayedOnError = onError;
  70797. return _this;
  70798. }
  70799. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  70800. if (!_this._texture) {
  70801. if (!scene || !scene.useDelayedTextureLoading) {
  70802. _this._texture = engine.createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  70803. if (deleteBuffer) {
  70804. delete _this._buffer;
  70805. }
  70806. }
  70807. else {
  70808. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_NOTLOADED;
  70809. _this._delayedOnLoad = load;
  70810. _this._delayedOnError = onError;
  70811. }
  70812. }
  70813. else {
  70814. if (_this._texture.isReady) {
  70815. _Misc_timingTools__WEBPACK_IMPORTED_MODULE_8__["TimingTools"].SetImmediate(function () { return load(); });
  70816. }
  70817. else {
  70818. _this._texture.onLoadedObservable.add(load);
  70819. }
  70820. }
  70821. return _this;
  70822. }
  70823. Object.defineProperty(Texture.prototype, "noMipmap", {
  70824. /**
  70825. * Are mip maps generated for this texture or not.
  70826. */
  70827. get: function () {
  70828. return this._noMipmap;
  70829. },
  70830. enumerable: true,
  70831. configurable: true
  70832. });
  70833. Object.defineProperty(Texture.prototype, "isBlocking", {
  70834. get: function () {
  70835. return this._isBlocking;
  70836. },
  70837. /**
  70838. * Is the texture preventing material to render while loading.
  70839. * If false, a default texture will be used instead of the loading one during the preparation step.
  70840. */
  70841. set: function (value) {
  70842. this._isBlocking = value;
  70843. },
  70844. enumerable: true,
  70845. configurable: true
  70846. });
  70847. Object.defineProperty(Texture.prototype, "samplingMode", {
  70848. /**
  70849. * Get the current sampling mode associated with the texture.
  70850. */
  70851. get: function () {
  70852. if (!this._texture) {
  70853. return this._initialSamplingMode;
  70854. }
  70855. return this._texture.samplingMode;
  70856. },
  70857. enumerable: true,
  70858. configurable: true
  70859. });
  70860. Object.defineProperty(Texture.prototype, "invertY", {
  70861. /**
  70862. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  70863. */
  70864. get: function () {
  70865. return this._invertY;
  70866. },
  70867. enumerable: true,
  70868. configurable: true
  70869. });
  70870. /**
  70871. * Update the url (and optional buffer) of this texture if url was null during construction.
  70872. * @param url the url of the texture
  70873. * @param buffer the buffer of the texture (defaults to null)
  70874. * @param onLoad callback called when the texture is loaded (defaults to null)
  70875. */
  70876. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  70877. if (buffer === void 0) { buffer = null; }
  70878. if (this.url) {
  70879. this.releaseInternalTexture();
  70880. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  70881. }
  70882. this.url = url;
  70883. this._buffer = buffer;
  70884. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_NOTLOADED;
  70885. if (onLoad) {
  70886. this._delayedOnLoad = onLoad;
  70887. }
  70888. this.delayLoad();
  70889. };
  70890. /**
  70891. * Finish the loading sequence of a texture flagged as delayed load.
  70892. * @hidden
  70893. */
  70894. Texture.prototype.delayLoad = function () {
  70895. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  70896. return;
  70897. }
  70898. var scene = this.getScene();
  70899. if (!scene) {
  70900. return;
  70901. }
  70902. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_LOADED;
  70903. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  70904. if (!this._texture) {
  70905. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  70906. if (this._deleteBuffer) {
  70907. delete this._buffer;
  70908. }
  70909. }
  70910. else {
  70911. if (this._delayedOnLoad) {
  70912. if (this._texture.isReady) {
  70913. _Misc_timingTools__WEBPACK_IMPORTED_MODULE_8__["TimingTools"].SetImmediate(this._delayedOnLoad);
  70914. }
  70915. else {
  70916. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  70917. }
  70918. }
  70919. }
  70920. this._delayedOnLoad = null;
  70921. this._delayedOnError = null;
  70922. };
  70923. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  70924. x *= this.uScale;
  70925. y *= this.vScale;
  70926. x -= this.uRotationCenter * this.uScale;
  70927. y -= this.vRotationCenter * this.vScale;
  70928. z -= this.wRotationCenter;
  70929. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  70930. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  70931. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  70932. t.z += this.wRotationCenter;
  70933. };
  70934. /**
  70935. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  70936. * @returns the transform matrix of the texture.
  70937. */
  70938. Texture.prototype.getTextureMatrix = function () {
  70939. var _this = this;
  70940. if (this.uOffset === this._cachedUOffset &&
  70941. this.vOffset === this._cachedVOffset &&
  70942. this.uScale === this._cachedUScale &&
  70943. this.vScale === this._cachedVScale &&
  70944. this.uAng === this._cachedUAng &&
  70945. this.vAng === this._cachedVAng &&
  70946. this.wAng === this._cachedWAng) {
  70947. return this._cachedTextureMatrix;
  70948. }
  70949. this._cachedUOffset = this.uOffset;
  70950. this._cachedVOffset = this.vOffset;
  70951. this._cachedUScale = this.uScale;
  70952. this._cachedVScale = this.vScale;
  70953. this._cachedUAng = this.uAng;
  70954. this._cachedVAng = this.vAng;
  70955. this._cachedWAng = this.wAng;
  70956. if (!this._cachedTextureMatrix) {
  70957. this._cachedTextureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  70958. this._rowGenerationMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  70959. this._t0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  70960. this._t1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  70961. this._t2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  70962. }
  70963. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  70964. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  70965. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  70966. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  70967. this._t1.subtractInPlace(this._t0);
  70968. this._t2.subtractInPlace(this._t0);
  70969. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["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);
  70970. var scene = this.getScene();
  70971. if (!scene) {
  70972. return this._cachedTextureMatrix;
  70973. }
  70974. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  70975. return mat.hasTexture(_this);
  70976. });
  70977. return this._cachedTextureMatrix;
  70978. };
  70979. /**
  70980. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  70981. * @returns The reflection texture transform
  70982. */
  70983. Texture.prototype.getReflectionTextureMatrix = function () {
  70984. var _this = this;
  70985. var scene = this.getScene();
  70986. if (!scene) {
  70987. return this._cachedTextureMatrix;
  70988. }
  70989. if (this.uOffset === this._cachedUOffset &&
  70990. this.vOffset === this._cachedVOffset &&
  70991. this.uScale === this._cachedUScale &&
  70992. this.vScale === this._cachedVScale &&
  70993. this.coordinatesMode === this._cachedCoordinatesMode) {
  70994. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  70995. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  70996. return this._cachedTextureMatrix;
  70997. }
  70998. }
  70999. else {
  71000. return this._cachedTextureMatrix;
  71001. }
  71002. }
  71003. if (!this._cachedTextureMatrix) {
  71004. this._cachedTextureMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  71005. }
  71006. if (!this._projectionModeMatrix) {
  71007. this._projectionModeMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  71008. }
  71009. this._cachedUOffset = this.uOffset;
  71010. this._cachedVOffset = this.vOffset;
  71011. this._cachedUScale = this.uScale;
  71012. this._cachedVScale = this.vScale;
  71013. this._cachedCoordinatesMode = this.coordinatesMode;
  71014. switch (this.coordinatesMode) {
  71015. case Texture.PLANAR_MODE:
  71016. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  71017. this._cachedTextureMatrix[0] = this.uScale;
  71018. this._cachedTextureMatrix[5] = this.vScale;
  71019. this._cachedTextureMatrix[12] = this.uOffset;
  71020. this._cachedTextureMatrix[13] = this.vOffset;
  71021. break;
  71022. case Texture.PROJECTION_MODE:
  71023. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["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);
  71024. var projectionMatrix = scene.getProjectionMatrix();
  71025. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  71026. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  71027. break;
  71028. default:
  71029. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  71030. break;
  71031. }
  71032. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  71033. return (mat.getActiveTextures().indexOf(_this) !== -1);
  71034. });
  71035. return this._cachedTextureMatrix;
  71036. };
  71037. /**
  71038. * Clones the texture.
  71039. * @returns the cloned texture
  71040. */
  71041. Texture.prototype.clone = function () {
  71042. var _this = this;
  71043. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  71044. 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);
  71045. }, this);
  71046. };
  71047. /**
  71048. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  71049. * @returns The JSON representation of the texture
  71050. */
  71051. Texture.prototype.serialize = function () {
  71052. var serializationObject = _super.prototype.serialize.call(this);
  71053. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  71054. serializationObject.base64String = this._buffer;
  71055. serializationObject.name = serializationObject.name.replace("data:", "");
  71056. }
  71057. serializationObject.invertY = this._invertY;
  71058. serializationObject.samplingMode = this.samplingMode;
  71059. return serializationObject;
  71060. };
  71061. /**
  71062. * Get the current class name of the texture useful for serialization or dynamic coding.
  71063. * @returns "Texture"
  71064. */
  71065. Texture.prototype.getClassName = function () {
  71066. return "Texture";
  71067. };
  71068. /**
  71069. * Dispose the texture and release its associated resources.
  71070. */
  71071. Texture.prototype.dispose = function () {
  71072. _super.prototype.dispose.call(this);
  71073. this.onLoadObservable.clear();
  71074. this._delayedOnLoad = null;
  71075. this._delayedOnError = null;
  71076. };
  71077. /**
  71078. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  71079. * @param parsedTexture Define the JSON representation of the texture
  71080. * @param scene Define the scene the parsed texture should be instantiated in
  71081. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  71082. * @returns The parsed texture if successful
  71083. */
  71084. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  71085. if (parsedTexture.customType) {
  71086. var customTexture = _Misc_instantiationTools__WEBPACK_IMPORTED_MODULE_9__["InstantiationTools"].Instantiate(parsedTexture.customType);
  71087. // Update Sampling Mode
  71088. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  71089. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  71090. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  71091. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  71092. }
  71093. }
  71094. return parsedCustomTexture;
  71095. }
  71096. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  71097. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  71098. }
  71099. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  71100. return null;
  71101. }
  71102. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  71103. var generateMipMaps = true;
  71104. if (parsedTexture.noMipmap) {
  71105. generateMipMaps = false;
  71106. }
  71107. if (parsedTexture.mirrorPlane) {
  71108. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  71109. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  71110. mirrorTexture.mirrorPlane = _Maths_math_plane__WEBPACK_IMPORTED_MODULE_10__["Plane"].FromArray(parsedTexture.mirrorPlane);
  71111. return mirrorTexture;
  71112. }
  71113. else if (parsedTexture.isRenderTarget) {
  71114. var renderTargetTexture = null;
  71115. if (parsedTexture.isCube) {
  71116. // Search for an existing reflection probe (which contains a cube render target texture)
  71117. if (scene.reflectionProbes) {
  71118. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  71119. var probe = scene.reflectionProbes[index];
  71120. if (probe.name === parsedTexture.name) {
  71121. return probe.cubeTexture;
  71122. }
  71123. }
  71124. }
  71125. }
  71126. else {
  71127. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  71128. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  71129. }
  71130. return renderTargetTexture;
  71131. }
  71132. else {
  71133. var texture;
  71134. if (parsedTexture.base64String) {
  71135. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  71136. }
  71137. else {
  71138. var url = rootUrl + parsedTexture.name;
  71139. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  71140. url = parsedTexture.url;
  71141. }
  71142. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  71143. }
  71144. return texture;
  71145. }
  71146. }, parsedTexture, scene);
  71147. // Update Sampling Mode
  71148. if (parsedTexture.samplingMode) {
  71149. var sampling = parsedTexture.samplingMode;
  71150. if (texture && texture.samplingMode !== sampling) {
  71151. texture.updateSamplingMode(sampling);
  71152. }
  71153. }
  71154. // Animations
  71155. if (texture && parsedTexture.animations) {
  71156. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  71157. var parsedAnimation = parsedTexture.animations[animationIndex];
  71158. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].GetClass("BABYLON.Animation");
  71159. if (internalClass) {
  71160. texture.animations.push(internalClass.Parse(parsedAnimation));
  71161. }
  71162. }
  71163. }
  71164. return texture;
  71165. };
  71166. /**
  71167. * Creates a texture from its base 64 representation.
  71168. * @param data Define the base64 payload without the data: prefix
  71169. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  71170. * @param scene Define the scene the texture should belong to
  71171. * @param noMipmap Forces the texture to not create mip map information if true
  71172. * @param invertY define if the texture needs to be inverted on the y axis during loading
  71173. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  71174. * @param onLoad define a callback triggered when the texture has been loaded
  71175. * @param onError define a callback triggered when an error occurred during the loading session
  71176. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  71177. * @returns the created texture
  71178. */
  71179. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  71180. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  71181. if (onLoad === void 0) { onLoad = null; }
  71182. if (onError === void 0) { onError = null; }
  71183. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  71184. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  71185. };
  71186. /**
  71187. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  71188. * @param data Define the base64 payload without the data: prefix
  71189. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  71190. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  71191. * @param scene Define the scene the texture should belong to
  71192. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  71193. * @param noMipmap Forces the texture to not create mip map information if true
  71194. * @param invertY define if the texture needs to be inverted on the y axis during loading
  71195. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  71196. * @param onLoad define a callback triggered when the texture has been loaded
  71197. * @param onError define a callback triggered when an error occurred during the loading session
  71198. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  71199. * @returns the created texture
  71200. */
  71201. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  71202. if (deleteBuffer === void 0) { deleteBuffer = false; }
  71203. if (noMipmap === void 0) { noMipmap = false; }
  71204. if (invertY === void 0) { invertY = true; }
  71205. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  71206. if (onLoad === void 0) { onLoad = null; }
  71207. if (onError === void 0) { onError = null; }
  71208. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  71209. if (name.substr(0, 5) !== "data:") {
  71210. name = "data:" + name;
  71211. }
  71212. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  71213. };
  71214. /** @hidden */
  71215. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  71216. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_7__["_DevTools"].WarnImport("CubeTexture");
  71217. };
  71218. /** @hidden */
  71219. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  71220. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_7__["_DevTools"].WarnImport("MirrorTexture");
  71221. };
  71222. /** @hidden */
  71223. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  71224. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_7__["_DevTools"].WarnImport("RenderTargetTexture");
  71225. };
  71226. /** nearest is mag = nearest and min = nearest and mip = linear */
  71227. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  71228. /** nearest is mag = nearest and min = nearest and mip = linear */
  71229. Texture.NEAREST_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR; // nearest is mag = nearest and min = nearest and mip = linear
  71230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71231. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  71232. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71233. Texture.LINEAR_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST; // Bilinear is mag = linear and min = linear and mip = nearest
  71234. /** Trilinear is mag = linear and min = linear and mip = linear */
  71235. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  71236. /** Trilinear is mag = linear and min = linear and mip = linear */
  71237. Texture.LINEAR_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR; // Trilinear is mag = linear and min = linear and mip = linear
  71238. /** mag = nearest and min = nearest and mip = nearest */
  71239. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  71240. /** mag = nearest and min = linear and mip = nearest */
  71241. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  71242. /** mag = nearest and min = linear and mip = linear */
  71243. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  71244. /** mag = nearest and min = linear and mip = none */
  71245. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_LINEAR;
  71246. /** mag = nearest and min = nearest and mip = none */
  71247. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_NEAREST_NEAREST;
  71248. /** mag = linear and min = nearest and mip = nearest */
  71249. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  71250. /** mag = linear and min = nearest and mip = linear */
  71251. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  71252. /** mag = linear and min = linear and mip = none */
  71253. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_LINEAR;
  71254. /** mag = linear and min = nearest and mip = none */
  71255. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_NEAREST;
  71256. /** Explicit coordinates mode */
  71257. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_EXPLICIT_MODE;
  71258. /** Spherical coordinates mode */
  71259. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_SPHERICAL_MODE;
  71260. /** Planar coordinates mode */
  71261. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_PLANAR_MODE;
  71262. /** Cubic coordinates mode */
  71263. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_CUBIC_MODE;
  71264. /** Projection coordinates mode */
  71265. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_PROJECTION_MODE;
  71266. /** Inverse Cubic coordinates mode */
  71267. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_SKYBOX_MODE;
  71268. /** Inverse Cubic coordinates mode */
  71269. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_INVCUBIC_MODE;
  71270. /** Equirectangular coordinates mode */
  71271. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  71272. /** Equirectangular Fixed coordinates mode */
  71273. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  71274. /** Equirectangular Fixed Mirrored coordinates mode */
  71275. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  71276. /** Texture is not repeating outside of 0..1 UVs */
  71277. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  71278. /** Texture is repeating outside of 0..1 UVs */
  71279. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  71280. /** Texture is repeating and mirrored */
  71281. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  71282. /**
  71283. * 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
  71284. */
  71285. Texture.UseSerializedUrlIfAny = false;
  71286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71288. ], Texture.prototype, "url", void 0);
  71289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71291. ], Texture.prototype, "uOffset", void 0);
  71292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71294. ], Texture.prototype, "vOffset", void 0);
  71295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71297. ], Texture.prototype, "uScale", void 0);
  71298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71300. ], Texture.prototype, "vScale", void 0);
  71301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71303. ], Texture.prototype, "uAng", void 0);
  71304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71306. ], Texture.prototype, "vAng", void 0);
  71307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71309. ], Texture.prototype, "wAng", void 0);
  71310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71312. ], Texture.prototype, "uRotationCenter", void 0);
  71313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71315. ], Texture.prototype, "vRotationCenter", void 0);
  71316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71318. ], Texture.prototype, "wRotationCenter", void 0);
  71319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71321. ], Texture.prototype, "isBlocking", null);
  71322. return Texture;
  71323. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  71324. // References the dependencies.
  71325. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  71326. /***/ }),
  71327. /***/ "./Materials/Textures/videoTexture.ts":
  71328. /*!********************************************!*\
  71329. !*** ./Materials/Textures/videoTexture.ts ***!
  71330. \********************************************/
  71331. /*! exports provided: VideoTexture */
  71332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71333. "use strict";
  71334. __webpack_require__.r(__webpack_exports__);
  71335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  71336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  71337. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  71338. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  71339. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  71340. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  71341. /**
  71342. * If you want to display a video in your scene, this is the special texture for that.
  71343. * This special texture works similar to other textures, with the exception of a few parameters.
  71344. * @see https://doc.babylonjs.com/how_to/video_texture
  71345. */
  71346. var VideoTexture = /** @class */ (function (_super) {
  71347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  71348. /**
  71349. * Creates a video texture.
  71350. * If you want to display a video in your scene, this is the special texture for that.
  71351. * This special texture works similar to other textures, with the exception of a few parameters.
  71352. * @see https://doc.babylonjs.com/how_to/video_texture
  71353. * @param name optional name, will detect from video source, if not defined
  71354. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  71355. * @param scene is obviously the current scene.
  71356. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  71357. * @param invertY is false by default but can be used to invert video on Y axis
  71358. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  71359. * @param settings allows finer control over video usage
  71360. */
  71361. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  71362. if (generateMipMaps === void 0) { generateMipMaps = false; }
  71363. if (invertY === void 0) { invertY = false; }
  71364. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  71365. if (settings === void 0) { settings = {
  71366. autoPlay: true,
  71367. loop: true,
  71368. autoUpdateTexture: true,
  71369. }; }
  71370. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  71371. _this._onUserActionRequestedObservable = null;
  71372. _this._stillImageCaptured = false;
  71373. _this._displayingPosterTexture = false;
  71374. _this._createInternalTexture = function () {
  71375. if (_this._texture != null) {
  71376. if (_this._displayingPosterTexture) {
  71377. _this._texture.dispose();
  71378. _this._displayingPosterTexture = false;
  71379. }
  71380. else {
  71381. return;
  71382. }
  71383. }
  71384. if (!_this._engine.needPOTTextures ||
  71385. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  71386. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  71387. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  71388. }
  71389. else {
  71390. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  71391. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  71392. _this._generateMipMaps = false;
  71393. }
  71394. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  71395. if (!_this.video.autoplay && !_this._settings.poster) {
  71396. var oldHandler_1 = _this.video.onplaying;
  71397. var error_1 = false;
  71398. var oldMuted_1 = _this.video.muted;
  71399. _this.video.muted = true;
  71400. _this.video.onplaying = function () {
  71401. _this.video.muted = oldMuted_1;
  71402. _this.video.onplaying = oldHandler_1;
  71403. _this._texture.isReady = true;
  71404. _this._updateInternalTexture();
  71405. if (!error_1) {
  71406. _this.video.pause();
  71407. }
  71408. if (_this.onLoadObservable.hasObservers()) {
  71409. _this.onLoadObservable.notifyObservers(_this);
  71410. }
  71411. };
  71412. var playing = _this.video.play();
  71413. if (playing) {
  71414. playing.then(function () {
  71415. // Everything is good.
  71416. })
  71417. .catch(function () {
  71418. error_1 = true;
  71419. // On Chrome for instance, new policies might prevent playing without user interaction.
  71420. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  71421. _this._onUserActionRequestedObservable.notifyObservers(_this);
  71422. }
  71423. });
  71424. }
  71425. else {
  71426. _this.video.onplaying = oldHandler_1;
  71427. _this._texture.isReady = true;
  71428. _this._updateInternalTexture();
  71429. if (_this.onLoadObservable.hasObservers()) {
  71430. _this.onLoadObservable.notifyObservers(_this);
  71431. }
  71432. }
  71433. }
  71434. else {
  71435. _this._texture.isReady = true;
  71436. _this._updateInternalTexture();
  71437. if (_this.onLoadObservable.hasObservers()) {
  71438. _this.onLoadObservable.notifyObservers(_this);
  71439. }
  71440. }
  71441. };
  71442. _this.reset = function () {
  71443. if (_this._texture == null) {
  71444. return;
  71445. }
  71446. if (!_this._displayingPosterTexture) {
  71447. _this._texture.dispose();
  71448. _this._texture = null;
  71449. }
  71450. };
  71451. _this._updateInternalTexture = function () {
  71452. if (_this._texture == null || !_this._texture.isReady) {
  71453. return;
  71454. }
  71455. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  71456. return;
  71457. }
  71458. if (_this._displayingPosterTexture) {
  71459. return;
  71460. }
  71461. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  71462. };
  71463. _this._engine = _this.getScene().getEngine();
  71464. _this._generateMipMaps = generateMipMaps;
  71465. _this._initialSamplingMode = samplingMode;
  71466. _this.autoUpdateTexture = settings.autoUpdateTexture;
  71467. _this.name = name || _this._getName(src);
  71468. _this.video = _this._getVideo(src);
  71469. _this._settings = settings;
  71470. if (settings.poster) {
  71471. _this.video.poster = settings.poster;
  71472. }
  71473. if (settings.autoPlay !== undefined) {
  71474. _this.video.autoplay = settings.autoPlay;
  71475. }
  71476. if (settings.loop !== undefined) {
  71477. _this.video.loop = settings.loop;
  71478. }
  71479. _this.video.setAttribute("playsinline", "");
  71480. _this.video.addEventListener("paused", _this._updateInternalTexture);
  71481. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  71482. _this.video.addEventListener("emptied", _this.reset);
  71483. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  71484. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  71485. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  71486. if (settings.poster &&
  71487. (!settings.autoPlay || !videoHasEnoughData)) {
  71488. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  71489. _this._displayingPosterTexture = true;
  71490. }
  71491. else if (videoHasEnoughData) {
  71492. _this._createInternalTexture();
  71493. }
  71494. return _this;
  71495. }
  71496. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  71497. /**
  71498. * Event triggerd when a dom action is required by the user to play the video.
  71499. * This happens due to recent changes in browser policies preventing video to auto start.
  71500. */
  71501. get: function () {
  71502. if (!this._onUserActionRequestedObservable) {
  71503. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  71504. }
  71505. return this._onUserActionRequestedObservable;
  71506. },
  71507. enumerable: true,
  71508. configurable: true
  71509. });
  71510. VideoTexture.prototype._getName = function (src) {
  71511. if (src instanceof HTMLVideoElement) {
  71512. return src.currentSrc;
  71513. }
  71514. if (typeof src === "object") {
  71515. return src.toString();
  71516. }
  71517. return src;
  71518. };
  71519. VideoTexture.prototype._getVideo = function (src) {
  71520. if (src instanceof HTMLVideoElement) {
  71521. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  71522. return src;
  71523. }
  71524. var video = document.createElement("video");
  71525. if (typeof src === "string") {
  71526. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  71527. video.src = src;
  71528. }
  71529. else {
  71530. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  71531. src.forEach(function (url) {
  71532. var source = document.createElement("source");
  71533. source.src = url;
  71534. video.appendChild(source);
  71535. });
  71536. }
  71537. return video;
  71538. };
  71539. /**
  71540. * @hidden Internal method to initiate `update`.
  71541. */
  71542. VideoTexture.prototype._rebuild = function () {
  71543. this.update();
  71544. };
  71545. /**
  71546. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  71547. */
  71548. VideoTexture.prototype.update = function () {
  71549. if (!this.autoUpdateTexture) {
  71550. // Expecting user to call `updateTexture` manually
  71551. return;
  71552. }
  71553. this.updateTexture(true);
  71554. };
  71555. /**
  71556. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  71557. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  71558. */
  71559. VideoTexture.prototype.updateTexture = function (isVisible) {
  71560. if (!isVisible) {
  71561. return;
  71562. }
  71563. if (this.video.paused && this._stillImageCaptured) {
  71564. return;
  71565. }
  71566. this._stillImageCaptured = true;
  71567. this._updateInternalTexture();
  71568. };
  71569. /**
  71570. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  71571. * @param url New url.
  71572. */
  71573. VideoTexture.prototype.updateURL = function (url) {
  71574. this.video.src = url;
  71575. };
  71576. /**
  71577. * Dispose the texture and release its associated resources.
  71578. */
  71579. VideoTexture.prototype.dispose = function () {
  71580. _super.prototype.dispose.call(this);
  71581. if (this._onUserActionRequestedObservable) {
  71582. this._onUserActionRequestedObservable.clear();
  71583. this._onUserActionRequestedObservable = null;
  71584. }
  71585. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  71586. this.video.removeEventListener("paused", this._updateInternalTexture);
  71587. this.video.removeEventListener("seeked", this._updateInternalTexture);
  71588. this.video.removeEventListener("emptied", this.reset);
  71589. this.video.pause();
  71590. };
  71591. /**
  71592. * Creates a video texture straight from a stream.
  71593. * @param scene Define the scene the texture should be created in
  71594. * @param stream Define the stream the texture should be created from
  71595. * @returns The created video texture as a promise
  71596. */
  71597. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  71598. var video = document.createElement("video");
  71599. video.setAttribute('autoplay', '');
  71600. video.setAttribute('muted', 'true');
  71601. video.setAttribute('playsinline', '');
  71602. video.muted = true;
  71603. if (video.mozSrcObject !== undefined) {
  71604. // hack for Firefox < 19
  71605. video.mozSrcObject = stream;
  71606. }
  71607. else {
  71608. if (typeof video.srcObject == "object") {
  71609. video.srcObject = stream;
  71610. }
  71611. else {
  71612. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  71613. video.src = (window.URL && window.URL.createObjectURL(stream));
  71614. }
  71615. }
  71616. return new Promise(function (resolve) {
  71617. var onPlaying = function () {
  71618. resolve(new VideoTexture("video", video, scene, true, true));
  71619. video.removeEventListener("playing", onPlaying);
  71620. };
  71621. video.addEventListener("playing", onPlaying);
  71622. video.play();
  71623. });
  71624. };
  71625. /**
  71626. * Creates a video texture straight from your WebCam video feed.
  71627. * @param scene Define the scene the texture should be created in
  71628. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  71629. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  71630. * @returns The created video texture as a promise
  71631. */
  71632. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  71633. var _this = this;
  71634. if (audioConstaints === void 0) { audioConstaints = false; }
  71635. var constraintsDeviceId;
  71636. if (constraints && constraints.deviceId) {
  71637. constraintsDeviceId = {
  71638. exact: constraints.deviceId,
  71639. };
  71640. }
  71641. if (navigator.mediaDevices) {
  71642. return navigator.mediaDevices.getUserMedia({
  71643. video: constraints,
  71644. audio: audioConstaints
  71645. })
  71646. .then(function (stream) {
  71647. return _this.CreateFromStreamAsync(scene, stream);
  71648. });
  71649. }
  71650. else {
  71651. navigator.getUserMedia =
  71652. navigator.getUserMedia ||
  71653. navigator.webkitGetUserMedia ||
  71654. navigator.mozGetUserMedia ||
  71655. navigator.msGetUserMedia;
  71656. if (navigator.getUserMedia) {
  71657. navigator.getUserMedia({
  71658. video: {
  71659. deviceId: constraintsDeviceId,
  71660. width: {
  71661. min: (constraints && constraints.minWidth) || 256,
  71662. max: (constraints && constraints.maxWidth) || 640,
  71663. },
  71664. height: {
  71665. min: (constraints && constraints.minHeight) || 256,
  71666. max: (constraints && constraints.maxHeight) || 480,
  71667. },
  71668. },
  71669. audio: audioConstaints
  71670. }, function (stream) {
  71671. return _this.CreateFromStreamAsync(scene, stream);
  71672. }, function (e) {
  71673. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  71674. });
  71675. }
  71676. }
  71677. return Promise.reject("No support for userMedia on this device");
  71678. };
  71679. /**
  71680. * Creates a video texture straight from your WebCam video feed.
  71681. * @param scene Define the scene the texture should be created in
  71682. * @param onReady Define a callback to triggered once the texture will be ready
  71683. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  71684. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  71685. */
  71686. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  71687. if (audioConstaints === void 0) { audioConstaints = false; }
  71688. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  71689. .then(function (videoTexture) {
  71690. if (onReady) {
  71691. onReady(videoTexture);
  71692. }
  71693. })
  71694. .catch(function (err) {
  71695. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  71696. });
  71697. };
  71698. return VideoTexture;
  71699. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  71700. /***/ }),
  71701. /***/ "./Materials/colorCurves.ts":
  71702. /*!**********************************!*\
  71703. !*** ./Materials/colorCurves.ts ***!
  71704. \**********************************/
  71705. /*! exports provided: ColorCurves */
  71706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71707. "use strict";
  71708. __webpack_require__.r(__webpack_exports__);
  71709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  71710. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  71711. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  71712. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  71713. /**
  71714. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71715. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71716. * 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;
  71717. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71718. */
  71719. var ColorCurves = /** @class */ (function () {
  71720. function ColorCurves() {
  71721. this._dirty = true;
  71722. this._tempColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71723. this._globalCurve = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71724. this._highlightsCurve = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71725. this._midtonesCurve = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71726. this._shadowsCurve = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71727. this._positiveCurve = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71728. this._negativeCurve = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  71729. this._globalHue = 30;
  71730. this._globalDensity = 0;
  71731. this._globalSaturation = 0;
  71732. this._globalExposure = 0;
  71733. this._highlightsHue = 30;
  71734. this._highlightsDensity = 0;
  71735. this._highlightsSaturation = 0;
  71736. this._highlightsExposure = 0;
  71737. this._midtonesHue = 30;
  71738. this._midtonesDensity = 0;
  71739. this._midtonesSaturation = 0;
  71740. this._midtonesExposure = 0;
  71741. this._shadowsHue = 30;
  71742. this._shadowsDensity = 0;
  71743. this._shadowsSaturation = 0;
  71744. this._shadowsExposure = 0;
  71745. }
  71746. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  71747. /**
  71748. * Gets the global Hue value.
  71749. * 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).
  71750. */
  71751. get: function () {
  71752. return this._globalHue;
  71753. },
  71754. /**
  71755. * Sets the global Hue value.
  71756. * 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).
  71757. */
  71758. set: function (value) {
  71759. this._globalHue = value;
  71760. this._dirty = true;
  71761. },
  71762. enumerable: true,
  71763. configurable: true
  71764. });
  71765. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  71766. /**
  71767. * Gets the global Density value.
  71768. * 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.
  71769. * Values less than zero provide a filter of opposite hue.
  71770. */
  71771. get: function () {
  71772. return this._globalDensity;
  71773. },
  71774. /**
  71775. * Sets the global Density value.
  71776. * 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.
  71777. * Values less than zero provide a filter of opposite hue.
  71778. */
  71779. set: function (value) {
  71780. this._globalDensity = value;
  71781. this._dirty = true;
  71782. },
  71783. enumerable: true,
  71784. configurable: true
  71785. });
  71786. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  71787. /**
  71788. * Gets the global Saturation value.
  71789. * 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.
  71790. */
  71791. get: function () {
  71792. return this._globalSaturation;
  71793. },
  71794. /**
  71795. * Sets the global Saturation value.
  71796. * 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.
  71797. */
  71798. set: function (value) {
  71799. this._globalSaturation = value;
  71800. this._dirty = true;
  71801. },
  71802. enumerable: true,
  71803. configurable: true
  71804. });
  71805. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  71806. /**
  71807. * Gets the global Exposure value.
  71808. * 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.
  71809. */
  71810. get: function () {
  71811. return this._globalExposure;
  71812. },
  71813. /**
  71814. * Sets the global Exposure value.
  71815. * 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.
  71816. */
  71817. set: function (value) {
  71818. this._globalExposure = value;
  71819. this._dirty = true;
  71820. },
  71821. enumerable: true,
  71822. configurable: true
  71823. });
  71824. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  71825. /**
  71826. * Gets the highlights Hue value.
  71827. * 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).
  71828. */
  71829. get: function () {
  71830. return this._highlightsHue;
  71831. },
  71832. /**
  71833. * Sets the highlights Hue value.
  71834. * 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).
  71835. */
  71836. set: function (value) {
  71837. this._highlightsHue = value;
  71838. this._dirty = true;
  71839. },
  71840. enumerable: true,
  71841. configurable: true
  71842. });
  71843. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  71844. /**
  71845. * Gets the highlights Density value.
  71846. * 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.
  71847. * Values less than zero provide a filter of opposite hue.
  71848. */
  71849. get: function () {
  71850. return this._highlightsDensity;
  71851. },
  71852. /**
  71853. * Sets the highlights Density value.
  71854. * 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.
  71855. * Values less than zero provide a filter of opposite hue.
  71856. */
  71857. set: function (value) {
  71858. this._highlightsDensity = value;
  71859. this._dirty = true;
  71860. },
  71861. enumerable: true,
  71862. configurable: true
  71863. });
  71864. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  71865. /**
  71866. * Gets the highlights Saturation value.
  71867. * 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.
  71868. */
  71869. get: function () {
  71870. return this._highlightsSaturation;
  71871. },
  71872. /**
  71873. * Sets the highlights Saturation value.
  71874. * 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.
  71875. */
  71876. set: function (value) {
  71877. this._highlightsSaturation = value;
  71878. this._dirty = true;
  71879. },
  71880. enumerable: true,
  71881. configurable: true
  71882. });
  71883. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  71884. /**
  71885. * Gets the highlights Exposure value.
  71886. * 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.
  71887. */
  71888. get: function () {
  71889. return this._highlightsExposure;
  71890. },
  71891. /**
  71892. * Sets the highlights Exposure value.
  71893. * 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.
  71894. */
  71895. set: function (value) {
  71896. this._highlightsExposure = value;
  71897. this._dirty = true;
  71898. },
  71899. enumerable: true,
  71900. configurable: true
  71901. });
  71902. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  71903. /**
  71904. * Gets the midtones Hue value.
  71905. * 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).
  71906. */
  71907. get: function () {
  71908. return this._midtonesHue;
  71909. },
  71910. /**
  71911. * Sets the midtones Hue value.
  71912. * 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).
  71913. */
  71914. set: function (value) {
  71915. this._midtonesHue = value;
  71916. this._dirty = true;
  71917. },
  71918. enumerable: true,
  71919. configurable: true
  71920. });
  71921. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  71922. /**
  71923. * Gets the midtones Density value.
  71924. * 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.
  71925. * Values less than zero provide a filter of opposite hue.
  71926. */
  71927. get: function () {
  71928. return this._midtonesDensity;
  71929. },
  71930. /**
  71931. * Sets the midtones Density value.
  71932. * 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.
  71933. * Values less than zero provide a filter of opposite hue.
  71934. */
  71935. set: function (value) {
  71936. this._midtonesDensity = value;
  71937. this._dirty = true;
  71938. },
  71939. enumerable: true,
  71940. configurable: true
  71941. });
  71942. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  71943. /**
  71944. * Gets the midtones Saturation value.
  71945. * 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.
  71946. */
  71947. get: function () {
  71948. return this._midtonesSaturation;
  71949. },
  71950. /**
  71951. * Sets the midtones Saturation value.
  71952. * 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.
  71953. */
  71954. set: function (value) {
  71955. this._midtonesSaturation = value;
  71956. this._dirty = true;
  71957. },
  71958. enumerable: true,
  71959. configurable: true
  71960. });
  71961. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  71962. /**
  71963. * Gets the midtones Exposure value.
  71964. * 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.
  71965. */
  71966. get: function () {
  71967. return this._midtonesExposure;
  71968. },
  71969. /**
  71970. * Sets the midtones Exposure value.
  71971. * 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.
  71972. */
  71973. set: function (value) {
  71974. this._midtonesExposure = value;
  71975. this._dirty = true;
  71976. },
  71977. enumerable: true,
  71978. configurable: true
  71979. });
  71980. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  71981. /**
  71982. * Gets the shadows Hue value.
  71983. * 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).
  71984. */
  71985. get: function () {
  71986. return this._shadowsHue;
  71987. },
  71988. /**
  71989. * Sets the shadows Hue value.
  71990. * 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).
  71991. */
  71992. set: function (value) {
  71993. this._shadowsHue = value;
  71994. this._dirty = true;
  71995. },
  71996. enumerable: true,
  71997. configurable: true
  71998. });
  71999. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  72000. /**
  72001. * Gets the shadows Density value.
  72002. * 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.
  72003. * Values less than zero provide a filter of opposite hue.
  72004. */
  72005. get: function () {
  72006. return this._shadowsDensity;
  72007. },
  72008. /**
  72009. * Sets the shadows Density value.
  72010. * 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.
  72011. * Values less than zero provide a filter of opposite hue.
  72012. */
  72013. set: function (value) {
  72014. this._shadowsDensity = value;
  72015. this._dirty = true;
  72016. },
  72017. enumerable: true,
  72018. configurable: true
  72019. });
  72020. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  72021. /**
  72022. * Gets the shadows Saturation value.
  72023. * 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.
  72024. */
  72025. get: function () {
  72026. return this._shadowsSaturation;
  72027. },
  72028. /**
  72029. * Sets the shadows Saturation value.
  72030. * 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.
  72031. */
  72032. set: function (value) {
  72033. this._shadowsSaturation = value;
  72034. this._dirty = true;
  72035. },
  72036. enumerable: true,
  72037. configurable: true
  72038. });
  72039. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  72040. /**
  72041. * Gets the shadows Exposure value.
  72042. * 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.
  72043. */
  72044. get: function () {
  72045. return this._shadowsExposure;
  72046. },
  72047. /**
  72048. * Sets the shadows Exposure value.
  72049. * 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.
  72050. */
  72051. set: function (value) {
  72052. this._shadowsExposure = value;
  72053. this._dirty = true;
  72054. },
  72055. enumerable: true,
  72056. configurable: true
  72057. });
  72058. /**
  72059. * Returns the class name
  72060. * @returns The class name
  72061. */
  72062. ColorCurves.prototype.getClassName = function () {
  72063. return "ColorCurves";
  72064. };
  72065. /**
  72066. * Binds the color curves to the shader.
  72067. * @param colorCurves The color curve to bind
  72068. * @param effect The effect to bind to
  72069. * @param positiveUniform The positive uniform shader parameter
  72070. * @param neutralUniform The neutral uniform shader parameter
  72071. * @param negativeUniform The negative uniform shader parameter
  72072. */
  72073. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  72074. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  72075. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  72076. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  72077. if (colorCurves._dirty) {
  72078. colorCurves._dirty = false;
  72079. // Fill in global info.
  72080. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  72081. // Compute highlights info.
  72082. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  72083. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  72084. // Compute midtones info.
  72085. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  72086. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  72087. // Compute shadows info.
  72088. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  72089. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  72090. // Compute deltas (neutral is midtones).
  72091. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  72092. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  72093. }
  72094. if (effect) {
  72095. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  72096. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  72097. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  72098. }
  72099. };
  72100. /**
  72101. * Prepare the list of uniforms associated with the ColorCurves effects.
  72102. * @param uniformsList The list of uniforms used in the effect
  72103. */
  72104. ColorCurves.PrepareUniforms = function (uniformsList) {
  72105. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  72106. };
  72107. /**
  72108. * Returns color grading data based on a hue, density, saturation and exposure value.
  72109. * @param filterHue The hue of the color filter.
  72110. * @param filterDensity The density of the color filter.
  72111. * @param saturation The saturation.
  72112. * @param exposure The exposure.
  72113. * @param result The result data container.
  72114. */
  72115. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  72116. if (hue == null) {
  72117. return;
  72118. }
  72119. hue = ColorCurves.clamp(hue, 0, 360);
  72120. density = ColorCurves.clamp(density, -100, 100);
  72121. saturation = ColorCurves.clamp(saturation, -100, 100);
  72122. exposure = ColorCurves.clamp(exposure, -100, 100);
  72123. // Remap the slider/config filter density with non-linear mapping and also scale by half
  72124. // so that the maximum filter density is only 50% control. This provides fine control
  72125. // for small values and reasonable range.
  72126. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  72127. density *= 0.5;
  72128. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  72129. if (density < 0) {
  72130. density *= -1;
  72131. hue = (hue + 180) % 360;
  72132. }
  72133. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  72134. result.scaleToRef(2, result);
  72135. result.a = 1 + 0.01 * saturation;
  72136. };
  72137. /**
  72138. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72139. * @param value The input slider value in range [-100,100].
  72140. * @returns Adjusted value.
  72141. */
  72142. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  72143. value /= 100;
  72144. var x = Math.abs(value);
  72145. x = Math.pow(x, 2);
  72146. if (value < 0) {
  72147. x *= -1;
  72148. }
  72149. x *= 100;
  72150. return x;
  72151. };
  72152. /**
  72153. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72154. * @param hue The hue (H) input.
  72155. * @param saturation The saturation (S) input.
  72156. * @param brightness The brightness (B) input.
  72157. * @result An RGBA color represented as Vector4.
  72158. */
  72159. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  72160. var h = ColorCurves.clamp(hue, 0, 360);
  72161. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  72162. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  72163. if (s === 0) {
  72164. result.r = v;
  72165. result.g = v;
  72166. result.b = v;
  72167. }
  72168. else {
  72169. // sector 0 to 5
  72170. h /= 60;
  72171. var i = Math.floor(h);
  72172. // fractional part of h
  72173. var f = h - i;
  72174. var p = v * (1 - s);
  72175. var q = v * (1 - s * f);
  72176. var t = v * (1 - s * (1 - f));
  72177. switch (i) {
  72178. case 0:
  72179. result.r = v;
  72180. result.g = t;
  72181. result.b = p;
  72182. break;
  72183. case 1:
  72184. result.r = q;
  72185. result.g = v;
  72186. result.b = p;
  72187. break;
  72188. case 2:
  72189. result.r = p;
  72190. result.g = v;
  72191. result.b = t;
  72192. break;
  72193. case 3:
  72194. result.r = p;
  72195. result.g = q;
  72196. result.b = v;
  72197. break;
  72198. case 4:
  72199. result.r = t;
  72200. result.g = p;
  72201. result.b = v;
  72202. break;
  72203. default: // case 5:
  72204. result.r = v;
  72205. result.g = p;
  72206. result.b = q;
  72207. break;
  72208. }
  72209. }
  72210. result.a = 1;
  72211. };
  72212. /**
  72213. * Returns a value clamped between min and max
  72214. * @param value The value to clamp
  72215. * @param min The minimum of value
  72216. * @param max The maximum of value
  72217. * @returns The clamped value.
  72218. */
  72219. ColorCurves.clamp = function (value, min, max) {
  72220. return Math.min(Math.max(value, min), max);
  72221. };
  72222. /**
  72223. * Clones the current color curve instance.
  72224. * @return The cloned curves
  72225. */
  72226. ColorCurves.prototype.clone = function () {
  72227. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  72228. };
  72229. /**
  72230. * Serializes the current color curve instance to a json representation.
  72231. * @return a JSON representation
  72232. */
  72233. ColorCurves.prototype.serialize = function () {
  72234. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  72235. };
  72236. /**
  72237. * Parses the color curve from a json representation.
  72238. * @param source the JSON source to parse
  72239. * @return The parsed curves
  72240. */
  72241. ColorCurves.Parse = function (source) {
  72242. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  72243. };
  72244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72246. ], ColorCurves.prototype, "_globalHue", void 0);
  72247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72249. ], ColorCurves.prototype, "_globalDensity", void 0);
  72250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72252. ], ColorCurves.prototype, "_globalSaturation", void 0);
  72253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72255. ], ColorCurves.prototype, "_globalExposure", void 0);
  72256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72258. ], ColorCurves.prototype, "_highlightsHue", void 0);
  72259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72261. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  72262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72264. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  72265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72267. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  72268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72270. ], ColorCurves.prototype, "_midtonesHue", void 0);
  72271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72273. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  72274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72276. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  72277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  72278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  72279. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  72280. return ColorCurves;
  72281. }());
  72282. // References the dependencies.
  72283. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  72284. /***/ }),
  72285. /***/ "./Materials/effect.ts":
  72286. /*!*****************************!*\
  72287. !*** ./Materials/effect.ts ***!
  72288. \*****************************/
  72289. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  72290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  72291. "use strict";
  72292. __webpack_require__.r(__webpack_exports__);
  72293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  72294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  72295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  72296. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  72297. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  72298. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  72299. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  72300. /* harmony import */ var _Engines_Processors_shaderProcessor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Processors/shaderProcessor */ "./Engines/Processors/shaderProcessor.ts");
  72301. /**
  72302. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  72303. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  72304. */
  72305. var EffectFallbacks = /** @class */ (function () {
  72306. function EffectFallbacks() {
  72307. this._defines = {};
  72308. this._currentRank = 32;
  72309. this._maxRank = -1;
  72310. this._mesh = null;
  72311. }
  72312. /**
  72313. * Removes the fallback from the bound mesh.
  72314. */
  72315. EffectFallbacks.prototype.unBindMesh = function () {
  72316. this._mesh = null;
  72317. };
  72318. /**
  72319. * Adds a fallback on the specified property.
  72320. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  72321. * @param define The name of the define in the shader
  72322. */
  72323. EffectFallbacks.prototype.addFallback = function (rank, define) {
  72324. if (!this._defines[rank]) {
  72325. if (rank < this._currentRank) {
  72326. this._currentRank = rank;
  72327. }
  72328. if (rank > this._maxRank) {
  72329. this._maxRank = rank;
  72330. }
  72331. this._defines[rank] = new Array();
  72332. }
  72333. this._defines[rank].push(define);
  72334. };
  72335. /**
  72336. * Sets the mesh to use CPU skinning when needing to fallback.
  72337. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  72338. * @param mesh The mesh to use the fallbacks.
  72339. */
  72340. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  72341. this._mesh = mesh;
  72342. if (rank < this._currentRank) {
  72343. this._currentRank = rank;
  72344. }
  72345. if (rank > this._maxRank) {
  72346. this._maxRank = rank;
  72347. }
  72348. };
  72349. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  72350. /**
  72351. * Checks to see if more fallbacks are still availible.
  72352. */
  72353. get: function () {
  72354. return this._currentRank <= this._maxRank;
  72355. },
  72356. enumerable: true,
  72357. configurable: true
  72358. });
  72359. /**
  72360. * Removes the defines that should be removed when falling back.
  72361. * @param currentDefines defines the current define statements for the shader.
  72362. * @param effect defines the current effect we try to compile
  72363. * @returns The resulting defines with defines of the current rank removed.
  72364. */
  72365. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  72366. // First we try to switch to CPU skinning
  72367. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
  72368. this._mesh.computeBonesUsingShaders = false;
  72369. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  72370. effect._bonesComputationForcedToCPU = true;
  72371. var scene = this._mesh.getScene();
  72372. for (var index = 0; index < scene.meshes.length; index++) {
  72373. var otherMesh = scene.meshes[index];
  72374. if (!otherMesh.material) {
  72375. if (!this._mesh.material && otherMesh.computeBonesUsingShaders && otherMesh.numBoneInfluencers > 0) {
  72376. otherMesh.computeBonesUsingShaders = false;
  72377. }
  72378. continue;
  72379. }
  72380. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  72381. continue;
  72382. }
  72383. if (otherMesh.material.getEffect() === effect) {
  72384. otherMesh.computeBonesUsingShaders = false;
  72385. }
  72386. else if (otherMesh.subMeshes) {
  72387. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  72388. var subMesh = _a[_i];
  72389. var subMeshEffect = subMesh.effect;
  72390. if (subMeshEffect === effect) {
  72391. otherMesh.computeBonesUsingShaders = false;
  72392. break;
  72393. }
  72394. }
  72395. }
  72396. }
  72397. }
  72398. else {
  72399. var currentFallbacks = this._defines[this._currentRank];
  72400. if (currentFallbacks) {
  72401. for (var index = 0; index < currentFallbacks.length; index++) {
  72402. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  72403. }
  72404. }
  72405. this._currentRank++;
  72406. }
  72407. return currentDefines;
  72408. };
  72409. return EffectFallbacks;
  72410. }());
  72411. /**
  72412. * Options to be used when creating an effect.
  72413. */
  72414. var EffectCreationOptions = /** @class */ (function () {
  72415. function EffectCreationOptions() {
  72416. }
  72417. return EffectCreationOptions;
  72418. }());
  72419. /**
  72420. * Effect containing vertex and fragment shader that can be executed on an object.
  72421. */
  72422. var Effect = /** @class */ (function () {
  72423. /**
  72424. * Instantiates an effect.
  72425. * An effect can be used to create/manage/execute vertex and fragment shaders.
  72426. * @param baseName Name of the effect.
  72427. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  72428. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  72429. * @param samplers List of sampler variables that will be passed to the shader.
  72430. * @param engine Engine to be used to render the effect
  72431. * @param defines Define statements to be added to the shader.
  72432. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  72433. * @param onCompiled Callback that will be called when the shader is compiled.
  72434. * @param onError Callback that will be called if an error occurs during shader compilation.
  72435. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  72436. */
  72437. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  72438. var _this = this;
  72439. if (samplers === void 0) { samplers = null; }
  72440. if (defines === void 0) { defines = null; }
  72441. if (fallbacks === void 0) { fallbacks = null; }
  72442. if (onCompiled === void 0) { onCompiled = null; }
  72443. if (onError === void 0) { onError = null; }
  72444. /**
  72445. * Name of the effect.
  72446. */
  72447. this.name = null;
  72448. /**
  72449. * String container all the define statements that should be set on the shader.
  72450. */
  72451. this.defines = "";
  72452. /**
  72453. * Callback that will be called when the shader is compiled.
  72454. */
  72455. this.onCompiled = null;
  72456. /**
  72457. * Callback that will be called if an error occurs during shader compilation.
  72458. */
  72459. this.onError = null;
  72460. /**
  72461. * Callback that will be called when effect is bound.
  72462. */
  72463. this.onBind = null;
  72464. /**
  72465. * Unique ID of the effect.
  72466. */
  72467. this.uniqueId = 0;
  72468. /**
  72469. * Observable that will be called when the shader is compiled.
  72470. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  72471. */
  72472. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  72473. /**
  72474. * Observable that will be called if an error occurs during shader compilation.
  72475. */
  72476. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  72477. /** @hidden */
  72478. this._onBindObservable = null;
  72479. /** @hidden */
  72480. this._bonesComputationForcedToCPU = false;
  72481. this._uniformBuffersNames = {};
  72482. this._samplers = {};
  72483. this._isReady = false;
  72484. this._compilationError = "";
  72485. this._uniforms = {};
  72486. /**
  72487. * Key for the effect.
  72488. * @hidden
  72489. */
  72490. this._key = "";
  72491. this._fallbacks = null;
  72492. this._vertexSourceCode = "";
  72493. this._fragmentSourceCode = "";
  72494. this._vertexSourceCodeOverride = "";
  72495. this._fragmentSourceCodeOverride = "";
  72496. this._transformFeedbackVaryings = null;
  72497. /**
  72498. * Compiled shader to webGL program.
  72499. * @hidden
  72500. */
  72501. this._pipelineContext = null;
  72502. this._valueCache = {};
  72503. this.name = baseName;
  72504. if (attributesNamesOrOptions.attributes) {
  72505. var options = attributesNamesOrOptions;
  72506. this._engine = uniformsNamesOrEngine;
  72507. this._attributesNames = options.attributes;
  72508. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  72509. this._samplerList = options.samplers.slice();
  72510. this.defines = options.defines;
  72511. this.onError = options.onError;
  72512. this.onCompiled = options.onCompiled;
  72513. this._fallbacks = options.fallbacks;
  72514. this._indexParameters = options.indexParameters;
  72515. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  72516. if (options.uniformBuffersNames) {
  72517. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  72518. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  72519. }
  72520. }
  72521. }
  72522. else {
  72523. this._engine = engine;
  72524. this.defines = (defines == null ? "" : defines);
  72525. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  72526. this._samplerList = samplers ? samplers.slice() : [];
  72527. this._attributesNames = attributesNamesOrOptions;
  72528. this.onError = onError;
  72529. this.onCompiled = onCompiled;
  72530. this._indexParameters = indexParameters;
  72531. this._fallbacks = fallbacks;
  72532. }
  72533. this.uniqueId = Effect._uniqueIdSeed++;
  72534. var vertexSource;
  72535. var fragmentSource;
  72536. if (baseName.vertexSource) {
  72537. vertexSource = "source:" + baseName.vertexSource;
  72538. }
  72539. else if (baseName.vertexElement) {
  72540. vertexSource = document.getElementById(baseName.vertexElement);
  72541. if (!vertexSource) {
  72542. vertexSource = baseName.vertexElement;
  72543. }
  72544. }
  72545. else {
  72546. vertexSource = baseName.vertex || baseName;
  72547. }
  72548. if (baseName.fragmentSource) {
  72549. fragmentSource = "source:" + baseName.fragmentSource;
  72550. }
  72551. else if (baseName.fragmentElement) {
  72552. fragmentSource = document.getElementById(baseName.fragmentElement);
  72553. if (!fragmentSource) {
  72554. fragmentSource = baseName.fragmentElement;
  72555. }
  72556. }
  72557. else {
  72558. fragmentSource = baseName.fragment || baseName;
  72559. }
  72560. var processorOptions = {
  72561. defines: this.defines.split("\n"),
  72562. indexParameters: this._indexParameters,
  72563. isFragment: false,
  72564. shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,
  72565. processor: this._engine._shaderProcessor,
  72566. supportsUniformBuffers: this._engine.supportsUniformBuffers,
  72567. shadersRepository: Effect.ShadersRepository,
  72568. includesShadersStore: Effect.IncludesShadersStore,
  72569. version: (this._engine.webGLVersion * 100).toString(),
  72570. platformName: this._engine.webGLVersion >= 2 ? "WEBGL2" : "WEBGL1"
  72571. };
  72572. this._loadVertexShader(vertexSource, function (vertexCode) {
  72573. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  72574. _Engines_Processors_shaderProcessor__WEBPACK_IMPORTED_MODULE_4__["ShaderProcessor"].Process(vertexCode, processorOptions, function (migratedVertexCode) {
  72575. processorOptions.isFragment = true;
  72576. _Engines_Processors_shaderProcessor__WEBPACK_IMPORTED_MODULE_4__["ShaderProcessor"].Process(fragmentCode, processorOptions, function (migratedFragmentCode) {
  72577. _this._useFinalCode(migratedVertexCode, migratedFragmentCode, baseName);
  72578. });
  72579. });
  72580. });
  72581. });
  72582. }
  72583. Object.defineProperty(Effect.prototype, "onBindObservable", {
  72584. /**
  72585. * Observable that will be called when effect is bound.
  72586. */
  72587. get: function () {
  72588. if (!this._onBindObservable) {
  72589. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  72590. }
  72591. return this._onBindObservable;
  72592. },
  72593. enumerable: true,
  72594. configurable: true
  72595. });
  72596. Effect.prototype._useFinalCode = function (migratedVertexCode, migratedFragmentCode, baseName) {
  72597. if (baseName) {
  72598. var vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;
  72599. var fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;
  72600. this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  72601. this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  72602. }
  72603. else {
  72604. this._vertexSourceCode = migratedVertexCode;
  72605. this._fragmentSourceCode = migratedFragmentCode;
  72606. }
  72607. this._prepareEffect();
  72608. };
  72609. Object.defineProperty(Effect.prototype, "key", {
  72610. /**
  72611. * Unique key for this effect
  72612. */
  72613. get: function () {
  72614. return this._key;
  72615. },
  72616. enumerable: true,
  72617. configurable: true
  72618. });
  72619. /**
  72620. * If the effect has been compiled and prepared.
  72621. * @returns if the effect is compiled and prepared.
  72622. */
  72623. Effect.prototype.isReady = function () {
  72624. if (this._isReady) {
  72625. return true;
  72626. }
  72627. if (this._pipelineContext) {
  72628. return this._pipelineContext.isReady;
  72629. }
  72630. return false;
  72631. };
  72632. /**
  72633. * The engine the effect was initialized with.
  72634. * @returns the engine.
  72635. */
  72636. Effect.prototype.getEngine = function () {
  72637. return this._engine;
  72638. };
  72639. /**
  72640. * The pipeline context for this effect
  72641. * @returns the associated pipeline context
  72642. */
  72643. Effect.prototype.getPipelineContext = function () {
  72644. return this._pipelineContext;
  72645. };
  72646. /**
  72647. * The set of names of attribute variables for the shader.
  72648. * @returns An array of attribute names.
  72649. */
  72650. Effect.prototype.getAttributesNames = function () {
  72651. return this._attributesNames;
  72652. };
  72653. /**
  72654. * Returns the attribute at the given index.
  72655. * @param index The index of the attribute.
  72656. * @returns The location of the attribute.
  72657. */
  72658. Effect.prototype.getAttributeLocation = function (index) {
  72659. return this._attributes[index];
  72660. };
  72661. /**
  72662. * Returns the attribute based on the name of the variable.
  72663. * @param name of the attribute to look up.
  72664. * @returns the attribute location.
  72665. */
  72666. Effect.prototype.getAttributeLocationByName = function (name) {
  72667. var index = this._attributesNames.indexOf(name);
  72668. return this._attributes[index];
  72669. };
  72670. /**
  72671. * The number of attributes.
  72672. * @returns the numnber of attributes.
  72673. */
  72674. Effect.prototype.getAttributesCount = function () {
  72675. return this._attributes.length;
  72676. };
  72677. /**
  72678. * Gets the index of a uniform variable.
  72679. * @param uniformName of the uniform to look up.
  72680. * @returns the index.
  72681. */
  72682. Effect.prototype.getUniformIndex = function (uniformName) {
  72683. return this._uniformsNames.indexOf(uniformName);
  72684. };
  72685. /**
  72686. * Returns the attribute based on the name of the variable.
  72687. * @param uniformName of the uniform to look up.
  72688. * @returns the location of the uniform.
  72689. */
  72690. Effect.prototype.getUniform = function (uniformName) {
  72691. return this._uniforms[uniformName];
  72692. };
  72693. /**
  72694. * Returns an array of sampler variable names
  72695. * @returns The array of sampler variable neames.
  72696. */
  72697. Effect.prototype.getSamplers = function () {
  72698. return this._samplerList;
  72699. };
  72700. /**
  72701. * The error from the last compilation.
  72702. * @returns the error string.
  72703. */
  72704. Effect.prototype.getCompilationError = function () {
  72705. return this._compilationError;
  72706. };
  72707. /**
  72708. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  72709. * @param func The callback to be used.
  72710. */
  72711. Effect.prototype.executeWhenCompiled = function (func) {
  72712. var _this = this;
  72713. if (this.isReady()) {
  72714. func(this);
  72715. return;
  72716. }
  72717. this.onCompileObservable.add(function (effect) {
  72718. func(effect);
  72719. });
  72720. if (!this._pipelineContext || this._pipelineContext.isAsync) {
  72721. setTimeout(function () {
  72722. _this._checkIsReady();
  72723. }, 16);
  72724. }
  72725. };
  72726. Effect.prototype._checkIsReady = function () {
  72727. var _this = this;
  72728. if (this.isReady()) {
  72729. return;
  72730. }
  72731. setTimeout(function () {
  72732. _this._checkIsReady();
  72733. }, 16);
  72734. };
  72735. /** @hidden */
  72736. Effect.prototype._loadVertexShader = function (vertex, callback) {
  72737. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  72738. // DOM element ?
  72739. if (vertex instanceof HTMLElement) {
  72740. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  72741. callback(vertexCode);
  72742. return;
  72743. }
  72744. }
  72745. // Direct source ?
  72746. if (vertex.substr(0, 7) === "source:") {
  72747. callback(vertex.substr(7));
  72748. return;
  72749. }
  72750. // Base64 encoded ?
  72751. if (vertex.substr(0, 7) === "base64:") {
  72752. var vertexBinary = window.atob(vertex.substr(7));
  72753. callback(vertexBinary);
  72754. return;
  72755. }
  72756. // Is in local store ?
  72757. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  72758. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  72759. return;
  72760. }
  72761. var vertexShaderUrl;
  72762. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  72763. vertexShaderUrl = vertex;
  72764. }
  72765. else {
  72766. vertexShaderUrl = Effect.ShadersRepository + vertex;
  72767. }
  72768. // Vertex shader
  72769. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  72770. };
  72771. /** @hidden */
  72772. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  72773. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  72774. // DOM element ?
  72775. if (fragment instanceof HTMLElement) {
  72776. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  72777. callback(fragmentCode);
  72778. return;
  72779. }
  72780. }
  72781. // Direct source ?
  72782. if (fragment.substr(0, 7) === "source:") {
  72783. callback(fragment.substr(7));
  72784. return;
  72785. }
  72786. // Base64 encoded ?
  72787. if (fragment.substr(0, 7) === "base64:") {
  72788. var fragmentBinary = window.atob(fragment.substr(7));
  72789. callback(fragmentBinary);
  72790. return;
  72791. }
  72792. // Is in local store ?
  72793. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  72794. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  72795. return;
  72796. }
  72797. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  72798. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  72799. return;
  72800. }
  72801. var fragmentShaderUrl;
  72802. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  72803. fragmentShaderUrl = fragment;
  72804. }
  72805. else {
  72806. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  72807. }
  72808. // Fragment shader
  72809. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  72810. };
  72811. /** @hidden */
  72812. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  72813. // Rebuild shaders source code
  72814. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  72815. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  72816. vertexCode = prefix + vertexCode;
  72817. fragmentCode = prefix + fragmentCode;
  72818. // Number lines of shaders source code
  72819. var i = 2;
  72820. var regex = /\n/gm;
  72821. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  72822. i = 2;
  72823. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  72824. // Dump shaders name and formatted source code
  72825. if (this.name.vertexElement) {
  72826. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  72827. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  72828. }
  72829. else if (this.name.vertex) {
  72830. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  72831. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  72832. }
  72833. else {
  72834. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  72835. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  72836. }
  72837. };
  72838. /**
  72839. * Recompiles the webGL program
  72840. * @param vertexSourceCode The source code for the vertex shader.
  72841. * @param fragmentSourceCode The source code for the fragment shader.
  72842. * @param onCompiled Callback called when completed.
  72843. * @param onError Callback called on error.
  72844. * @hidden
  72845. */
  72846. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  72847. var _this = this;
  72848. this._isReady = false;
  72849. this._vertexSourceCodeOverride = vertexSourceCode;
  72850. this._fragmentSourceCodeOverride = fragmentSourceCode;
  72851. this.onError = function (effect, error) {
  72852. if (onError) {
  72853. onError(error);
  72854. }
  72855. };
  72856. this.onCompiled = function () {
  72857. var scenes = _this.getEngine().scenes;
  72858. for (var i = 0; i < scenes.length; i++) {
  72859. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  72860. }
  72861. _this._pipelineContext._handlesSpectorRebuildCallback(onCompiled);
  72862. };
  72863. this._fallbacks = null;
  72864. this._prepareEffect();
  72865. };
  72866. /**
  72867. * Prepares the effect
  72868. * @hidden
  72869. */
  72870. Effect.prototype._prepareEffect = function () {
  72871. var _this = this;
  72872. var attributesNames = this._attributesNames;
  72873. var defines = this.defines;
  72874. var fallbacks = this._fallbacks;
  72875. this._valueCache = {};
  72876. var previousPipelineContext = this._pipelineContext;
  72877. try {
  72878. var engine_1 = this._engine;
  72879. this._pipelineContext = engine_1.createPipelineContext();
  72880. var rebuildRebind = this._rebuildProgram.bind(this);
  72881. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  72882. engine_1._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, true, rebuildRebind, null, this._transformFeedbackVaryings);
  72883. }
  72884. else {
  72885. engine_1._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, false, rebuildRebind, defines, this._transformFeedbackVaryings);
  72886. }
  72887. engine_1._executeWhenRenderingStateIsCompiled(this._pipelineContext, function () {
  72888. if (engine_1.supportsUniformBuffers) {
  72889. for (var name in _this._uniformBuffersNames) {
  72890. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  72891. }
  72892. }
  72893. var uniforms = engine_1.getUniforms(_this._pipelineContext, _this._uniformsNames);
  72894. uniforms.forEach(function (uniform, index) {
  72895. _this._uniforms[_this._uniformsNames[index]] = uniform;
  72896. });
  72897. _this._attributes = engine_1.getAttributes(_this._pipelineContext, attributesNames);
  72898. var index;
  72899. for (index = 0; index < _this._samplerList.length; index++) {
  72900. var sampler = _this.getUniform(_this._samplerList[index]);
  72901. if (sampler == null) {
  72902. _this._samplerList.splice(index, 1);
  72903. index--;
  72904. }
  72905. }
  72906. _this._samplerList.forEach(function (name, index) {
  72907. _this._samplers[name] = index;
  72908. });
  72909. engine_1.bindSamplers(_this);
  72910. _this._compilationError = "";
  72911. _this._isReady = true;
  72912. if (_this.onCompiled) {
  72913. _this.onCompiled(_this);
  72914. }
  72915. _this.onCompileObservable.notifyObservers(_this);
  72916. _this.onCompileObservable.clear();
  72917. // Unbind mesh reference in fallbacks
  72918. if (_this._fallbacks) {
  72919. _this._fallbacks.unBindMesh();
  72920. }
  72921. if (previousPipelineContext) {
  72922. _this.getEngine()._deletePipelineContext(previousPipelineContext);
  72923. }
  72924. });
  72925. if (this._pipelineContext.isAsync) {
  72926. this._checkIsReady();
  72927. }
  72928. }
  72929. catch (e) {
  72930. this._compilationError = e.message;
  72931. // Let's go through fallbacks then
  72932. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  72933. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  72934. return " " + uniform;
  72935. }));
  72936. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  72937. return " " + attribute;
  72938. }));
  72939. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  72940. if (previousPipelineContext) {
  72941. this._pipelineContext = previousPipelineContext;
  72942. this._isReady = true;
  72943. if (this.onError) {
  72944. this.onError(this, this._compilationError);
  72945. }
  72946. this.onErrorObservable.notifyObservers(this);
  72947. }
  72948. if (fallbacks) {
  72949. this._pipelineContext = null;
  72950. if (fallbacks.isMoreFallbacks) {
  72951. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  72952. this.defines = fallbacks.reduce(this.defines, this);
  72953. this._prepareEffect();
  72954. }
  72955. else { // Sorry we did everything we can
  72956. if (this.onError) {
  72957. this.onError(this, this._compilationError);
  72958. }
  72959. this.onErrorObservable.notifyObservers(this);
  72960. this.onErrorObservable.clear();
  72961. // Unbind mesh reference in fallbacks
  72962. if (this._fallbacks) {
  72963. this._fallbacks.unBindMesh();
  72964. }
  72965. }
  72966. }
  72967. }
  72968. };
  72969. Object.defineProperty(Effect.prototype, "isSupported", {
  72970. /**
  72971. * Checks if the effect is supported. (Must be called after compilation)
  72972. */
  72973. get: function () {
  72974. return this._compilationError === "";
  72975. },
  72976. enumerable: true,
  72977. configurable: true
  72978. });
  72979. /**
  72980. * Binds a texture to the engine to be used as output of the shader.
  72981. * @param channel Name of the output variable.
  72982. * @param texture Texture to bind.
  72983. * @hidden
  72984. */
  72985. Effect.prototype._bindTexture = function (channel, texture) {
  72986. this._engine._bindTexture(this._samplers[channel], texture);
  72987. };
  72988. /**
  72989. * Sets a texture on the engine to be used in the shader.
  72990. * @param channel Name of the sampler variable.
  72991. * @param texture Texture to set.
  72992. */
  72993. Effect.prototype.setTexture = function (channel, texture) {
  72994. this._engine.setTexture(this._samplers[channel], this._uniforms[channel], texture);
  72995. };
  72996. /**
  72997. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  72998. * @param channel Name of the sampler variable.
  72999. * @param texture Texture to set.
  73000. */
  73001. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  73002. this._engine.setDepthStencilTexture(this._samplers[channel], this._uniforms[channel], texture);
  73003. };
  73004. /**
  73005. * Sets an array of textures on the engine to be used in the shader.
  73006. * @param channel Name of the variable.
  73007. * @param textures Textures to set.
  73008. */
  73009. Effect.prototype.setTextureArray = function (channel, textures) {
  73010. var exName = channel + "Ex";
  73011. if (this._samplerList.indexOf(exName + "0") === -1) {
  73012. var initialPos = this._samplerList.indexOf(channel);
  73013. for (var index = 1; index < textures.length; index++) {
  73014. var currentExName = exName + (index - 1).toString();
  73015. this._samplerList.splice(initialPos + index, 0, currentExName);
  73016. }
  73017. // Reset every channels
  73018. var channelIndex = 0;
  73019. for (var _i = 0, _a = this._samplerList; _i < _a.length; _i++) {
  73020. var key = _a[_i];
  73021. this._samplers[key] = channelIndex;
  73022. channelIndex += 1;
  73023. }
  73024. }
  73025. this._engine.setTextureArray(this._samplers[channel], this._uniforms[channel], textures);
  73026. };
  73027. /**
  73028. * 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)
  73029. * @param channel Name of the sampler variable.
  73030. * @param postProcess Post process to get the input texture from.
  73031. */
  73032. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  73033. this._engine.setTextureFromPostProcess(this._samplers[channel], postProcess);
  73034. };
  73035. /**
  73036. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  73037. * 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)
  73038. * @param channel Name of the sampler variable.
  73039. * @param postProcess Post process to get the output texture from.
  73040. */
  73041. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  73042. this._engine.setTextureFromPostProcessOutput(this._samplers[channel], postProcess);
  73043. };
  73044. /** @hidden */
  73045. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  73046. var cache = this._valueCache[uniformName];
  73047. var flag = matrix.updateFlag;
  73048. if (cache !== undefined && cache === flag) {
  73049. return false;
  73050. }
  73051. this._valueCache[uniformName] = flag;
  73052. return true;
  73053. };
  73054. /** @hidden */
  73055. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  73056. var cache = this._valueCache[uniformName];
  73057. if (!cache) {
  73058. cache = [x, y];
  73059. this._valueCache[uniformName] = cache;
  73060. return true;
  73061. }
  73062. var changed = false;
  73063. if (cache[0] !== x) {
  73064. cache[0] = x;
  73065. changed = true;
  73066. }
  73067. if (cache[1] !== y) {
  73068. cache[1] = y;
  73069. changed = true;
  73070. }
  73071. return changed;
  73072. };
  73073. /** @hidden */
  73074. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  73075. var cache = this._valueCache[uniformName];
  73076. if (!cache) {
  73077. cache = [x, y, z];
  73078. this._valueCache[uniformName] = cache;
  73079. return true;
  73080. }
  73081. var changed = false;
  73082. if (cache[0] !== x) {
  73083. cache[0] = x;
  73084. changed = true;
  73085. }
  73086. if (cache[1] !== y) {
  73087. cache[1] = y;
  73088. changed = true;
  73089. }
  73090. if (cache[2] !== z) {
  73091. cache[2] = z;
  73092. changed = true;
  73093. }
  73094. return changed;
  73095. };
  73096. /** @hidden */
  73097. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  73098. var cache = this._valueCache[uniformName];
  73099. if (!cache) {
  73100. cache = [x, y, z, w];
  73101. this._valueCache[uniformName] = cache;
  73102. return true;
  73103. }
  73104. var changed = false;
  73105. if (cache[0] !== x) {
  73106. cache[0] = x;
  73107. changed = true;
  73108. }
  73109. if (cache[1] !== y) {
  73110. cache[1] = y;
  73111. changed = true;
  73112. }
  73113. if (cache[2] !== z) {
  73114. cache[2] = z;
  73115. changed = true;
  73116. }
  73117. if (cache[3] !== w) {
  73118. cache[3] = w;
  73119. changed = true;
  73120. }
  73121. return changed;
  73122. };
  73123. /**
  73124. * Binds a buffer to a uniform.
  73125. * @param buffer Buffer to bind.
  73126. * @param name Name of the uniform variable to bind to.
  73127. */
  73128. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  73129. var bufferName = this._uniformBuffersNames[name];
  73130. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  73131. return;
  73132. }
  73133. Effect._baseCache[bufferName] = buffer;
  73134. this._engine.bindUniformBufferBase(buffer, bufferName);
  73135. };
  73136. /**
  73137. * Binds block to a uniform.
  73138. * @param blockName Name of the block to bind.
  73139. * @param index Index to bind.
  73140. */
  73141. Effect.prototype.bindUniformBlock = function (blockName, index) {
  73142. this._engine.bindUniformBlock(this._pipelineContext, blockName, index);
  73143. };
  73144. /**
  73145. * Sets an interger value on a uniform variable.
  73146. * @param uniformName Name of the variable.
  73147. * @param value Value to be set.
  73148. * @returns this effect.
  73149. */
  73150. Effect.prototype.setInt = function (uniformName, value) {
  73151. var cache = this._valueCache[uniformName];
  73152. if (cache !== undefined && cache === value) {
  73153. return this;
  73154. }
  73155. this._valueCache[uniformName] = value;
  73156. this._engine.setInt(this._uniforms[uniformName], value);
  73157. return this;
  73158. };
  73159. /**
  73160. * Sets an int array on a uniform variable.
  73161. * @param uniformName Name of the variable.
  73162. * @param array array to be set.
  73163. * @returns this effect.
  73164. */
  73165. Effect.prototype.setIntArray = function (uniformName, array) {
  73166. this._valueCache[uniformName] = null;
  73167. this._engine.setIntArray(this._uniforms[uniformName], array);
  73168. return this;
  73169. };
  73170. /**
  73171. * 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)
  73172. * @param uniformName Name of the variable.
  73173. * @param array array to be set.
  73174. * @returns this effect.
  73175. */
  73176. Effect.prototype.setIntArray2 = function (uniformName, array) {
  73177. this._valueCache[uniformName] = null;
  73178. this._engine.setIntArray2(this._uniforms[uniformName], array);
  73179. return this;
  73180. };
  73181. /**
  73182. * 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)
  73183. * @param uniformName Name of the variable.
  73184. * @param array array to be set.
  73185. * @returns this effect.
  73186. */
  73187. Effect.prototype.setIntArray3 = function (uniformName, array) {
  73188. this._valueCache[uniformName] = null;
  73189. this._engine.setIntArray3(this._uniforms[uniformName], array);
  73190. return this;
  73191. };
  73192. /**
  73193. * 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)
  73194. * @param uniformName Name of the variable.
  73195. * @param array array to be set.
  73196. * @returns this effect.
  73197. */
  73198. Effect.prototype.setIntArray4 = function (uniformName, array) {
  73199. this._valueCache[uniformName] = null;
  73200. this._engine.setIntArray4(this._uniforms[uniformName], array);
  73201. return this;
  73202. };
  73203. /**
  73204. * Sets an float array on a uniform variable.
  73205. * @param uniformName Name of the variable.
  73206. * @param array array to be set.
  73207. * @returns this effect.
  73208. */
  73209. Effect.prototype.setFloatArray = function (uniformName, array) {
  73210. this._valueCache[uniformName] = null;
  73211. this._engine.setFloatArray(this._uniforms[uniformName], array);
  73212. return this;
  73213. };
  73214. /**
  73215. * 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)
  73216. * @param uniformName Name of the variable.
  73217. * @param array array to be set.
  73218. * @returns this effect.
  73219. */
  73220. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  73221. this._valueCache[uniformName] = null;
  73222. this._engine.setFloatArray2(this._uniforms[uniformName], array);
  73223. return this;
  73224. };
  73225. /**
  73226. * 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)
  73227. * @param uniformName Name of the variable.
  73228. * @param array array to be set.
  73229. * @returns this effect.
  73230. */
  73231. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  73232. this._valueCache[uniformName] = null;
  73233. this._engine.setFloatArray3(this._uniforms[uniformName], array);
  73234. return this;
  73235. };
  73236. /**
  73237. * 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)
  73238. * @param uniformName Name of the variable.
  73239. * @param array array to be set.
  73240. * @returns this effect.
  73241. */
  73242. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  73243. this._valueCache[uniformName] = null;
  73244. this._engine.setFloatArray4(this._uniforms[uniformName], array);
  73245. return this;
  73246. };
  73247. /**
  73248. * Sets an array on a uniform variable.
  73249. * @param uniformName Name of the variable.
  73250. * @param array array to be set.
  73251. * @returns this effect.
  73252. */
  73253. Effect.prototype.setArray = function (uniformName, array) {
  73254. this._valueCache[uniformName] = null;
  73255. this._engine.setArray(this._uniforms[uniformName], array);
  73256. return this;
  73257. };
  73258. /**
  73259. * 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)
  73260. * @param uniformName Name of the variable.
  73261. * @param array array to be set.
  73262. * @returns this effect.
  73263. */
  73264. Effect.prototype.setArray2 = function (uniformName, array) {
  73265. this._valueCache[uniformName] = null;
  73266. this._engine.setArray2(this._uniforms[uniformName], array);
  73267. return this;
  73268. };
  73269. /**
  73270. * 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)
  73271. * @param uniformName Name of the variable.
  73272. * @param array array to be set.
  73273. * @returns this effect.
  73274. */
  73275. Effect.prototype.setArray3 = function (uniformName, array) {
  73276. this._valueCache[uniformName] = null;
  73277. this._engine.setArray3(this._uniforms[uniformName], array);
  73278. return this;
  73279. };
  73280. /**
  73281. * 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)
  73282. * @param uniformName Name of the variable.
  73283. * @param array array to be set.
  73284. * @returns this effect.
  73285. */
  73286. Effect.prototype.setArray4 = function (uniformName, array) {
  73287. this._valueCache[uniformName] = null;
  73288. this._engine.setArray4(this._uniforms[uniformName], array);
  73289. return this;
  73290. };
  73291. /**
  73292. * Sets matrices on a uniform variable.
  73293. * @param uniformName Name of the variable.
  73294. * @param matrices matrices to be set.
  73295. * @returns this effect.
  73296. */
  73297. Effect.prototype.setMatrices = function (uniformName, matrices) {
  73298. if (!matrices) {
  73299. return this;
  73300. }
  73301. this._valueCache[uniformName] = null;
  73302. this._engine.setMatrices(this._uniforms[uniformName], matrices);
  73303. return this;
  73304. };
  73305. /**
  73306. * Sets matrix on a uniform variable.
  73307. * @param uniformName Name of the variable.
  73308. * @param matrix matrix to be set.
  73309. * @returns this effect.
  73310. */
  73311. Effect.prototype.setMatrix = function (uniformName, matrix) {
  73312. if (this._cacheMatrix(uniformName, matrix)) {
  73313. this._engine.setMatrices(this._uniforms[uniformName], matrix.toArray());
  73314. }
  73315. return this;
  73316. };
  73317. /**
  73318. * 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)
  73319. * @param uniformName Name of the variable.
  73320. * @param matrix matrix to be set.
  73321. * @returns this effect.
  73322. */
  73323. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  73324. this._valueCache[uniformName] = null;
  73325. this._engine.setMatrix3x3(this._uniforms[uniformName], matrix);
  73326. return this;
  73327. };
  73328. /**
  73329. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  73330. * @param uniformName Name of the variable.
  73331. * @param matrix matrix to be set.
  73332. * @returns this effect.
  73333. */
  73334. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  73335. this._valueCache[uniformName] = null;
  73336. this._engine.setMatrix2x2(this._uniforms[uniformName], matrix);
  73337. return this;
  73338. };
  73339. /**
  73340. * Sets a float on a uniform variable.
  73341. * @param uniformName Name of the variable.
  73342. * @param value value to be set.
  73343. * @returns this effect.
  73344. */
  73345. Effect.prototype.setFloat = function (uniformName, value) {
  73346. var cache = this._valueCache[uniformName];
  73347. if (cache !== undefined && cache === value) {
  73348. return this;
  73349. }
  73350. this._valueCache[uniformName] = value;
  73351. this._engine.setFloat(this._uniforms[uniformName], value);
  73352. return this;
  73353. };
  73354. /**
  73355. * Sets a boolean on a uniform variable.
  73356. * @param uniformName Name of the variable.
  73357. * @param bool value to be set.
  73358. * @returns this effect.
  73359. */
  73360. Effect.prototype.setBool = function (uniformName, bool) {
  73361. var cache = this._valueCache[uniformName];
  73362. if (cache !== undefined && cache === bool) {
  73363. return this;
  73364. }
  73365. this._valueCache[uniformName] = bool;
  73366. this._engine.setBool(this._uniforms[uniformName], bool ? 1 : 0);
  73367. return this;
  73368. };
  73369. /**
  73370. * Sets a Vector2 on a uniform variable.
  73371. * @param uniformName Name of the variable.
  73372. * @param vector2 vector2 to be set.
  73373. * @returns this effect.
  73374. */
  73375. Effect.prototype.setVector2 = function (uniformName, vector2) {
  73376. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  73377. this._engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y);
  73378. }
  73379. return this;
  73380. };
  73381. /**
  73382. * Sets a float2 on a uniform variable.
  73383. * @param uniformName Name of the variable.
  73384. * @param x First float in float2.
  73385. * @param y Second float in float2.
  73386. * @returns this effect.
  73387. */
  73388. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  73389. if (this._cacheFloat2(uniformName, x, y)) {
  73390. this._engine.setFloat2(this._uniforms[uniformName], x, y);
  73391. }
  73392. return this;
  73393. };
  73394. /**
  73395. * Sets a Vector3 on a uniform variable.
  73396. * @param uniformName Name of the variable.
  73397. * @param vector3 Value to be set.
  73398. * @returns this effect.
  73399. */
  73400. Effect.prototype.setVector3 = function (uniformName, vector3) {
  73401. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  73402. this._engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z);
  73403. }
  73404. return this;
  73405. };
  73406. /**
  73407. * Sets a float3 on a uniform variable.
  73408. * @param uniformName Name of the variable.
  73409. * @param x First float in float3.
  73410. * @param y Second float in float3.
  73411. * @param z Third float in float3.
  73412. * @returns this effect.
  73413. */
  73414. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  73415. if (this._cacheFloat3(uniformName, x, y, z)) {
  73416. this._engine.setFloat3(this._uniforms[uniformName], x, y, z);
  73417. }
  73418. return this;
  73419. };
  73420. /**
  73421. * Sets a Vector4 on a uniform variable.
  73422. * @param uniformName Name of the variable.
  73423. * @param vector4 Value to be set.
  73424. * @returns this effect.
  73425. */
  73426. Effect.prototype.setVector4 = function (uniformName, vector4) {
  73427. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  73428. this._engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w);
  73429. }
  73430. return this;
  73431. };
  73432. /**
  73433. * Sets a float4 on a uniform variable.
  73434. * @param uniformName Name of the variable.
  73435. * @param x First float in float4.
  73436. * @param y Second float in float4.
  73437. * @param z Third float in float4.
  73438. * @param w Fourth float in float4.
  73439. * @returns this effect.
  73440. */
  73441. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  73442. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  73443. this._engine.setFloat4(this._uniforms[uniformName], x, y, z, w);
  73444. }
  73445. return this;
  73446. };
  73447. /**
  73448. * Sets a Color3 on a uniform variable.
  73449. * @param uniformName Name of the variable.
  73450. * @param color3 Value to be set.
  73451. * @returns this effect.
  73452. */
  73453. Effect.prototype.setColor3 = function (uniformName, color3) {
  73454. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  73455. this._engine.setFloat3(this._uniforms[uniformName], color3.r, color3.g, color3.b);
  73456. }
  73457. return this;
  73458. };
  73459. /**
  73460. * Sets a Color4 on a uniform variable.
  73461. * @param uniformName Name of the variable.
  73462. * @param color3 Value to be set.
  73463. * @param alpha Alpha value to be set.
  73464. * @returns this effect.
  73465. */
  73466. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  73467. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  73468. this._engine.setFloat4(this._uniforms[uniformName], color3.r, color3.g, color3.b, alpha);
  73469. }
  73470. return this;
  73471. };
  73472. /**
  73473. * Sets a Color4 on a uniform variable
  73474. * @param uniformName defines the name of the variable
  73475. * @param color4 defines the value to be set
  73476. * @returns this effect.
  73477. */
  73478. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  73479. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  73480. this._engine.setDirectColor4(this._uniforms[uniformName], color4);
  73481. }
  73482. return this;
  73483. };
  73484. /** Release all associated resources */
  73485. Effect.prototype.dispose = function () {
  73486. this._engine._releaseEffect(this);
  73487. };
  73488. /**
  73489. * This function will add a new shader to the shader store
  73490. * @param name the name of the shader
  73491. * @param pixelShader optional pixel shader content
  73492. * @param vertexShader optional vertex shader content
  73493. */
  73494. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  73495. if (pixelShader) {
  73496. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  73497. }
  73498. if (vertexShader) {
  73499. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  73500. }
  73501. };
  73502. /**
  73503. * Resets the cache of effects.
  73504. */
  73505. Effect.ResetCache = function () {
  73506. Effect._baseCache = {};
  73507. };
  73508. /**
  73509. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  73510. */
  73511. Effect.ShadersRepository = "src/Shaders/";
  73512. Effect._uniqueIdSeed = 0;
  73513. Effect._baseCache = {};
  73514. /**
  73515. * Store of each shader (The can be looked up using effect.key)
  73516. */
  73517. Effect.ShadersStore = {};
  73518. /**
  73519. * Store of each included file for a shader (The can be looked up using effect.key)
  73520. */
  73521. Effect.IncludesShadersStore = {};
  73522. return Effect;
  73523. }());
  73524. /***/ }),
  73525. /***/ "./Materials/effectRenderer.ts":
  73526. /*!*************************************!*\
  73527. !*** ./Materials/effectRenderer.ts ***!
  73528. \*************************************/
  73529. /*! exports provided: EffectRenderer, EffectWrapper */
  73530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73531. "use strict";
  73532. __webpack_require__.r(__webpack_exports__);
  73533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectRenderer", function() { return EffectRenderer; });
  73534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectWrapper", function() { return EffectWrapper; });
  73535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  73536. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  73537. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  73538. /* harmony import */ var _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.viewport */ "./Maths/math.viewport.ts");
  73539. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  73540. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  73541. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  73542. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  73543. // Prevents ES6 Crash if not imported.
  73544. /**
  73545. * Helper class to render one or more effects
  73546. */
  73547. var EffectRenderer = /** @class */ (function () {
  73548. /**
  73549. * Creates an effect renderer
  73550. * @param engine the engine to use for rendering
  73551. * @param options defines the options of the effect renderer
  73552. */
  73553. function EffectRenderer(engine, options) {
  73554. var _a;
  73555. if (options === void 0) { options = EffectRenderer._DefaultOptions; }
  73556. this.engine = engine;
  73557. this._ringBufferIndex = 0;
  73558. this._ringScreenBuffer = null;
  73559. this._fullscreenViewport = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1);
  73560. options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EffectRenderer._DefaultOptions, options);
  73561. this._vertexBuffers = (_a = {},
  73562. _a[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](engine, options.positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false, false, 2),
  73563. _a);
  73564. this._indexBuffer = engine.createIndexBuffer(options.indices);
  73565. // No need here for full screen render.
  73566. engine.setDepthBuffer(false);
  73567. engine.setStencilBuffer(false);
  73568. }
  73569. EffectRenderer.prototype._getNextFrameBuffer = function (incrementIndex) {
  73570. if (incrementIndex === void 0) { incrementIndex = true; }
  73571. if (!this._ringScreenBuffer) {
  73572. this._ringScreenBuffer = [];
  73573. for (var i = 0; i < 2; i++) {
  73574. var internalTexture = this.engine.createRenderTargetTexture({
  73575. width: this.engine.getRenderWidth(true),
  73576. height: this.engine.getRenderHeight(true),
  73577. }, {
  73578. generateDepthBuffer: false,
  73579. generateStencilBuffer: false,
  73580. generateMipMaps: false,
  73581. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_NEAREST,
  73582. });
  73583. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]("", null);
  73584. texture._texture = internalTexture;
  73585. this._ringScreenBuffer.push(texture);
  73586. }
  73587. }
  73588. var ret = this._ringScreenBuffer[this._ringBufferIndex];
  73589. if (incrementIndex) {
  73590. this._ringBufferIndex = (this._ringBufferIndex + 1) % 2;
  73591. }
  73592. return ret;
  73593. };
  73594. /**
  73595. * Sets the current viewport in normalized coordinates 0-1
  73596. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  73597. */
  73598. EffectRenderer.prototype.setViewport = function (viewport) {
  73599. if (viewport === void 0) { viewport = this._fullscreenViewport; }
  73600. this.engine.setViewport(viewport);
  73601. };
  73602. /**
  73603. * Sets the current effect wrapper to use during draw.
  73604. * The effect needs to be ready before calling this api.
  73605. * This also sets the default full screen position attribute.
  73606. * @param effectWrapper Defines the effect to draw with
  73607. */
  73608. EffectRenderer.prototype.applyEffectWrapper = function (effectWrapper) {
  73609. this.engine.enableEffect(effectWrapper.effect);
  73610. this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effectWrapper.effect);
  73611. effectWrapper.onApplyObservable.notifyObservers({});
  73612. };
  73613. /**
  73614. * Draws a full screen quad.
  73615. */
  73616. EffectRenderer.prototype.draw = function () {
  73617. this.engine.drawElementsType(_Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_TriangleFillMode, 0, 6);
  73618. };
  73619. /**
  73620. * renders one or more effects to a specified texture
  73621. * @param effectWrappers list of effects to renderer
  73622. * @param outputTexture texture to draw to, if null it will render to the screen
  73623. */
  73624. EffectRenderer.prototype.render = function (effectWrappers, outputTexture) {
  73625. var _this = this;
  73626. if (outputTexture === void 0) { outputTexture = null; }
  73627. if (!Array.isArray(effectWrappers)) {
  73628. effectWrappers = [effectWrappers];
  73629. }
  73630. // Ensure all effects are ready
  73631. for (var _i = 0, effectWrappers_1 = effectWrappers; _i < effectWrappers_1.length; _i++) {
  73632. var wrapper = effectWrappers_1[_i];
  73633. if (!wrapper.effect.isReady()) {
  73634. return;
  73635. }
  73636. }
  73637. effectWrappers.forEach(function (effectWrapper, i) {
  73638. var renderTo = outputTexture;
  73639. // for any next effect make it's input the output of the previous effect
  73640. if (i !== 0) {
  73641. effectWrapper.effect.onBindObservable.addOnce(function () {
  73642. effectWrapper.effect.setTexture("textureSampler", _this._getNextFrameBuffer(false));
  73643. });
  73644. }
  73645. // Set the output to the next screenbuffer
  73646. if (effectWrappers.length > 1 && i != effectWrappers.length - 1) {
  73647. renderTo = _this._getNextFrameBuffer();
  73648. }
  73649. else {
  73650. renderTo = outputTexture;
  73651. }
  73652. // Reset state
  73653. _this.setViewport();
  73654. _this.applyEffectWrapper(effectWrapper);
  73655. if (renderTo) {
  73656. _this.engine.bindFramebuffer(renderTo.getInternalTexture());
  73657. }
  73658. _this.draw();
  73659. if (renderTo) {
  73660. _this.engine.unBindFramebuffer(renderTo.getInternalTexture());
  73661. }
  73662. });
  73663. };
  73664. /**
  73665. * Disposes of the effect renderer
  73666. */
  73667. EffectRenderer.prototype.dispose = function () {
  73668. if (this._ringScreenBuffer) {
  73669. this._ringScreenBuffer.forEach(function (b) {
  73670. b.dispose();
  73671. });
  73672. this._ringScreenBuffer = null;
  73673. }
  73674. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  73675. if (vertexBuffer) {
  73676. vertexBuffer.dispose();
  73677. delete this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  73678. }
  73679. if (this._indexBuffer) {
  73680. this.engine._releaseBuffer(this._indexBuffer);
  73681. }
  73682. };
  73683. // Fullscreen quad buffers by default.
  73684. EffectRenderer._DefaultOptions = {
  73685. positions: [1, 1, -1, 1, -1, -1, 1, -1],
  73686. indices: [0, 1, 2, 0, 2, 3]
  73687. };
  73688. return EffectRenderer;
  73689. }());
  73690. /**
  73691. * Wraps an effect to be used for rendering
  73692. */
  73693. var EffectWrapper = /** @class */ (function () {
  73694. /**
  73695. * Creates an effect to be renderer
  73696. * @param creationOptions options to create the effect
  73697. */
  73698. function EffectWrapper(creationOptions) {
  73699. /**
  73700. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  73701. */
  73702. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_5__["Observable"]();
  73703. this.effect = new _effect__WEBPACK_IMPORTED_MODULE_6__["Effect"]({
  73704. fragmentSource: creationOptions.fragmentShader,
  73705. vertexSource: creationOptions.vertexShader || "postprocess",
  73706. spectorName: creationOptions.name || "effectWrapper"
  73707. }, creationOptions.attributeNames || ["position"], creationOptions.uniformNames || ["scale"], creationOptions.samplerNames, creationOptions.engine);
  73708. }
  73709. /**
  73710. * Disposes of the effect wrapper
  73711. */
  73712. EffectWrapper.prototype.dispose = function () {
  73713. this.effect.dispose();
  73714. };
  73715. return EffectWrapper;
  73716. }());
  73717. /***/ }),
  73718. /***/ "./Materials/fresnelParameters.ts":
  73719. /*!****************************************!*\
  73720. !*** ./Materials/fresnelParameters.ts ***!
  73721. \****************************************/
  73722. /*! exports provided: FresnelParameters */
  73723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73724. "use strict";
  73725. __webpack_require__.r(__webpack_exports__);
  73726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  73727. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  73728. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  73729. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  73730. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  73731. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  73732. /**
  73733. * This represents all the required information to add a fresnel effect on a material:
  73734. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  73735. */
  73736. var FresnelParameters = /** @class */ (function () {
  73737. function FresnelParameters() {
  73738. this._isEnabled = true;
  73739. /**
  73740. * Define the color used on edges (grazing angle)
  73741. */
  73742. this.leftColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  73743. /**
  73744. * Define the color used on center
  73745. */
  73746. this.rightColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  73747. /**
  73748. * Define bias applied to computed fresnel term
  73749. */
  73750. this.bias = 0;
  73751. /**
  73752. * Defined the power exponent applied to fresnel term
  73753. */
  73754. this.power = 1;
  73755. }
  73756. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  73757. /**
  73758. * Define if the fresnel effect is enable or not.
  73759. */
  73760. get: function () {
  73761. return this._isEnabled;
  73762. },
  73763. set: function (value) {
  73764. if (this._isEnabled === value) {
  73765. return;
  73766. }
  73767. this._isEnabled = value;
  73768. _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);
  73769. },
  73770. enumerable: true,
  73771. configurable: true
  73772. });
  73773. /**
  73774. * Clones the current fresnel and its valuues
  73775. * @returns a clone fresnel configuration
  73776. */
  73777. FresnelParameters.prototype.clone = function () {
  73778. var newFresnelParameters = new FresnelParameters();
  73779. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  73780. return newFresnelParameters;
  73781. };
  73782. /**
  73783. * Serializes the current fresnel parameters to a JSON representation.
  73784. * @return the JSON serialization
  73785. */
  73786. FresnelParameters.prototype.serialize = function () {
  73787. var serializationObject = {};
  73788. serializationObject.isEnabled = this.isEnabled;
  73789. serializationObject.leftColor = this.leftColor.asArray();
  73790. serializationObject.rightColor = this.rightColor.asArray();
  73791. serializationObject.bias = this.bias;
  73792. serializationObject.power = this.power;
  73793. return serializationObject;
  73794. };
  73795. /**
  73796. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  73797. * @param parsedFresnelParameters Define the JSON representation
  73798. * @returns the parsed parameters
  73799. */
  73800. FresnelParameters.Parse = function (parsedFresnelParameters) {
  73801. var fresnelParameters = new FresnelParameters();
  73802. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  73803. fresnelParameters.leftColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  73804. fresnelParameters.rightColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  73805. fresnelParameters.bias = parsedFresnelParameters.bias;
  73806. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  73807. return fresnelParameters;
  73808. };
  73809. return FresnelParameters;
  73810. }());
  73811. // References the dependencies.
  73812. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  73813. /***/ }),
  73814. /***/ "./Materials/imageProcessingConfiguration.ts":
  73815. /*!***************************************************!*\
  73816. !*** ./Materials/imageProcessingConfiguration.ts ***!
  73817. \***************************************************/
  73818. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  73819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73820. "use strict";
  73821. __webpack_require__.r(__webpack_exports__);
  73822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  73823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  73824. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  73825. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  73826. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  73827. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  73828. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  73829. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  73830. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  73831. /**
  73832. * @hidden
  73833. */
  73834. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  73835. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  73836. function ImageProcessingConfigurationDefines() {
  73837. var _this = _super.call(this) || this;
  73838. _this.IMAGEPROCESSING = false;
  73839. _this.VIGNETTE = false;
  73840. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  73841. _this.VIGNETTEBLENDMODEOPAQUE = false;
  73842. _this.TONEMAPPING = false;
  73843. _this.TONEMAPPING_ACES = false;
  73844. _this.CONTRAST = false;
  73845. _this.COLORCURVES = false;
  73846. _this.COLORGRADING = false;
  73847. _this.COLORGRADING3D = false;
  73848. _this.SAMPLER3DGREENDEPTH = false;
  73849. _this.SAMPLER3DBGRMAP = false;
  73850. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  73851. _this.EXPOSURE = false;
  73852. _this.rebuild();
  73853. return _this;
  73854. }
  73855. return ImageProcessingConfigurationDefines;
  73856. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  73857. /**
  73858. * This groups together the common properties used for image processing either in direct forward pass
  73859. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73860. * or not.
  73861. */
  73862. var ImageProcessingConfiguration = /** @class */ (function () {
  73863. function ImageProcessingConfiguration() {
  73864. /**
  73865. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73866. */
  73867. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  73868. this._colorCurvesEnabled = false;
  73869. this._colorGradingEnabled = false;
  73870. this._colorGradingWithGreenDepth = true;
  73871. this._colorGradingBGR = true;
  73872. /** @hidden */
  73873. this._exposure = 1.0;
  73874. this._toneMappingEnabled = false;
  73875. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  73876. this._contrast = 1.0;
  73877. /**
  73878. * Vignette stretch size.
  73879. */
  73880. this.vignetteStretch = 0;
  73881. /**
  73882. * Vignette centre X Offset.
  73883. */
  73884. this.vignetteCentreX = 0;
  73885. /**
  73886. * Vignette centre Y Offset.
  73887. */
  73888. this.vignetteCentreY = 0;
  73889. /**
  73890. * Vignette weight or intensity of the vignette effect.
  73891. */
  73892. this.vignetteWeight = 1.5;
  73893. /**
  73894. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73895. * if vignetteEnabled is set to true.
  73896. */
  73897. this.vignetteColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  73898. /**
  73899. * Camera field of view used by the Vignette effect.
  73900. */
  73901. this.vignetteCameraFov = 0.5;
  73902. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  73903. this._vignetteEnabled = false;
  73904. this._applyByPostProcess = false;
  73905. this._isEnabled = true;
  73906. /**
  73907. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73908. */
  73909. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  73910. }
  73911. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  73912. /**
  73913. * Gets wether the color curves effect is enabled.
  73914. */
  73915. get: function () {
  73916. return this._colorCurvesEnabled;
  73917. },
  73918. /**
  73919. * Sets wether the color curves effect is enabled.
  73920. */
  73921. set: function (value) {
  73922. if (this._colorCurvesEnabled === value) {
  73923. return;
  73924. }
  73925. this._colorCurvesEnabled = value;
  73926. this._updateParameters();
  73927. },
  73928. enumerable: true,
  73929. configurable: true
  73930. });
  73931. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  73932. /**
  73933. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73934. */
  73935. get: function () {
  73936. return this._colorGradingTexture;
  73937. },
  73938. /**
  73939. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73940. */
  73941. set: function (value) {
  73942. if (this._colorGradingTexture === value) {
  73943. return;
  73944. }
  73945. this._colorGradingTexture = value;
  73946. this._updateParameters();
  73947. },
  73948. enumerable: true,
  73949. configurable: true
  73950. });
  73951. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  73952. /**
  73953. * Gets wether the color grading effect is enabled.
  73954. */
  73955. get: function () {
  73956. return this._colorGradingEnabled;
  73957. },
  73958. /**
  73959. * Sets wether the color grading effect is enabled.
  73960. */
  73961. set: function (value) {
  73962. if (this._colorGradingEnabled === value) {
  73963. return;
  73964. }
  73965. this._colorGradingEnabled = value;
  73966. this._updateParameters();
  73967. },
  73968. enumerable: true,
  73969. configurable: true
  73970. });
  73971. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  73972. /**
  73973. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73974. */
  73975. get: function () {
  73976. return this._colorGradingWithGreenDepth;
  73977. },
  73978. /**
  73979. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73980. */
  73981. set: function (value) {
  73982. if (this._colorGradingWithGreenDepth === value) {
  73983. return;
  73984. }
  73985. this._colorGradingWithGreenDepth = value;
  73986. this._updateParameters();
  73987. },
  73988. enumerable: true,
  73989. configurable: true
  73990. });
  73991. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  73992. /**
  73993. * Gets wether the color grading texture contains BGR values.
  73994. */
  73995. get: function () {
  73996. return this._colorGradingBGR;
  73997. },
  73998. /**
  73999. * Sets wether the color grading texture contains BGR values.
  74000. */
  74001. set: function (value) {
  74002. if (this._colorGradingBGR === value) {
  74003. return;
  74004. }
  74005. this._colorGradingBGR = value;
  74006. this._updateParameters();
  74007. },
  74008. enumerable: true,
  74009. configurable: true
  74010. });
  74011. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  74012. /**
  74013. * Gets the Exposure used in the effect.
  74014. */
  74015. get: function () {
  74016. return this._exposure;
  74017. },
  74018. /**
  74019. * Sets the Exposure used in the effect.
  74020. */
  74021. set: function (value) {
  74022. if (this._exposure === value) {
  74023. return;
  74024. }
  74025. this._exposure = value;
  74026. this._updateParameters();
  74027. },
  74028. enumerable: true,
  74029. configurable: true
  74030. });
  74031. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  74032. /**
  74033. * Gets wether the tone mapping effect is enabled.
  74034. */
  74035. get: function () {
  74036. return this._toneMappingEnabled;
  74037. },
  74038. /**
  74039. * Sets wether the tone mapping effect is enabled.
  74040. */
  74041. set: function (value) {
  74042. if (this._toneMappingEnabled === value) {
  74043. return;
  74044. }
  74045. this._toneMappingEnabled = value;
  74046. this._updateParameters();
  74047. },
  74048. enumerable: true,
  74049. configurable: true
  74050. });
  74051. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  74052. /**
  74053. * Gets the type of tone mapping effect.
  74054. */
  74055. get: function () {
  74056. return this._toneMappingType;
  74057. },
  74058. /**
  74059. * Sets the type of tone mapping effect used in BabylonJS.
  74060. */
  74061. set: function (value) {
  74062. if (this._toneMappingType === value) {
  74063. return;
  74064. }
  74065. this._toneMappingType = value;
  74066. this._updateParameters();
  74067. },
  74068. enumerable: true,
  74069. configurable: true
  74070. });
  74071. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  74072. /**
  74073. * Gets the contrast used in the effect.
  74074. */
  74075. get: function () {
  74076. return this._contrast;
  74077. },
  74078. /**
  74079. * Sets the contrast used in the effect.
  74080. */
  74081. set: function (value) {
  74082. if (this._contrast === value) {
  74083. return;
  74084. }
  74085. this._contrast = value;
  74086. this._updateParameters();
  74087. },
  74088. enumerable: true,
  74089. configurable: true
  74090. });
  74091. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  74092. /**
  74093. * Gets the vignette blend mode allowing different kind of effect.
  74094. */
  74095. get: function () {
  74096. return this._vignetteBlendMode;
  74097. },
  74098. /**
  74099. * Sets the vignette blend mode allowing different kind of effect.
  74100. */
  74101. set: function (value) {
  74102. if (this._vignetteBlendMode === value) {
  74103. return;
  74104. }
  74105. this._vignetteBlendMode = value;
  74106. this._updateParameters();
  74107. },
  74108. enumerable: true,
  74109. configurable: true
  74110. });
  74111. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  74112. /**
  74113. * Gets wether the vignette effect is enabled.
  74114. */
  74115. get: function () {
  74116. return this._vignetteEnabled;
  74117. },
  74118. /**
  74119. * Sets wether the vignette effect is enabled.
  74120. */
  74121. set: function (value) {
  74122. if (this._vignetteEnabled === value) {
  74123. return;
  74124. }
  74125. this._vignetteEnabled = value;
  74126. this._updateParameters();
  74127. },
  74128. enumerable: true,
  74129. configurable: true
  74130. });
  74131. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  74132. /**
  74133. * Gets wether the image processing is applied through a post process or not.
  74134. */
  74135. get: function () {
  74136. return this._applyByPostProcess;
  74137. },
  74138. /**
  74139. * Sets wether the image processing is applied through a post process or not.
  74140. */
  74141. set: function (value) {
  74142. if (this._applyByPostProcess === value) {
  74143. return;
  74144. }
  74145. this._applyByPostProcess = value;
  74146. this._updateParameters();
  74147. },
  74148. enumerable: true,
  74149. configurable: true
  74150. });
  74151. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  74152. /**
  74153. * Gets wether the image processing is enabled or not.
  74154. */
  74155. get: function () {
  74156. return this._isEnabled;
  74157. },
  74158. /**
  74159. * Sets wether the image processing is enabled or not.
  74160. */
  74161. set: function (value) {
  74162. if (this._isEnabled === value) {
  74163. return;
  74164. }
  74165. this._isEnabled = value;
  74166. this._updateParameters();
  74167. },
  74168. enumerable: true,
  74169. configurable: true
  74170. });
  74171. /**
  74172. * Method called each time the image processing information changes requires to recompile the effect.
  74173. */
  74174. ImageProcessingConfiguration.prototype._updateParameters = function () {
  74175. this.onUpdateParameters.notifyObservers(this);
  74176. };
  74177. /**
  74178. * Gets the current class name.
  74179. * @return "ImageProcessingConfiguration"
  74180. */
  74181. ImageProcessingConfiguration.prototype.getClassName = function () {
  74182. return "ImageProcessingConfiguration";
  74183. };
  74184. /**
  74185. * Prepare the list of uniforms associated with the Image Processing effects.
  74186. * @param uniforms The list of uniforms used in the effect
  74187. * @param defines the list of defines currently in use
  74188. */
  74189. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  74190. if (defines.EXPOSURE) {
  74191. uniforms.push("exposureLinear");
  74192. }
  74193. if (defines.CONTRAST) {
  74194. uniforms.push("contrast");
  74195. }
  74196. if (defines.COLORGRADING) {
  74197. uniforms.push("colorTransformSettings");
  74198. }
  74199. if (defines.VIGNETTE) {
  74200. uniforms.push("vInverseScreenSize");
  74201. uniforms.push("vignetteSettings1");
  74202. uniforms.push("vignetteSettings2");
  74203. }
  74204. if (defines.COLORCURVES) {
  74205. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  74206. }
  74207. };
  74208. /**
  74209. * Prepare the list of samplers associated with the Image Processing effects.
  74210. * @param samplersList The list of uniforms used in the effect
  74211. * @param defines the list of defines currently in use
  74212. */
  74213. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  74214. if (defines.COLORGRADING) {
  74215. samplersList.push("txColorTransform");
  74216. }
  74217. };
  74218. /**
  74219. * Prepare the list of defines associated to the shader.
  74220. * @param defines the list of defines to complete
  74221. * @param forPostProcess Define if we are currently in post process mode or not
  74222. */
  74223. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  74224. if (forPostProcess === void 0) { forPostProcess = false; }
  74225. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  74226. defines.VIGNETTE = false;
  74227. defines.TONEMAPPING = false;
  74228. defines.TONEMAPPING_ACES = false;
  74229. defines.CONTRAST = false;
  74230. defines.EXPOSURE = false;
  74231. defines.COLORCURVES = false;
  74232. defines.COLORGRADING = false;
  74233. defines.COLORGRADING3D = false;
  74234. defines.IMAGEPROCESSING = false;
  74235. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  74236. return;
  74237. }
  74238. defines.VIGNETTE = this.vignetteEnabled;
  74239. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  74240. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  74241. defines.TONEMAPPING = this.toneMappingEnabled;
  74242. switch (this._toneMappingType) {
  74243. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  74244. defines.TONEMAPPING_ACES = true;
  74245. break;
  74246. default:
  74247. defines.TONEMAPPING_ACES = false;
  74248. break;
  74249. }
  74250. defines.CONTRAST = (this.contrast !== 1.0);
  74251. defines.EXPOSURE = (this.exposure !== 1.0);
  74252. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  74253. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  74254. if (defines.COLORGRADING) {
  74255. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  74256. }
  74257. else {
  74258. defines.COLORGRADING3D = false;
  74259. }
  74260. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  74261. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  74262. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  74263. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  74264. };
  74265. /**
  74266. * Returns true if all the image processing information are ready.
  74267. * @returns True if ready, otherwise, false
  74268. */
  74269. ImageProcessingConfiguration.prototype.isReady = function () {
  74270. // Color Grading texure can not be none blocking.
  74271. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  74272. };
  74273. /**
  74274. * Binds the image processing to the shader.
  74275. * @param effect The effect to bind to
  74276. * @param aspectRatio Define the current aspect ratio of the effect
  74277. */
  74278. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  74279. if (aspectRatio === void 0) { aspectRatio = 1; }
  74280. // Color Curves
  74281. if (this._colorCurvesEnabled && this.colorCurves) {
  74282. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  74283. }
  74284. // Vignette
  74285. if (this._vignetteEnabled) {
  74286. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  74287. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  74288. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  74289. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  74290. var vignetteScaleX = vignetteScaleY * aspectRatio;
  74291. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  74292. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  74293. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  74294. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  74295. var vignettePower = -2.0 * this.vignetteWeight;
  74296. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  74297. }
  74298. // Exposure
  74299. effect.setFloat("exposureLinear", this.exposure);
  74300. // Contrast
  74301. effect.setFloat("contrast", this.contrast);
  74302. // Color transform settings
  74303. if (this.colorGradingTexture) {
  74304. effect.setTexture("txColorTransform", this.colorGradingTexture);
  74305. var textureSize = this.colorGradingTexture.getSize().height;
  74306. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  74307. 0.5 / textureSize, // textureOffset
  74308. textureSize, // textureSize
  74309. this.colorGradingTexture.level // weight
  74310. );
  74311. }
  74312. };
  74313. /**
  74314. * Clones the current image processing instance.
  74315. * @return The cloned image processing
  74316. */
  74317. ImageProcessingConfiguration.prototype.clone = function () {
  74318. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  74319. };
  74320. /**
  74321. * Serializes the current image processing instance to a json representation.
  74322. * @return a JSON representation
  74323. */
  74324. ImageProcessingConfiguration.prototype.serialize = function () {
  74325. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  74326. };
  74327. /**
  74328. * Parses the image processing from a json representation.
  74329. * @param source the JSON source to parse
  74330. * @return The parsed image processing
  74331. */
  74332. ImageProcessingConfiguration.Parse = function (source) {
  74333. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  74334. };
  74335. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  74336. /**
  74337. * Used to apply the vignette as a mix with the pixel color.
  74338. */
  74339. get: function () {
  74340. return this._VIGNETTEMODE_MULTIPLY;
  74341. },
  74342. enumerable: true,
  74343. configurable: true
  74344. });
  74345. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  74346. /**
  74347. * Used to apply the vignette as a replacement of the pixel color.
  74348. */
  74349. get: function () {
  74350. return this._VIGNETTEMODE_OPAQUE;
  74351. },
  74352. enumerable: true,
  74353. configurable: true
  74354. });
  74355. /**
  74356. * Default tone mapping applied in BabylonJS.
  74357. */
  74358. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  74359. /**
  74360. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74361. * to other engines rendering to increase portability.
  74362. */
  74363. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  74364. // Static constants associated to the image processing.
  74365. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  74366. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  74367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  74369. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  74370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74372. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  74373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  74375. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  74376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74378. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  74379. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74381. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  74382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74384. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  74385. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74386. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74387. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  74388. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74390. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  74391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74393. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  74394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74396. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  74397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74399. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  74400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74402. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  74403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74405. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  74406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74408. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  74409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  74411. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  74412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74414. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  74415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74417. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  74418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74420. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  74421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74423. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  74424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  74425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  74426. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  74427. return ImageProcessingConfiguration;
  74428. }());
  74429. // References the dependencies.
  74430. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  74431. /***/ }),
  74432. /***/ "./Materials/index.ts":
  74433. /*!****************************!*\
  74434. !*** ./Materials/index.ts ***!
  74435. \****************************/
  74436. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, EffectRenderer, EffectWrapper, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, NodeMaterialBlockTargets, NodeMaterialBlockConnectionPointTypes, NodeMaterialConnectionPoint, NodeMaterialBlock, NodeMaterialDefines, NodeMaterial, NodeMaterialWellKnownValues, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, _BasisTextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, MultiplyBlock, AddBlock, ClampBlock, CrossBlock, DotBlock, TransformBlock, NodeMaterialOptimizer, VertexOutputBlock, BonesBlock, InstancesBlock, MorphTargetsBlock, FragmentOutputBlock, AlphaTestBlock, ColorMergerBlock, VectorMergerBlock, ColorSplitterBlock, VectorSplitterBlock, ImageProcessingBlock, FogBlock, LightBlock, TextureBlock, InputBlock */
  74437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74438. "use strict";
  74439. __webpack_require__.r(__webpack_exports__);
  74440. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  74441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  74442. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  74443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  74444. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  74445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  74446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  74447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  74448. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  74449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  74450. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  74451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  74452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  74453. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  74454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  74455. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  74456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  74457. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  74458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  74459. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  74460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  74461. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  74462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterialDefines"]; });
  74463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  74464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  74465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  74466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  74467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  74468. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  74469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  74470. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  74471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  74472. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  74473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  74474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  74475. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  74476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  74477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  74478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  74479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  74480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  74481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  74482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  74483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  74484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  74485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  74486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  74487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  74488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  74489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  74490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  74491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  74492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HtmlElementTexture"]; });
  74493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  74494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  74495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  74496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  74497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BasisTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_BasisTextureLoader"]; });
  74498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  74499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  74500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  74501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  74502. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  74503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  74504. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  74505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  74506. /* harmony import */ var _Node_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Node/index */ "./Materials/Node/index.ts");
  74507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockTargets", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialBlockTargets"]; });
  74508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockConnectionPointTypes", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialBlockConnectionPointTypes"]; });
  74509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialConnectionPoint", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialConnectionPoint"]; });
  74510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialBlock"]; });
  74511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialDefines", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialDefines"]; });
  74512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterial", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterial"]; });
  74513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialWellKnownValues", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialWellKnownValues"]; });
  74514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiplyBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["MultiplyBlock"]; });
  74515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AddBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["AddBlock"]; });
  74516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClampBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["ClampBlock"]; });
  74517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CrossBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["CrossBlock"]; });
  74518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DotBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["DotBlock"]; });
  74519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["TransformBlock"]; });
  74520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialOptimizer", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["NodeMaterialOptimizer"]; });
  74521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["VertexOutputBlock"]; });
  74522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["BonesBlock"]; });
  74523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["InstancesBlock"]; });
  74524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["MorphTargetsBlock"]; });
  74525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["FragmentOutputBlock"]; });
  74526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["AlphaTestBlock"]; });
  74527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["ColorMergerBlock"]; });
  74528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["VectorMergerBlock"]; });
  74529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["ColorSplitterBlock"]; });
  74530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["VectorSplitterBlock"]; });
  74531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingBlock"]; });
  74532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["FogBlock"]; });
  74533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["LightBlock"]; });
  74534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["TextureBlock"]; });
  74535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return _Node_index__WEBPACK_IMPORTED_MODULE_16__["InputBlock"]; });
  74536. /* harmony import */ var _effectRenderer__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./effectRenderer */ "./Materials/effectRenderer.ts");
  74537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectRenderer", function() { return _effectRenderer__WEBPACK_IMPORTED_MODULE_17__["EffectRenderer"]; });
  74538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectWrapper", function() { return _effectRenderer__WEBPACK_IMPORTED_MODULE_17__["EffectWrapper"]; });
  74539. /***/ }),
  74540. /***/ "./Materials/material.ts":
  74541. /*!*******************************!*\
  74542. !*** ./Materials/material.ts ***!
  74543. \*******************************/
  74544. /*! exports provided: Material */
  74545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74546. "use strict";
  74547. __webpack_require__.r(__webpack_exports__);
  74548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  74549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  74550. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  74551. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  74552. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  74553. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  74554. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  74555. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  74556. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  74557. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  74558. /* harmony import */ var _Maths_math_plane__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Maths/math.plane */ "./Maths/math.plane.ts");
  74559. /**
  74560. * Base class for the main features of a material in Babylon.js
  74561. */
  74562. var Material = /** @class */ (function () {
  74563. /**
  74564. * Creates a material instance
  74565. * @param name defines the name of the material
  74566. * @param scene defines the scene to reference
  74567. * @param doNotAdd specifies if the material should be added to the scene
  74568. */
  74569. function Material(name, scene, doNotAdd) {
  74570. /**
  74571. * Gets or sets user defined metadata
  74572. */
  74573. this.metadata = null;
  74574. /**
  74575. * For internal use only. Please do not use.
  74576. */
  74577. this.reservedDataStore = null;
  74578. /**
  74579. * Specifies if the ready state should be checked on each call
  74580. */
  74581. this.checkReadyOnEveryCall = false;
  74582. /**
  74583. * Specifies if the ready state should be checked once
  74584. */
  74585. this.checkReadyOnlyOnce = false;
  74586. /**
  74587. * The state of the material
  74588. */
  74589. this.state = "";
  74590. /**
  74591. * The alpha value of the material
  74592. */
  74593. this._alpha = 1.0;
  74594. /**
  74595. * Specifies if back face culling is enabled
  74596. */
  74597. this._backFaceCulling = true;
  74598. /**
  74599. * Callback triggered when the material is compiled
  74600. */
  74601. this.onCompiled = null;
  74602. /**
  74603. * Callback triggered when an error occurs
  74604. */
  74605. this.onError = null;
  74606. /**
  74607. * Callback triggered to get the render target textures
  74608. */
  74609. this.getRenderTargetTextures = null;
  74610. /**
  74611. * Specifies if the material should be serialized
  74612. */
  74613. this.doNotSerialize = false;
  74614. /**
  74615. * @hidden
  74616. */
  74617. this._storeEffectOnSubMeshes = false;
  74618. /**
  74619. * Stores the animations for the material
  74620. */
  74621. this.animations = null;
  74622. /**
  74623. * An event triggered when the material is disposed
  74624. */
  74625. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  74626. /**
  74627. * An observer which watches for dispose events
  74628. */
  74629. this._onDisposeObserver = null;
  74630. this._onUnBindObservable = null;
  74631. /**
  74632. * An observer which watches for bind events
  74633. */
  74634. this._onBindObserver = null;
  74635. /**
  74636. * Stores the value of the alpha mode
  74637. */
  74638. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].ALPHA_COMBINE;
  74639. /**
  74640. * Stores the state of the need depth pre-pass value
  74641. */
  74642. this._needDepthPrePass = false;
  74643. /**
  74644. * Specifies if depth writing should be disabled
  74645. */
  74646. this.disableDepthWrite = false;
  74647. /**
  74648. * Specifies if depth writing should be forced
  74649. */
  74650. this.forceDepthWrite = false;
  74651. /**
  74652. * Specifies if there should be a separate pass for culling
  74653. */
  74654. this.separateCullingPass = false;
  74655. /**
  74656. * Stores the state specifing if fog should be enabled
  74657. */
  74658. this._fogEnabled = true;
  74659. /**
  74660. * Stores the size of points
  74661. */
  74662. this.pointSize = 1.0;
  74663. /**
  74664. * Stores the z offset value
  74665. */
  74666. this.zOffset = 0;
  74667. /**
  74668. * @hidden
  74669. * Stores the effects for the material
  74670. */
  74671. this._effect = null;
  74672. /**
  74673. * @hidden
  74674. * Specifies if the material was previously ready
  74675. */
  74676. this._wasPreviouslyReady = false;
  74677. /**
  74678. * Specifies if uniform buffers should be used
  74679. */
  74680. this._useUBO = false;
  74681. /**
  74682. * Stores the fill mode state
  74683. */
  74684. this._fillMode = Material.TriangleFillMode;
  74685. /**
  74686. * Specifies if the depth write state should be cached
  74687. */
  74688. this._cachedDepthWriteState = false;
  74689. /** @hidden */
  74690. this._indexInSceneMaterialArray = -1;
  74691. /** @hidden */
  74692. this.meshMap = null;
  74693. this.name = name;
  74694. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  74695. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  74696. this.uniqueId = this._scene.getUniqueId();
  74697. if (this._scene.useRightHandedSystem) {
  74698. this.sideOrientation = Material.ClockWiseSideOrientation;
  74699. }
  74700. else {
  74701. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  74702. }
  74703. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_6__["UniformBuffer"](this._scene.getEngine());
  74704. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  74705. if (!doNotAdd) {
  74706. this._scene.addMaterial(this);
  74707. }
  74708. if (this._scene.useMaterialMeshMap) {
  74709. this.meshMap = {};
  74710. }
  74711. }
  74712. Object.defineProperty(Material.prototype, "alpha", {
  74713. /**
  74714. * Gets the alpha value of the material
  74715. */
  74716. get: function () {
  74717. return this._alpha;
  74718. },
  74719. /**
  74720. * Sets the alpha value of the material
  74721. */
  74722. set: function (value) {
  74723. if (this._alpha === value) {
  74724. return;
  74725. }
  74726. this._alpha = value;
  74727. this.markAsDirty(Material.MiscDirtyFlag);
  74728. },
  74729. enumerable: true,
  74730. configurable: true
  74731. });
  74732. Object.defineProperty(Material.prototype, "backFaceCulling", {
  74733. /**
  74734. * Gets the back-face culling state
  74735. */
  74736. get: function () {
  74737. return this._backFaceCulling;
  74738. },
  74739. /**
  74740. * Sets the back-face culling state
  74741. */
  74742. set: function (value) {
  74743. if (this._backFaceCulling === value) {
  74744. return;
  74745. }
  74746. this._backFaceCulling = value;
  74747. this.markAsDirty(Material.TextureDirtyFlag);
  74748. },
  74749. enumerable: true,
  74750. configurable: true
  74751. });
  74752. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  74753. /**
  74754. * Gets a boolean indicating that current material needs to register RTT
  74755. */
  74756. get: function () {
  74757. return false;
  74758. },
  74759. enumerable: true,
  74760. configurable: true
  74761. });
  74762. Object.defineProperty(Material.prototype, "onDispose", {
  74763. /**
  74764. * Called during a dispose event
  74765. */
  74766. set: function (callback) {
  74767. if (this._onDisposeObserver) {
  74768. this.onDisposeObservable.remove(this._onDisposeObserver);
  74769. }
  74770. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  74771. },
  74772. enumerable: true,
  74773. configurable: true
  74774. });
  74775. Object.defineProperty(Material.prototype, "onBindObservable", {
  74776. /**
  74777. * An event triggered when the material is bound
  74778. */
  74779. get: function () {
  74780. if (!this._onBindObservable) {
  74781. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  74782. }
  74783. return this._onBindObservable;
  74784. },
  74785. enumerable: true,
  74786. configurable: true
  74787. });
  74788. Object.defineProperty(Material.prototype, "onBind", {
  74789. /**
  74790. * Called during a bind event
  74791. */
  74792. set: function (callback) {
  74793. if (this._onBindObserver) {
  74794. this.onBindObservable.remove(this._onBindObserver);
  74795. }
  74796. this._onBindObserver = this.onBindObservable.add(callback);
  74797. },
  74798. enumerable: true,
  74799. configurable: true
  74800. });
  74801. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  74802. /**
  74803. * An event triggered when the material is unbound
  74804. */
  74805. get: function () {
  74806. if (!this._onUnBindObservable) {
  74807. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  74808. }
  74809. return this._onUnBindObservable;
  74810. },
  74811. enumerable: true,
  74812. configurable: true
  74813. });
  74814. Object.defineProperty(Material.prototype, "alphaMode", {
  74815. /**
  74816. * Gets the value of the alpha mode
  74817. */
  74818. get: function () {
  74819. return this._alphaMode;
  74820. },
  74821. /**
  74822. * Sets the value of the alpha mode.
  74823. *
  74824. * | Value | Type | Description |
  74825. * | --- | --- | --- |
  74826. * | 0 | ALPHA_DISABLE | |
  74827. * | 1 | ALPHA_ADD | |
  74828. * | 2 | ALPHA_COMBINE | |
  74829. * | 3 | ALPHA_SUBTRACT | |
  74830. * | 4 | ALPHA_MULTIPLY | |
  74831. * | 5 | ALPHA_MAXIMIZED | |
  74832. * | 6 | ALPHA_ONEONE | |
  74833. * | 7 | ALPHA_PREMULTIPLIED | |
  74834. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  74835. * | 9 | ALPHA_INTERPOLATE | |
  74836. * | 10 | ALPHA_SCREENMODE | |
  74837. *
  74838. */
  74839. set: function (value) {
  74840. if (this._alphaMode === value) {
  74841. return;
  74842. }
  74843. this._alphaMode = value;
  74844. this.markAsDirty(Material.TextureDirtyFlag);
  74845. },
  74846. enumerable: true,
  74847. configurable: true
  74848. });
  74849. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  74850. /**
  74851. * Gets the depth pre-pass value
  74852. */
  74853. get: function () {
  74854. return this._needDepthPrePass;
  74855. },
  74856. /**
  74857. * Sets the need depth pre-pass value
  74858. */
  74859. set: function (value) {
  74860. if (this._needDepthPrePass === value) {
  74861. return;
  74862. }
  74863. this._needDepthPrePass = value;
  74864. if (this._needDepthPrePass) {
  74865. this.checkReadyOnEveryCall = true;
  74866. }
  74867. },
  74868. enumerable: true,
  74869. configurable: true
  74870. });
  74871. Object.defineProperty(Material.prototype, "fogEnabled", {
  74872. /**
  74873. * Gets the value of the fog enabled state
  74874. */
  74875. get: function () {
  74876. return this._fogEnabled;
  74877. },
  74878. /**
  74879. * Sets the state for enabling fog
  74880. */
  74881. set: function (value) {
  74882. if (this._fogEnabled === value) {
  74883. return;
  74884. }
  74885. this._fogEnabled = value;
  74886. this.markAsDirty(Material.MiscDirtyFlag);
  74887. },
  74888. enumerable: true,
  74889. configurable: true
  74890. });
  74891. Object.defineProperty(Material.prototype, "wireframe", {
  74892. /**
  74893. * Gets a value specifying if wireframe mode is enabled
  74894. */
  74895. get: function () {
  74896. switch (this._fillMode) {
  74897. case Material.WireFrameFillMode:
  74898. case Material.LineListDrawMode:
  74899. case Material.LineLoopDrawMode:
  74900. case Material.LineStripDrawMode:
  74901. return true;
  74902. }
  74903. return this._scene.forceWireframe;
  74904. },
  74905. /**
  74906. * Sets the state of wireframe mode
  74907. */
  74908. set: function (value) {
  74909. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  74910. },
  74911. enumerable: true,
  74912. configurable: true
  74913. });
  74914. Object.defineProperty(Material.prototype, "pointsCloud", {
  74915. /**
  74916. * Gets the value specifying if point clouds are enabled
  74917. */
  74918. get: function () {
  74919. switch (this._fillMode) {
  74920. case Material.PointFillMode:
  74921. case Material.PointListDrawMode:
  74922. return true;
  74923. }
  74924. return this._scene.forcePointsCloud;
  74925. },
  74926. /**
  74927. * Sets the state of point cloud mode
  74928. */
  74929. set: function (value) {
  74930. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  74931. },
  74932. enumerable: true,
  74933. configurable: true
  74934. });
  74935. Object.defineProperty(Material.prototype, "fillMode", {
  74936. /**
  74937. * Gets the material fill mode
  74938. */
  74939. get: function () {
  74940. return this._fillMode;
  74941. },
  74942. /**
  74943. * Sets the material fill mode
  74944. */
  74945. set: function (value) {
  74946. if (this._fillMode === value) {
  74947. return;
  74948. }
  74949. this._fillMode = value;
  74950. this.markAsDirty(Material.MiscDirtyFlag);
  74951. },
  74952. enumerable: true,
  74953. configurable: true
  74954. });
  74955. /**
  74956. * Returns a string representation of the current material
  74957. * @param fullDetails defines a boolean indicating which levels of logging is desired
  74958. * @returns a string with material information
  74959. */
  74960. Material.prototype.toString = function (fullDetails) {
  74961. var ret = "Name: " + this.name;
  74962. if (fullDetails) {
  74963. }
  74964. return ret;
  74965. };
  74966. /**
  74967. * Gets the class name of the material
  74968. * @returns a string with the class name of the material
  74969. */
  74970. Material.prototype.getClassName = function () {
  74971. return "Material";
  74972. };
  74973. Object.defineProperty(Material.prototype, "isFrozen", {
  74974. /**
  74975. * Specifies if updates for the material been locked
  74976. */
  74977. get: function () {
  74978. return this.checkReadyOnlyOnce;
  74979. },
  74980. enumerable: true,
  74981. configurable: true
  74982. });
  74983. /**
  74984. * Locks updates for the material
  74985. */
  74986. Material.prototype.freeze = function () {
  74987. this.checkReadyOnlyOnce = true;
  74988. };
  74989. /**
  74990. * Unlocks updates for the material
  74991. */
  74992. Material.prototype.unfreeze = function () {
  74993. this.checkReadyOnlyOnce = false;
  74994. };
  74995. /**
  74996. * Specifies if the material is ready to be used
  74997. * @param mesh defines the mesh to check
  74998. * @param useInstances specifies if instances should be used
  74999. * @returns a boolean indicating if the material is ready to be used
  75000. */
  75001. Material.prototype.isReady = function (mesh, useInstances) {
  75002. return true;
  75003. };
  75004. /**
  75005. * Specifies that the submesh is ready to be used
  75006. * @param mesh defines the mesh to check
  75007. * @param subMesh defines which submesh to check
  75008. * @param useInstances specifies that instances should be used
  75009. * @returns a boolean indicating that the submesh is ready or not
  75010. */
  75011. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  75012. return false;
  75013. };
  75014. /**
  75015. * Returns the material effect
  75016. * @returns the effect associated with the material
  75017. */
  75018. Material.prototype.getEffect = function () {
  75019. return this._effect;
  75020. };
  75021. /**
  75022. * Returns the current scene
  75023. * @returns a Scene
  75024. */
  75025. Material.prototype.getScene = function () {
  75026. return this._scene;
  75027. };
  75028. /**
  75029. * Specifies if the material will require alpha blending
  75030. * @returns a boolean specifying if alpha blending is needed
  75031. */
  75032. Material.prototype.needAlphaBlending = function () {
  75033. return (this.alpha < 1.0);
  75034. };
  75035. /**
  75036. * Specifies if the mesh will require alpha blending
  75037. * @param mesh defines the mesh to check
  75038. * @returns a boolean specifying if alpha blending is needed for the mesh
  75039. */
  75040. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  75041. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  75042. };
  75043. /**
  75044. * Specifies if this material should be rendered in alpha test mode
  75045. * @returns a boolean specifying if an alpha test is needed.
  75046. */
  75047. Material.prototype.needAlphaTesting = function () {
  75048. return false;
  75049. };
  75050. /**
  75051. * Gets the texture used for the alpha test
  75052. * @returns the texture to use for alpha testing
  75053. */
  75054. Material.prototype.getAlphaTestTexture = function () {
  75055. return null;
  75056. };
  75057. /**
  75058. * Marks the material to indicate that it needs to be re-calculated
  75059. */
  75060. Material.prototype.markDirty = function () {
  75061. this._wasPreviouslyReady = false;
  75062. };
  75063. /** @hidden */
  75064. Material.prototype._preBind = function (effect, overrideOrientation) {
  75065. if (overrideOrientation === void 0) { overrideOrientation = null; }
  75066. var engine = this._scene.getEngine();
  75067. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  75068. var reverse = orientation === Material.ClockWiseSideOrientation;
  75069. engine.enableEffect(effect ? effect : this._effect);
  75070. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  75071. return reverse;
  75072. };
  75073. /**
  75074. * Binds the material to the mesh
  75075. * @param world defines the world transformation matrix
  75076. * @param mesh defines the mesh to bind the material to
  75077. */
  75078. Material.prototype.bind = function (world, mesh) {
  75079. };
  75080. /**
  75081. * Binds the submesh to the material
  75082. * @param world defines the world transformation matrix
  75083. * @param mesh defines the mesh containing the submesh
  75084. * @param subMesh defines the submesh to bind the material to
  75085. */
  75086. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  75087. };
  75088. /**
  75089. * Binds the world matrix to the material
  75090. * @param world defines the world transformation matrix
  75091. */
  75092. Material.prototype.bindOnlyWorldMatrix = function (world) {
  75093. };
  75094. /**
  75095. * Binds the scene's uniform buffer to the effect.
  75096. * @param effect defines the effect to bind to the scene uniform buffer
  75097. * @param sceneUbo defines the uniform buffer storing scene data
  75098. */
  75099. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  75100. sceneUbo.bindToEffect(effect, "Scene");
  75101. };
  75102. /**
  75103. * Binds the view matrix to the effect
  75104. * @param effect defines the effect to bind the view matrix to
  75105. */
  75106. Material.prototype.bindView = function (effect) {
  75107. if (!this._useUBO) {
  75108. effect.setMatrix("view", this.getScene().getViewMatrix());
  75109. }
  75110. else {
  75111. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  75112. }
  75113. };
  75114. /**
  75115. * Binds the view projection matrix to the effect
  75116. * @param effect defines the effect to bind the view projection matrix to
  75117. */
  75118. Material.prototype.bindViewProjection = function (effect) {
  75119. if (!this._useUBO) {
  75120. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  75121. }
  75122. else {
  75123. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  75124. }
  75125. };
  75126. /**
  75127. * Specifies if material alpha testing should be turned on for the mesh
  75128. * @param mesh defines the mesh to check
  75129. */
  75130. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  75131. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  75132. };
  75133. /**
  75134. * Processes to execute after binding the material to a mesh
  75135. * @param mesh defines the rendered mesh
  75136. */
  75137. Material.prototype._afterBind = function (mesh) {
  75138. this._scene._cachedMaterial = this;
  75139. if (mesh) {
  75140. this._scene._cachedVisibility = mesh.visibility;
  75141. }
  75142. else {
  75143. this._scene._cachedVisibility = 1;
  75144. }
  75145. if (this._onBindObservable && mesh) {
  75146. this._onBindObservable.notifyObservers(mesh);
  75147. }
  75148. if (this.disableDepthWrite) {
  75149. var engine = this._scene.getEngine();
  75150. this._cachedDepthWriteState = engine.getDepthWrite();
  75151. engine.setDepthWrite(false);
  75152. }
  75153. };
  75154. /**
  75155. * Unbinds the material from the mesh
  75156. */
  75157. Material.prototype.unbind = function () {
  75158. if (this._onUnBindObservable) {
  75159. this._onUnBindObservable.notifyObservers(this);
  75160. }
  75161. if (this.disableDepthWrite) {
  75162. var engine = this._scene.getEngine();
  75163. engine.setDepthWrite(this._cachedDepthWriteState);
  75164. }
  75165. };
  75166. /**
  75167. * Gets the active textures from the material
  75168. * @returns an array of textures
  75169. */
  75170. Material.prototype.getActiveTextures = function () {
  75171. return [];
  75172. };
  75173. /**
  75174. * Specifies if the material uses a texture
  75175. * @param texture defines the texture to check against the material
  75176. * @returns a boolean specifying if the material uses the texture
  75177. */
  75178. Material.prototype.hasTexture = function (texture) {
  75179. return false;
  75180. };
  75181. /**
  75182. * Makes a duplicate of the material, and gives it a new name
  75183. * @param name defines the new name for the duplicated material
  75184. * @returns the cloned material
  75185. */
  75186. Material.prototype.clone = function (name) {
  75187. return null;
  75188. };
  75189. /**
  75190. * Gets the meshes bound to the material
  75191. * @returns an array of meshes bound to the material
  75192. */
  75193. Material.prototype.getBindedMeshes = function () {
  75194. var _this = this;
  75195. if (this.meshMap) {
  75196. var result = new Array();
  75197. for (var meshId in this.meshMap) {
  75198. var mesh = this.meshMap[meshId];
  75199. if (mesh) {
  75200. result.push(mesh);
  75201. }
  75202. }
  75203. return result;
  75204. }
  75205. else {
  75206. var meshes = this._scene.meshes;
  75207. return meshes.filter(function (mesh) { return mesh.material === _this; });
  75208. }
  75209. };
  75210. /**
  75211. * Force shader compilation
  75212. * @param mesh defines the mesh associated with this material
  75213. * @param onCompiled defines a function to execute once the material is compiled
  75214. * @param options defines the options to configure the compilation
  75215. */
  75216. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  75217. var _this = this;
  75218. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  75219. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_5__["BaseSubMesh"]();
  75220. var scene = this.getScene();
  75221. var checkReady = function () {
  75222. if (!_this._scene || !_this._scene.getEngine()) {
  75223. return;
  75224. }
  75225. if (subMesh._materialDefines) {
  75226. subMesh._materialDefines._renderId = -1;
  75227. }
  75228. var clipPlaneState = scene.clipPlane;
  75229. if (localOptions.clipPlane) {
  75230. scene.clipPlane = new _Maths_math_plane__WEBPACK_IMPORTED_MODULE_9__["Plane"](0, 0, 0, 1);
  75231. }
  75232. if (_this._storeEffectOnSubMeshes) {
  75233. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  75234. if (onCompiled) {
  75235. onCompiled(_this);
  75236. }
  75237. }
  75238. else {
  75239. setTimeout(checkReady, 16);
  75240. }
  75241. }
  75242. else {
  75243. if (_this.isReady()) {
  75244. if (onCompiled) {
  75245. onCompiled(_this);
  75246. }
  75247. }
  75248. else {
  75249. setTimeout(checkReady, 16);
  75250. }
  75251. }
  75252. if (localOptions.clipPlane) {
  75253. scene.clipPlane = clipPlaneState;
  75254. }
  75255. };
  75256. checkReady();
  75257. };
  75258. /**
  75259. * Force shader compilation
  75260. * @param mesh defines the mesh that will use this material
  75261. * @param options defines additional options for compiling the shaders
  75262. * @returns a promise that resolves when the compilation completes
  75263. */
  75264. Material.prototype.forceCompilationAsync = function (mesh, options) {
  75265. var _this = this;
  75266. return new Promise(function (resolve) {
  75267. _this.forceCompilation(mesh, function () {
  75268. resolve();
  75269. }, options);
  75270. });
  75271. };
  75272. /**
  75273. * Marks a define in the material to indicate that it needs to be re-computed
  75274. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  75275. */
  75276. Material.prototype.markAsDirty = function (flag) {
  75277. if (this.getScene().blockMaterialDirtyMechanism) {
  75278. return;
  75279. }
  75280. Material._DirtyCallbackArray.length = 0;
  75281. if (flag & Material.TextureDirtyFlag) {
  75282. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  75283. }
  75284. if (flag & Material.LightDirtyFlag) {
  75285. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  75286. }
  75287. if (flag & Material.FresnelDirtyFlag) {
  75288. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  75289. }
  75290. if (flag & Material.AttributesDirtyFlag) {
  75291. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  75292. }
  75293. if (flag & Material.MiscDirtyFlag) {
  75294. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  75295. }
  75296. if (Material._DirtyCallbackArray.length) {
  75297. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  75298. }
  75299. this.getScene().resetCachedMaterial();
  75300. };
  75301. /**
  75302. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  75303. * @param func defines a function which checks material defines against the submeshes
  75304. */
  75305. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  75306. if (this.getScene().blockMaterialDirtyMechanism) {
  75307. return;
  75308. }
  75309. var meshes = this.getScene().meshes;
  75310. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  75311. var mesh = meshes_1[_i];
  75312. if (!mesh.subMeshes) {
  75313. continue;
  75314. }
  75315. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  75316. var subMesh = _b[_a];
  75317. if (subMesh.getMaterial() !== this) {
  75318. continue;
  75319. }
  75320. if (!subMesh._materialDefines) {
  75321. continue;
  75322. }
  75323. func(subMesh._materialDefines);
  75324. }
  75325. }
  75326. };
  75327. /**
  75328. * Indicates that we need to re-calculated for all submeshes
  75329. */
  75330. Material.prototype._markAllSubMeshesAsAllDirty = function () {
  75331. this._markAllSubMeshesAsDirty(Material._AllDirtyCallBack);
  75332. };
  75333. /**
  75334. * Indicates that image processing needs to be re-calculated for all submeshes
  75335. */
  75336. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  75337. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  75338. };
  75339. /**
  75340. * Indicates that textures need to be re-calculated for all submeshes
  75341. */
  75342. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  75343. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  75344. };
  75345. /**
  75346. * Indicates that fresnel needs to be re-calculated for all submeshes
  75347. */
  75348. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  75349. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  75350. };
  75351. /**
  75352. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  75353. */
  75354. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  75355. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  75356. };
  75357. /**
  75358. * Indicates that lights need to be re-calculated for all submeshes
  75359. */
  75360. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  75361. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  75362. };
  75363. /**
  75364. * Indicates that attributes need to be re-calculated for all submeshes
  75365. */
  75366. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  75367. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  75368. };
  75369. /**
  75370. * Indicates that misc needs to be re-calculated for all submeshes
  75371. */
  75372. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  75373. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  75374. };
  75375. /**
  75376. * Indicates that textures and misc need to be re-calculated for all submeshes
  75377. */
  75378. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  75379. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  75380. };
  75381. /**
  75382. * Disposes the material
  75383. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75384. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75385. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75386. */
  75387. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  75388. var scene = this.getScene();
  75389. // Animations
  75390. scene.stopAnimation(this);
  75391. scene.freeProcessedMaterials();
  75392. // Remove from scene
  75393. scene.removeMaterial(this);
  75394. if (notBoundToMesh !== true) {
  75395. // Remove from meshes
  75396. if (this.meshMap) {
  75397. for (var meshId in this.meshMap) {
  75398. var mesh = this.meshMap[meshId];
  75399. if (mesh) {
  75400. mesh.material = null; // will set the entry in the map to undefined
  75401. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  75402. }
  75403. }
  75404. }
  75405. else {
  75406. var meshes = scene.meshes;
  75407. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  75408. var mesh = meshes_2[_i];
  75409. if (mesh.material === this && !mesh.sourceMesh) {
  75410. mesh.material = null;
  75411. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  75412. }
  75413. }
  75414. }
  75415. }
  75416. this._uniformBuffer.dispose();
  75417. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  75418. if (forceDisposeEffect && this._effect) {
  75419. if (!this._storeEffectOnSubMeshes) {
  75420. this._effect.dispose();
  75421. }
  75422. this._effect = null;
  75423. }
  75424. // Callback
  75425. this.onDisposeObservable.notifyObservers(this);
  75426. this.onDisposeObservable.clear();
  75427. if (this._onBindObservable) {
  75428. this._onBindObservable.clear();
  75429. }
  75430. if (this._onUnBindObservable) {
  75431. this._onUnBindObservable.clear();
  75432. }
  75433. };
  75434. /** @hidden */
  75435. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  75436. if (mesh.geometry) {
  75437. var geometry = (mesh.geometry);
  75438. if (this._storeEffectOnSubMeshes) {
  75439. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  75440. var subMesh = _a[_i];
  75441. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  75442. if (forceDisposeEffect && subMesh._materialEffect) {
  75443. subMesh._materialEffect.dispose();
  75444. }
  75445. }
  75446. }
  75447. else {
  75448. geometry._releaseVertexArrayObject(this._effect);
  75449. }
  75450. }
  75451. };
  75452. /**
  75453. * Serializes this material
  75454. * @returns the serialized material object
  75455. */
  75456. Material.prototype.serialize = function () {
  75457. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  75458. };
  75459. /**
  75460. * Creates a material from parsed material data
  75461. * @param parsedMaterial defines parsed material data
  75462. * @param scene defines the hosting scene
  75463. * @param rootUrl defines the root URL to use to load textures
  75464. * @returns a new material
  75465. */
  75466. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  75467. if (!parsedMaterial.customType) {
  75468. parsedMaterial.customType = "BABYLON.StandardMaterial";
  75469. }
  75470. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  75471. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  75472. if (!BABYLON.LegacyPBRMaterial) {
  75473. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
  75474. return null;
  75475. }
  75476. }
  75477. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  75478. return materialType.Parse(parsedMaterial, scene, rootUrl);
  75479. };
  75480. /**
  75481. * Returns the triangle fill mode
  75482. */
  75483. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleFillMode;
  75484. /**
  75485. * Returns the wireframe mode
  75486. */
  75487. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_WireFrameFillMode;
  75488. /**
  75489. * Returns the point fill mode
  75490. */
  75491. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_PointFillMode;
  75492. /**
  75493. * Returns the point list draw mode
  75494. */
  75495. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_PointListDrawMode;
  75496. /**
  75497. * Returns the line list draw mode
  75498. */
  75499. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LineListDrawMode;
  75500. /**
  75501. * Returns the line loop draw mode
  75502. */
  75503. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LineLoopDrawMode;
  75504. /**
  75505. * Returns the line strip draw mode
  75506. */
  75507. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LineStripDrawMode;
  75508. /**
  75509. * Returns the triangle strip draw mode
  75510. */
  75511. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleStripDrawMode;
  75512. /**
  75513. * Returns the triangle fan draw mode
  75514. */
  75515. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TriangleFanDrawMode;
  75516. /**
  75517. * Stores the clock-wise side orientation
  75518. */
  75519. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_ClockWiseSideOrientation;
  75520. /**
  75521. * Stores the counter clock-wise side orientation
  75522. */
  75523. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  75524. /**
  75525. * The dirty texture flag value
  75526. */
  75527. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag;
  75528. /**
  75529. * The dirty light flag value
  75530. */
  75531. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_LightDirtyFlag;
  75532. /**
  75533. * The dirty fresnel flag value
  75534. */
  75535. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_FresnelDirtyFlag;
  75536. /**
  75537. * The dirty attribute flag value
  75538. */
  75539. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_AttributesDirtyFlag;
  75540. /**
  75541. * The dirty misc flag value
  75542. */
  75543. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag;
  75544. /**
  75545. * The all dirty flag value
  75546. */
  75547. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_AllDirtyFlag;
  75548. Material._AllDirtyCallBack = function (defines) { return defines.markAllAsDirty(); };
  75549. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  75550. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  75551. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  75552. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  75553. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  75554. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  75555. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  75556. Material._FresnelDirtyCallBack(defines);
  75557. Material._MiscDirtyCallBack(defines);
  75558. };
  75559. Material._TextureAndMiscDirtyCallBack = function (defines) {
  75560. Material._TextureDirtyCallBack(defines);
  75561. Material._MiscDirtyCallBack(defines);
  75562. };
  75563. Material._DirtyCallbackArray = [];
  75564. Material._RunDirtyCallBacks = function (defines) {
  75565. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  75566. var cb = _a[_i];
  75567. cb(defines);
  75568. }
  75569. };
  75570. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75572. ], Material.prototype, "id", void 0);
  75573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75575. ], Material.prototype, "uniqueId", void 0);
  75576. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75577. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75578. ], Material.prototype, "name", void 0);
  75579. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75580. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75581. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  75582. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75583. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75584. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  75585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75586. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75587. ], Material.prototype, "state", void 0);
  75588. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75589. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  75590. ], Material.prototype, "_alpha", void 0);
  75591. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75592. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  75593. ], Material.prototype, "_backFaceCulling", void 0);
  75594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75596. ], Material.prototype, "sideOrientation", void 0);
  75597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  75599. ], Material.prototype, "_alphaMode", void 0);
  75600. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75601. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75602. ], Material.prototype, "_needDepthPrePass", void 0);
  75603. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75604. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75605. ], Material.prototype, "disableDepthWrite", void 0);
  75606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75608. ], Material.prototype, "forceDepthWrite", void 0);
  75609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75611. ], Material.prototype, "separateCullingPass", void 0);
  75612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  75614. ], Material.prototype, "_fogEnabled", void 0);
  75615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75617. ], Material.prototype, "pointSize", void 0);
  75618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75620. ], Material.prototype, "zOffset", void 0);
  75621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75623. ], Material.prototype, "wireframe", null);
  75624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75626. ], Material.prototype, "pointsCloud", null);
  75627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  75628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  75629. ], Material.prototype, "fillMode", null);
  75630. return Material;
  75631. }());
  75632. /***/ }),
  75633. /***/ "./Materials/materialDefines.ts":
  75634. /*!**************************************!*\
  75635. !*** ./Materials/materialDefines.ts ***!
  75636. \**************************************/
  75637. /*! exports provided: MaterialDefines */
  75638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75639. "use strict";
  75640. __webpack_require__.r(__webpack_exports__);
  75641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  75642. /**
  75643. * Manages the defines for the Material
  75644. */
  75645. var MaterialDefines = /** @class */ (function () {
  75646. function MaterialDefines() {
  75647. this._isDirty = true;
  75648. /** @hidden */
  75649. this._areLightsDirty = true;
  75650. /** @hidden */
  75651. this._areAttributesDirty = true;
  75652. /** @hidden */
  75653. this._areTexturesDirty = true;
  75654. /** @hidden */
  75655. this._areFresnelDirty = true;
  75656. /** @hidden */
  75657. this._areMiscDirty = true;
  75658. /** @hidden */
  75659. this._areImageProcessingDirty = true;
  75660. /** @hidden */
  75661. this._normals = false;
  75662. /** @hidden */
  75663. this._uvs = false;
  75664. /** @hidden */
  75665. this._needNormals = false;
  75666. /** @hidden */
  75667. this._needUVs = false;
  75668. }
  75669. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  75670. /**
  75671. * Specifies if the material needs to be re-calculated
  75672. */
  75673. get: function () {
  75674. return this._isDirty;
  75675. },
  75676. enumerable: true,
  75677. configurable: true
  75678. });
  75679. /**
  75680. * Marks the material to indicate that it has been re-calculated
  75681. */
  75682. MaterialDefines.prototype.markAsProcessed = function () {
  75683. this._isDirty = false;
  75684. this._areAttributesDirty = false;
  75685. this._areTexturesDirty = false;
  75686. this._areFresnelDirty = false;
  75687. this._areLightsDirty = false;
  75688. this._areMiscDirty = false;
  75689. this._areImageProcessingDirty = false;
  75690. };
  75691. /**
  75692. * Marks the material to indicate that it needs to be re-calculated
  75693. */
  75694. MaterialDefines.prototype.markAsUnprocessed = function () {
  75695. this._isDirty = true;
  75696. };
  75697. /**
  75698. * Marks the material to indicate all of its defines need to be re-calculated
  75699. */
  75700. MaterialDefines.prototype.markAllAsDirty = function () {
  75701. this._areTexturesDirty = true;
  75702. this._areAttributesDirty = true;
  75703. this._areLightsDirty = true;
  75704. this._areFresnelDirty = true;
  75705. this._areMiscDirty = true;
  75706. this._areImageProcessingDirty = true;
  75707. this._isDirty = true;
  75708. };
  75709. /**
  75710. * Marks the material to indicate that image processing needs to be re-calculated
  75711. */
  75712. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  75713. this._areImageProcessingDirty = true;
  75714. this._isDirty = true;
  75715. };
  75716. /**
  75717. * Marks the material to indicate the lights need to be re-calculated
  75718. */
  75719. MaterialDefines.prototype.markAsLightDirty = function () {
  75720. this._areLightsDirty = true;
  75721. this._isDirty = true;
  75722. };
  75723. /**
  75724. * Marks the attribute state as changed
  75725. */
  75726. MaterialDefines.prototype.markAsAttributesDirty = function () {
  75727. this._areAttributesDirty = true;
  75728. this._isDirty = true;
  75729. };
  75730. /**
  75731. * Marks the texture state as changed
  75732. */
  75733. MaterialDefines.prototype.markAsTexturesDirty = function () {
  75734. this._areTexturesDirty = true;
  75735. this._isDirty = true;
  75736. };
  75737. /**
  75738. * Marks the fresnel state as changed
  75739. */
  75740. MaterialDefines.prototype.markAsFresnelDirty = function () {
  75741. this._areFresnelDirty = true;
  75742. this._isDirty = true;
  75743. };
  75744. /**
  75745. * Marks the misc state as changed
  75746. */
  75747. MaterialDefines.prototype.markAsMiscDirty = function () {
  75748. this._areMiscDirty = true;
  75749. this._isDirty = true;
  75750. };
  75751. /**
  75752. * Rebuilds the material defines
  75753. */
  75754. MaterialDefines.prototype.rebuild = function () {
  75755. if (this._keys) {
  75756. delete this._keys;
  75757. }
  75758. this._keys = [];
  75759. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  75760. var key = _a[_i];
  75761. if (key[0] === "_") {
  75762. continue;
  75763. }
  75764. this._keys.push(key);
  75765. }
  75766. };
  75767. /**
  75768. * Specifies if two material defines are equal
  75769. * @param other - A material define instance to compare to
  75770. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75771. */
  75772. MaterialDefines.prototype.isEqual = function (other) {
  75773. if (this._keys.length !== other._keys.length) {
  75774. return false;
  75775. }
  75776. for (var index = 0; index < this._keys.length; index++) {
  75777. var prop = this._keys[index];
  75778. if (this[prop] !== other[prop]) {
  75779. return false;
  75780. }
  75781. }
  75782. return true;
  75783. };
  75784. /**
  75785. * Clones this instance's defines to another instance
  75786. * @param other - material defines to clone values to
  75787. */
  75788. MaterialDefines.prototype.cloneTo = function (other) {
  75789. if (this._keys.length !== other._keys.length) {
  75790. other._keys = this._keys.slice(0);
  75791. }
  75792. for (var index = 0; index < this._keys.length; index++) {
  75793. var prop = this._keys[index];
  75794. other[prop] = this[prop];
  75795. }
  75796. };
  75797. /**
  75798. * Resets the material define values
  75799. */
  75800. MaterialDefines.prototype.reset = function () {
  75801. for (var index = 0; index < this._keys.length; index++) {
  75802. var prop = this._keys[index];
  75803. var type = typeof this[prop];
  75804. switch (type) {
  75805. case "number":
  75806. this[prop] = 0;
  75807. break;
  75808. case "string":
  75809. this[prop] = "";
  75810. break;
  75811. default:
  75812. this[prop] = false;
  75813. break;
  75814. }
  75815. }
  75816. };
  75817. /**
  75818. * Converts the material define values to a string
  75819. * @returns - String of material define information
  75820. */
  75821. MaterialDefines.prototype.toString = function () {
  75822. var result = "";
  75823. for (var index = 0; index < this._keys.length; index++) {
  75824. var prop = this._keys[index];
  75825. var value = this[prop];
  75826. var type = typeof value;
  75827. switch (type) {
  75828. case "number":
  75829. case "string":
  75830. result += "#define " + prop + " " + value + "\n";
  75831. break;
  75832. default:
  75833. if (value) {
  75834. result += "#define " + prop + "\n";
  75835. }
  75836. break;
  75837. }
  75838. }
  75839. return result;
  75840. };
  75841. return MaterialDefines;
  75842. }());
  75843. /***/ }),
  75844. /***/ "./Materials/materialFlags.ts":
  75845. /*!************************************!*\
  75846. !*** ./Materials/materialFlags.ts ***!
  75847. \************************************/
  75848. /*! exports provided: MaterialFlags */
  75849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75850. "use strict";
  75851. __webpack_require__.r(__webpack_exports__);
  75852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  75853. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  75854. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  75855. /**
  75856. * This groups all the flags used to control the materials channel.
  75857. */
  75858. var MaterialFlags = /** @class */ (function () {
  75859. function MaterialFlags() {
  75860. }
  75861. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  75862. /**
  75863. * Are diffuse textures enabled in the application.
  75864. */
  75865. get: function () {
  75866. return this._DiffuseTextureEnabled;
  75867. },
  75868. set: function (value) {
  75869. if (this._DiffuseTextureEnabled === value) {
  75870. return;
  75871. }
  75872. this._DiffuseTextureEnabled = value;
  75873. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75874. },
  75875. enumerable: true,
  75876. configurable: true
  75877. });
  75878. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  75879. /**
  75880. * Are ambient textures enabled in the application.
  75881. */
  75882. get: function () {
  75883. return this._AmbientTextureEnabled;
  75884. },
  75885. set: function (value) {
  75886. if (this._AmbientTextureEnabled === value) {
  75887. return;
  75888. }
  75889. this._AmbientTextureEnabled = value;
  75890. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75891. },
  75892. enumerable: true,
  75893. configurable: true
  75894. });
  75895. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  75896. /**
  75897. * Are opacity textures enabled in the application.
  75898. */
  75899. get: function () {
  75900. return this._OpacityTextureEnabled;
  75901. },
  75902. set: function (value) {
  75903. if (this._OpacityTextureEnabled === value) {
  75904. return;
  75905. }
  75906. this._OpacityTextureEnabled = value;
  75907. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75908. },
  75909. enumerable: true,
  75910. configurable: true
  75911. });
  75912. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  75913. /**
  75914. * Are reflection textures enabled in the application.
  75915. */
  75916. get: function () {
  75917. return this._ReflectionTextureEnabled;
  75918. },
  75919. set: function (value) {
  75920. if (this._ReflectionTextureEnabled === value) {
  75921. return;
  75922. }
  75923. this._ReflectionTextureEnabled = value;
  75924. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75925. },
  75926. enumerable: true,
  75927. configurable: true
  75928. });
  75929. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  75930. /**
  75931. * Are emissive textures enabled in the application.
  75932. */
  75933. get: function () {
  75934. return this._EmissiveTextureEnabled;
  75935. },
  75936. set: function (value) {
  75937. if (this._EmissiveTextureEnabled === value) {
  75938. return;
  75939. }
  75940. this._EmissiveTextureEnabled = value;
  75941. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75942. },
  75943. enumerable: true,
  75944. configurable: true
  75945. });
  75946. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  75947. /**
  75948. * Are specular textures enabled in the application.
  75949. */
  75950. get: function () {
  75951. return this._SpecularTextureEnabled;
  75952. },
  75953. set: function (value) {
  75954. if (this._SpecularTextureEnabled === value) {
  75955. return;
  75956. }
  75957. this._SpecularTextureEnabled = value;
  75958. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75959. },
  75960. enumerable: true,
  75961. configurable: true
  75962. });
  75963. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  75964. /**
  75965. * Are bump textures enabled in the application.
  75966. */
  75967. get: function () {
  75968. return this._BumpTextureEnabled;
  75969. },
  75970. set: function (value) {
  75971. if (this._BumpTextureEnabled === value) {
  75972. return;
  75973. }
  75974. this._BumpTextureEnabled = value;
  75975. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75976. },
  75977. enumerable: true,
  75978. configurable: true
  75979. });
  75980. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  75981. /**
  75982. * Are lightmap textures enabled in the application.
  75983. */
  75984. get: function () {
  75985. return this._LightmapTextureEnabled;
  75986. },
  75987. set: function (value) {
  75988. if (this._LightmapTextureEnabled === value) {
  75989. return;
  75990. }
  75991. this._LightmapTextureEnabled = value;
  75992. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  75993. },
  75994. enumerable: true,
  75995. configurable: true
  75996. });
  75997. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  75998. /**
  75999. * Are refraction textures enabled in the application.
  76000. */
  76001. get: function () {
  76002. return this._RefractionTextureEnabled;
  76003. },
  76004. set: function (value) {
  76005. if (this._RefractionTextureEnabled === value) {
  76006. return;
  76007. }
  76008. this._RefractionTextureEnabled = value;
  76009. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76010. },
  76011. enumerable: true,
  76012. configurable: true
  76013. });
  76014. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  76015. /**
  76016. * Are color grading textures enabled in the application.
  76017. */
  76018. get: function () {
  76019. return this._ColorGradingTextureEnabled;
  76020. },
  76021. set: function (value) {
  76022. if (this._ColorGradingTextureEnabled === value) {
  76023. return;
  76024. }
  76025. this._ColorGradingTextureEnabled = value;
  76026. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76027. },
  76028. enumerable: true,
  76029. configurable: true
  76030. });
  76031. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  76032. /**
  76033. * Are fresnels enabled in the application.
  76034. */
  76035. get: function () {
  76036. return this._FresnelEnabled;
  76037. },
  76038. set: function (value) {
  76039. if (this._FresnelEnabled === value) {
  76040. return;
  76041. }
  76042. this._FresnelEnabled = value;
  76043. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  76044. },
  76045. enumerable: true,
  76046. configurable: true
  76047. });
  76048. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  76049. /**
  76050. * Are clear coat textures enabled in the application.
  76051. */
  76052. get: function () {
  76053. return this._ClearCoatTextureEnabled;
  76054. },
  76055. set: function (value) {
  76056. if (this._ClearCoatTextureEnabled === value) {
  76057. return;
  76058. }
  76059. this._ClearCoatTextureEnabled = value;
  76060. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76061. },
  76062. enumerable: true,
  76063. configurable: true
  76064. });
  76065. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  76066. /**
  76067. * Are clear coat bump textures enabled in the application.
  76068. */
  76069. get: function () {
  76070. return this._ClearCoatBumpTextureEnabled;
  76071. },
  76072. set: function (value) {
  76073. if (this._ClearCoatBumpTextureEnabled === value) {
  76074. return;
  76075. }
  76076. this._ClearCoatBumpTextureEnabled = value;
  76077. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76078. },
  76079. enumerable: true,
  76080. configurable: true
  76081. });
  76082. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  76083. /**
  76084. * Are clear coat tint textures enabled in the application.
  76085. */
  76086. get: function () {
  76087. return this._ClearCoatTintTextureEnabled;
  76088. },
  76089. set: function (value) {
  76090. if (this._ClearCoatTintTextureEnabled === value) {
  76091. return;
  76092. }
  76093. this._ClearCoatTintTextureEnabled = value;
  76094. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76095. },
  76096. enumerable: true,
  76097. configurable: true
  76098. });
  76099. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  76100. /**
  76101. * Are sheen textures enabled in the application.
  76102. */
  76103. get: function () {
  76104. return this._SheenTextureEnabled;
  76105. },
  76106. set: function (value) {
  76107. if (this._SheenTextureEnabled === value) {
  76108. return;
  76109. }
  76110. this._SheenTextureEnabled = value;
  76111. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76112. },
  76113. enumerable: true,
  76114. configurable: true
  76115. });
  76116. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  76117. /**
  76118. * Are anisotropic textures enabled in the application.
  76119. */
  76120. get: function () {
  76121. return this._AnisotropicTextureEnabled;
  76122. },
  76123. set: function (value) {
  76124. if (this._AnisotropicTextureEnabled === value) {
  76125. return;
  76126. }
  76127. this._AnisotropicTextureEnabled = value;
  76128. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76129. },
  76130. enumerable: true,
  76131. configurable: true
  76132. });
  76133. Object.defineProperty(MaterialFlags, "ThicknessTextureEnabled", {
  76134. /**
  76135. * Are thickness textures enabled in the application.
  76136. */
  76137. get: function () {
  76138. return this._ThicknessTextureEnabled;
  76139. },
  76140. set: function (value) {
  76141. if (this._ThicknessTextureEnabled === value) {
  76142. return;
  76143. }
  76144. this._ThicknessTextureEnabled = value;
  76145. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  76146. },
  76147. enumerable: true,
  76148. configurable: true
  76149. });
  76150. // Flags used to enable or disable a type of texture for all Standard Materials
  76151. MaterialFlags._DiffuseTextureEnabled = true;
  76152. MaterialFlags._AmbientTextureEnabled = true;
  76153. MaterialFlags._OpacityTextureEnabled = true;
  76154. MaterialFlags._ReflectionTextureEnabled = true;
  76155. MaterialFlags._EmissiveTextureEnabled = true;
  76156. MaterialFlags._SpecularTextureEnabled = true;
  76157. MaterialFlags._BumpTextureEnabled = true;
  76158. MaterialFlags._LightmapTextureEnabled = true;
  76159. MaterialFlags._RefractionTextureEnabled = true;
  76160. MaterialFlags._ColorGradingTextureEnabled = true;
  76161. MaterialFlags._FresnelEnabled = true;
  76162. MaterialFlags._ClearCoatTextureEnabled = true;
  76163. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  76164. MaterialFlags._ClearCoatTintTextureEnabled = true;
  76165. MaterialFlags._SheenTextureEnabled = true;
  76166. MaterialFlags._AnisotropicTextureEnabled = true;
  76167. MaterialFlags._ThicknessTextureEnabled = true;
  76168. return MaterialFlags;
  76169. }());
  76170. /***/ }),
  76171. /***/ "./Materials/materialHelper.ts":
  76172. /*!*************************************!*\
  76173. !*** ./Materials/materialHelper.ts ***!
  76174. \*************************************/
  76175. /*! exports provided: MaterialHelper */
  76176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76177. "use strict";
  76178. __webpack_require__.r(__webpack_exports__);
  76179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  76180. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  76181. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  76182. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  76183. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  76184. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  76185. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  76186. /**
  76187. * "Static Class" containing the most commonly used helper while dealing with material for
  76188. * rendering purpose.
  76189. *
  76190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76191. *
  76192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76193. */
  76194. var MaterialHelper = /** @class */ (function () {
  76195. function MaterialHelper() {
  76196. }
  76197. /**
  76198. * Bind the current view position to an effect.
  76199. * @param effect The effect to be bound
  76200. * @param scene The scene the eyes position is used from
  76201. */
  76202. MaterialHelper.BindEyePosition = function (effect, scene) {
  76203. if (scene._forcedViewPosition) {
  76204. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  76205. return;
  76206. }
  76207. var globalPosition = scene.activeCamera.globalPosition;
  76208. if (!globalPosition) {
  76209. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  76210. globalPosition = scene.activeCamera.devicePosition;
  76211. }
  76212. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  76213. };
  76214. /**
  76215. * Helps preparing the defines values about the UVs in used in the effect.
  76216. * UVs are shared as much as we can accross channels in the shaders.
  76217. * @param texture The texture we are preparing the UVs for
  76218. * @param defines The defines to update
  76219. * @param key The channel key "diffuse", "specular"... used in the shader
  76220. */
  76221. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  76222. defines._needUVs = true;
  76223. defines[key] = true;
  76224. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  76225. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  76226. if (texture.coordinatesIndex === 0) {
  76227. defines["MAINUV1"] = true;
  76228. }
  76229. else {
  76230. defines["MAINUV2"] = true;
  76231. }
  76232. }
  76233. else {
  76234. defines[key + "DIRECTUV"] = 0;
  76235. }
  76236. };
  76237. /**
  76238. * Binds a texture matrix value to its corrsponding uniform
  76239. * @param texture The texture to bind the matrix for
  76240. * @param uniformBuffer The uniform buffer receivin the data
  76241. * @param key The channel key "diffuse", "specular"... used in the shader
  76242. */
  76243. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  76244. var matrix = texture.getTextureMatrix();
  76245. if (!matrix.isIdentityAs3x2()) {
  76246. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  76247. }
  76248. };
  76249. /**
  76250. * Gets the current status of the fog (should it be enabled?)
  76251. * @param mesh defines the mesh to evaluate for fog support
  76252. * @param scene defines the hosting scene
  76253. * @returns true if fog must be enabled
  76254. */
  76255. MaterialHelper.GetFogState = function (mesh, scene) {
  76256. return (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE);
  76257. };
  76258. /**
  76259. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76260. * @param mesh defines the current mesh
  76261. * @param scene defines the current scene
  76262. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76263. * @param pointsCloud defines if point cloud rendering has to be turned on
  76264. * @param fogEnabled defines if fog has to be turned on
  76265. * @param alphaTest defines if alpha testing has to be turned on
  76266. * @param defines defines the current list of defines
  76267. */
  76268. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  76269. if (defines._areMiscDirty) {
  76270. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  76271. defines["POINTSIZE"] = pointsCloud;
  76272. defines["FOG"] = fogEnabled && this.GetFogState(mesh, scene);
  76273. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  76274. defines["ALPHATEST"] = alphaTest;
  76275. }
  76276. };
  76277. /**
  76278. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76279. * @param scene defines the current scene
  76280. * @param engine defines the current engine
  76281. * @param defines specifies the list of active defines
  76282. * @param useInstances defines if instances have to be turned on
  76283. * @param useClipPlane defines if clip plane have to be turned on
  76284. */
  76285. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  76286. if (useClipPlane === void 0) { useClipPlane = null; }
  76287. var changed = false;
  76288. var useClipPlane1 = false;
  76289. var useClipPlane2 = false;
  76290. var useClipPlane3 = false;
  76291. var useClipPlane4 = false;
  76292. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  76293. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  76294. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  76295. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  76296. if (defines["CLIPPLANE"] !== useClipPlane1) {
  76297. defines["CLIPPLANE"] = useClipPlane1;
  76298. changed = true;
  76299. }
  76300. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  76301. defines["CLIPPLANE2"] = useClipPlane2;
  76302. changed = true;
  76303. }
  76304. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  76305. defines["CLIPPLANE3"] = useClipPlane3;
  76306. changed = true;
  76307. }
  76308. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  76309. defines["CLIPPLANE4"] = useClipPlane4;
  76310. changed = true;
  76311. }
  76312. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  76313. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  76314. changed = true;
  76315. }
  76316. if (defines["INSTANCES"] !== useInstances) {
  76317. defines["INSTANCES"] = useInstances;
  76318. changed = true;
  76319. }
  76320. if (changed) {
  76321. defines.markAsUnprocessed();
  76322. }
  76323. };
  76324. /**
  76325. * Prepares the defines for bones
  76326. * @param mesh The mesh containing the geometry data we will draw
  76327. * @param defines The defines to update
  76328. */
  76329. MaterialHelper.PrepareDefinesForBones = function (mesh, defines) {
  76330. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  76331. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  76332. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  76333. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  76334. defines["BONETEXTURE"] = true;
  76335. }
  76336. else {
  76337. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  76338. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  76339. }
  76340. }
  76341. else {
  76342. defines["NUM_BONE_INFLUENCERS"] = 0;
  76343. defines["BonesPerMesh"] = 0;
  76344. }
  76345. };
  76346. /**
  76347. * Prepares the defines for morph targets
  76348. * @param mesh The mesh containing the geometry data we will draw
  76349. * @param defines The defines to update
  76350. */
  76351. MaterialHelper.PrepareDefinesForMorphTargets = function (mesh, defines) {
  76352. var manager = mesh.morphTargetManager;
  76353. if (manager) {
  76354. defines["MORPHTARGETS_UV"] = manager.supportsUVs && defines["UV1"];
  76355. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  76356. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  76357. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  76358. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  76359. }
  76360. else {
  76361. defines["MORPHTARGETS_UV"] = false;
  76362. defines["MORPHTARGETS_TANGENT"] = false;
  76363. defines["MORPHTARGETS_NORMAL"] = false;
  76364. defines["MORPHTARGETS"] = false;
  76365. defines["NUM_MORPH_INFLUENCERS"] = 0;
  76366. }
  76367. };
  76368. /**
  76369. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76370. * @param mesh The mesh containing the geometry data we will draw
  76371. * @param defines The defines to update
  76372. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76373. * @param useBones Precise whether bones should be used or not (override mesh info)
  76374. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76375. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76376. * @returns false if defines are considered not dirty and have not been checked
  76377. */
  76378. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  76379. if (useMorphTargets === void 0) { useMorphTargets = false; }
  76380. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  76381. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  76382. return false;
  76383. }
  76384. defines._normals = defines._needNormals;
  76385. defines._uvs = defines._needUVs;
  76386. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  76387. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  76388. defines["TANGENT"] = true;
  76389. }
  76390. if (defines._needUVs) {
  76391. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind);
  76392. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind);
  76393. }
  76394. else {
  76395. defines["UV1"] = false;
  76396. defines["UV2"] = false;
  76397. }
  76398. if (useVertexColor) {
  76399. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  76400. defines["VERTEXCOLOR"] = hasVertexColors;
  76401. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  76402. }
  76403. if (useBones) {
  76404. this.PrepareDefinesForBones(mesh, defines);
  76405. }
  76406. if (useMorphTargets) {
  76407. this.PrepareDefinesForMorphTargets(mesh, defines);
  76408. }
  76409. return true;
  76410. };
  76411. /**
  76412. * Prepares the defines related to multiview
  76413. * @param scene The scene we are intending to draw
  76414. * @param defines The defines to update
  76415. */
  76416. MaterialHelper.PrepareDefinesForMultiview = function (scene, defines) {
  76417. if (scene.activeCamera) {
  76418. var previousMultiview = defines.MULTIVIEW;
  76419. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  76420. if (defines.MULTIVIEW != previousMultiview) {
  76421. defines.markAsUnprocessed();
  76422. }
  76423. }
  76424. };
  76425. /**
  76426. * Prepares the defines related to the light information passed in parameter
  76427. * @param scene The scene we are intending to draw
  76428. * @param mesh The mesh the effect is compiling for
  76429. * @param light The light the effect is compiling for
  76430. * @param lightIndex The index of the light
  76431. * @param defines The defines to update
  76432. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76433. * @param state Defines the current state regarding what is needed (normals, etc...)
  76434. */
  76435. MaterialHelper.PrepareDefinesForLight = function (scene, mesh, light, lightIndex, defines, specularSupported, state) {
  76436. state.needNormals = true;
  76437. if (defines["LIGHT" + lightIndex] === undefined) {
  76438. state.needRebuild = true;
  76439. }
  76440. defines["LIGHT" + lightIndex] = true;
  76441. defines["SPOTLIGHT" + lightIndex] = false;
  76442. defines["HEMILIGHT" + lightIndex] = false;
  76443. defines["POINTLIGHT" + lightIndex] = false;
  76444. defines["DIRLIGHT" + lightIndex] = false;
  76445. light.prepareLightSpecificDefines(defines, lightIndex);
  76446. // FallOff.
  76447. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  76448. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  76449. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  76450. switch (light.falloffType) {
  76451. case _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].FALLOFF_GLTF:
  76452. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  76453. break;
  76454. case _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].FALLOFF_PHYSICAL:
  76455. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  76456. break;
  76457. case _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].FALLOFF_STANDARD:
  76458. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  76459. break;
  76460. }
  76461. // Specular
  76462. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  76463. state.specularEnabled = true;
  76464. }
  76465. // Shadows
  76466. defines["SHADOW" + lightIndex] = false;
  76467. defines["SHADOWPCF" + lightIndex] = false;
  76468. defines["SHADOWPCSS" + lightIndex] = false;
  76469. defines["SHADOWPOISSON" + lightIndex] = false;
  76470. defines["SHADOWESM" + lightIndex] = false;
  76471. defines["SHADOWCUBE" + lightIndex] = false;
  76472. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  76473. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  76474. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  76475. var shadowGenerator = light.getShadowGenerator();
  76476. if (shadowGenerator) {
  76477. var shadowMap = shadowGenerator.getShadowMap();
  76478. if (shadowMap) {
  76479. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  76480. state.shadowEnabled = true;
  76481. shadowGenerator.prepareDefines(defines, lightIndex);
  76482. }
  76483. }
  76484. }
  76485. }
  76486. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTMAP_DEFAULT) {
  76487. state.lightmapMode = true;
  76488. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  76489. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTMAP_SHADOWSONLY);
  76490. }
  76491. else {
  76492. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  76493. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  76494. }
  76495. };
  76496. /**
  76497. * Prepares the defines related to the light information passed in parameter
  76498. * @param scene The scene we are intending to draw
  76499. * @param mesh The mesh the effect is compiling for
  76500. * @param defines The defines to update
  76501. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76502. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76503. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76504. * @returns true if normals will be required for the rest of the effect
  76505. */
  76506. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  76507. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  76508. if (disableLighting === void 0) { disableLighting = false; }
  76509. if (!defines._areLightsDirty) {
  76510. return defines._needNormals;
  76511. }
  76512. var lightIndex = 0;
  76513. var state = {
  76514. needNormals: false,
  76515. needRebuild: false,
  76516. lightmapMode: false,
  76517. shadowEnabled: false,
  76518. specularEnabled: false
  76519. };
  76520. if (scene.lightsEnabled && !disableLighting) {
  76521. for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
  76522. var light = _a[_i];
  76523. this.PrepareDefinesForLight(scene, mesh, light, lightIndex, defines, specularSupported, state);
  76524. lightIndex++;
  76525. if (lightIndex === maxSimultaneousLights) {
  76526. break;
  76527. }
  76528. }
  76529. }
  76530. defines["SPECULARTERM"] = state.specularEnabled;
  76531. defines["SHADOWS"] = state.shadowEnabled;
  76532. // Resetting all other lights if any
  76533. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  76534. if (defines["LIGHT" + index] !== undefined) {
  76535. defines["LIGHT" + index] = false;
  76536. defines["HEMILIGHT" + index] = false;
  76537. defines["POINTLIGHT" + index] = false;
  76538. defines["DIRLIGHT" + index] = false;
  76539. defines["SPOTLIGHT" + index] = false;
  76540. defines["SHADOW" + index] = false;
  76541. defines["SHADOWPCF" + index] = false;
  76542. defines["SHADOWPCSS" + index] = false;
  76543. defines["SHADOWPOISSON" + index] = false;
  76544. defines["SHADOWESM" + index] = false;
  76545. defines["SHADOWCUBE" + index] = false;
  76546. defines["SHADOWLOWQUALITY" + index] = false;
  76547. defines["SHADOWMEDIUMQUALITY" + index] = false;
  76548. }
  76549. }
  76550. var caps = scene.getEngine().getCaps();
  76551. if (defines["SHADOWFLOAT"] === undefined) {
  76552. state.needRebuild = true;
  76553. }
  76554. defines["SHADOWFLOAT"] = state.shadowEnabled &&
  76555. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  76556. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  76557. defines["LIGHTMAPEXCLUDED"] = state.lightmapMode;
  76558. if (state.needRebuild) {
  76559. defines.rebuild();
  76560. }
  76561. return state.needNormals;
  76562. };
  76563. /**
  76564. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76565. * @param lightIndex defines the light index
  76566. * @param uniformsList The uniform list
  76567. * @param samplersList The sampler list
  76568. * @param projectedLightTexture defines if projected texture must be used
  76569. * @param uniformBuffersList defines an optional list of uniform buffers
  76570. */
  76571. MaterialHelper.PrepareUniformsAndSamplersForLight = function (lightIndex, uniformsList, samplersList, projectedLightTexture, uniformBuffersList) {
  76572. if (uniformBuffersList === void 0) { uniformBuffersList = null; }
  76573. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  76574. if (uniformBuffersList) {
  76575. uniformBuffersList.push("Light" + lightIndex);
  76576. }
  76577. samplersList.push("shadowSampler" + lightIndex);
  76578. samplersList.push("depthSampler" + lightIndex);
  76579. if (projectedLightTexture) {
  76580. samplersList.push("projectionLightSampler" + lightIndex);
  76581. uniformsList.push("textureProjectionMatrix" + lightIndex);
  76582. }
  76583. };
  76584. /**
  76585. * Prepares the uniforms and samplers list to be used in the effect
  76586. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76587. * @param samplersList The sampler list
  76588. * @param defines The defines helping in the list generation
  76589. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76590. */
  76591. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  76592. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  76593. var uniformsList;
  76594. var uniformBuffersList = null;
  76595. if (uniformsListOrOptions.uniformsNames) {
  76596. var options = uniformsListOrOptions;
  76597. uniformsList = options.uniformsNames;
  76598. uniformBuffersList = options.uniformBuffersNames;
  76599. samplersList = options.samplers;
  76600. defines = options.defines;
  76601. maxSimultaneousLights = options.maxSimultaneousLights;
  76602. }
  76603. else {
  76604. uniformsList = uniformsListOrOptions;
  76605. if (!samplersList) {
  76606. samplersList = [];
  76607. }
  76608. }
  76609. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  76610. if (!defines["LIGHT" + lightIndex]) {
  76611. break;
  76612. }
  76613. this.PrepareUniformsAndSamplersForLight(lightIndex, uniformsList, samplersList, defines["PROJECTEDLIGHTTEXTURE" + lightIndex], uniformBuffersList);
  76614. }
  76615. if (defines["NUM_MORPH_INFLUENCERS"]) {
  76616. uniformsList.push("morphTargetInfluences");
  76617. }
  76618. };
  76619. /**
  76620. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76621. * @param defines The defines to update while falling back
  76622. * @param fallbacks The authorized effect fallbacks
  76623. * @param maxSimultaneousLights The maximum number of lights allowed
  76624. * @param rank the current rank of the Effect
  76625. * @returns The newly affected rank
  76626. */
  76627. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  76628. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  76629. if (rank === void 0) { rank = 0; }
  76630. var lightFallbackRank = 0;
  76631. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  76632. if (!defines["LIGHT" + lightIndex]) {
  76633. break;
  76634. }
  76635. if (lightIndex > 0) {
  76636. lightFallbackRank = rank + lightIndex;
  76637. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  76638. }
  76639. if (!defines["SHADOWS"]) {
  76640. if (defines["SHADOW" + lightIndex]) {
  76641. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  76642. }
  76643. if (defines["SHADOWPCF" + lightIndex]) {
  76644. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  76645. }
  76646. if (defines["SHADOWPCSS" + lightIndex]) {
  76647. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  76648. }
  76649. if (defines["SHADOWPOISSON" + lightIndex]) {
  76650. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  76651. }
  76652. if (defines["SHADOWESM" + lightIndex]) {
  76653. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  76654. }
  76655. }
  76656. }
  76657. return lightFallbackRank++;
  76658. };
  76659. /**
  76660. * Prepares the list of attributes required for morph targets according to the effect defines.
  76661. * @param attribs The current list of supported attribs
  76662. * @param mesh The mesh to prepare the morph targets attributes for
  76663. * @param influencers The number of influencers
  76664. */
  76665. MaterialHelper.PrepareAttributesForMorphTargetsInfluencers = function (attribs, mesh, influencers) {
  76666. this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = influencers;
  76667. this.PrepareAttributesForMorphTargets(attribs, mesh, this._TmpMorphInfluencers);
  76668. };
  76669. /**
  76670. * Prepares the list of attributes required for morph targets according to the effect defines.
  76671. * @param attribs The current list of supported attribs
  76672. * @param mesh The mesh to prepare the morph targets attributes for
  76673. * @param defines The current Defines of the effect
  76674. */
  76675. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  76676. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  76677. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedEngine) {
  76678. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  76679. var manager = mesh.morphTargetManager;
  76680. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  76681. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  76682. var uv = manager && manager.supportsUVs && defines["UV1"];
  76683. for (var index = 0; index < influencers; index++) {
  76684. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind + index);
  76685. if (normal) {
  76686. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind + index);
  76687. }
  76688. if (tangent) {
  76689. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind + index);
  76690. }
  76691. if (uv) {
  76692. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind + "_" + index);
  76693. }
  76694. if (attribs.length > maxAttributesCount) {
  76695. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  76696. }
  76697. }
  76698. }
  76699. };
  76700. /**
  76701. * Prepares the list of attributes required for bones according to the effect defines.
  76702. * @param attribs The current list of supported attribs
  76703. * @param mesh The mesh to prepare the bones attributes for
  76704. * @param defines The current Defines of the effect
  76705. * @param fallbacks The current efffect fallback strategy
  76706. */
  76707. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  76708. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  76709. fallbacks.addCPUSkinningFallback(0, mesh);
  76710. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  76711. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  76712. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  76713. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  76714. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  76715. }
  76716. }
  76717. };
  76718. /**
  76719. * Check and prepare the list of attributes required for instances according to the effect defines.
  76720. * @param attribs The current list of supported attribs
  76721. * @param defines The current MaterialDefines of the effect
  76722. */
  76723. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  76724. if (defines["INSTANCES"]) {
  76725. this.PushAttributesForInstances(attribs);
  76726. }
  76727. };
  76728. /**
  76729. * Add the list of attributes required for instances to the attribs array.
  76730. * @param attribs The current list of supported attribs
  76731. */
  76732. MaterialHelper.PushAttributesForInstances = function (attribs) {
  76733. attribs.push("world0");
  76734. attribs.push("world1");
  76735. attribs.push("world2");
  76736. attribs.push("world3");
  76737. };
  76738. /**
  76739. * Binds the light shadow information to the effect for the given mesh.
  76740. * @param light The light containing the generator
  76741. * @param scene The scene the lights belongs to
  76742. * @param mesh The mesh we are binding the information to render
  76743. * @param lightIndex The light index in the effect used to render the mesh
  76744. * @param effect The effect we are binding the data to
  76745. */
  76746. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  76747. if (light.shadowEnabled && mesh.receiveShadows) {
  76748. var shadowGenerator = light.getShadowGenerator();
  76749. if (shadowGenerator) {
  76750. shadowGenerator.bindShadowLight(lightIndex, effect);
  76751. }
  76752. }
  76753. };
  76754. /**
  76755. * Binds the light information to the effect.
  76756. * @param light The light containing the generator
  76757. * @param effect The effect we are binding the data to
  76758. * @param lightIndex The light index in the effect used to render
  76759. */
  76760. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  76761. light.transferToEffect(effect, lightIndex + "");
  76762. };
  76763. /**
  76764. * Binds the lights information from the scene to the effect for the given mesh.
  76765. * @param light Light to bind
  76766. * @param lightIndex Light index
  76767. * @param scene The scene where the light belongs to
  76768. * @param mesh The mesh we are binding the information to render
  76769. * @param effect The effect we are binding the data to
  76770. * @param useSpecular Defines if specular is supported
  76771. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76772. */
  76773. MaterialHelper.BindLight = function (light, lightIndex, scene, mesh, effect, useSpecular, usePhysicalLightFalloff) {
  76774. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  76775. var iAsString = lightIndex.toString();
  76776. var scaledIntensity = light.getScaledIntensity();
  76777. light._uniformBuffer.bindToEffect(effect, "Light" + iAsString);
  76778. MaterialHelper.BindLightProperties(light, effect, lightIndex);
  76779. light.diffuse.scaleToRef(scaledIntensity, _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[0]);
  76780. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  76781. if (useSpecular) {
  76782. light.specular.scaleToRef(scaledIntensity, _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[1]);
  76783. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["TmpColors"].Color3[1], iAsString);
  76784. }
  76785. // Shadows
  76786. if (scene.shadowsEnabled) {
  76787. this.BindLightShadow(light, mesh, iAsString, effect);
  76788. }
  76789. light._uniformBuffer.update();
  76790. };
  76791. /**
  76792. * Binds the lights information from the scene to the effect for the given mesh.
  76793. * @param scene The scene the lights belongs to
  76794. * @param mesh The mesh we are binding the information to render
  76795. * @param effect The effect we are binding the data to
  76796. * @param defines The generated defines for the effect
  76797. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76798. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76799. */
  76800. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  76801. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  76802. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  76803. var len = Math.min(mesh.lightSources.length, maxSimultaneousLights);
  76804. for (var i = 0; i < len; i++) {
  76805. var light = mesh.lightSources[i];
  76806. this.BindLight(light, i, scene, mesh, effect, typeof defines === "boolean" ? defines : defines["SPECULARTERM"], usePhysicalLightFalloff);
  76807. }
  76808. };
  76809. /**
  76810. * Binds the fog information from the scene to the effect for the given mesh.
  76811. * @param scene The scene the lights belongs to
  76812. * @param mesh The mesh we are binding the information to render
  76813. * @param effect The effect we are binding the data to
  76814. * @param linearSpace Defines if the fog effect is applied in linear space
  76815. */
  76816. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  76817. if (linearSpace === void 0) { linearSpace = false; }
  76818. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  76819. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  76820. // Convert fog color to linear space if used in a linear space computed shader.
  76821. if (linearSpace) {
  76822. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  76823. effect.setColor3("vFogColor", this._tempFogColor);
  76824. }
  76825. else {
  76826. effect.setColor3("vFogColor", scene.fogColor);
  76827. }
  76828. }
  76829. };
  76830. /**
  76831. * Binds the bones information from the mesh to the effect.
  76832. * @param mesh The mesh we are binding the information to render
  76833. * @param effect The effect we are binding the data to
  76834. */
  76835. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  76836. if (!effect || !mesh) {
  76837. return;
  76838. }
  76839. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  76840. mesh.computeBonesUsingShaders = false;
  76841. }
  76842. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  76843. var skeleton = mesh.skeleton;
  76844. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  76845. var boneTexture = skeleton.getTransformMatrixTexture(mesh);
  76846. effect.setTexture("boneSampler", boneTexture);
  76847. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  76848. }
  76849. else {
  76850. var matrices = skeleton.getTransformMatrices(mesh);
  76851. if (matrices) {
  76852. effect.setMatrices("mBones", matrices);
  76853. }
  76854. }
  76855. }
  76856. };
  76857. /**
  76858. * Binds the morph targets information from the mesh to the effect.
  76859. * @param abstractMesh The mesh we are binding the information to render
  76860. * @param effect The effect we are binding the data to
  76861. */
  76862. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  76863. var manager = abstractMesh.morphTargetManager;
  76864. if (!abstractMesh || !manager) {
  76865. return;
  76866. }
  76867. effect.setFloatArray("morphTargetInfluences", manager.influences);
  76868. };
  76869. /**
  76870. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76871. * @param defines The generated defines used in the effect
  76872. * @param effect The effect we are binding the data to
  76873. * @param scene The scene we are willing to render with logarithmic scale for
  76874. */
  76875. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  76876. if (defines["LOGARITHMICDEPTH"]) {
  76877. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  76878. }
  76879. };
  76880. /**
  76881. * Binds the clip plane information from the scene to the effect.
  76882. * @param scene The scene the clip plane information are extracted from
  76883. * @param effect The effect we are binding the data to
  76884. */
  76885. MaterialHelper.BindClipPlane = function (effect, scene) {
  76886. if (scene.clipPlane) {
  76887. var clipPlane = scene.clipPlane;
  76888. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  76889. }
  76890. if (scene.clipPlane2) {
  76891. var clipPlane = scene.clipPlane2;
  76892. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  76893. }
  76894. if (scene.clipPlane3) {
  76895. var clipPlane = scene.clipPlane3;
  76896. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  76897. }
  76898. if (scene.clipPlane4) {
  76899. var clipPlane = scene.clipPlane4;
  76900. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  76901. }
  76902. };
  76903. MaterialHelper._TmpMorphInfluencers = { "NUM_MORPH_INFLUENCERS": 0 };
  76904. MaterialHelper._tempFogColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"].Black();
  76905. return MaterialHelper;
  76906. }());
  76907. /***/ }),
  76908. /***/ "./Materials/multiMaterial.ts":
  76909. /*!************************************!*\
  76910. !*** ./Materials/multiMaterial.ts ***!
  76911. \************************************/
  76912. /*! exports provided: MultiMaterial */
  76913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76914. "use strict";
  76915. __webpack_require__.r(__webpack_exports__);
  76916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  76917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  76918. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  76919. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  76920. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  76921. /**
  76922. * A multi-material is used to apply different materials to different parts of the same object without the need of
  76923. * separate meshes. This can be use to improve performances.
  76924. * @see http://doc.babylonjs.com/how_to/multi_materials
  76925. */
  76926. var MultiMaterial = /** @class */ (function (_super) {
  76927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  76928. /**
  76929. * Instantiates a new Multi Material
  76930. * A multi-material is used to apply different materials to different parts of the same object without the need of
  76931. * separate meshes. This can be use to improve performances.
  76932. * @see http://doc.babylonjs.com/how_to/multi_materials
  76933. * @param name Define the name in the scene
  76934. * @param scene Define the scene the material belongs to
  76935. */
  76936. function MultiMaterial(name, scene) {
  76937. var _this = _super.call(this, name, scene, true) || this;
  76938. scene.multiMaterials.push(_this);
  76939. _this.subMaterials = new Array();
  76940. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  76941. return _this;
  76942. }
  76943. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  76944. /**
  76945. * Gets or Sets the list of Materials used within the multi material.
  76946. * They need to be ordered according to the submeshes order in the associated mesh
  76947. */
  76948. get: function () {
  76949. return this._subMaterials;
  76950. },
  76951. set: function (value) {
  76952. this._subMaterials = value;
  76953. this._hookArray(value);
  76954. },
  76955. enumerable: true,
  76956. configurable: true
  76957. });
  76958. /**
  76959. * Function used to align with Node.getChildren()
  76960. * @returns the list of Materials used within the multi material
  76961. */
  76962. MultiMaterial.prototype.getChildren = function () {
  76963. return this.subMaterials;
  76964. };
  76965. MultiMaterial.prototype._hookArray = function (array) {
  76966. var _this = this;
  76967. var oldPush = array.push;
  76968. array.push = function () {
  76969. var items = [];
  76970. for (var _i = 0; _i < arguments.length; _i++) {
  76971. items[_i] = arguments[_i];
  76972. }
  76973. var result = oldPush.apply(array, items);
  76974. _this._markAllSubMeshesAsTexturesDirty();
  76975. return result;
  76976. };
  76977. var oldSplice = array.splice;
  76978. array.splice = function (index, deleteCount) {
  76979. var deleted = oldSplice.apply(array, [index, deleteCount]);
  76980. _this._markAllSubMeshesAsTexturesDirty();
  76981. return deleted;
  76982. };
  76983. };
  76984. /**
  76985. * Get one of the submaterial by its index in the submaterials array
  76986. * @param index The index to look the sub material at
  76987. * @returns The Material if the index has been defined
  76988. */
  76989. MultiMaterial.prototype.getSubMaterial = function (index) {
  76990. if (index < 0 || index >= this.subMaterials.length) {
  76991. return this.getScene().defaultMaterial;
  76992. }
  76993. return this.subMaterials[index];
  76994. };
  76995. /**
  76996. * Get the list of active textures for the whole sub materials list.
  76997. * @returns All the textures that will be used during the rendering
  76998. */
  76999. MultiMaterial.prototype.getActiveTextures = function () {
  77000. var _a;
  77001. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  77002. if (subMaterial) {
  77003. return subMaterial.getActiveTextures();
  77004. }
  77005. else {
  77006. return [];
  77007. }
  77008. }));
  77009. };
  77010. /**
  77011. * Gets the current class name of the material e.g. "MultiMaterial"
  77012. * Mainly use in serialization.
  77013. * @returns the class name
  77014. */
  77015. MultiMaterial.prototype.getClassName = function () {
  77016. return "MultiMaterial";
  77017. };
  77018. /**
  77019. * Checks if the material is ready to render the requested sub mesh
  77020. * @param mesh Define the mesh the submesh belongs to
  77021. * @param subMesh Define the sub mesh to look readyness for
  77022. * @param useInstances Define whether or not the material is used with instances
  77023. * @returns true if ready, otherwise false
  77024. */
  77025. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  77026. for (var index = 0; index < this.subMaterials.length; index++) {
  77027. var subMaterial = this.subMaterials[index];
  77028. if (subMaterial) {
  77029. if (subMaterial._storeEffectOnSubMeshes) {
  77030. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  77031. return false;
  77032. }
  77033. continue;
  77034. }
  77035. if (!subMaterial.isReady(mesh)) {
  77036. return false;
  77037. }
  77038. }
  77039. }
  77040. return true;
  77041. };
  77042. /**
  77043. * Clones the current material and its related sub materials
  77044. * @param name Define the name of the newly cloned material
  77045. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  77046. * @returns the cloned material
  77047. */
  77048. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  77049. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  77050. for (var index = 0; index < this.subMaterials.length; index++) {
  77051. var subMaterial = null;
  77052. var current = this.subMaterials[index];
  77053. if (cloneChildren && current) {
  77054. subMaterial = current.clone(name + "-" + current.name);
  77055. }
  77056. else {
  77057. subMaterial = this.subMaterials[index];
  77058. }
  77059. newMultiMaterial.subMaterials.push(subMaterial);
  77060. }
  77061. return newMultiMaterial;
  77062. };
  77063. /**
  77064. * Serializes the materials into a JSON representation.
  77065. * @returns the JSON representation
  77066. */
  77067. MultiMaterial.prototype.serialize = function () {
  77068. var serializationObject = {};
  77069. serializationObject.name = this.name;
  77070. serializationObject.id = this.id;
  77071. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  77072. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  77073. }
  77074. serializationObject.materials = [];
  77075. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  77076. var subMat = this.subMaterials[matIndex];
  77077. if (subMat) {
  77078. serializationObject.materials.push(subMat.id);
  77079. }
  77080. else {
  77081. serializationObject.materials.push(null);
  77082. }
  77083. }
  77084. return serializationObject;
  77085. };
  77086. /**
  77087. * Dispose the material and release its associated resources
  77088. * @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)
  77089. * @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)
  77090. * @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)
  77091. */
  77092. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  77093. var scene = this.getScene();
  77094. if (!scene) {
  77095. return;
  77096. }
  77097. if (forceDisposeChildren) {
  77098. for (var index = 0; index < this.subMaterials.length; index++) {
  77099. var subMaterial = this.subMaterials[index];
  77100. if (subMaterial) {
  77101. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  77102. }
  77103. }
  77104. }
  77105. var index = scene.multiMaterials.indexOf(this);
  77106. if (index >= 0) {
  77107. scene.multiMaterials.splice(index, 1);
  77108. }
  77109. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  77110. };
  77111. /**
  77112. * Creates a MultiMaterial from parsed MultiMaterial data.
  77113. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  77114. * @param scene defines the hosting scene
  77115. * @returns a new MultiMaterial
  77116. */
  77117. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  77118. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  77119. multiMaterial.id = parsedMultiMaterial.id;
  77120. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  77121. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  77122. }
  77123. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  77124. var subMatId = parsedMultiMaterial.materials[matIndex];
  77125. if (subMatId) {
  77126. // If the same multimaterial is loaded twice, the 2nd multimaterial needs to reference the latest material by that id which
  77127. // is why this lookup should use getLastMaterialByID instead of getMaterialByID
  77128. multiMaterial.subMaterials.push(scene.getLastMaterialByID(subMatId));
  77129. }
  77130. else {
  77131. multiMaterial.subMaterials.push(null);
  77132. }
  77133. }
  77134. return multiMaterial;
  77135. };
  77136. return MultiMaterial;
  77137. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  77138. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  77139. /***/ }),
  77140. /***/ "./Materials/pushMaterial.ts":
  77141. /*!***********************************!*\
  77142. !*** ./Materials/pushMaterial.ts ***!
  77143. \***********************************/
  77144. /*! exports provided: PushMaterial */
  77145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77146. "use strict";
  77147. __webpack_require__.r(__webpack_exports__);
  77148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  77149. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  77150. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  77151. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  77152. /**
  77153. * Base class of materials working in push mode in babylon JS
  77154. * @hidden
  77155. */
  77156. var PushMaterial = /** @class */ (function (_super) {
  77157. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  77158. function PushMaterial(name, scene) {
  77159. var _this = _super.call(this, name, scene) || this;
  77160. _this._normalMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  77161. /**
  77162. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  77163. * This means that the material can keep using a previous shader while a new one is being compiled.
  77164. * This is mostly used when shader parallel compilation is supported (true by default)
  77165. */
  77166. _this.allowShaderHotSwapping = true;
  77167. _this._storeEffectOnSubMeshes = true;
  77168. return _this;
  77169. }
  77170. PushMaterial.prototype.getEffect = function () {
  77171. return this._activeEffect;
  77172. };
  77173. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  77174. if (!mesh) {
  77175. return false;
  77176. }
  77177. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  77178. return true;
  77179. }
  77180. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  77181. };
  77182. /**
  77183. * Binds the given world matrix to the active effect
  77184. *
  77185. * @param world the matrix to bind
  77186. */
  77187. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  77188. this._activeEffect.setMatrix("world", world);
  77189. };
  77190. /**
  77191. * Binds the given normal matrix to the active effect
  77192. *
  77193. * @param normalMatrix the matrix to bind
  77194. */
  77195. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  77196. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  77197. };
  77198. PushMaterial.prototype.bind = function (world, mesh) {
  77199. if (!mesh) {
  77200. return;
  77201. }
  77202. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  77203. };
  77204. PushMaterial.prototype._afterBind = function (mesh, effect) {
  77205. if (effect === void 0) { effect = null; }
  77206. _super.prototype._afterBind.call(this, mesh);
  77207. this.getScene()._cachedEffect = effect;
  77208. };
  77209. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  77210. if (visibility === void 0) { visibility = 1; }
  77211. return scene.isCachedMaterialInvalid(this, effect, visibility);
  77212. };
  77213. return PushMaterial;
  77214. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  77215. /***/ }),
  77216. /***/ "./Materials/shaderMaterial.ts":
  77217. /*!*************************************!*\
  77218. !*** ./Materials/shaderMaterial.ts ***!
  77219. \*************************************/
  77220. /*! exports provided: ShaderMaterial */
  77221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77222. "use strict";
  77223. __webpack_require__.r(__webpack_exports__);
  77224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  77225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  77226. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  77227. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  77228. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  77229. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  77230. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  77231. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  77232. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  77233. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  77234. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  77235. /**
  77236. * 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.
  77237. *
  77238. * This returned material effects how the mesh will look based on the code in the shaders.
  77239. *
  77240. * @see http://doc.babylonjs.com/how_to/shader_material
  77241. */
  77242. var ShaderMaterial = /** @class */ (function (_super) {
  77243. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  77244. /**
  77245. * Instantiate a new shader material.
  77246. * 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.
  77247. * This returned material effects how the mesh will look based on the code in the shaders.
  77248. * @see http://doc.babylonjs.com/how_to/shader_material
  77249. * @param name Define the name of the material in the scene
  77250. * @param scene Define the scene the material belongs to
  77251. * @param shaderPath Defines the route to the shader code in one of three ways:
  77252. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  77253. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  77254. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  77255. * @param options Define the options used to create the shader
  77256. */
  77257. function ShaderMaterial(name, scene, shaderPath, options) {
  77258. if (options === void 0) { options = {}; }
  77259. var _this = _super.call(this, name, scene) || this;
  77260. _this._textures = {};
  77261. _this._textureArrays = {};
  77262. _this._floats = {};
  77263. _this._ints = {};
  77264. _this._floatsArrays = {};
  77265. _this._colors3 = {};
  77266. _this._colors3Arrays = {};
  77267. _this._colors4 = {};
  77268. _this._colors4Arrays = {};
  77269. _this._vectors2 = {};
  77270. _this._vectors3 = {};
  77271. _this._vectors4 = {};
  77272. _this._matrices = {};
  77273. _this._matrices3x3 = {};
  77274. _this._matrices2x2 = {};
  77275. _this._vectors2Arrays = {};
  77276. _this._vectors3Arrays = {};
  77277. _this._vectors4Arrays = {};
  77278. _this._cachedWorldViewMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  77279. _this._cachedWorldViewProjectionMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  77280. _this._shaderPath = shaderPath;
  77281. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  77282. return _this;
  77283. }
  77284. Object.defineProperty(ShaderMaterial.prototype, "options", {
  77285. /**
  77286. * Gets the options used to compile the shader.
  77287. * They can be modified to trigger a new compilation
  77288. */
  77289. get: function () {
  77290. return this._options;
  77291. },
  77292. enumerable: true,
  77293. configurable: true
  77294. });
  77295. /**
  77296. * Gets the current class name of the material e.g. "ShaderMaterial"
  77297. * Mainly use in serialization.
  77298. * @returns the class name
  77299. */
  77300. ShaderMaterial.prototype.getClassName = function () {
  77301. return "ShaderMaterial";
  77302. };
  77303. /**
  77304. * Specifies if the material will require alpha blending
  77305. * @returns a boolean specifying if alpha blending is needed
  77306. */
  77307. ShaderMaterial.prototype.needAlphaBlending = function () {
  77308. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  77309. };
  77310. /**
  77311. * Specifies if this material should be rendered in alpha test mode
  77312. * @returns a boolean specifying if an alpha test is needed.
  77313. */
  77314. ShaderMaterial.prototype.needAlphaTesting = function () {
  77315. return this._options.needAlphaTesting;
  77316. };
  77317. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  77318. if (this._options.uniforms.indexOf(uniformName) === -1) {
  77319. this._options.uniforms.push(uniformName);
  77320. }
  77321. };
  77322. /**
  77323. * Set a texture in the shader.
  77324. * @param name Define the name of the uniform samplers as defined in the shader
  77325. * @param texture Define the texture to bind to this sampler
  77326. * @return the material itself allowing "fluent" like uniform updates
  77327. */
  77328. ShaderMaterial.prototype.setTexture = function (name, texture) {
  77329. if (this._options.samplers.indexOf(name) === -1) {
  77330. this._options.samplers.push(name);
  77331. }
  77332. this._textures[name] = texture;
  77333. return this;
  77334. };
  77335. /**
  77336. * Set a texture array in the shader.
  77337. * @param name Define the name of the uniform sampler array as defined in the shader
  77338. * @param textures Define the list of textures to bind to this sampler
  77339. * @return the material itself allowing "fluent" like uniform updates
  77340. */
  77341. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  77342. if (this._options.samplers.indexOf(name) === -1) {
  77343. this._options.samplers.push(name);
  77344. }
  77345. this._checkUniform(name);
  77346. this._textureArrays[name] = textures;
  77347. return this;
  77348. };
  77349. /**
  77350. * Set a float in the shader.
  77351. * @param name Define the name of the uniform as defined in the shader
  77352. * @param value Define the value to give to the uniform
  77353. * @return the material itself allowing "fluent" like uniform updates
  77354. */
  77355. ShaderMaterial.prototype.setFloat = function (name, value) {
  77356. this._checkUniform(name);
  77357. this._floats[name] = value;
  77358. return this;
  77359. };
  77360. /**
  77361. * Set a int in the shader.
  77362. * @param name Define the name of the uniform as defined in the shader
  77363. * @param value Define the value to give to the uniform
  77364. * @return the material itself allowing "fluent" like uniform updates
  77365. */
  77366. ShaderMaterial.prototype.setInt = function (name, value) {
  77367. this._checkUniform(name);
  77368. this._ints[name] = value;
  77369. return this;
  77370. };
  77371. /**
  77372. * Set an array of floats in the shader.
  77373. * @param name Define the name of the uniform as defined in the shader
  77374. * @param value Define the value to give to the uniform
  77375. * @return the material itself allowing "fluent" like uniform updates
  77376. */
  77377. ShaderMaterial.prototype.setFloats = function (name, value) {
  77378. this._checkUniform(name);
  77379. this._floatsArrays[name] = value;
  77380. return this;
  77381. };
  77382. /**
  77383. * Set a vec3 in the shader from a Color3.
  77384. * @param name Define the name of the uniform as defined in the shader
  77385. * @param value Define the value to give to the uniform
  77386. * @return the material itself allowing "fluent" like uniform updates
  77387. */
  77388. ShaderMaterial.prototype.setColor3 = function (name, value) {
  77389. this._checkUniform(name);
  77390. this._colors3[name] = value;
  77391. return this;
  77392. };
  77393. /**
  77394. * Set a vec3 array in the shader from a Color3 array.
  77395. * @param name Define the name of the uniform as defined in the shader
  77396. * @param value Define the value to give to the uniform
  77397. * @return the material itself allowing "fluent" like uniform updates
  77398. */
  77399. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  77400. this._checkUniform(name);
  77401. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  77402. color.toArray(arr, arr.length);
  77403. return arr;
  77404. }, []);
  77405. return this;
  77406. };
  77407. /**
  77408. * Set a vec4 in the shader from a Color4.
  77409. * @param name Define the name of the uniform as defined in the shader
  77410. * @param value Define the value to give to the uniform
  77411. * @return the material itself allowing "fluent" like uniform updates
  77412. */
  77413. ShaderMaterial.prototype.setColor4 = function (name, value) {
  77414. this._checkUniform(name);
  77415. this._colors4[name] = value;
  77416. return this;
  77417. };
  77418. /**
  77419. * Set a vec4 array in the shader from a Color4 array.
  77420. * @param name Define the name of the uniform as defined in the shader
  77421. * @param value Define the value to give to the uniform
  77422. * @return the material itself allowing "fluent" like uniform updates
  77423. */
  77424. ShaderMaterial.prototype.setColor4Array = function (name, value) {
  77425. this._checkUniform(name);
  77426. this._colors4Arrays[name] = value.reduce(function (arr, color) {
  77427. color.toArray(arr, arr.length);
  77428. return arr;
  77429. }, []);
  77430. return this;
  77431. };
  77432. /**
  77433. * Set a vec2 in the shader from a Vector2.
  77434. * @param name Define the name of the uniform as defined in the shader
  77435. * @param value Define the value to give to the uniform
  77436. * @return the material itself allowing "fluent" like uniform updates
  77437. */
  77438. ShaderMaterial.prototype.setVector2 = function (name, value) {
  77439. this._checkUniform(name);
  77440. this._vectors2[name] = value;
  77441. return this;
  77442. };
  77443. /**
  77444. * Set a vec3 in the shader from a Vector3.
  77445. * @param name Define the name of the uniform as defined in the shader
  77446. * @param value Define the value to give to the uniform
  77447. * @return the material itself allowing "fluent" like uniform updates
  77448. */
  77449. ShaderMaterial.prototype.setVector3 = function (name, value) {
  77450. this._checkUniform(name);
  77451. this._vectors3[name] = value;
  77452. return this;
  77453. };
  77454. /**
  77455. * Set a vec4 in the shader from a Vector4.
  77456. * @param name Define the name of the uniform as defined in the shader
  77457. * @param value Define the value to give to the uniform
  77458. * @return the material itself allowing "fluent" like uniform updates
  77459. */
  77460. ShaderMaterial.prototype.setVector4 = function (name, value) {
  77461. this._checkUniform(name);
  77462. this._vectors4[name] = value;
  77463. return this;
  77464. };
  77465. /**
  77466. * Set a mat4 in the shader from a Matrix.
  77467. * @param name Define the name of the uniform as defined in the shader
  77468. * @param value Define the value to give to the uniform
  77469. * @return the material itself allowing "fluent" like uniform updates
  77470. */
  77471. ShaderMaterial.prototype.setMatrix = function (name, value) {
  77472. this._checkUniform(name);
  77473. this._matrices[name] = value;
  77474. return this;
  77475. };
  77476. /**
  77477. * Set a mat3 in the shader from a Float32Array.
  77478. * @param name Define the name of the uniform as defined in the shader
  77479. * @param value Define the value to give to the uniform
  77480. * @return the material itself allowing "fluent" like uniform updates
  77481. */
  77482. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  77483. this._checkUniform(name);
  77484. this._matrices3x3[name] = value;
  77485. return this;
  77486. };
  77487. /**
  77488. * Set a mat2 in the shader from a Float32Array.
  77489. * @param name Define the name of the uniform as defined in the shader
  77490. * @param value Define the value to give to the uniform
  77491. * @return the material itself allowing "fluent" like uniform updates
  77492. */
  77493. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  77494. this._checkUniform(name);
  77495. this._matrices2x2[name] = value;
  77496. return this;
  77497. };
  77498. /**
  77499. * Set a vec2 array in the shader from a number array.
  77500. * @param name Define the name of the uniform as defined in the shader
  77501. * @param value Define the value to give to the uniform
  77502. * @return the material itself allowing "fluent" like uniform updates
  77503. */
  77504. ShaderMaterial.prototype.setArray2 = function (name, value) {
  77505. this._checkUniform(name);
  77506. this._vectors2Arrays[name] = value;
  77507. return this;
  77508. };
  77509. /**
  77510. * Set a vec3 array in the shader from a number array.
  77511. * @param name Define the name of the uniform as defined in the shader
  77512. * @param value Define the value to give to the uniform
  77513. * @return the material itself allowing "fluent" like uniform updates
  77514. */
  77515. ShaderMaterial.prototype.setArray3 = function (name, value) {
  77516. this._checkUniform(name);
  77517. this._vectors3Arrays[name] = value;
  77518. return this;
  77519. };
  77520. /**
  77521. * Set a vec4 array in the shader from a number array.
  77522. * @param name Define the name of the uniform as defined in the shader
  77523. * @param value Define the value to give to the uniform
  77524. * @return the material itself allowing "fluent" like uniform updates
  77525. */
  77526. ShaderMaterial.prototype.setArray4 = function (name, value) {
  77527. this._checkUniform(name);
  77528. this._vectors4Arrays[name] = value;
  77529. return this;
  77530. };
  77531. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  77532. if (!mesh) {
  77533. return true;
  77534. }
  77535. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  77536. return false;
  77537. }
  77538. return false;
  77539. };
  77540. /**
  77541. * Specifies that the submesh is ready to be used
  77542. * @param mesh defines the mesh to check
  77543. * @param subMesh defines which submesh to check
  77544. * @param useInstances specifies that instances should be used
  77545. * @returns a boolean indicating that the submesh is ready or not
  77546. */
  77547. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  77548. return this.isReady(mesh, useInstances);
  77549. };
  77550. /**
  77551. * Checks if the material is ready to render the requested mesh
  77552. * @param mesh Define the mesh to render
  77553. * @param useInstances Define whether or not the material is used with instances
  77554. * @returns true if ready, otherwise false
  77555. */
  77556. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  77557. var scene = this.getScene();
  77558. var engine = scene.getEngine();
  77559. if (!this.checkReadyOnEveryCall) {
  77560. if (this._renderId === scene.getRenderId()) {
  77561. if (this._checkCache(mesh, useInstances)) {
  77562. return true;
  77563. }
  77564. }
  77565. }
  77566. // Instances
  77567. var defines = [];
  77568. var attribs = [];
  77569. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  77570. for (var index = 0; index < this._options.defines.length; index++) {
  77571. defines.push(this._options.defines[index]);
  77572. }
  77573. for (var index = 0; index < this._options.attributes.length; index++) {
  77574. attribs.push(this._options.attributes[index]);
  77575. }
  77576. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  77577. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  77578. defines.push("#define VERTEXCOLOR");
  77579. }
  77580. if (useInstances) {
  77581. defines.push("#define INSTANCES");
  77582. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PushAttributesForInstances(attribs);
  77583. }
  77584. // Bones
  77585. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  77586. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  77587. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  77588. if (mesh.numBoneInfluencers > 4) {
  77589. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  77590. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  77591. }
  77592. var skeleton = mesh.skeleton;
  77593. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  77594. fallbacks.addCPUSkinningFallback(0, mesh);
  77595. if (skeleton.isUsingTextureForMatrices) {
  77596. defines.push("#define BONETEXTURE");
  77597. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  77598. this._options.uniforms.push("boneTextureWidth");
  77599. }
  77600. if (this._options.samplers.indexOf("boneSampler") === -1) {
  77601. this._options.samplers.push("boneSampler");
  77602. }
  77603. }
  77604. else {
  77605. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  77606. if (this._options.uniforms.indexOf("mBones") === -1) {
  77607. this._options.uniforms.push("mBones");
  77608. }
  77609. }
  77610. }
  77611. else {
  77612. defines.push("#define NUM_BONE_INFLUENCERS 0");
  77613. }
  77614. // Textures
  77615. for (var name in this._textures) {
  77616. if (!this._textures[name].isReady()) {
  77617. return false;
  77618. }
  77619. }
  77620. // Alpha test
  77621. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  77622. defines.push("#define ALPHATEST");
  77623. }
  77624. var previousEffect = this._effect;
  77625. var join = defines.join("\n");
  77626. this._effect = engine.createEffect(this._shaderPath, {
  77627. attributes: attribs,
  77628. uniformsNames: this._options.uniforms,
  77629. uniformBuffersNames: this._options.uniformBuffers,
  77630. samplers: this._options.samplers,
  77631. defines: join,
  77632. fallbacks: fallbacks,
  77633. onCompiled: this.onCompiled,
  77634. onError: this.onError
  77635. }, engine);
  77636. if (!this._effect.isReady()) {
  77637. return false;
  77638. }
  77639. if (previousEffect !== this._effect) {
  77640. scene.resetCachedMaterial();
  77641. }
  77642. this._renderId = scene.getRenderId();
  77643. return true;
  77644. };
  77645. /**
  77646. * Binds the world matrix to the material
  77647. * @param world defines the world transformation matrix
  77648. */
  77649. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  77650. var scene = this.getScene();
  77651. if (!this._effect) {
  77652. return;
  77653. }
  77654. if (this._options.uniforms.indexOf("world") !== -1) {
  77655. this._effect.setMatrix("world", world);
  77656. }
  77657. if (this._options.uniforms.indexOf("worldView") !== -1) {
  77658. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  77659. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  77660. }
  77661. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  77662. world.multiplyToRef(scene.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
  77663. this._effect.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix);
  77664. }
  77665. };
  77666. /**
  77667. * Binds the material to the mesh
  77668. * @param world defines the world transformation matrix
  77669. * @param mesh defines the mesh to bind the material to
  77670. */
  77671. ShaderMaterial.prototype.bind = function (world, mesh) {
  77672. // Std values
  77673. this.bindOnlyWorldMatrix(world);
  77674. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  77675. if (this._options.uniforms.indexOf("view") !== -1) {
  77676. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  77677. }
  77678. if (this._options.uniforms.indexOf("projection") !== -1) {
  77679. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  77680. }
  77681. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  77682. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  77683. }
  77684. // Bones
  77685. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  77686. var name;
  77687. // Texture
  77688. for (name in this._textures) {
  77689. this._effect.setTexture(name, this._textures[name]);
  77690. }
  77691. // Texture arrays
  77692. for (name in this._textureArrays) {
  77693. this._effect.setTextureArray(name, this._textureArrays[name]);
  77694. }
  77695. // Int
  77696. for (name in this._ints) {
  77697. this._effect.setInt(name, this._ints[name]);
  77698. }
  77699. // Float
  77700. for (name in this._floats) {
  77701. this._effect.setFloat(name, this._floats[name]);
  77702. }
  77703. // Floats
  77704. for (name in this._floatsArrays) {
  77705. this._effect.setArray(name, this._floatsArrays[name]);
  77706. }
  77707. // Color3
  77708. for (name in this._colors3) {
  77709. this._effect.setColor3(name, this._colors3[name]);
  77710. }
  77711. // Color3Array
  77712. for (name in this._colors3Arrays) {
  77713. this._effect.setArray3(name, this._colors3Arrays[name]);
  77714. }
  77715. // Color4
  77716. for (name in this._colors4) {
  77717. var color = this._colors4[name];
  77718. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  77719. }
  77720. // Color4Array
  77721. for (name in this._colors4Arrays) {
  77722. this._effect.setArray4(name, this._colors4Arrays[name]);
  77723. }
  77724. // Vector2
  77725. for (name in this._vectors2) {
  77726. this._effect.setVector2(name, this._vectors2[name]);
  77727. }
  77728. // Vector3
  77729. for (name in this._vectors3) {
  77730. this._effect.setVector3(name, this._vectors3[name]);
  77731. }
  77732. // Vector4
  77733. for (name in this._vectors4) {
  77734. this._effect.setVector4(name, this._vectors4[name]);
  77735. }
  77736. // Matrix
  77737. for (name in this._matrices) {
  77738. this._effect.setMatrix(name, this._matrices[name]);
  77739. }
  77740. // Matrix 3x3
  77741. for (name in this._matrices3x3) {
  77742. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  77743. }
  77744. // Matrix 2x2
  77745. for (name in this._matrices2x2) {
  77746. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  77747. }
  77748. // Vector2Array
  77749. for (name in this._vectors2Arrays) {
  77750. this._effect.setArray2(name, this._vectors2Arrays[name]);
  77751. }
  77752. // Vector3Array
  77753. for (name in this._vectors3Arrays) {
  77754. this._effect.setArray3(name, this._vectors3Arrays[name]);
  77755. }
  77756. // Vector4Array
  77757. for (name in this._vectors4Arrays) {
  77758. this._effect.setArray4(name, this._vectors4Arrays[name]);
  77759. }
  77760. }
  77761. this._afterBind(mesh);
  77762. };
  77763. /**
  77764. * Gets the active textures from the material
  77765. * @returns an array of textures
  77766. */
  77767. ShaderMaterial.prototype.getActiveTextures = function () {
  77768. var activeTextures = _super.prototype.getActiveTextures.call(this);
  77769. for (var name in this._textures) {
  77770. activeTextures.push(this._textures[name]);
  77771. }
  77772. for (var name in this._textureArrays) {
  77773. var array = this._textureArrays[name];
  77774. for (var index = 0; index < array.length; index++) {
  77775. activeTextures.push(array[index]);
  77776. }
  77777. }
  77778. return activeTextures;
  77779. };
  77780. /**
  77781. * Specifies if the material uses a texture
  77782. * @param texture defines the texture to check against the material
  77783. * @returns a boolean specifying if the material uses the texture
  77784. */
  77785. ShaderMaterial.prototype.hasTexture = function (texture) {
  77786. if (_super.prototype.hasTexture.call(this, texture)) {
  77787. return true;
  77788. }
  77789. for (var name in this._textures) {
  77790. if (this._textures[name] === texture) {
  77791. return true;
  77792. }
  77793. }
  77794. for (var name in this._textureArrays) {
  77795. var array = this._textureArrays[name];
  77796. for (var index = 0; index < array.length; index++) {
  77797. if (array[index] === texture) {
  77798. return true;
  77799. }
  77800. }
  77801. }
  77802. return false;
  77803. };
  77804. /**
  77805. * Makes a duplicate of the material, and gives it a new name
  77806. * @param name defines the new name for the duplicated material
  77807. * @returns the cloned material
  77808. */
  77809. ShaderMaterial.prototype.clone = function (name) {
  77810. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  77811. return newShaderMaterial;
  77812. };
  77813. /**
  77814. * Disposes the material
  77815. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77816. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77817. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77818. */
  77819. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  77820. if (forceDisposeTextures) {
  77821. var name;
  77822. for (name in this._textures) {
  77823. this._textures[name].dispose();
  77824. }
  77825. for (name in this._textureArrays) {
  77826. var array = this._textureArrays[name];
  77827. for (var index = 0; index < array.length; index++) {
  77828. array[index].dispose();
  77829. }
  77830. }
  77831. }
  77832. this._textures = {};
  77833. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  77834. };
  77835. /**
  77836. * Serializes this material in a JSON representation
  77837. * @returns the serialized material object
  77838. */
  77839. ShaderMaterial.prototype.serialize = function () {
  77840. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  77841. serializationObject.customType = "BABYLON.ShaderMaterial";
  77842. serializationObject.options = this._options;
  77843. serializationObject.shaderPath = this._shaderPath;
  77844. var name;
  77845. // Texture
  77846. serializationObject.textures = {};
  77847. for (name in this._textures) {
  77848. serializationObject.textures[name] = this._textures[name].serialize();
  77849. }
  77850. // Texture arrays
  77851. serializationObject.textureArrays = {};
  77852. for (name in this._textureArrays) {
  77853. serializationObject.textureArrays[name] = [];
  77854. var array = this._textureArrays[name];
  77855. for (var index = 0; index < array.length; index++) {
  77856. serializationObject.textureArrays[name].push(array[index].serialize());
  77857. }
  77858. }
  77859. // Float
  77860. serializationObject.floats = {};
  77861. for (name in this._floats) {
  77862. serializationObject.floats[name] = this._floats[name];
  77863. }
  77864. // Float s
  77865. serializationObject.FloatArrays = {};
  77866. for (name in this._floatsArrays) {
  77867. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  77868. }
  77869. // Color3
  77870. serializationObject.colors3 = {};
  77871. for (name in this._colors3) {
  77872. serializationObject.colors3[name] = this._colors3[name].asArray();
  77873. }
  77874. // Color3 array
  77875. serializationObject.colors3Arrays = {};
  77876. for (name in this._colors3Arrays) {
  77877. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  77878. }
  77879. // Color4
  77880. serializationObject.colors4 = {};
  77881. for (name in this._colors4) {
  77882. serializationObject.colors4[name] = this._colors4[name].asArray();
  77883. }
  77884. // Color4 array
  77885. serializationObject.colors4Arrays = {};
  77886. for (name in this._colors4Arrays) {
  77887. serializationObject.colors4Arrays[name] = this._colors4Arrays[name];
  77888. }
  77889. // Vector2
  77890. serializationObject.vectors2 = {};
  77891. for (name in this._vectors2) {
  77892. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  77893. }
  77894. // Vector3
  77895. serializationObject.vectors3 = {};
  77896. for (name in this._vectors3) {
  77897. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  77898. }
  77899. // Vector4
  77900. serializationObject.vectors4 = {};
  77901. for (name in this._vectors4) {
  77902. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  77903. }
  77904. // Matrix
  77905. serializationObject.matrices = {};
  77906. for (name in this._matrices) {
  77907. serializationObject.matrices[name] = this._matrices[name].asArray();
  77908. }
  77909. // Matrix 3x3
  77910. serializationObject.matrices3x3 = {};
  77911. for (name in this._matrices3x3) {
  77912. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  77913. }
  77914. // Matrix 2x2
  77915. serializationObject.matrices2x2 = {};
  77916. for (name in this._matrices2x2) {
  77917. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  77918. }
  77919. // Vector2Array
  77920. serializationObject.vectors2Arrays = {};
  77921. for (name in this._vectors2Arrays) {
  77922. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  77923. }
  77924. // Vector3Array
  77925. serializationObject.vectors3Arrays = {};
  77926. for (name in this._vectors3Arrays) {
  77927. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  77928. }
  77929. // Vector4Array
  77930. serializationObject.vectors4Arrays = {};
  77931. for (name in this._vectors4Arrays) {
  77932. serializationObject.vectors4Arrays[name] = this._vectors4Arrays[name];
  77933. }
  77934. return serializationObject;
  77935. };
  77936. /**
  77937. * Creates a shader material from parsed shader material data
  77938. * @param source defines the JSON represnetation of the material
  77939. * @param scene defines the hosting scene
  77940. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77941. * @returns a new material
  77942. */
  77943. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  77944. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  77945. var name;
  77946. // Texture
  77947. for (name in source.textures) {
  77948. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  77949. }
  77950. // Texture arrays
  77951. for (name in source.textureArrays) {
  77952. var array = source.textureArrays[name];
  77953. var textureArray = new Array();
  77954. for (var index = 0; index < array.length; index++) {
  77955. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  77956. }
  77957. material.setTextureArray(name, textureArray);
  77958. }
  77959. // Float
  77960. for (name in source.floats) {
  77961. material.setFloat(name, source.floats[name]);
  77962. }
  77963. // Float s
  77964. for (name in source.floatsArrays) {
  77965. material.setFloats(name, source.floatsArrays[name]);
  77966. }
  77967. // Color3
  77968. for (name in source.colors3) {
  77969. material.setColor3(name, _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color3"].FromArray(source.colors3[name]));
  77970. }
  77971. // Color3 arrays
  77972. for (name in source.colors3Arrays) {
  77973. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  77974. if (i % 3 === 0) {
  77975. arr.push([num]);
  77976. }
  77977. else {
  77978. arr[arr.length - 1].push(num);
  77979. }
  77980. return arr;
  77981. }, []).map(function (color) { return _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color3"].FromArray(color); });
  77982. material.setColor3Array(name, colors);
  77983. }
  77984. // Color4
  77985. for (name in source.colors4) {
  77986. material.setColor4(name, _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color4"].FromArray(source.colors4[name]));
  77987. }
  77988. // Color4 arrays
  77989. for (name in source.colors4Arrays) {
  77990. var colors = source.colors4Arrays[name].reduce(function (arr, num, i) {
  77991. if (i % 4 === 0) {
  77992. arr.push([num]);
  77993. }
  77994. else {
  77995. arr[arr.length - 1].push(num);
  77996. }
  77997. return arr;
  77998. }, []).map(function (color) { return _Maths_math_color__WEBPACK_IMPORTED_MODULE_9__["Color4"].FromArray(color); });
  77999. material.setColor4Array(name, colors);
  78000. }
  78001. // Vector2
  78002. for (name in source.vectors2) {
  78003. material.setVector2(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  78004. }
  78005. // Vector3
  78006. for (name in source.vectors3) {
  78007. material.setVector3(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  78008. }
  78009. // Vector4
  78010. for (name in source.vectors4) {
  78011. material.setVector4(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  78012. }
  78013. // Matrix
  78014. for (name in source.matrices) {
  78015. material.setMatrix(name, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  78016. }
  78017. // Matrix 3x3
  78018. for (name in source.matrices3x3) {
  78019. material.setMatrix3x3(name, source.matrices3x3[name]);
  78020. }
  78021. // Matrix 2x2
  78022. for (name in source.matrices2x2) {
  78023. material.setMatrix2x2(name, source.matrices2x2[name]);
  78024. }
  78025. // Vector2Array
  78026. for (name in source.vectors2Arrays) {
  78027. material.setArray2(name, source.vectors2Arrays[name]);
  78028. }
  78029. // Vector3Array
  78030. for (name in source.vectors3Arrays) {
  78031. material.setArray3(name, source.vectors3Arrays[name]);
  78032. }
  78033. // Vector4Array
  78034. for (name in source.vectors4Arrays) {
  78035. material.setArray4(name, source.vectors4Arrays[name]);
  78036. }
  78037. return material;
  78038. };
  78039. return ShaderMaterial;
  78040. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  78041. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  78042. /***/ }),
  78043. /***/ "./Materials/standardMaterial.ts":
  78044. /*!***************************************!*\
  78045. !*** ./Materials/standardMaterial.ts ***!
  78046. \***************************************/
  78047. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  78048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78049. "use strict";
  78050. __webpack_require__.r(__webpack_exports__);
  78051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  78052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  78053. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78054. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  78055. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  78056. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  78057. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  78058. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  78059. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78060. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  78061. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  78062. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  78063. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  78064. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  78065. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  78066. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  78067. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  78068. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  78069. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  78070. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78071. /** @hidden */
  78072. var StandardMaterialDefines = /** @class */ (function (_super) {
  78073. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  78074. function StandardMaterialDefines() {
  78075. var _this = _super.call(this) || this;
  78076. _this.MAINUV1 = false;
  78077. _this.MAINUV2 = false;
  78078. _this.DIFFUSE = false;
  78079. _this.DIFFUSEDIRECTUV = 0;
  78080. _this.AMBIENT = false;
  78081. _this.AMBIENTDIRECTUV = 0;
  78082. _this.OPACITY = false;
  78083. _this.OPACITYDIRECTUV = 0;
  78084. _this.OPACITYRGB = false;
  78085. _this.REFLECTION = false;
  78086. _this.EMISSIVE = false;
  78087. _this.EMISSIVEDIRECTUV = 0;
  78088. _this.SPECULAR = false;
  78089. _this.SPECULARDIRECTUV = 0;
  78090. _this.BUMP = false;
  78091. _this.BUMPDIRECTUV = 0;
  78092. _this.PARALLAX = false;
  78093. _this.PARALLAXOCCLUSION = false;
  78094. _this.SPECULAROVERALPHA = false;
  78095. _this.CLIPPLANE = false;
  78096. _this.CLIPPLANE2 = false;
  78097. _this.CLIPPLANE3 = false;
  78098. _this.CLIPPLANE4 = false;
  78099. _this.ALPHATEST = false;
  78100. _this.DEPTHPREPASS = false;
  78101. _this.ALPHAFROMDIFFUSE = false;
  78102. _this.POINTSIZE = false;
  78103. _this.FOG = false;
  78104. _this.SPECULARTERM = false;
  78105. _this.DIFFUSEFRESNEL = false;
  78106. _this.OPACITYFRESNEL = false;
  78107. _this.REFLECTIONFRESNEL = false;
  78108. _this.REFRACTIONFRESNEL = false;
  78109. _this.EMISSIVEFRESNEL = false;
  78110. _this.FRESNEL = false;
  78111. _this.NORMAL = false;
  78112. _this.UV1 = false;
  78113. _this.UV2 = false;
  78114. _this.VERTEXCOLOR = false;
  78115. _this.VERTEXALPHA = false;
  78116. _this.NUM_BONE_INFLUENCERS = 0;
  78117. _this.BonesPerMesh = 0;
  78118. _this.BONETEXTURE = false;
  78119. _this.INSTANCES = false;
  78120. _this.GLOSSINESS = false;
  78121. _this.ROUGHNESS = false;
  78122. _this.EMISSIVEASILLUMINATION = false;
  78123. _this.LINKEMISSIVEWITHDIFFUSE = false;
  78124. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  78125. _this.LIGHTMAP = false;
  78126. _this.LIGHTMAPDIRECTUV = 0;
  78127. _this.OBJECTSPACE_NORMALMAP = false;
  78128. _this.USELIGHTMAPASSHADOWMAP = false;
  78129. _this.REFLECTIONMAP_3D = false;
  78130. _this.REFLECTIONMAP_SPHERICAL = false;
  78131. _this.REFLECTIONMAP_PLANAR = false;
  78132. _this.REFLECTIONMAP_CUBIC = false;
  78133. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  78134. _this.REFLECTIONMAP_PROJECTION = false;
  78135. _this.REFLECTIONMAP_SKYBOX = false;
  78136. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  78137. _this.REFLECTIONMAP_EXPLICIT = false;
  78138. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  78139. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  78140. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  78141. _this.INVERTCUBICMAP = false;
  78142. _this.LOGARITHMICDEPTH = false;
  78143. _this.REFRACTION = false;
  78144. _this.REFRACTIONMAP_3D = false;
  78145. _this.REFLECTIONOVERALPHA = false;
  78146. _this.TWOSIDEDLIGHTING = false;
  78147. _this.SHADOWFLOAT = false;
  78148. _this.MORPHTARGETS = false;
  78149. _this.MORPHTARGETS_NORMAL = false;
  78150. _this.MORPHTARGETS_TANGENT = false;
  78151. _this.MORPHTARGETS_UV = false;
  78152. _this.NUM_MORPH_INFLUENCERS = 0;
  78153. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  78154. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  78155. _this.IMAGEPROCESSING = false;
  78156. _this.VIGNETTE = false;
  78157. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  78158. _this.VIGNETTEBLENDMODEOPAQUE = false;
  78159. _this.TONEMAPPING = false;
  78160. _this.TONEMAPPING_ACES = false;
  78161. _this.CONTRAST = false;
  78162. _this.COLORCURVES = false;
  78163. _this.COLORGRADING = false;
  78164. _this.COLORGRADING3D = false;
  78165. _this.SAMPLER3DGREENDEPTH = false;
  78166. _this.SAMPLER3DBGRMAP = false;
  78167. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  78168. _this.MULTIVIEW = false;
  78169. /**
  78170. * If the reflection texture on this material is in linear color space
  78171. * @hidden
  78172. */
  78173. _this.IS_REFLECTION_LINEAR = false;
  78174. /**
  78175. * If the refraction texture on this material is in linear color space
  78176. * @hidden
  78177. */
  78178. _this.IS_REFRACTION_LINEAR = false;
  78179. _this.EXPOSURE = false;
  78180. _this.rebuild();
  78181. return _this;
  78182. }
  78183. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  78184. var modes = [
  78185. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  78186. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  78187. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  78188. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  78189. ];
  78190. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  78191. var mode = modes_1[_i];
  78192. this[mode] = (mode === modeToEnable);
  78193. }
  78194. };
  78195. return StandardMaterialDefines;
  78196. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_9__["MaterialDefines"]));
  78197. /**
  78198. * This is the default material used in Babylon. It is the best trade off between quality
  78199. * and performances.
  78200. * @see http://doc.babylonjs.com/babylon101/materials
  78201. */
  78202. var StandardMaterial = /** @class */ (function (_super) {
  78203. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  78204. /**
  78205. * Instantiates a new standard material.
  78206. * This is the default material used in Babylon. It is the best trade off between quality
  78207. * and performances.
  78208. * @see http://doc.babylonjs.com/babylon101/materials
  78209. * @param name Define the name of the material in the scene
  78210. * @param scene Define the scene the material belong to
  78211. */
  78212. function StandardMaterial(name, scene) {
  78213. var _this = _super.call(this, name, scene) || this;
  78214. _this._diffuseTexture = null;
  78215. _this._ambientTexture = null;
  78216. _this._opacityTexture = null;
  78217. _this._reflectionTexture = null;
  78218. _this._emissiveTexture = null;
  78219. _this._specularTexture = null;
  78220. _this._bumpTexture = null;
  78221. _this._lightmapTexture = null;
  78222. _this._refractionTexture = null;
  78223. /**
  78224. * The color of the material lit by the environmental background lighting.
  78225. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  78226. */
  78227. _this.ambientColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](0, 0, 0);
  78228. /**
  78229. * The basic color of the material as viewed under a light.
  78230. */
  78231. _this.diffuseColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](1, 1, 1);
  78232. /**
  78233. * Define how the color and intensity of the highlight given by the light in the material.
  78234. */
  78235. _this.specularColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](1, 1, 1);
  78236. /**
  78237. * Define the color of the material as if self lit.
  78238. * This will be mixed in the final result even in the absence of light.
  78239. */
  78240. _this.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](0, 0, 0);
  78241. /**
  78242. * Defines how sharp are the highlights in the material.
  78243. * The bigger the value the sharper giving a more glossy feeling to the result.
  78244. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  78245. */
  78246. _this.specularPower = 64;
  78247. _this._useAlphaFromDiffuseTexture = false;
  78248. _this._useEmissiveAsIllumination = false;
  78249. _this._linkEmissiveWithDiffuse = false;
  78250. _this._useSpecularOverAlpha = false;
  78251. _this._useReflectionOverAlpha = false;
  78252. _this._disableLighting = false;
  78253. _this._useObjectSpaceNormalMap = false;
  78254. _this._useParallax = false;
  78255. _this._useParallaxOcclusion = false;
  78256. /**
  78257. * 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.
  78258. */
  78259. _this.parallaxScaleBias = 0.05;
  78260. _this._roughness = 0;
  78261. /**
  78262. * In case of refraction, define the value of the index of refraction.
  78263. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  78264. */
  78265. _this.indexOfRefraction = 0.98;
  78266. /**
  78267. * Invert the refraction texture alongside the y axis.
  78268. * It can be useful with procedural textures or probe for instance.
  78269. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  78270. */
  78271. _this.invertRefractionY = true;
  78272. /**
  78273. * Defines the alpha limits in alpha test mode.
  78274. */
  78275. _this.alphaCutOff = 0.4;
  78276. _this._useLightmapAsShadowmap = false;
  78277. _this._useReflectionFresnelFromSpecular = false;
  78278. _this._useGlossinessFromSpecularMapAlpha = false;
  78279. _this._maxSimultaneousLights = 4;
  78280. _this._invertNormalMapX = false;
  78281. _this._invertNormalMapY = false;
  78282. _this._twoSidedLighting = false;
  78283. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  78284. _this._worldViewProjectionMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  78285. _this._globalAmbientColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](0, 0, 0);
  78286. // Setup the default processing configuration to the scene.
  78287. _this._attachImageProcessingConfiguration(null);
  78288. _this.getRenderTargetTextures = function () {
  78289. _this._renderTargets.reset();
  78290. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  78291. _this._renderTargets.push(_this._reflectionTexture);
  78292. }
  78293. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  78294. _this._renderTargets.push(_this._refractionTexture);
  78295. }
  78296. return _this._renderTargets;
  78297. };
  78298. return _this;
  78299. }
  78300. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  78301. /**
  78302. * Gets the image processing configuration used either in this material.
  78303. */
  78304. get: function () {
  78305. return this._imageProcessingConfiguration;
  78306. },
  78307. /**
  78308. * Sets the Default image processing configuration used either in the this material.
  78309. *
  78310. * If sets to null, the scene one is in use.
  78311. */
  78312. set: function (value) {
  78313. this._attachImageProcessingConfiguration(value);
  78314. // Ensure the effect will be rebuilt.
  78315. this._markAllSubMeshesAsTexturesDirty();
  78316. },
  78317. enumerable: true,
  78318. configurable: true
  78319. });
  78320. /**
  78321. * Attaches a new image processing configuration to the Standard Material.
  78322. * @param configuration
  78323. */
  78324. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  78325. var _this = this;
  78326. if (configuration === this._imageProcessingConfiguration) {
  78327. return;
  78328. }
  78329. // Detaches observer
  78330. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  78331. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  78332. }
  78333. // Pick the scene configuration if needed
  78334. if (!configuration) {
  78335. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  78336. }
  78337. else {
  78338. this._imageProcessingConfiguration = configuration;
  78339. }
  78340. // Attaches observer
  78341. if (this._imageProcessingConfiguration) {
  78342. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  78343. _this._markAllSubMeshesAsImageProcessingDirty();
  78344. });
  78345. }
  78346. };
  78347. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  78348. /**
  78349. * Gets wether the color curves effect is enabled.
  78350. */
  78351. get: function () {
  78352. return this.imageProcessingConfiguration.colorCurvesEnabled;
  78353. },
  78354. /**
  78355. * Sets wether the color curves effect is enabled.
  78356. */
  78357. set: function (value) {
  78358. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  78359. },
  78360. enumerable: true,
  78361. configurable: true
  78362. });
  78363. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  78364. /**
  78365. * Gets wether the color grading effect is enabled.
  78366. */
  78367. get: function () {
  78368. return this.imageProcessingConfiguration.colorGradingEnabled;
  78369. },
  78370. /**
  78371. * Gets wether the color grading effect is enabled.
  78372. */
  78373. set: function (value) {
  78374. this.imageProcessingConfiguration.colorGradingEnabled = value;
  78375. },
  78376. enumerable: true,
  78377. configurable: true
  78378. });
  78379. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  78380. /**
  78381. * Gets wether tonemapping is enabled or not.
  78382. */
  78383. get: function () {
  78384. return this._imageProcessingConfiguration.toneMappingEnabled;
  78385. },
  78386. /**
  78387. * Sets wether tonemapping is enabled or not
  78388. */
  78389. set: function (value) {
  78390. this._imageProcessingConfiguration.toneMappingEnabled = value;
  78391. },
  78392. enumerable: true,
  78393. configurable: true
  78394. });
  78395. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  78396. /**
  78397. * The camera exposure used on this material.
  78398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  78399. * This corresponds to a photographic exposure.
  78400. */
  78401. get: function () {
  78402. return this._imageProcessingConfiguration.exposure;
  78403. },
  78404. /**
  78405. * The camera exposure used on this material.
  78406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  78407. * This corresponds to a photographic exposure.
  78408. */
  78409. set: function (value) {
  78410. this._imageProcessingConfiguration.exposure = value;
  78411. },
  78412. enumerable: true,
  78413. configurable: true
  78414. });
  78415. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  78416. /**
  78417. * Gets The camera contrast used on this material.
  78418. */
  78419. get: function () {
  78420. return this._imageProcessingConfiguration.contrast;
  78421. },
  78422. /**
  78423. * Sets The camera contrast used on this material.
  78424. */
  78425. set: function (value) {
  78426. this._imageProcessingConfiguration.contrast = value;
  78427. },
  78428. enumerable: true,
  78429. configurable: true
  78430. });
  78431. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  78432. /**
  78433. * Gets the Color Grading 2D Lookup Texture.
  78434. */
  78435. get: function () {
  78436. return this._imageProcessingConfiguration.colorGradingTexture;
  78437. },
  78438. /**
  78439. * Sets the Color Grading 2D Lookup Texture.
  78440. */
  78441. set: function (value) {
  78442. this._imageProcessingConfiguration.colorGradingTexture = value;
  78443. },
  78444. enumerable: true,
  78445. configurable: true
  78446. });
  78447. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  78448. /**
  78449. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78450. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78451. * 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;
  78452. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78453. */
  78454. get: function () {
  78455. return this._imageProcessingConfiguration.colorCurves;
  78456. },
  78457. /**
  78458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78460. * 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;
  78461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78462. */
  78463. set: function (value) {
  78464. this._imageProcessingConfiguration.colorCurves = value;
  78465. },
  78466. enumerable: true,
  78467. configurable: true
  78468. });
  78469. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  78470. /**
  78471. * Gets a boolean indicating that current material needs to register RTT
  78472. */
  78473. get: function () {
  78474. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  78475. return true;
  78476. }
  78477. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  78478. return true;
  78479. }
  78480. return false;
  78481. },
  78482. enumerable: true,
  78483. configurable: true
  78484. });
  78485. /**
  78486. * Gets the current class name of the material e.g. "StandardMaterial"
  78487. * Mainly use in serialization.
  78488. * @returns the class name
  78489. */
  78490. StandardMaterial.prototype.getClassName = function () {
  78491. return "StandardMaterial";
  78492. };
  78493. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  78494. /**
  78495. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  78496. * You can try switching to logarithmic depth.
  78497. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  78498. */
  78499. get: function () {
  78500. return this._useLogarithmicDepth;
  78501. },
  78502. set: function (value) {
  78503. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  78504. this._markAllSubMeshesAsMiscDirty();
  78505. },
  78506. enumerable: true,
  78507. configurable: true
  78508. });
  78509. /**
  78510. * Specifies if the material will require alpha blending
  78511. * @returns a boolean specifying if alpha blending is needed
  78512. */
  78513. StandardMaterial.prototype.needAlphaBlending = function () {
  78514. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  78515. };
  78516. /**
  78517. * Specifies if this material should be rendered in alpha test mode
  78518. * @returns a boolean specifying if an alpha test is needed.
  78519. */
  78520. StandardMaterial.prototype.needAlphaTesting = function () {
  78521. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  78522. };
  78523. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  78524. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  78525. };
  78526. /**
  78527. * Get the texture used for alpha test purpose.
  78528. * @returns the diffuse texture in case of the standard material.
  78529. */
  78530. StandardMaterial.prototype.getAlphaTestTexture = function () {
  78531. return this._diffuseTexture;
  78532. };
  78533. /**
  78534. * Get if the submesh is ready to be used and all its information available.
  78535. * Child classes can use it to update shaders
  78536. * @param mesh defines the mesh to check
  78537. * @param subMesh defines which submesh to check
  78538. * @param useInstances specifies that instances should be used
  78539. * @returns a boolean indicating that the submesh is ready or not
  78540. */
  78541. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  78542. if (useInstances === void 0) { useInstances = false; }
  78543. if (subMesh.effect && this.isFrozen) {
  78544. if (this._wasPreviouslyReady) {
  78545. return true;
  78546. }
  78547. }
  78548. if (!subMesh._materialDefines) {
  78549. subMesh._materialDefines = new StandardMaterialDefines();
  78550. }
  78551. var scene = this.getScene();
  78552. var defines = subMesh._materialDefines;
  78553. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  78554. if (defines._renderId === scene.getRenderId()) {
  78555. return true;
  78556. }
  78557. }
  78558. var engine = scene.getEngine();
  78559. // Lights
  78560. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  78561. // Multiview
  78562. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  78563. // Textures
  78564. if (defines._areTexturesDirty) {
  78565. defines._needUVs = false;
  78566. defines.MAINUV1 = false;
  78567. defines.MAINUV2 = false;
  78568. if (scene.texturesEnabled) {
  78569. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  78570. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  78571. return false;
  78572. }
  78573. else {
  78574. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  78575. }
  78576. }
  78577. else {
  78578. defines.DIFFUSE = false;
  78579. }
  78580. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  78581. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  78582. return false;
  78583. }
  78584. else {
  78585. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  78586. }
  78587. }
  78588. else {
  78589. defines.AMBIENT = false;
  78590. }
  78591. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  78592. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  78593. return false;
  78594. }
  78595. else {
  78596. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  78597. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  78598. }
  78599. }
  78600. else {
  78601. defines.OPACITY = false;
  78602. }
  78603. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  78604. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  78605. return false;
  78606. }
  78607. else {
  78608. defines._needNormals = true;
  78609. defines.REFLECTION = true;
  78610. defines.ROUGHNESS = (this._roughness > 0);
  78611. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  78612. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].INVCUBIC_MODE);
  78613. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  78614. switch (this._reflectionTexture.coordinatesMode) {
  78615. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].EXPLICIT_MODE:
  78616. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  78617. break;
  78618. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].PLANAR_MODE:
  78619. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  78620. break;
  78621. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].PROJECTION_MODE:
  78622. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  78623. break;
  78624. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].SKYBOX_MODE:
  78625. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  78626. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  78627. break;
  78628. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].SPHERICAL_MODE:
  78629. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  78630. break;
  78631. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].EQUIRECTANGULAR_MODE:
  78632. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  78633. break;
  78634. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  78635. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  78636. break;
  78637. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  78638. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  78639. break;
  78640. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].CUBIC_MODE:
  78641. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_12__["Texture"].INVCUBIC_MODE:
  78642. default:
  78643. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  78644. break;
  78645. }
  78646. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  78647. }
  78648. }
  78649. else {
  78650. defines.REFLECTION = false;
  78651. }
  78652. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  78653. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  78654. return false;
  78655. }
  78656. else {
  78657. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  78658. }
  78659. }
  78660. else {
  78661. defines.EMISSIVE = false;
  78662. }
  78663. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  78664. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  78665. return false;
  78666. }
  78667. else {
  78668. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  78669. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  78670. }
  78671. }
  78672. else {
  78673. defines.LIGHTMAP = false;
  78674. }
  78675. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  78676. if (!this._specularTexture.isReadyOrNotBlocking()) {
  78677. return false;
  78678. }
  78679. else {
  78680. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  78681. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  78682. }
  78683. }
  78684. else {
  78685. defines.SPECULAR = false;
  78686. }
  78687. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  78688. // Bump texure can not be not blocking.
  78689. if (!this._bumpTexture.isReady()) {
  78690. return false;
  78691. }
  78692. else {
  78693. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  78694. defines.PARALLAX = this._useParallax;
  78695. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  78696. }
  78697. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  78698. }
  78699. else {
  78700. defines.BUMP = false;
  78701. }
  78702. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  78703. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  78704. return false;
  78705. }
  78706. else {
  78707. defines._needUVs = true;
  78708. defines.REFRACTION = true;
  78709. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  78710. }
  78711. }
  78712. else {
  78713. defines.REFRACTION = false;
  78714. }
  78715. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  78716. }
  78717. else {
  78718. defines.DIFFUSE = false;
  78719. defines.AMBIENT = false;
  78720. defines.OPACITY = false;
  78721. defines.REFLECTION = false;
  78722. defines.EMISSIVE = false;
  78723. defines.LIGHTMAP = false;
  78724. defines.BUMP = false;
  78725. defines.REFRACTION = false;
  78726. }
  78727. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  78728. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  78729. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  78730. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  78731. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  78732. }
  78733. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  78734. if (!this._imageProcessingConfiguration.isReady()) {
  78735. return false;
  78736. }
  78737. this._imageProcessingConfiguration.prepareDefines(defines);
  78738. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  78739. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  78740. }
  78741. if (defines._areFresnelDirty) {
  78742. if (StandardMaterial.FresnelEnabled) {
  78743. // Fresnel
  78744. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  78745. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  78746. this._reflectionFresnelParameters) {
  78747. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  78748. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  78749. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  78750. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  78751. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  78752. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  78753. defines._needNormals = true;
  78754. defines.FRESNEL = true;
  78755. }
  78756. }
  78757. else {
  78758. defines.FRESNEL = false;
  78759. }
  78760. }
  78761. // Misc.
  78762. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  78763. // Attribs
  78764. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  78765. // Values that need to be evaluated on every frame
  78766. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  78767. // Get correct effect
  78768. if (defines.isDirty) {
  78769. defines.markAsProcessed();
  78770. // Fallbacks
  78771. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_8__["EffectFallbacks"]();
  78772. if (defines.REFLECTION) {
  78773. fallbacks.addFallback(0, "REFLECTION");
  78774. }
  78775. if (defines.SPECULAR) {
  78776. fallbacks.addFallback(0, "SPECULAR");
  78777. }
  78778. if (defines.BUMP) {
  78779. fallbacks.addFallback(0, "BUMP");
  78780. }
  78781. if (defines.PARALLAX) {
  78782. fallbacks.addFallback(1, "PARALLAX");
  78783. }
  78784. if (defines.PARALLAXOCCLUSION) {
  78785. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  78786. }
  78787. if (defines.SPECULAROVERALPHA) {
  78788. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  78789. }
  78790. if (defines.FOG) {
  78791. fallbacks.addFallback(1, "FOG");
  78792. }
  78793. if (defines.POINTSIZE) {
  78794. fallbacks.addFallback(0, "POINTSIZE");
  78795. }
  78796. if (defines.LOGARITHMICDEPTH) {
  78797. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  78798. }
  78799. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  78800. if (defines.SPECULARTERM) {
  78801. fallbacks.addFallback(0, "SPECULARTERM");
  78802. }
  78803. if (defines.DIFFUSEFRESNEL) {
  78804. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  78805. }
  78806. if (defines.OPACITYFRESNEL) {
  78807. fallbacks.addFallback(2, "OPACITYFRESNEL");
  78808. }
  78809. if (defines.REFLECTIONFRESNEL) {
  78810. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  78811. }
  78812. if (defines.EMISSIVEFRESNEL) {
  78813. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  78814. }
  78815. if (defines.FRESNEL) {
  78816. fallbacks.addFallback(4, "FRESNEL");
  78817. }
  78818. if (defines.MULTIVIEW) {
  78819. fallbacks.addFallback(0, "MULTIVIEW");
  78820. }
  78821. //Attributes
  78822. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  78823. if (defines.NORMAL) {
  78824. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].NormalKind);
  78825. }
  78826. if (defines.UV1) {
  78827. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  78828. }
  78829. if (defines.UV2) {
  78830. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  78831. }
  78832. if (defines.VERTEXCOLOR) {
  78833. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  78834. }
  78835. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  78836. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  78837. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  78838. var shaderName = "default";
  78839. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  78840. "vFogInfos", "vFogColor", "pointSize",
  78841. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  78842. "mBones",
  78843. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  78844. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  78845. "vReflectionPosition", "vReflectionSize",
  78846. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  78847. ];
  78848. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  78849. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  78850. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  78851. var uniformBuffers = ["Material", "Scene"];
  78852. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_7__["ImageProcessingConfiguration"]) {
  78853. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_7__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  78854. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_7__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  78855. }
  78856. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].PrepareUniformsAndSamplersList({
  78857. uniformsNames: uniforms,
  78858. uniformBuffersNames: uniformBuffers,
  78859. samplers: samplers,
  78860. defines: defines,
  78861. maxSimultaneousLights: this._maxSimultaneousLights
  78862. });
  78863. if (this.customShaderNameResolve) {
  78864. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  78865. }
  78866. var join = defines.toString();
  78867. var previousEffect = subMesh.effect;
  78868. var effect = scene.getEngine().createEffect(shaderName, {
  78869. attributes: attribs,
  78870. uniformsNames: uniforms,
  78871. uniformBuffersNames: uniformBuffers,
  78872. samplers: samplers,
  78873. defines: join,
  78874. fallbacks: fallbacks,
  78875. onCompiled: this.onCompiled,
  78876. onError: this.onError,
  78877. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  78878. }, engine);
  78879. if (effect) {
  78880. // Use previous effect while new one is compiling
  78881. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  78882. effect = previousEffect;
  78883. defines.markAsUnprocessed();
  78884. }
  78885. else {
  78886. scene.resetCachedMaterial();
  78887. subMesh.setEffect(effect, defines);
  78888. this.buildUniformLayout();
  78889. }
  78890. }
  78891. }
  78892. if (!subMesh.effect || !subMesh.effect.isReady()) {
  78893. return false;
  78894. }
  78895. defines._renderId = scene.getRenderId();
  78896. this._wasPreviouslyReady = true;
  78897. return true;
  78898. };
  78899. /**
  78900. * Builds the material UBO layouts.
  78901. * Used internally during the effect preparation.
  78902. */
  78903. StandardMaterial.prototype.buildUniformLayout = function () {
  78904. // Order is important !
  78905. var ubo = this._uniformBuffer;
  78906. ubo.addUniform("diffuseLeftColor", 4);
  78907. ubo.addUniform("diffuseRightColor", 4);
  78908. ubo.addUniform("opacityParts", 4);
  78909. ubo.addUniform("reflectionLeftColor", 4);
  78910. ubo.addUniform("reflectionRightColor", 4);
  78911. ubo.addUniform("refractionLeftColor", 4);
  78912. ubo.addUniform("refractionRightColor", 4);
  78913. ubo.addUniform("emissiveLeftColor", 4);
  78914. ubo.addUniform("emissiveRightColor", 4);
  78915. ubo.addUniform("vDiffuseInfos", 2);
  78916. ubo.addUniform("vAmbientInfos", 2);
  78917. ubo.addUniform("vOpacityInfos", 2);
  78918. ubo.addUniform("vReflectionInfos", 2);
  78919. ubo.addUniform("vReflectionPosition", 3);
  78920. ubo.addUniform("vReflectionSize", 3);
  78921. ubo.addUniform("vEmissiveInfos", 2);
  78922. ubo.addUniform("vLightmapInfos", 2);
  78923. ubo.addUniform("vSpecularInfos", 2);
  78924. ubo.addUniform("vBumpInfos", 3);
  78925. ubo.addUniform("diffuseMatrix", 16);
  78926. ubo.addUniform("ambientMatrix", 16);
  78927. ubo.addUniform("opacityMatrix", 16);
  78928. ubo.addUniform("reflectionMatrix", 16);
  78929. ubo.addUniform("emissiveMatrix", 16);
  78930. ubo.addUniform("lightmapMatrix", 16);
  78931. ubo.addUniform("specularMatrix", 16);
  78932. ubo.addUniform("bumpMatrix", 16);
  78933. ubo.addUniform("vTangentSpaceParams", 2);
  78934. ubo.addUniform("pointSize", 1);
  78935. ubo.addUniform("refractionMatrix", 16);
  78936. ubo.addUniform("vRefractionInfos", 4);
  78937. ubo.addUniform("vSpecularColor", 4);
  78938. ubo.addUniform("vEmissiveColor", 3);
  78939. ubo.addUniform("visibility", 1);
  78940. ubo.addUniform("vDiffuseColor", 4);
  78941. ubo.create();
  78942. };
  78943. /**
  78944. * Unbinds the material from the mesh
  78945. */
  78946. StandardMaterial.prototype.unbind = function () {
  78947. if (this._activeEffect) {
  78948. var needFlag = false;
  78949. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  78950. this._activeEffect.setTexture("reflection2DSampler", null);
  78951. needFlag = true;
  78952. }
  78953. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  78954. this._activeEffect.setTexture("refraction2DSampler", null);
  78955. needFlag = true;
  78956. }
  78957. if (needFlag) {
  78958. this._markAllSubMeshesAsTexturesDirty();
  78959. }
  78960. }
  78961. _super.prototype.unbind.call(this);
  78962. };
  78963. /**
  78964. * Binds the submesh to this material by preparing the effect and shader to draw
  78965. * @param world defines the world transformation matrix
  78966. * @param mesh defines the mesh containing the submesh
  78967. * @param subMesh defines the submesh to bind the material to
  78968. */
  78969. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  78970. var scene = this.getScene();
  78971. var defines = subMesh._materialDefines;
  78972. if (!defines) {
  78973. return;
  78974. }
  78975. var effect = subMesh.effect;
  78976. if (!effect) {
  78977. return;
  78978. }
  78979. this._activeEffect = effect;
  78980. // Matrices
  78981. if (!defines.INSTANCES) {
  78982. this.bindOnlyWorldMatrix(world);
  78983. }
  78984. // Normal Matrix
  78985. if (defines.OBJECTSPACE_NORMALMAP) {
  78986. world.toNormalMatrix(this._normalMatrix);
  78987. this.bindOnlyNormalMatrix(this._normalMatrix);
  78988. }
  78989. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  78990. // Bones
  78991. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindBonesParameters(mesh, effect);
  78992. var ubo = this._uniformBuffer;
  78993. if (mustRebind) {
  78994. ubo.bindToEffect(effect, "Material");
  78995. this.bindViewProjection(effect);
  78996. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  78997. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  78998. // Fresnel
  78999. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  79000. ubo.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  79001. ubo.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  79002. }
  79003. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  79004. ubo.updateColor4("opacityParts", new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
  79005. }
  79006. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  79007. ubo.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  79008. ubo.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  79009. }
  79010. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  79011. ubo.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  79012. ubo.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  79013. }
  79014. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  79015. ubo.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  79016. ubo.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  79017. }
  79018. }
  79019. // Textures
  79020. if (scene.texturesEnabled) {
  79021. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  79022. ubo.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  79023. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, ubo, "diffuse");
  79024. if (this._diffuseTexture.hasAlpha) {
  79025. effect.setFloat("alphaCutOff", this.alphaCutOff);
  79026. }
  79027. }
  79028. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  79029. ubo.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  79030. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  79031. }
  79032. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  79033. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  79034. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  79035. }
  79036. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  79037. ubo.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  79038. ubo.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  79039. if (this._reflectionTexture.boundingBoxSize) {
  79040. var cubeTexture = this._reflectionTexture;
  79041. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  79042. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  79043. }
  79044. }
  79045. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  79046. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  79047. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  79048. }
  79049. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  79050. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  79051. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  79052. }
  79053. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  79054. ubo.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  79055. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._specularTexture, ubo, "specular");
  79056. }
  79057. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  79058. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  79059. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  79060. if (scene._mirroredCameraPosition) {
  79061. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  79062. }
  79063. else {
  79064. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  79065. }
  79066. }
  79067. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  79068. var depth = 1.0;
  79069. if (!this._refractionTexture.isCube) {
  79070. ubo.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  79071. if (this._refractionTexture.depth) {
  79072. depth = this._refractionTexture.depth;
  79073. }
  79074. }
  79075. ubo.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  79076. }
  79077. }
  79078. // Point size
  79079. if (this.pointsCloud) {
  79080. ubo.updateFloat("pointSize", this.pointSize);
  79081. }
  79082. if (defines.SPECULARTERM) {
  79083. ubo.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  79084. }
  79085. ubo.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"].BlackReadOnly);
  79086. // Visibility
  79087. ubo.updateFloat("visibility", mesh.visibility);
  79088. // Diffuse
  79089. ubo.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  79090. }
  79091. // Textures
  79092. if (scene.texturesEnabled) {
  79093. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  79094. effect.setTexture("diffuseSampler", this._diffuseTexture);
  79095. }
  79096. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  79097. effect.setTexture("ambientSampler", this._ambientTexture);
  79098. }
  79099. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  79100. effect.setTexture("opacitySampler", this._opacityTexture);
  79101. }
  79102. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  79103. if (this._reflectionTexture.isCube) {
  79104. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  79105. }
  79106. else {
  79107. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  79108. }
  79109. }
  79110. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  79111. effect.setTexture("emissiveSampler", this._emissiveTexture);
  79112. }
  79113. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  79114. effect.setTexture("lightmapSampler", this._lightmapTexture);
  79115. }
  79116. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  79117. effect.setTexture("specularSampler", this._specularTexture);
  79118. }
  79119. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  79120. effect.setTexture("bumpSampler", this._bumpTexture);
  79121. }
  79122. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  79123. var depth = 1.0;
  79124. if (this._refractionTexture.isCube) {
  79125. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  79126. }
  79127. else {
  79128. effect.setTexture("refraction2DSampler", this._refractionTexture);
  79129. }
  79130. }
  79131. }
  79132. // Clip plane
  79133. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(effect, scene);
  79134. // Colors
  79135. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  79136. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindEyePosition(effect, scene);
  79137. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  79138. }
  79139. if (mustRebind || !this.isFrozen) {
  79140. // Lights
  79141. if (scene.lightsEnabled && !this._disableLighting) {
  79142. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  79143. }
  79144. // View
  79145. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  79146. this.bindView(effect);
  79147. }
  79148. // Fog
  79149. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  79150. // Morph targets
  79151. if (defines.NUM_MORPH_INFLUENCERS) {
  79152. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  79153. }
  79154. // Log. depth
  79155. _materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  79156. // image processing
  79157. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  79158. this._imageProcessingConfiguration.bind(this._activeEffect);
  79159. }
  79160. }
  79161. ubo.update();
  79162. this._afterBind(mesh, this._activeEffect);
  79163. };
  79164. /**
  79165. * Get the list of animatables in the material.
  79166. * @returns the list of animatables object used in the material
  79167. */
  79168. StandardMaterial.prototype.getAnimatables = function () {
  79169. var results = [];
  79170. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  79171. results.push(this._diffuseTexture);
  79172. }
  79173. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  79174. results.push(this._ambientTexture);
  79175. }
  79176. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  79177. results.push(this._opacityTexture);
  79178. }
  79179. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  79180. results.push(this._reflectionTexture);
  79181. }
  79182. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  79183. results.push(this._emissiveTexture);
  79184. }
  79185. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  79186. results.push(this._specularTexture);
  79187. }
  79188. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  79189. results.push(this._bumpTexture);
  79190. }
  79191. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  79192. results.push(this._lightmapTexture);
  79193. }
  79194. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  79195. results.push(this._refractionTexture);
  79196. }
  79197. return results;
  79198. };
  79199. /**
  79200. * Gets the active textures from the material
  79201. * @returns an array of textures
  79202. */
  79203. StandardMaterial.prototype.getActiveTextures = function () {
  79204. var activeTextures = _super.prototype.getActiveTextures.call(this);
  79205. if (this._diffuseTexture) {
  79206. activeTextures.push(this._diffuseTexture);
  79207. }
  79208. if (this._ambientTexture) {
  79209. activeTextures.push(this._ambientTexture);
  79210. }
  79211. if (this._opacityTexture) {
  79212. activeTextures.push(this._opacityTexture);
  79213. }
  79214. if (this._reflectionTexture) {
  79215. activeTextures.push(this._reflectionTexture);
  79216. }
  79217. if (this._emissiveTexture) {
  79218. activeTextures.push(this._emissiveTexture);
  79219. }
  79220. if (this._specularTexture) {
  79221. activeTextures.push(this._specularTexture);
  79222. }
  79223. if (this._bumpTexture) {
  79224. activeTextures.push(this._bumpTexture);
  79225. }
  79226. if (this._lightmapTexture) {
  79227. activeTextures.push(this._lightmapTexture);
  79228. }
  79229. if (this._refractionTexture) {
  79230. activeTextures.push(this._refractionTexture);
  79231. }
  79232. return activeTextures;
  79233. };
  79234. /**
  79235. * Specifies if the material uses a texture
  79236. * @param texture defines the texture to check against the material
  79237. * @returns a boolean specifying if the material uses the texture
  79238. */
  79239. StandardMaterial.prototype.hasTexture = function (texture) {
  79240. if (_super.prototype.hasTexture.call(this, texture)) {
  79241. return true;
  79242. }
  79243. if (this._diffuseTexture === texture) {
  79244. return true;
  79245. }
  79246. if (this._ambientTexture === texture) {
  79247. return true;
  79248. }
  79249. if (this._opacityTexture === texture) {
  79250. return true;
  79251. }
  79252. if (this._reflectionTexture === texture) {
  79253. return true;
  79254. }
  79255. if (this._emissiveTexture === texture) {
  79256. return true;
  79257. }
  79258. if (this._specularTexture === texture) {
  79259. return true;
  79260. }
  79261. if (this._bumpTexture === texture) {
  79262. return true;
  79263. }
  79264. if (this._lightmapTexture === texture) {
  79265. return true;
  79266. }
  79267. if (this._refractionTexture === texture) {
  79268. return true;
  79269. }
  79270. return false;
  79271. };
  79272. /**
  79273. * Disposes the material
  79274. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79275. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79276. */
  79277. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  79278. if (forceDisposeTextures) {
  79279. if (this._diffuseTexture) {
  79280. this._diffuseTexture.dispose();
  79281. }
  79282. if (this._ambientTexture) {
  79283. this._ambientTexture.dispose();
  79284. }
  79285. if (this._opacityTexture) {
  79286. this._opacityTexture.dispose();
  79287. }
  79288. if (this._reflectionTexture) {
  79289. this._reflectionTexture.dispose();
  79290. }
  79291. if (this._emissiveTexture) {
  79292. this._emissiveTexture.dispose();
  79293. }
  79294. if (this._specularTexture) {
  79295. this._specularTexture.dispose();
  79296. }
  79297. if (this._bumpTexture) {
  79298. this._bumpTexture.dispose();
  79299. }
  79300. if (this._lightmapTexture) {
  79301. this._lightmapTexture.dispose();
  79302. }
  79303. if (this._refractionTexture) {
  79304. this._refractionTexture.dispose();
  79305. }
  79306. }
  79307. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  79308. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  79309. }
  79310. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  79311. };
  79312. /**
  79313. * Makes a duplicate of the material, and gives it a new name
  79314. * @param name defines the new name for the duplicated material
  79315. * @returns the cloned material
  79316. */
  79317. StandardMaterial.prototype.clone = function (name) {
  79318. var _this = this;
  79319. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  79320. result.name = name;
  79321. result.id = name;
  79322. return result;
  79323. };
  79324. /**
  79325. * Serializes this material in a JSON representation
  79326. * @returns the serialized material object
  79327. */
  79328. StandardMaterial.prototype.serialize = function () {
  79329. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  79330. };
  79331. /**
  79332. * Creates a standard material from parsed material data
  79333. * @param source defines the JSON representation of the material
  79334. * @param scene defines the hosting scene
  79335. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79336. * @returns a new standard material
  79337. */
  79338. StandardMaterial.Parse = function (source, scene, rootUrl) {
  79339. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  79340. };
  79341. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  79342. // Flags used to enable or disable a type of texture for all Standard Materials
  79343. /**
  79344. * Are diffuse textures enabled in the application.
  79345. */
  79346. get: function () {
  79347. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled;
  79348. },
  79349. set: function (value) {
  79350. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled = value;
  79351. },
  79352. enumerable: true,
  79353. configurable: true
  79354. });
  79355. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  79356. /**
  79357. * Are ambient textures enabled in the application.
  79358. */
  79359. get: function () {
  79360. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled;
  79361. },
  79362. set: function (value) {
  79363. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled = value;
  79364. },
  79365. enumerable: true,
  79366. configurable: true
  79367. });
  79368. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  79369. /**
  79370. * Are opacity textures enabled in the application.
  79371. */
  79372. get: function () {
  79373. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled;
  79374. },
  79375. set: function (value) {
  79376. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled = value;
  79377. },
  79378. enumerable: true,
  79379. configurable: true
  79380. });
  79381. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  79382. /**
  79383. * Are reflection textures enabled in the application.
  79384. */
  79385. get: function () {
  79386. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled;
  79387. },
  79388. set: function (value) {
  79389. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled = value;
  79390. },
  79391. enumerable: true,
  79392. configurable: true
  79393. });
  79394. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  79395. /**
  79396. * Are emissive textures enabled in the application.
  79397. */
  79398. get: function () {
  79399. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled;
  79400. },
  79401. set: function (value) {
  79402. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled = value;
  79403. },
  79404. enumerable: true,
  79405. configurable: true
  79406. });
  79407. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  79408. /**
  79409. * Are specular textures enabled in the application.
  79410. */
  79411. get: function () {
  79412. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled;
  79413. },
  79414. set: function (value) {
  79415. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled = value;
  79416. },
  79417. enumerable: true,
  79418. configurable: true
  79419. });
  79420. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  79421. /**
  79422. * Are bump textures enabled in the application.
  79423. */
  79424. get: function () {
  79425. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled;
  79426. },
  79427. set: function (value) {
  79428. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled = value;
  79429. },
  79430. enumerable: true,
  79431. configurable: true
  79432. });
  79433. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  79434. /**
  79435. * Are lightmap textures enabled in the application.
  79436. */
  79437. get: function () {
  79438. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled;
  79439. },
  79440. set: function (value) {
  79441. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled = value;
  79442. },
  79443. enumerable: true,
  79444. configurable: true
  79445. });
  79446. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  79447. /**
  79448. * Are refraction textures enabled in the application.
  79449. */
  79450. get: function () {
  79451. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled;
  79452. },
  79453. set: function (value) {
  79454. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled = value;
  79455. },
  79456. enumerable: true,
  79457. configurable: true
  79458. });
  79459. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  79460. /**
  79461. * Are color grading textures enabled in the application.
  79462. */
  79463. get: function () {
  79464. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ColorGradingTextureEnabled;
  79465. },
  79466. set: function (value) {
  79467. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ColorGradingTextureEnabled = value;
  79468. },
  79469. enumerable: true,
  79470. configurable: true
  79471. });
  79472. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  79473. /**
  79474. * Are fresnels enabled in the application.
  79475. */
  79476. get: function () {
  79477. return _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].FresnelEnabled;
  79478. },
  79479. set: function (value) {
  79480. _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].FresnelEnabled = value;
  79481. },
  79482. enumerable: true,
  79483. configurable: true
  79484. });
  79485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  79487. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  79488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  79490. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  79491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  79493. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  79494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79496. ], StandardMaterial.prototype, "ambientTexture", void 0);
  79497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  79499. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  79500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  79502. ], StandardMaterial.prototype, "opacityTexture", void 0);
  79503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  79505. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  79506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79508. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  79509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  79511. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  79512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79514. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  79515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  79517. ], StandardMaterial.prototype, "_specularTexture", void 0);
  79518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79520. ], StandardMaterial.prototype, "specularTexture", void 0);
  79521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  79523. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  79524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79526. ], StandardMaterial.prototype, "bumpTexture", void 0);
  79527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  79529. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  79530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79532. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  79533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  79535. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  79536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79538. ], StandardMaterial.prototype, "refractionTexture", void 0);
  79539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  79541. ], StandardMaterial.prototype, "ambientColor", void 0);
  79542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  79544. ], StandardMaterial.prototype, "diffuseColor", void 0);
  79545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  79547. ], StandardMaterial.prototype, "specularColor", void 0);
  79548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  79550. ], StandardMaterial.prototype, "emissiveColor", void 0);
  79551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  79553. ], StandardMaterial.prototype, "specularPower", void 0);
  79554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  79556. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  79557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79559. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  79560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  79562. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  79563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79565. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  79566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  79568. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  79569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79571. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  79572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  79574. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  79575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79576. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79577. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  79578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  79580. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  79581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79583. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  79584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  79586. ], StandardMaterial.prototype, "_disableLighting", void 0);
  79587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  79589. ], StandardMaterial.prototype, "disableLighting", void 0);
  79590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  79592. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  79593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79595. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  79596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  79598. ], StandardMaterial.prototype, "_useParallax", void 0);
  79599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79601. ], StandardMaterial.prototype, "useParallax", void 0);
  79602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  79604. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  79605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79607. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  79608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  79610. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  79611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  79613. ], StandardMaterial.prototype, "_roughness", void 0);
  79614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79616. ], StandardMaterial.prototype, "roughness", void 0);
  79617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  79619. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  79620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  79622. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  79623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  79625. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  79626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  79628. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  79629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79631. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  79632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  79634. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  79635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  79637. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  79638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  79640. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  79641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  79643. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  79644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  79646. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  79647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  79649. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  79650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  79652. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  79653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  79655. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  79656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  79658. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  79659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  79661. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  79662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  79664. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  79665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  79667. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  79668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  79670. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  79671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79673. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  79674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  79676. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  79677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  79679. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  79680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  79682. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  79683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79685. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  79686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  79688. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  79689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79691. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  79692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  79694. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  79695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  79697. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  79698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  79699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  79700. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  79701. return StandardMaterial;
  79702. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]));
  79703. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  79704. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  79705. return new StandardMaterial("default material", scene);
  79706. };
  79707. /***/ }),
  79708. /***/ "./Materials/uniformBuffer.ts":
  79709. /*!************************************!*\
  79710. !*** ./Materials/uniformBuffer.ts ***!
  79711. \************************************/
  79712. /*! exports provided: UniformBuffer */
  79713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79714. "use strict";
  79715. __webpack_require__.r(__webpack_exports__);
  79716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  79717. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  79718. /**
  79719. * Uniform buffer objects.
  79720. *
  79721. * Handles blocks of uniform on the GPU.
  79722. *
  79723. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79724. *
  79725. * For more information, please refer to :
  79726. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79727. */
  79728. var UniformBuffer = /** @class */ (function () {
  79729. /**
  79730. * Instantiates a new Uniform buffer objects.
  79731. *
  79732. * Handles blocks of uniform on the GPU.
  79733. *
  79734. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79735. *
  79736. * For more information, please refer to :
  79737. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79738. * @param engine Define the engine the buffer is associated with
  79739. * @param data Define the data contained in the buffer
  79740. * @param dynamic Define if the buffer is updatable
  79741. */
  79742. function UniformBuffer(engine, data, dynamic) {
  79743. this._engine = engine;
  79744. this._noUBO = !engine.supportsUniformBuffers;
  79745. this._dynamic = dynamic;
  79746. this._data = data || [];
  79747. this._uniformLocations = {};
  79748. this._uniformSizes = {};
  79749. this._uniformLocationPointer = 0;
  79750. this._needSync = false;
  79751. if (this._noUBO) {
  79752. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  79753. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  79754. this.updateFloat = this._updateFloatForEffect;
  79755. this.updateFloat2 = this._updateFloat2ForEffect;
  79756. this.updateFloat3 = this._updateFloat3ForEffect;
  79757. this.updateFloat4 = this._updateFloat4ForEffect;
  79758. this.updateMatrix = this._updateMatrixForEffect;
  79759. this.updateVector3 = this._updateVector3ForEffect;
  79760. this.updateVector4 = this._updateVector4ForEffect;
  79761. this.updateColor3 = this._updateColor3ForEffect;
  79762. this.updateColor4 = this._updateColor4ForEffect;
  79763. }
  79764. else {
  79765. this._engine._uniformBuffers.push(this);
  79766. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  79767. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  79768. this.updateFloat = this._updateFloatForUniform;
  79769. this.updateFloat2 = this._updateFloat2ForUniform;
  79770. this.updateFloat3 = this._updateFloat3ForUniform;
  79771. this.updateFloat4 = this._updateFloat4ForUniform;
  79772. this.updateMatrix = this._updateMatrixForUniform;
  79773. this.updateVector3 = this._updateVector3ForUniform;
  79774. this.updateVector4 = this._updateVector4ForUniform;
  79775. this.updateColor3 = this._updateColor3ForUniform;
  79776. this.updateColor4 = this._updateColor4ForUniform;
  79777. }
  79778. }
  79779. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  79780. /**
  79781. * Indicates if the buffer is using the WebGL2 UBO implementation,
  79782. * or just falling back on setUniformXXX calls.
  79783. */
  79784. get: function () {
  79785. return !this._noUBO;
  79786. },
  79787. enumerable: true,
  79788. configurable: true
  79789. });
  79790. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  79791. /**
  79792. * Indicates if the WebGL underlying uniform buffer is in sync
  79793. * with the javascript cache data.
  79794. */
  79795. get: function () {
  79796. return !this._needSync;
  79797. },
  79798. enumerable: true,
  79799. configurable: true
  79800. });
  79801. /**
  79802. * Indicates if the WebGL underlying uniform buffer is dynamic.
  79803. * Also, a dynamic UniformBuffer will disable cache verification and always
  79804. * update the underlying WebGL uniform buffer to the GPU.
  79805. * @returns if Dynamic, otherwise false
  79806. */
  79807. UniformBuffer.prototype.isDynamic = function () {
  79808. return this._dynamic !== undefined;
  79809. };
  79810. /**
  79811. * The data cache on JS side.
  79812. * @returns the underlying data as a float array
  79813. */
  79814. UniformBuffer.prototype.getData = function () {
  79815. return this._bufferData;
  79816. };
  79817. /**
  79818. * The underlying WebGL Uniform buffer.
  79819. * @returns the webgl buffer
  79820. */
  79821. UniformBuffer.prototype.getBuffer = function () {
  79822. return this._buffer;
  79823. };
  79824. /**
  79825. * std140 layout specifies how to align data within an UBO structure.
  79826. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  79827. * for specs.
  79828. */
  79829. UniformBuffer.prototype._fillAlignment = function (size) {
  79830. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  79831. // and 4x4 matrices
  79832. // TODO : change if other types are used
  79833. var alignment;
  79834. if (size <= 2) {
  79835. alignment = size;
  79836. }
  79837. else {
  79838. alignment = 4;
  79839. }
  79840. if ((this._uniformLocationPointer % alignment) !== 0) {
  79841. var oldPointer = this._uniformLocationPointer;
  79842. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  79843. var diff = this._uniformLocationPointer - oldPointer;
  79844. for (var i = 0; i < diff; i++) {
  79845. this._data.push(0);
  79846. }
  79847. }
  79848. };
  79849. /**
  79850. * Adds an uniform in the buffer.
  79851. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  79852. * for the layout to be correct !
  79853. * @param name Name of the uniform, as used in the uniform block in the shader.
  79854. * @param size Data size, or data directly.
  79855. */
  79856. UniformBuffer.prototype.addUniform = function (name, size) {
  79857. if (this._noUBO) {
  79858. return;
  79859. }
  79860. if (this._uniformLocations[name] !== undefined) {
  79861. // Already existing uniform
  79862. return;
  79863. }
  79864. // This function must be called in the order of the shader layout !
  79865. // size can be the size of the uniform, or data directly
  79866. var data;
  79867. if (size instanceof Array) {
  79868. data = size;
  79869. size = data.length;
  79870. }
  79871. else {
  79872. size = size;
  79873. data = [];
  79874. // Fill with zeros
  79875. for (var i = 0; i < size; i++) {
  79876. data.push(0);
  79877. }
  79878. }
  79879. this._fillAlignment(size);
  79880. this._uniformSizes[name] = size;
  79881. this._uniformLocations[name] = this._uniformLocationPointer;
  79882. this._uniformLocationPointer += size;
  79883. for (var i = 0; i < size; i++) {
  79884. this._data.push(data[i]);
  79885. }
  79886. this._needSync = true;
  79887. };
  79888. /**
  79889. * Adds a Matrix 4x4 to the uniform buffer.
  79890. * @param name Name of the uniform, as used in the uniform block in the shader.
  79891. * @param mat A 4x4 matrix.
  79892. */
  79893. UniformBuffer.prototype.addMatrix = function (name, mat) {
  79894. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  79895. };
  79896. /**
  79897. * Adds a vec2 to the uniform buffer.
  79898. * @param name Name of the uniform, as used in the uniform block in the shader.
  79899. * @param x Define the x component value of the vec2
  79900. * @param y Define the y component value of the vec2
  79901. */
  79902. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  79903. var temp = [x, y];
  79904. this.addUniform(name, temp);
  79905. };
  79906. /**
  79907. * Adds a vec3 to the uniform buffer.
  79908. * @param name Name of the uniform, as used in the uniform block in the shader.
  79909. * @param x Define the x component value of the vec3
  79910. * @param y Define the y component value of the vec3
  79911. * @param z Define the z component value of the vec3
  79912. */
  79913. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  79914. var temp = [x, y, z];
  79915. this.addUniform(name, temp);
  79916. };
  79917. /**
  79918. * Adds a vec3 to the uniform buffer.
  79919. * @param name Name of the uniform, as used in the uniform block in the shader.
  79920. * @param color Define the vec3 from a Color
  79921. */
  79922. UniformBuffer.prototype.addColor3 = function (name, color) {
  79923. var temp = new Array();
  79924. color.toArray(temp);
  79925. this.addUniform(name, temp);
  79926. };
  79927. /**
  79928. * Adds a vec4 to the uniform buffer.
  79929. * @param name Name of the uniform, as used in the uniform block in the shader.
  79930. * @param color Define the rgb components from a Color
  79931. * @param alpha Define the a component of the vec4
  79932. */
  79933. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  79934. var temp = new Array();
  79935. color.toArray(temp);
  79936. temp.push(alpha);
  79937. this.addUniform(name, temp);
  79938. };
  79939. /**
  79940. * Adds a vec3 to the uniform buffer.
  79941. * @param name Name of the uniform, as used in the uniform block in the shader.
  79942. * @param vector Define the vec3 components from a Vector
  79943. */
  79944. UniformBuffer.prototype.addVector3 = function (name, vector) {
  79945. var temp = new Array();
  79946. vector.toArray(temp);
  79947. this.addUniform(name, temp);
  79948. };
  79949. /**
  79950. * Adds a Matrix 3x3 to the uniform buffer.
  79951. * @param name Name of the uniform, as used in the uniform block in the shader.
  79952. */
  79953. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  79954. this.addUniform(name, 12);
  79955. };
  79956. /**
  79957. * Adds a Matrix 2x2 to the uniform buffer.
  79958. * @param name Name of the uniform, as used in the uniform block in the shader.
  79959. */
  79960. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  79961. this.addUniform(name, 8);
  79962. };
  79963. /**
  79964. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  79965. */
  79966. UniformBuffer.prototype.create = function () {
  79967. if (this._noUBO) {
  79968. return;
  79969. }
  79970. if (this._buffer) {
  79971. return; // nothing to do
  79972. }
  79973. // See spec, alignment must be filled as a vec4
  79974. this._fillAlignment(4);
  79975. this._bufferData = new Float32Array(this._data);
  79976. this._rebuild();
  79977. this._needSync = true;
  79978. };
  79979. /** @hidden */
  79980. UniformBuffer.prototype._rebuild = function () {
  79981. if (this._noUBO || !this._bufferData) {
  79982. return;
  79983. }
  79984. if (this._dynamic) {
  79985. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  79986. }
  79987. else {
  79988. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  79989. }
  79990. };
  79991. /**
  79992. * Updates the WebGL Uniform Buffer on the GPU.
  79993. * If the `dynamic` flag is set to true, no cache comparison is done.
  79994. * Otherwise, the buffer will be updated only if the cache differs.
  79995. */
  79996. UniformBuffer.prototype.update = function () {
  79997. if (!this._buffer) {
  79998. this.create();
  79999. return;
  80000. }
  80001. if (!this._dynamic && !this._needSync) {
  80002. return;
  80003. }
  80004. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  80005. this._needSync = false;
  80006. };
  80007. /**
  80008. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80009. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80010. * @param data Define the flattened data
  80011. * @param size Define the size of the data.
  80012. */
  80013. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  80014. var location = this._uniformLocations[uniformName];
  80015. if (location === undefined) {
  80016. if (this._buffer) {
  80017. // Cannot add an uniform if the buffer is already created
  80018. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  80019. return;
  80020. }
  80021. this.addUniform(uniformName, size);
  80022. location = this._uniformLocations[uniformName];
  80023. }
  80024. if (!this._buffer) {
  80025. this.create();
  80026. }
  80027. if (!this._dynamic) {
  80028. // Cache for static uniform buffers
  80029. var changed = false;
  80030. for (var i = 0; i < size; i++) {
  80031. if (this._bufferData[location + i] !== data[i]) {
  80032. changed = true;
  80033. this._bufferData[location + i] = data[i];
  80034. }
  80035. }
  80036. this._needSync = this._needSync || changed;
  80037. }
  80038. else {
  80039. // No cache for dynamic
  80040. for (var i = 0; i < size; i++) {
  80041. this._bufferData[location + i] = data[i];
  80042. }
  80043. }
  80044. };
  80045. // Update methods
  80046. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  80047. // To match std140, matrix must be realigned
  80048. for (var i = 0; i < 3; i++) {
  80049. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  80050. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  80051. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  80052. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  80053. }
  80054. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  80055. };
  80056. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  80057. this._currentEffect.setMatrix3x3(name, matrix);
  80058. };
  80059. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  80060. this._currentEffect.setMatrix2x2(name, matrix);
  80061. };
  80062. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  80063. // To match std140, matrix must be realigned
  80064. for (var i = 0; i < 2; i++) {
  80065. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  80066. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  80067. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  80068. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  80069. }
  80070. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  80071. };
  80072. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  80073. this._currentEffect.setFloat(name, x);
  80074. };
  80075. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  80076. UniformBuffer._tempBuffer[0] = x;
  80077. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  80078. };
  80079. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  80080. if (suffix === void 0) { suffix = ""; }
  80081. this._currentEffect.setFloat2(name + suffix, x, y);
  80082. };
  80083. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  80084. UniformBuffer._tempBuffer[0] = x;
  80085. UniformBuffer._tempBuffer[1] = y;
  80086. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  80087. };
  80088. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  80089. if (suffix === void 0) { suffix = ""; }
  80090. this._currentEffect.setFloat3(name + suffix, x, y, z);
  80091. };
  80092. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  80093. UniformBuffer._tempBuffer[0] = x;
  80094. UniformBuffer._tempBuffer[1] = y;
  80095. UniformBuffer._tempBuffer[2] = z;
  80096. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  80097. };
  80098. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  80099. if (suffix === void 0) { suffix = ""; }
  80100. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  80101. };
  80102. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  80103. UniformBuffer._tempBuffer[0] = x;
  80104. UniformBuffer._tempBuffer[1] = y;
  80105. UniformBuffer._tempBuffer[2] = z;
  80106. UniformBuffer._tempBuffer[3] = w;
  80107. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  80108. };
  80109. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  80110. this._currentEffect.setMatrix(name, mat);
  80111. };
  80112. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  80113. this.updateUniform(name, mat.toArray(), 16);
  80114. };
  80115. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  80116. this._currentEffect.setVector3(name, vector);
  80117. };
  80118. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  80119. vector.toArray(UniformBuffer._tempBuffer);
  80120. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  80121. };
  80122. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  80123. this._currentEffect.setVector4(name, vector);
  80124. };
  80125. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  80126. vector.toArray(UniformBuffer._tempBuffer);
  80127. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  80128. };
  80129. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  80130. if (suffix === void 0) { suffix = ""; }
  80131. this._currentEffect.setColor3(name + suffix, color);
  80132. };
  80133. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  80134. color.toArray(UniformBuffer._tempBuffer);
  80135. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  80136. };
  80137. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  80138. if (suffix === void 0) { suffix = ""; }
  80139. this._currentEffect.setColor4(name + suffix, color, alpha);
  80140. };
  80141. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  80142. color.toArray(UniformBuffer._tempBuffer);
  80143. UniformBuffer._tempBuffer[3] = alpha;
  80144. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  80145. };
  80146. /**
  80147. * Sets a sampler uniform on the effect.
  80148. * @param name Define the name of the sampler.
  80149. * @param texture Define the texture to set in the sampler
  80150. */
  80151. UniformBuffer.prototype.setTexture = function (name, texture) {
  80152. this._currentEffect.setTexture(name, texture);
  80153. };
  80154. /**
  80155. * Directly updates the value of the uniform in the cache AND on the GPU.
  80156. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80157. * @param data Define the flattened data
  80158. */
  80159. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  80160. this.updateUniform(uniformName, data, data.length);
  80161. this.update();
  80162. };
  80163. /**
  80164. * Binds this uniform buffer to an effect.
  80165. * @param effect Define the effect to bind the buffer to
  80166. * @param name Name of the uniform block in the shader.
  80167. */
  80168. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  80169. this._currentEffect = effect;
  80170. if (this._noUBO || !this._buffer) {
  80171. return;
  80172. }
  80173. effect.bindUniformBuffer(this._buffer, name);
  80174. };
  80175. /**
  80176. * Disposes the uniform buffer.
  80177. */
  80178. UniformBuffer.prototype.dispose = function () {
  80179. if (this._noUBO) {
  80180. return;
  80181. }
  80182. var uniformBuffers = this._engine._uniformBuffers;
  80183. var index = uniformBuffers.indexOf(this);
  80184. if (index !== -1) {
  80185. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  80186. uniformBuffers.pop();
  80187. }
  80188. if (!this._buffer) {
  80189. return;
  80190. }
  80191. if (this._engine._releaseBuffer(this._buffer)) {
  80192. this._buffer = null;
  80193. }
  80194. };
  80195. // Pool for avoiding memory leaks
  80196. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  80197. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  80198. return UniformBuffer;
  80199. }());
  80200. /***/ }),
  80201. /***/ "./Maths/index.ts":
  80202. /*!************************!*\
  80203. !*** ./Maths/index.ts ***!
  80204. \************************/
  80205. /*! exports provided: Scalar, Space, Axis, Color3, Color4, TmpColors, ToGammaSpace, ToLinearSpace, Epsilon, Frustum, Plane, Size, Vector2, Vector3, Vector4, Quaternion, Matrix, TmpVectors, Viewport, SphericalHarmonics, SphericalPolynomial, Orientation, BezierCurve, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex */
  80206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80207. "use strict";
  80208. __webpack_require__.r(__webpack_exports__);
  80209. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  80210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  80211. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  80212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  80213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  80214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  80215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  80216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpColors", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["TmpColors"]; });
  80217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  80218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  80219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  80220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  80221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  80222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  80223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  80224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  80225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  80226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  80227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  80228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpVectors", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"]; });
  80229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  80230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  80231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  80232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  80233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  80234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  80235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  80236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  80237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  80238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  80239. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  80240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  80241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  80242. /***/ }),
  80243. /***/ "./Maths/math.axis.ts":
  80244. /*!****************************!*\
  80245. !*** ./Maths/math.axis.ts ***!
  80246. \****************************/
  80247. /*! exports provided: Space, Axis */
  80248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80249. "use strict";
  80250. __webpack_require__.r(__webpack_exports__);
  80251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  80252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  80253. /* harmony import */ var _math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.vector */ "./Maths/math.vector.ts");
  80254. /** Defines supported spaces */
  80255. var Space;
  80256. (function (Space) {
  80257. /** Local (object) space */
  80258. Space[Space["LOCAL"] = 0] = "LOCAL";
  80259. /** World space */
  80260. Space[Space["WORLD"] = 1] = "WORLD";
  80261. /** Bone space */
  80262. Space[Space["BONE"] = 2] = "BONE";
  80263. })(Space || (Space = {}));
  80264. /** Defines the 3 main axes */
  80265. var Axis = /** @class */ (function () {
  80266. function Axis() {
  80267. }
  80268. /** X axis */
  80269. Axis.X = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 0.0, 0.0);
  80270. /** Y axis */
  80271. Axis.Y = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0.0, 1.0, 0.0);
  80272. /** Z axis */
  80273. Axis.Z = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0.0, 0.0, 1.0);
  80274. return Axis;
  80275. }());
  80276. /***/ }),
  80277. /***/ "./Maths/math.color.ts":
  80278. /*!*****************************!*\
  80279. !*** ./Maths/math.color.ts ***!
  80280. \*****************************/
  80281. /*! exports provided: Color3, Color4, TmpColors */
  80282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80283. "use strict";
  80284. __webpack_require__.r(__webpack_exports__);
  80285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  80286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  80287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmpColors", function() { return TmpColors; });
  80288. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  80289. /* harmony import */ var _math_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.constants */ "./Maths/math.constants.ts");
  80290. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  80291. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  80292. /**
  80293. * Class used to hold a RBG color
  80294. */
  80295. var Color3 = /** @class */ (function () {
  80296. /**
  80297. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  80298. * @param r defines the red component (between 0 and 1, default is 0)
  80299. * @param g defines the green component (between 0 and 1, default is 0)
  80300. * @param b defines the blue component (between 0 and 1, default is 0)
  80301. */
  80302. function Color3(
  80303. /**
  80304. * Defines the red component (between 0 and 1, default is 0)
  80305. */
  80306. r,
  80307. /**
  80308. * Defines the green component (between 0 and 1, default is 0)
  80309. */
  80310. g,
  80311. /**
  80312. * Defines the blue component (between 0 and 1, default is 0)
  80313. */
  80314. b) {
  80315. if (r === void 0) { r = 0; }
  80316. if (g === void 0) { g = 0; }
  80317. if (b === void 0) { b = 0; }
  80318. this.r = r;
  80319. this.g = g;
  80320. this.b = b;
  80321. }
  80322. /**
  80323. * Creates a string with the Color3 current values
  80324. * @returns the string representation of the Color3 object
  80325. */
  80326. Color3.prototype.toString = function () {
  80327. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  80328. };
  80329. /**
  80330. * Returns the string "Color3"
  80331. * @returns "Color3"
  80332. */
  80333. Color3.prototype.getClassName = function () {
  80334. return "Color3";
  80335. };
  80336. /**
  80337. * Compute the Color3 hash code
  80338. * @returns an unique number that can be used to hash Color3 objects
  80339. */
  80340. Color3.prototype.getHashCode = function () {
  80341. var hash = (this.r * 255) | 0;
  80342. hash = (hash * 397) ^ ((this.g * 255) | 0);
  80343. hash = (hash * 397) ^ ((this.b * 255) | 0);
  80344. return hash;
  80345. };
  80346. // Operators
  80347. /**
  80348. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  80349. * @param array defines the array where to store the r,g,b components
  80350. * @param index defines an optional index in the target array to define where to start storing values
  80351. * @returns the current Color3 object
  80352. */
  80353. Color3.prototype.toArray = function (array, index) {
  80354. if (index === void 0) { index = 0; }
  80355. array[index] = this.r;
  80356. array[index + 1] = this.g;
  80357. array[index + 2] = this.b;
  80358. return this;
  80359. };
  80360. /**
  80361. * Returns a new Color4 object from the current Color3 and the given alpha
  80362. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  80363. * @returns a new Color4 object
  80364. */
  80365. Color3.prototype.toColor4 = function (alpha) {
  80366. if (alpha === void 0) { alpha = 1; }
  80367. return new Color4(this.r, this.g, this.b, alpha);
  80368. };
  80369. /**
  80370. * Returns a new array populated with 3 numeric elements : red, green and blue values
  80371. * @returns the new array
  80372. */
  80373. Color3.prototype.asArray = function () {
  80374. var result = new Array();
  80375. this.toArray(result, 0);
  80376. return result;
  80377. };
  80378. /**
  80379. * Returns the luminance value
  80380. * @returns a float value
  80381. */
  80382. Color3.prototype.toLuminance = function () {
  80383. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  80384. };
  80385. /**
  80386. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  80387. * @param otherColor defines the second operand
  80388. * @returns the new Color3 object
  80389. */
  80390. Color3.prototype.multiply = function (otherColor) {
  80391. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  80392. };
  80393. /**
  80394. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  80395. * @param otherColor defines the second operand
  80396. * @param result defines the Color3 object where to store the result
  80397. * @returns the current Color3
  80398. */
  80399. Color3.prototype.multiplyToRef = function (otherColor, result) {
  80400. result.r = this.r * otherColor.r;
  80401. result.g = this.g * otherColor.g;
  80402. result.b = this.b * otherColor.b;
  80403. return this;
  80404. };
  80405. /**
  80406. * Determines equality between Color3 objects
  80407. * @param otherColor defines the second operand
  80408. * @returns true if the rgb values are equal to the given ones
  80409. */
  80410. Color3.prototype.equals = function (otherColor) {
  80411. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  80412. };
  80413. /**
  80414. * Determines equality between the current Color3 object and a set of r,b,g values
  80415. * @param r defines the red component to check
  80416. * @param g defines the green component to check
  80417. * @param b defines the blue component to check
  80418. * @returns true if the rgb values are equal to the given ones
  80419. */
  80420. Color3.prototype.equalsFloats = function (r, g, b) {
  80421. return this.r === r && this.g === g && this.b === b;
  80422. };
  80423. /**
  80424. * Multiplies in place each rgb value by scale
  80425. * @param scale defines the scaling factor
  80426. * @returns the updated Color3
  80427. */
  80428. Color3.prototype.scale = function (scale) {
  80429. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  80430. };
  80431. /**
  80432. * Multiplies the rgb values by scale and stores the result into "result"
  80433. * @param scale defines the scaling factor
  80434. * @param result defines the Color3 object where to store the result
  80435. * @returns the unmodified current Color3
  80436. */
  80437. Color3.prototype.scaleToRef = function (scale, result) {
  80438. result.r = this.r * scale;
  80439. result.g = this.g * scale;
  80440. result.b = this.b * scale;
  80441. return this;
  80442. };
  80443. /**
  80444. * Scale the current Color3 values by a factor and add the result to a given Color3
  80445. * @param scale defines the scale factor
  80446. * @param result defines color to store the result into
  80447. * @returns the unmodified current Color3
  80448. */
  80449. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  80450. result.r += this.r * scale;
  80451. result.g += this.g * scale;
  80452. result.b += this.b * scale;
  80453. return this;
  80454. };
  80455. /**
  80456. * Clamps the rgb values by the min and max values and stores the result into "result"
  80457. * @param min defines minimum clamping value (default is 0)
  80458. * @param max defines maximum clamping value (default is 1)
  80459. * @param result defines color to store the result into
  80460. * @returns the original Color3
  80461. */
  80462. Color3.prototype.clampToRef = function (min, max, result) {
  80463. if (min === void 0) { min = 0; }
  80464. if (max === void 0) { max = 1; }
  80465. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.r, min, max);
  80466. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.g, min, max);
  80467. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.b, min, max);
  80468. return this;
  80469. };
  80470. /**
  80471. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  80472. * @param otherColor defines the second operand
  80473. * @returns the new Color3
  80474. */
  80475. Color3.prototype.add = function (otherColor) {
  80476. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  80477. };
  80478. /**
  80479. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  80480. * @param otherColor defines the second operand
  80481. * @param result defines Color3 object to store the result into
  80482. * @returns the unmodified current Color3
  80483. */
  80484. Color3.prototype.addToRef = function (otherColor, result) {
  80485. result.r = this.r + otherColor.r;
  80486. result.g = this.g + otherColor.g;
  80487. result.b = this.b + otherColor.b;
  80488. return this;
  80489. };
  80490. /**
  80491. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  80492. * @param otherColor defines the second operand
  80493. * @returns the new Color3
  80494. */
  80495. Color3.prototype.subtract = function (otherColor) {
  80496. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  80497. };
  80498. /**
  80499. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  80500. * @param otherColor defines the second operand
  80501. * @param result defines Color3 object to store the result into
  80502. * @returns the unmodified current Color3
  80503. */
  80504. Color3.prototype.subtractToRef = function (otherColor, result) {
  80505. result.r = this.r - otherColor.r;
  80506. result.g = this.g - otherColor.g;
  80507. result.b = this.b - otherColor.b;
  80508. return this;
  80509. };
  80510. /**
  80511. * Copy the current object
  80512. * @returns a new Color3 copied the current one
  80513. */
  80514. Color3.prototype.clone = function () {
  80515. return new Color3(this.r, this.g, this.b);
  80516. };
  80517. /**
  80518. * Copies the rgb values from the source in the current Color3
  80519. * @param source defines the source Color3 object
  80520. * @returns the updated Color3 object
  80521. */
  80522. Color3.prototype.copyFrom = function (source) {
  80523. this.r = source.r;
  80524. this.g = source.g;
  80525. this.b = source.b;
  80526. return this;
  80527. };
  80528. /**
  80529. * Updates the Color3 rgb values from the given floats
  80530. * @param r defines the red component to read from
  80531. * @param g defines the green component to read from
  80532. * @param b defines the blue component to read from
  80533. * @returns the current Color3 object
  80534. */
  80535. Color3.prototype.copyFromFloats = function (r, g, b) {
  80536. this.r = r;
  80537. this.g = g;
  80538. this.b = b;
  80539. return this;
  80540. };
  80541. /**
  80542. * Updates the Color3 rgb values from the given floats
  80543. * @param r defines the red component to read from
  80544. * @param g defines the green component to read from
  80545. * @param b defines the blue component to read from
  80546. * @returns the current Color3 object
  80547. */
  80548. Color3.prototype.set = function (r, g, b) {
  80549. return this.copyFromFloats(r, g, b);
  80550. };
  80551. /**
  80552. * Compute the Color3 hexadecimal code as a string
  80553. * @returns a string containing the hexadecimal representation of the Color3 object
  80554. */
  80555. Color3.prototype.toHexString = function () {
  80556. var intR = (this.r * 255) | 0;
  80557. var intG = (this.g * 255) | 0;
  80558. var intB = (this.b * 255) | 0;
  80559. return "#" + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intR) + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intG) + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intB);
  80560. };
  80561. /**
  80562. * Computes a new Color3 converted from the current one to linear space
  80563. * @returns a new Color3 object
  80564. */
  80565. Color3.prototype.toLinearSpace = function () {
  80566. var convertedColor = new Color3();
  80567. this.toLinearSpaceToRef(convertedColor);
  80568. return convertedColor;
  80569. };
  80570. /**
  80571. * Converts current color in rgb space to HSV values
  80572. * @returns a new color3 representing the HSV values
  80573. */
  80574. Color3.prototype.toHSV = function () {
  80575. var result = new Color3();
  80576. this.toHSVToRef(result);
  80577. return result;
  80578. };
  80579. /**
  80580. * Converts current color in rgb space to HSV values
  80581. * @param result defines the Color3 where to store the HSV values
  80582. */
  80583. Color3.prototype.toHSVToRef = function (result) {
  80584. var r = this.r;
  80585. var g = this.g;
  80586. var b = this.b;
  80587. var max = Math.max(r, g, b);
  80588. var min = Math.min(r, g, b);
  80589. var h = 0;
  80590. var s = 0;
  80591. var v = max;
  80592. var dm = max - min;
  80593. if (max !== 0) {
  80594. s = dm / max;
  80595. }
  80596. if (max != min) {
  80597. if (max == r) {
  80598. h = (g - b) / dm;
  80599. if (g < b) {
  80600. h += 6;
  80601. }
  80602. }
  80603. else if (max == g) {
  80604. h = (b - r) / dm + 2;
  80605. }
  80606. else if (max == b) {
  80607. h = (r - g) / dm + 4;
  80608. }
  80609. h *= 60;
  80610. }
  80611. result.r = h;
  80612. result.g = s;
  80613. result.b = v;
  80614. };
  80615. /**
  80616. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  80617. * @param convertedColor defines the Color3 object where to store the linear space version
  80618. * @returns the unmodified Color3
  80619. */
  80620. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  80621. convertedColor.r = Math.pow(this.r, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]);
  80622. convertedColor.g = Math.pow(this.g, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]);
  80623. convertedColor.b = Math.pow(this.b, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]);
  80624. return this;
  80625. };
  80626. /**
  80627. * Computes a new Color3 converted from the current one to gamma space
  80628. * @returns a new Color3 object
  80629. */
  80630. Color3.prototype.toGammaSpace = function () {
  80631. var convertedColor = new Color3();
  80632. this.toGammaSpaceToRef(convertedColor);
  80633. return convertedColor;
  80634. };
  80635. /**
  80636. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  80637. * @param convertedColor defines the Color3 object where to store the gamma space version
  80638. * @returns the unmodified Color3
  80639. */
  80640. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  80641. convertedColor.r = Math.pow(this.r, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  80642. convertedColor.g = Math.pow(this.g, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  80643. convertedColor.b = Math.pow(this.b, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  80644. return this;
  80645. };
  80646. /**
  80647. * Convert Hue, saturation and value to a Color3 (RGB)
  80648. * @param hue defines the hue
  80649. * @param saturation defines the saturation
  80650. * @param value defines the value
  80651. * @param result defines the Color3 where to store the RGB values
  80652. */
  80653. Color3.HSVtoRGBToRef = function (hue, saturation, value, result) {
  80654. var chroma = value * saturation;
  80655. var h = hue / 60;
  80656. var x = chroma * (1 - Math.abs((h % 2) - 1));
  80657. var r = 0;
  80658. var g = 0;
  80659. var b = 0;
  80660. if (h >= 0 && h <= 1) {
  80661. r = chroma;
  80662. g = x;
  80663. }
  80664. else if (h >= 1 && h <= 2) {
  80665. r = x;
  80666. g = chroma;
  80667. }
  80668. else if (h >= 2 && h <= 3) {
  80669. g = chroma;
  80670. b = x;
  80671. }
  80672. else if (h >= 3 && h <= 4) {
  80673. g = x;
  80674. b = chroma;
  80675. }
  80676. else if (h >= 4 && h <= 5) {
  80677. r = x;
  80678. b = chroma;
  80679. }
  80680. else if (h >= 5 && h <= 6) {
  80681. r = chroma;
  80682. b = x;
  80683. }
  80684. var m = value - chroma;
  80685. result.set((r + m), (g + m), (b + m));
  80686. };
  80687. /**
  80688. * Creates a new Color3 from the string containing valid hexadecimal values
  80689. * @param hex defines a string containing valid hexadecimal values
  80690. * @returns a new Color3 object
  80691. */
  80692. Color3.FromHexString = function (hex) {
  80693. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  80694. return new Color3(0, 0, 0);
  80695. }
  80696. var r = parseInt(hex.substring(1, 3), 16);
  80697. var g = parseInt(hex.substring(3, 5), 16);
  80698. var b = parseInt(hex.substring(5, 7), 16);
  80699. return Color3.FromInts(r, g, b);
  80700. };
  80701. /**
  80702. * Creates a new Color3 from the starting index of the given array
  80703. * @param array defines the source array
  80704. * @param offset defines an offset in the source array
  80705. * @returns a new Color3 object
  80706. */
  80707. Color3.FromArray = function (array, offset) {
  80708. if (offset === void 0) { offset = 0; }
  80709. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  80710. };
  80711. /**
  80712. * Creates a new Color3 from integer values (< 256)
  80713. * @param r defines the red component to read from (value between 0 and 255)
  80714. * @param g defines the green component to read from (value between 0 and 255)
  80715. * @param b defines the blue component to read from (value between 0 and 255)
  80716. * @returns a new Color3 object
  80717. */
  80718. Color3.FromInts = function (r, g, b) {
  80719. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  80720. };
  80721. /**
  80722. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  80723. * @param start defines the start Color3 value
  80724. * @param end defines the end Color3 value
  80725. * @param amount defines the gradient value between start and end
  80726. * @returns a new Color3 object
  80727. */
  80728. Color3.Lerp = function (start, end, amount) {
  80729. var result = new Color3(0.0, 0.0, 0.0);
  80730. Color3.LerpToRef(start, end, amount, result);
  80731. return result;
  80732. };
  80733. /**
  80734. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  80735. * @param left defines the start value
  80736. * @param right defines the end value
  80737. * @param amount defines the gradient factor
  80738. * @param result defines the Color3 object where to store the result
  80739. */
  80740. Color3.LerpToRef = function (left, right, amount, result) {
  80741. result.r = left.r + ((right.r - left.r) * amount);
  80742. result.g = left.g + ((right.g - left.g) * amount);
  80743. result.b = left.b + ((right.b - left.b) * amount);
  80744. };
  80745. /**
  80746. * Returns a Color3 value containing a red color
  80747. * @returns a new Color3 object
  80748. */
  80749. Color3.Red = function () { return new Color3(1, 0, 0); };
  80750. /**
  80751. * Returns a Color3 value containing a green color
  80752. * @returns a new Color3 object
  80753. */
  80754. Color3.Green = function () { return new Color3(0, 1, 0); };
  80755. /**
  80756. * Returns a Color3 value containing a blue color
  80757. * @returns a new Color3 object
  80758. */
  80759. Color3.Blue = function () { return new Color3(0, 0, 1); };
  80760. /**
  80761. * Returns a Color3 value containing a black color
  80762. * @returns a new Color3 object
  80763. */
  80764. Color3.Black = function () { return new Color3(0, 0, 0); };
  80765. Object.defineProperty(Color3, "BlackReadOnly", {
  80766. /**
  80767. * Gets a Color3 value containing a black color that must not be updated
  80768. */
  80769. get: function () {
  80770. return Color3._BlackReadOnly;
  80771. },
  80772. enumerable: true,
  80773. configurable: true
  80774. });
  80775. /**
  80776. * Returns a Color3 value containing a white color
  80777. * @returns a new Color3 object
  80778. */
  80779. Color3.White = function () { return new Color3(1, 1, 1); };
  80780. /**
  80781. * Returns a Color3 value containing a purple color
  80782. * @returns a new Color3 object
  80783. */
  80784. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  80785. /**
  80786. * Returns a Color3 value containing a magenta color
  80787. * @returns a new Color3 object
  80788. */
  80789. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  80790. /**
  80791. * Returns a Color3 value containing a yellow color
  80792. * @returns a new Color3 object
  80793. */
  80794. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  80795. /**
  80796. * Returns a Color3 value containing a gray color
  80797. * @returns a new Color3 object
  80798. */
  80799. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  80800. /**
  80801. * Returns a Color3 value containing a teal color
  80802. * @returns a new Color3 object
  80803. */
  80804. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  80805. /**
  80806. * Returns a Color3 value containing a random color
  80807. * @returns a new Color3 object
  80808. */
  80809. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  80810. // Statics
  80811. Color3._BlackReadOnly = Color3.Black();
  80812. return Color3;
  80813. }());
  80814. /**
  80815. * Class used to hold a RBGA color
  80816. */
  80817. var Color4 = /** @class */ (function () {
  80818. /**
  80819. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  80820. * @param r defines the red component (between 0 and 1, default is 0)
  80821. * @param g defines the green component (between 0 and 1, default is 0)
  80822. * @param b defines the blue component (between 0 and 1, default is 0)
  80823. * @param a defines the alpha component (between 0 and 1, default is 1)
  80824. */
  80825. function Color4(
  80826. /**
  80827. * Defines the red component (between 0 and 1, default is 0)
  80828. */
  80829. r,
  80830. /**
  80831. * Defines the green component (between 0 and 1, default is 0)
  80832. */
  80833. g,
  80834. /**
  80835. * Defines the blue component (between 0 and 1, default is 0)
  80836. */
  80837. b,
  80838. /**
  80839. * Defines the alpha component (between 0 and 1, default is 1)
  80840. */
  80841. a) {
  80842. if (r === void 0) { r = 0; }
  80843. if (g === void 0) { g = 0; }
  80844. if (b === void 0) { b = 0; }
  80845. if (a === void 0) { a = 1; }
  80846. this.r = r;
  80847. this.g = g;
  80848. this.b = b;
  80849. this.a = a;
  80850. }
  80851. // Operators
  80852. /**
  80853. * Adds in place the given Color4 values to the current Color4 object
  80854. * @param right defines the second operand
  80855. * @returns the current updated Color4 object
  80856. */
  80857. Color4.prototype.addInPlace = function (right) {
  80858. this.r += right.r;
  80859. this.g += right.g;
  80860. this.b += right.b;
  80861. this.a += right.a;
  80862. return this;
  80863. };
  80864. /**
  80865. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  80866. * @returns the new array
  80867. */
  80868. Color4.prototype.asArray = function () {
  80869. var result = new Array();
  80870. this.toArray(result, 0);
  80871. return result;
  80872. };
  80873. /**
  80874. * Stores from the starting index in the given array the Color4 successive values
  80875. * @param array defines the array where to store the r,g,b components
  80876. * @param index defines an optional index in the target array to define where to start storing values
  80877. * @returns the current Color4 object
  80878. */
  80879. Color4.prototype.toArray = function (array, index) {
  80880. if (index === void 0) { index = 0; }
  80881. array[index] = this.r;
  80882. array[index + 1] = this.g;
  80883. array[index + 2] = this.b;
  80884. array[index + 3] = this.a;
  80885. return this;
  80886. };
  80887. /**
  80888. * Determines equality between Color4 objects
  80889. * @param otherColor defines the second operand
  80890. * @returns true if the rgba values are equal to the given ones
  80891. */
  80892. Color4.prototype.equals = function (otherColor) {
  80893. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  80894. };
  80895. /**
  80896. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  80897. * @param right defines the second operand
  80898. * @returns a new Color4 object
  80899. */
  80900. Color4.prototype.add = function (right) {
  80901. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  80902. };
  80903. /**
  80904. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  80905. * @param right defines the second operand
  80906. * @returns a new Color4 object
  80907. */
  80908. Color4.prototype.subtract = function (right) {
  80909. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  80910. };
  80911. /**
  80912. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  80913. * @param right defines the second operand
  80914. * @param result defines the Color4 object where to store the result
  80915. * @returns the current Color4 object
  80916. */
  80917. Color4.prototype.subtractToRef = function (right, result) {
  80918. result.r = this.r - right.r;
  80919. result.g = this.g - right.g;
  80920. result.b = this.b - right.b;
  80921. result.a = this.a - right.a;
  80922. return this;
  80923. };
  80924. /**
  80925. * Creates a new Color4 with the current Color4 values multiplied by scale
  80926. * @param scale defines the scaling factor to apply
  80927. * @returns a new Color4 object
  80928. */
  80929. Color4.prototype.scale = function (scale) {
  80930. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  80931. };
  80932. /**
  80933. * Multiplies the current Color4 values by scale and stores the result in "result"
  80934. * @param scale defines the scaling factor to apply
  80935. * @param result defines the Color4 object where to store the result
  80936. * @returns the current unmodified Color4
  80937. */
  80938. Color4.prototype.scaleToRef = function (scale, result) {
  80939. result.r = this.r * scale;
  80940. result.g = this.g * scale;
  80941. result.b = this.b * scale;
  80942. result.a = this.a * scale;
  80943. return this;
  80944. };
  80945. /**
  80946. * Scale the current Color4 values by a factor and add the result to a given Color4
  80947. * @param scale defines the scale factor
  80948. * @param result defines the Color4 object where to store the result
  80949. * @returns the unmodified current Color4
  80950. */
  80951. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  80952. result.r += this.r * scale;
  80953. result.g += this.g * scale;
  80954. result.b += this.b * scale;
  80955. result.a += this.a * scale;
  80956. return this;
  80957. };
  80958. /**
  80959. * Clamps the rgb values by the min and max values and stores the result into "result"
  80960. * @param min defines minimum clamping value (default is 0)
  80961. * @param max defines maximum clamping value (default is 1)
  80962. * @param result defines color to store the result into.
  80963. * @returns the cuurent Color4
  80964. */
  80965. Color4.prototype.clampToRef = function (min, max, result) {
  80966. if (min === void 0) { min = 0; }
  80967. if (max === void 0) { max = 1; }
  80968. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.r, min, max);
  80969. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.g, min, max);
  80970. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.b, min, max);
  80971. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(this.a, min, max);
  80972. return this;
  80973. };
  80974. /**
  80975. * Multipy an Color4 value by another and return a new Color4 object
  80976. * @param color defines the Color4 value to multiply by
  80977. * @returns a new Color4 object
  80978. */
  80979. Color4.prototype.multiply = function (color) {
  80980. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  80981. };
  80982. /**
  80983. * Multipy a Color4 value by another and push the result in a reference value
  80984. * @param color defines the Color4 value to multiply by
  80985. * @param result defines the Color4 to fill the result in
  80986. * @returns the result Color4
  80987. */
  80988. Color4.prototype.multiplyToRef = function (color, result) {
  80989. result.r = this.r * color.r;
  80990. result.g = this.g * color.g;
  80991. result.b = this.b * color.b;
  80992. result.a = this.a * color.a;
  80993. return result;
  80994. };
  80995. /**
  80996. * Creates a string with the Color4 current values
  80997. * @returns the string representation of the Color4 object
  80998. */
  80999. Color4.prototype.toString = function () {
  81000. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  81001. };
  81002. /**
  81003. * Returns the string "Color4"
  81004. * @returns "Color4"
  81005. */
  81006. Color4.prototype.getClassName = function () {
  81007. return "Color4";
  81008. };
  81009. /**
  81010. * Compute the Color4 hash code
  81011. * @returns an unique number that can be used to hash Color4 objects
  81012. */
  81013. Color4.prototype.getHashCode = function () {
  81014. var hash = (this.r * 255) | 0;
  81015. hash = (hash * 397) ^ ((this.g * 255) | 0);
  81016. hash = (hash * 397) ^ ((this.b * 255) | 0);
  81017. hash = (hash * 397) ^ ((this.a * 255) | 0);
  81018. return hash;
  81019. };
  81020. /**
  81021. * Creates a new Color4 copied from the current one
  81022. * @returns a new Color4 object
  81023. */
  81024. Color4.prototype.clone = function () {
  81025. return new Color4(this.r, this.g, this.b, this.a);
  81026. };
  81027. /**
  81028. * Copies the given Color4 values into the current one
  81029. * @param source defines the source Color4 object
  81030. * @returns the current updated Color4 object
  81031. */
  81032. Color4.prototype.copyFrom = function (source) {
  81033. this.r = source.r;
  81034. this.g = source.g;
  81035. this.b = source.b;
  81036. this.a = source.a;
  81037. return this;
  81038. };
  81039. /**
  81040. * Copies the given float values into the current one
  81041. * @param r defines the red component to read from
  81042. * @param g defines the green component to read from
  81043. * @param b defines the blue component to read from
  81044. * @param a defines the alpha component to read from
  81045. * @returns the current updated Color4 object
  81046. */
  81047. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  81048. this.r = r;
  81049. this.g = g;
  81050. this.b = b;
  81051. this.a = a;
  81052. return this;
  81053. };
  81054. /**
  81055. * Copies the given float values into the current one
  81056. * @param r defines the red component to read from
  81057. * @param g defines the green component to read from
  81058. * @param b defines the blue component to read from
  81059. * @param a defines the alpha component to read from
  81060. * @returns the current updated Color4 object
  81061. */
  81062. Color4.prototype.set = function (r, g, b, a) {
  81063. return this.copyFromFloats(r, g, b, a);
  81064. };
  81065. /**
  81066. * Compute the Color4 hexadecimal code as a string
  81067. * @returns a string containing the hexadecimal representation of the Color4 object
  81068. */
  81069. Color4.prototype.toHexString = function () {
  81070. var intR = (this.r * 255) | 0;
  81071. var intG = (this.g * 255) | 0;
  81072. var intB = (this.b * 255) | 0;
  81073. var intA = (this.a * 255) | 0;
  81074. return "#" + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intR) + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intG) + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intB) + _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].ToHex(intA);
  81075. };
  81076. /**
  81077. * Computes a new Color4 converted from the current one to linear space
  81078. * @returns a new Color4 object
  81079. */
  81080. Color4.prototype.toLinearSpace = function () {
  81081. var convertedColor = new Color4();
  81082. this.toLinearSpaceToRef(convertedColor);
  81083. return convertedColor;
  81084. };
  81085. /**
  81086. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81087. * @param convertedColor defines the Color4 object where to store the linear space version
  81088. * @returns the unmodified Color4
  81089. */
  81090. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  81091. convertedColor.r = Math.pow(this.r, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]);
  81092. convertedColor.g = Math.pow(this.g, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]);
  81093. convertedColor.b = Math.pow(this.b, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]);
  81094. convertedColor.a = this.a;
  81095. return this;
  81096. };
  81097. /**
  81098. * Computes a new Color4 converted from the current one to gamma space
  81099. * @returns a new Color4 object
  81100. */
  81101. Color4.prototype.toGammaSpace = function () {
  81102. var convertedColor = new Color4();
  81103. this.toGammaSpaceToRef(convertedColor);
  81104. return convertedColor;
  81105. };
  81106. /**
  81107. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81108. * @param convertedColor defines the Color4 object where to store the gamma space version
  81109. * @returns the unmodified Color4
  81110. */
  81111. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  81112. convertedColor.r = Math.pow(this.r, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  81113. convertedColor.g = Math.pow(this.g, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  81114. convertedColor.b = Math.pow(this.b, _math_constants__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  81115. convertedColor.a = this.a;
  81116. return this;
  81117. };
  81118. // Statics
  81119. /**
  81120. * Creates a new Color4 from the string containing valid hexadecimal values
  81121. * @param hex defines a string containing valid hexadecimal values
  81122. * @returns a new Color4 object
  81123. */
  81124. Color4.FromHexString = function (hex) {
  81125. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  81126. return new Color4(0.0, 0.0, 0.0, 0.0);
  81127. }
  81128. var r = parseInt(hex.substring(1, 3), 16);
  81129. var g = parseInt(hex.substring(3, 5), 16);
  81130. var b = parseInt(hex.substring(5, 7), 16);
  81131. var a = parseInt(hex.substring(7, 9), 16);
  81132. return Color4.FromInts(r, g, b, a);
  81133. };
  81134. /**
  81135. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81136. * @param left defines the start value
  81137. * @param right defines the end value
  81138. * @param amount defines the gradient factor
  81139. * @returns a new Color4 object
  81140. */
  81141. Color4.Lerp = function (left, right, amount) {
  81142. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  81143. Color4.LerpToRef(left, right, amount, result);
  81144. return result;
  81145. };
  81146. /**
  81147. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81148. * @param left defines the start value
  81149. * @param right defines the end value
  81150. * @param amount defines the gradient factor
  81151. * @param result defines the Color4 object where to store data
  81152. */
  81153. Color4.LerpToRef = function (left, right, amount, result) {
  81154. result.r = left.r + (right.r - left.r) * amount;
  81155. result.g = left.g + (right.g - left.g) * amount;
  81156. result.b = left.b + (right.b - left.b) * amount;
  81157. result.a = left.a + (right.a - left.a) * amount;
  81158. };
  81159. /**
  81160. * Creates a new Color4 from a Color3 and an alpha value
  81161. * @param color3 defines the source Color3 to read from
  81162. * @param alpha defines the alpha component (1.0 by default)
  81163. * @returns a new Color4 object
  81164. */
  81165. Color4.FromColor3 = function (color3, alpha) {
  81166. if (alpha === void 0) { alpha = 1.0; }
  81167. return new Color4(color3.r, color3.g, color3.b, alpha);
  81168. };
  81169. /**
  81170. * Creates a new Color4 from the starting index element of the given array
  81171. * @param array defines the source array to read from
  81172. * @param offset defines the offset in the source array
  81173. * @returns a new Color4 object
  81174. */
  81175. Color4.FromArray = function (array, offset) {
  81176. if (offset === void 0) { offset = 0; }
  81177. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  81178. };
  81179. /**
  81180. * Creates a new Color3 from integer values (< 256)
  81181. * @param r defines the red component to read from (value between 0 and 255)
  81182. * @param g defines the green component to read from (value between 0 and 255)
  81183. * @param b defines the blue component to read from (value between 0 and 255)
  81184. * @param a defines the alpha component to read from (value between 0 and 255)
  81185. * @returns a new Color3 object
  81186. */
  81187. Color4.FromInts = function (r, g, b, a) {
  81188. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  81189. };
  81190. /**
  81191. * Check the content of a given array and convert it to an array containing RGBA data
  81192. * If the original array was already containing count * 4 values then it is returned directly
  81193. * @param colors defines the array to check
  81194. * @param count defines the number of RGBA data to expect
  81195. * @returns an array containing count * 4 values (RGBA)
  81196. */
  81197. Color4.CheckColors4 = function (colors, count) {
  81198. // Check if color3 was used
  81199. if (colors.length === count * 3) {
  81200. var colors4 = [];
  81201. for (var index = 0; index < colors.length; index += 3) {
  81202. var newIndex = (index / 3) * 4;
  81203. colors4[newIndex] = colors[index];
  81204. colors4[newIndex + 1] = colors[index + 1];
  81205. colors4[newIndex + 2] = colors[index + 2];
  81206. colors4[newIndex + 3] = 1.0;
  81207. }
  81208. return colors4;
  81209. }
  81210. return colors;
  81211. };
  81212. return Color4;
  81213. }());
  81214. /**
  81215. * @hidden
  81216. */
  81217. var TmpColors = /** @class */ (function () {
  81218. function TmpColors() {
  81219. }
  81220. TmpColors.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(3, Color3.Black);
  81221. TmpColors.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  81222. return TmpColors;
  81223. }());
  81224. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Color3"] = Color3;
  81225. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Color4"] = Color4;
  81226. /***/ }),
  81227. /***/ "./Maths/math.constants.ts":
  81228. /*!*********************************!*\
  81229. !*** ./Maths/math.constants.ts ***!
  81230. \*********************************/
  81231. /*! exports provided: ToGammaSpace, ToLinearSpace, Epsilon */
  81232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81233. "use strict";
  81234. __webpack_require__.r(__webpack_exports__);
  81235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  81236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  81237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  81238. /**
  81239. * Constant used to convert a value to gamma space
  81240. * @ignorenaming
  81241. */
  81242. var ToGammaSpace = 1 / 2.2;
  81243. /**
  81244. * Constant used to convert a value to linear space
  81245. * @ignorenaming
  81246. */
  81247. var ToLinearSpace = 2.2;
  81248. /**
  81249. * Constant used to define the minimal number value in Babylon.js
  81250. * @ignorenaming
  81251. */
  81252. var Epsilon = 0.001;
  81253. /***/ }),
  81254. /***/ "./Maths/math.frustum.ts":
  81255. /*!*******************************!*\
  81256. !*** ./Maths/math.frustum.ts ***!
  81257. \*******************************/
  81258. /*! exports provided: Frustum */
  81259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81260. "use strict";
  81261. __webpack_require__.r(__webpack_exports__);
  81262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  81263. /* harmony import */ var _math_plane__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.plane */ "./Maths/math.plane.ts");
  81264. /**
  81265. * Reprasents a camera frustum
  81266. */
  81267. var Frustum = /** @class */ (function () {
  81268. function Frustum() {
  81269. }
  81270. /**
  81271. * Gets the planes representing the frustum
  81272. * @param transform matrix to be applied to the returned planes
  81273. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81274. */
  81275. Frustum.GetPlanes = function (transform) {
  81276. var frustumPlanes = [];
  81277. for (var index = 0; index < 6; index++) {
  81278. frustumPlanes.push(new _math_plane__WEBPACK_IMPORTED_MODULE_0__["Plane"](0.0, 0.0, 0.0, 0.0));
  81279. }
  81280. Frustum.GetPlanesToRef(transform, frustumPlanes);
  81281. return frustumPlanes;
  81282. };
  81283. /**
  81284. * Gets the near frustum plane transformed by the transform matrix
  81285. * @param transform transformation matrix to be applied to the resulting frustum plane
  81286. * @param frustumPlane the resuling frustum plane
  81287. */
  81288. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  81289. var m = transform.m;
  81290. frustumPlane.normal.x = m[3] + m[2];
  81291. frustumPlane.normal.y = m[7] + m[6];
  81292. frustumPlane.normal.z = m[11] + m[10];
  81293. frustumPlane.d = m[15] + m[14];
  81294. frustumPlane.normalize();
  81295. };
  81296. /**
  81297. * Gets the far frustum plane transformed by the transform matrix
  81298. * @param transform transformation matrix to be applied to the resulting frustum plane
  81299. * @param frustumPlane the resuling frustum plane
  81300. */
  81301. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  81302. var m = transform.m;
  81303. frustumPlane.normal.x = m[3] - m[2];
  81304. frustumPlane.normal.y = m[7] - m[6];
  81305. frustumPlane.normal.z = m[11] - m[10];
  81306. frustumPlane.d = m[15] - m[14];
  81307. frustumPlane.normalize();
  81308. };
  81309. /**
  81310. * Gets the left frustum plane transformed by the transform matrix
  81311. * @param transform transformation matrix to be applied to the resulting frustum plane
  81312. * @param frustumPlane the resuling frustum plane
  81313. */
  81314. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  81315. var m = transform.m;
  81316. frustumPlane.normal.x = m[3] + m[0];
  81317. frustumPlane.normal.y = m[7] + m[4];
  81318. frustumPlane.normal.z = m[11] + m[8];
  81319. frustumPlane.d = m[15] + m[12];
  81320. frustumPlane.normalize();
  81321. };
  81322. /**
  81323. * Gets the right frustum plane transformed by the transform matrix
  81324. * @param transform transformation matrix to be applied to the resulting frustum plane
  81325. * @param frustumPlane the resuling frustum plane
  81326. */
  81327. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  81328. var m = transform.m;
  81329. frustumPlane.normal.x = m[3] - m[0];
  81330. frustumPlane.normal.y = m[7] - m[4];
  81331. frustumPlane.normal.z = m[11] - m[8];
  81332. frustumPlane.d = m[15] - m[12];
  81333. frustumPlane.normalize();
  81334. };
  81335. /**
  81336. * Gets the top frustum plane transformed by the transform matrix
  81337. * @param transform transformation matrix to be applied to the resulting frustum plane
  81338. * @param frustumPlane the resuling frustum plane
  81339. */
  81340. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  81341. var m = transform.m;
  81342. frustumPlane.normal.x = m[3] - m[1];
  81343. frustumPlane.normal.y = m[7] - m[5];
  81344. frustumPlane.normal.z = m[11] - m[9];
  81345. frustumPlane.d = m[15] - m[13];
  81346. frustumPlane.normalize();
  81347. };
  81348. /**
  81349. * Gets the bottom frustum plane transformed by the transform matrix
  81350. * @param transform transformation matrix to be applied to the resulting frustum plane
  81351. * @param frustumPlane the resuling frustum plane
  81352. */
  81353. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  81354. var m = transform.m;
  81355. frustumPlane.normal.x = m[3] + m[1];
  81356. frustumPlane.normal.y = m[7] + m[5];
  81357. frustumPlane.normal.z = m[11] + m[9];
  81358. frustumPlane.d = m[15] + m[13];
  81359. frustumPlane.normalize();
  81360. };
  81361. /**
  81362. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81363. * @param transform transformation matrix to be applied to the resulting frustum planes
  81364. * @param frustumPlanes the resuling frustum planes
  81365. */
  81366. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  81367. // Near
  81368. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  81369. // Far
  81370. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  81371. // Left
  81372. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  81373. // Right
  81374. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  81375. // Top
  81376. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  81377. // Bottom
  81378. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  81379. };
  81380. return Frustum;
  81381. }());
  81382. /***/ }),
  81383. /***/ "./Maths/math.functions.ts":
  81384. /*!*********************************!*\
  81385. !*** ./Maths/math.functions.ts ***!
  81386. \*********************************/
  81387. /*! exports provided: extractMinAndMaxIndexed, extractMinAndMax */
  81388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81389. "use strict";
  81390. __webpack_require__.r(__webpack_exports__);
  81391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractMinAndMaxIndexed", function() { return extractMinAndMaxIndexed; });
  81392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractMinAndMax", function() { return extractMinAndMax; });
  81393. /* harmony import */ var _math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.vector */ "./Maths/math.vector.ts");
  81394. /**
  81395. * Extracts minimum and maximum values from a list of indexed positions
  81396. * @param positions defines the positions to use
  81397. * @param indices defines the indices to the positions
  81398. * @param indexStart defines the start index
  81399. * @param indexCount defines the end index
  81400. * @param bias defines bias value to add to the result
  81401. * @return minimum and maximum values
  81402. */
  81403. function extractMinAndMaxIndexed(positions, indices, indexStart, indexCount, bias) {
  81404. if (bias === void 0) { bias = null; }
  81405. var minimum = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  81406. var maximum = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  81407. for (var index = indexStart; index < indexStart + indexCount; index++) {
  81408. var offset = indices[index] * 3;
  81409. var x = positions[offset];
  81410. var y = positions[offset + 1];
  81411. var z = positions[offset + 2];
  81412. minimum.minimizeInPlaceFromFloats(x, y, z);
  81413. maximum.maximizeInPlaceFromFloats(x, y, z);
  81414. }
  81415. if (bias) {
  81416. minimum.x -= minimum.x * bias.x + bias.y;
  81417. minimum.y -= minimum.y * bias.x + bias.y;
  81418. minimum.z -= minimum.z * bias.x + bias.y;
  81419. maximum.x += maximum.x * bias.x + bias.y;
  81420. maximum.y += maximum.y * bias.x + bias.y;
  81421. maximum.z += maximum.z * bias.x + bias.y;
  81422. }
  81423. return {
  81424. minimum: minimum,
  81425. maximum: maximum
  81426. };
  81427. }
  81428. /**
  81429. * Extracts minimum and maximum values from a list of positions
  81430. * @param positions defines the positions to use
  81431. * @param start defines the start index in the positions array
  81432. * @param count defines the number of positions to handle
  81433. * @param bias defines bias value to add to the result
  81434. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81435. * @return minimum and maximum values
  81436. */
  81437. function extractMinAndMax(positions, start, count, bias, stride) {
  81438. if (bias === void 0) { bias = null; }
  81439. var minimum = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  81440. var maximum = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  81441. if (!stride) {
  81442. stride = 3;
  81443. }
  81444. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  81445. var x = positions[offset];
  81446. var y = positions[offset + 1];
  81447. var z = positions[offset + 2];
  81448. minimum.minimizeInPlaceFromFloats(x, y, z);
  81449. maximum.maximizeInPlaceFromFloats(x, y, z);
  81450. }
  81451. if (bias) {
  81452. minimum.x -= minimum.x * bias.x + bias.y;
  81453. minimum.y -= minimum.y * bias.x + bias.y;
  81454. minimum.z -= minimum.z * bias.x + bias.y;
  81455. maximum.x += maximum.x * bias.x + bias.y;
  81456. maximum.y += maximum.y * bias.x + bias.y;
  81457. maximum.z += maximum.z * bias.x + bias.y;
  81458. }
  81459. return {
  81460. minimum: minimum,
  81461. maximum: maximum
  81462. };
  81463. }
  81464. /***/ }),
  81465. /***/ "./Maths/math.path.ts":
  81466. /*!****************************!*\
  81467. !*** ./Maths/math.path.ts ***!
  81468. \****************************/
  81469. /*! exports provided: Orientation, BezierCurve, Angle, Arc2, Path2, Path3D, Curve3 */
  81470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81471. "use strict";
  81472. __webpack_require__.r(__webpack_exports__);
  81473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  81474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  81475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  81476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  81477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  81478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  81479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  81480. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  81481. /* harmony import */ var _math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.vector */ "./Maths/math.vector.ts");
  81482. /* harmony import */ var _math_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./math.constants */ "./Maths/math.constants.ts");
  81483. /**
  81484. * Defines potential orientation for back face culling
  81485. */
  81486. var Orientation;
  81487. (function (Orientation) {
  81488. /**
  81489. * Clockwise
  81490. */
  81491. Orientation[Orientation["CW"] = 0] = "CW";
  81492. /** Counter clockwise */
  81493. Orientation[Orientation["CCW"] = 1] = "CCW";
  81494. })(Orientation || (Orientation = {}));
  81495. /** Class used to represent a Bezier curve */
  81496. var BezierCurve = /** @class */ (function () {
  81497. function BezierCurve() {
  81498. }
  81499. /**
  81500. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  81501. * @param t defines the time
  81502. * @param x1 defines the left coordinate on X axis
  81503. * @param y1 defines the left coordinate on Y axis
  81504. * @param x2 defines the right coordinate on X axis
  81505. * @param y2 defines the right coordinate on Y axis
  81506. * @returns the interpolated value
  81507. */
  81508. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  81509. // Extract X (which is equal to time here)
  81510. var f0 = 1 - 3 * x2 + 3 * x1;
  81511. var f1 = 3 * x2 - 6 * x1;
  81512. var f2 = 3 * x1;
  81513. var refinedT = t;
  81514. for (var i = 0; i < 5; i++) {
  81515. var refinedT2 = refinedT * refinedT;
  81516. var refinedT3 = refinedT2 * refinedT;
  81517. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  81518. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  81519. refinedT -= (x - t) * slope;
  81520. refinedT = Math.min(1, Math.max(0, refinedT));
  81521. }
  81522. // Resolve cubic bezier for the given x
  81523. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  81524. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  81525. Math.pow(refinedT, 3);
  81526. };
  81527. return BezierCurve;
  81528. }());
  81529. /**
  81530. * Defines angle representation
  81531. */
  81532. var Angle = /** @class */ (function () {
  81533. /**
  81534. * Creates an Angle object of "radians" radians (float).
  81535. * @param radians the angle in radians
  81536. */
  81537. function Angle(radians) {
  81538. this._radians = radians;
  81539. if (this._radians < 0.0) {
  81540. this._radians += (2.0 * Math.PI);
  81541. }
  81542. }
  81543. /**
  81544. * Get value in degrees
  81545. * @returns the Angle value in degrees (float)
  81546. */
  81547. Angle.prototype.degrees = function () {
  81548. return this._radians * 180.0 / Math.PI;
  81549. };
  81550. /**
  81551. * Get value in radians
  81552. * @returns the Angle value in radians (float)
  81553. */
  81554. Angle.prototype.radians = function () {
  81555. return this._radians;
  81556. };
  81557. /**
  81558. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  81559. * @param a defines first vector
  81560. * @param b defines second vector
  81561. * @returns a new Angle
  81562. */
  81563. Angle.BetweenTwoPoints = function (a, b) {
  81564. var delta = b.subtract(a);
  81565. var theta = Math.atan2(delta.y, delta.x);
  81566. return new Angle(theta);
  81567. };
  81568. /**
  81569. * Gets a new Angle object from the given float in radians
  81570. * @param radians defines the angle value in radians
  81571. * @returns a new Angle
  81572. */
  81573. Angle.FromRadians = function (radians) {
  81574. return new Angle(radians);
  81575. };
  81576. /**
  81577. * Gets a new Angle object from the given float in degrees
  81578. * @param degrees defines the angle value in degrees
  81579. * @returns a new Angle
  81580. */
  81581. Angle.FromDegrees = function (degrees) {
  81582. return new Angle(degrees * Math.PI / 180.0);
  81583. };
  81584. return Angle;
  81585. }());
  81586. /**
  81587. * This represents an arc in a 2d space.
  81588. */
  81589. var Arc2 = /** @class */ (function () {
  81590. /**
  81591. * Creates an Arc object from the three given points : start, middle and end.
  81592. * @param startPoint Defines the start point of the arc
  81593. * @param midPoint Defines the midlle point of the arc
  81594. * @param endPoint Defines the end point of the arc
  81595. */
  81596. function Arc2(
  81597. /** Defines the start point of the arc */
  81598. startPoint,
  81599. /** Defines the mid point of the arc */
  81600. midPoint,
  81601. /** Defines the end point of the arc */
  81602. endPoint) {
  81603. this.startPoint = startPoint;
  81604. this.midPoint = midPoint;
  81605. this.endPoint = endPoint;
  81606. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  81607. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  81608. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  81609. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  81610. this.centerPoint = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]((startToMid * (midPoint.y - endPoint.y) - midToEnd * (startPoint.y - midPoint.y)) / det, ((startPoint.x - midPoint.x) * midToEnd - (midPoint.x - endPoint.x) * startToMid) / det);
  81611. this.radius = this.centerPoint.subtract(this.startPoint).length();
  81612. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  81613. var a1 = this.startAngle.degrees();
  81614. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  81615. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  81616. // angles correction
  81617. if (a2 - a1 > +180.0) {
  81618. a2 -= 360.0;
  81619. }
  81620. if (a2 - a1 < -180.0) {
  81621. a2 += 360.0;
  81622. }
  81623. if (a3 - a2 > +180.0) {
  81624. a3 -= 360.0;
  81625. }
  81626. if (a3 - a2 < -180.0) {
  81627. a3 += 360.0;
  81628. }
  81629. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  81630. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  81631. }
  81632. return Arc2;
  81633. }());
  81634. /**
  81635. * Represents a 2D path made up of multiple 2D points
  81636. */
  81637. var Path2 = /** @class */ (function () {
  81638. /**
  81639. * Creates a Path2 object from the starting 2D coordinates x and y.
  81640. * @param x the starting points x value
  81641. * @param y the starting points y value
  81642. */
  81643. function Path2(x, y) {
  81644. this._points = new Array();
  81645. this._length = 0.0;
  81646. /**
  81647. * If the path start and end point are the same
  81648. */
  81649. this.closed = false;
  81650. this._points.push(new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](x, y));
  81651. }
  81652. /**
  81653. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  81654. * @param x the added points x value
  81655. * @param y the added points y value
  81656. * @returns the updated Path2.
  81657. */
  81658. Path2.prototype.addLineTo = function (x, y) {
  81659. if (this.closed) {
  81660. return this;
  81661. }
  81662. var newPoint = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](x, y);
  81663. var previousPoint = this._points[this._points.length - 1];
  81664. this._points.push(newPoint);
  81665. this._length += newPoint.subtract(previousPoint).length();
  81666. return this;
  81667. };
  81668. /**
  81669. * 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.
  81670. * @param midX middle point x value
  81671. * @param midY middle point y value
  81672. * @param endX end point x value
  81673. * @param endY end point y value
  81674. * @param numberOfSegments (default: 36)
  81675. * @returns the updated Path2.
  81676. */
  81677. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  81678. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  81679. if (this.closed) {
  81680. return this;
  81681. }
  81682. var startPoint = this._points[this._points.length - 1];
  81683. var midPoint = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](midX, midY);
  81684. var endPoint = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](endX, endY);
  81685. var arc = new Arc2(startPoint, midPoint, endPoint);
  81686. var increment = arc.angle.radians() / numberOfSegments;
  81687. if (arc.orientation === Orientation.CW) {
  81688. increment *= -1;
  81689. }
  81690. var currentAngle = arc.startAngle.radians() + increment;
  81691. for (var i = 0; i < numberOfSegments; i++) {
  81692. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  81693. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  81694. this.addLineTo(x, y);
  81695. currentAngle += increment;
  81696. }
  81697. return this;
  81698. };
  81699. /**
  81700. * Closes the Path2.
  81701. * @returns the Path2.
  81702. */
  81703. Path2.prototype.close = function () {
  81704. this.closed = true;
  81705. return this;
  81706. };
  81707. /**
  81708. * Gets the sum of the distance between each sequential point in the path
  81709. * @returns the Path2 total length (float).
  81710. */
  81711. Path2.prototype.length = function () {
  81712. var result = this._length;
  81713. if (!this.closed) {
  81714. var lastPoint = this._points[this._points.length - 1];
  81715. var firstPoint = this._points[0];
  81716. result += (firstPoint.subtract(lastPoint).length());
  81717. }
  81718. return result;
  81719. };
  81720. /**
  81721. * Gets the points which construct the path
  81722. * @returns the Path2 internal array of points.
  81723. */
  81724. Path2.prototype.getPoints = function () {
  81725. return this._points;
  81726. };
  81727. /**
  81728. * Retreives the point at the distance aways from the starting point
  81729. * @param normalizedLengthPosition the length along the path to retreive the point from
  81730. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  81731. */
  81732. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  81733. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  81734. return _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  81735. }
  81736. var lengthPosition = normalizedLengthPosition * this.length();
  81737. var previousOffset = 0;
  81738. for (var i = 0; i < this._points.length; i++) {
  81739. var j = (i + 1) % this._points.length;
  81740. var a = this._points[i];
  81741. var b = this._points[j];
  81742. var bToA = b.subtract(a);
  81743. var nextOffset = (bToA.length() + previousOffset);
  81744. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  81745. var dir = bToA.normalize();
  81746. var localOffset = lengthPosition - previousOffset;
  81747. return new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  81748. }
  81749. previousOffset = nextOffset;
  81750. }
  81751. return _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  81752. };
  81753. /**
  81754. * Creates a new path starting from an x and y position
  81755. * @param x starting x value
  81756. * @param y starting y value
  81757. * @returns a new Path2 starting at the coordinates (x, y).
  81758. */
  81759. Path2.StartingAt = function (x, y) {
  81760. return new Path2(x, y);
  81761. };
  81762. return Path2;
  81763. }());
  81764. /**
  81765. * Represents a 3D path made up of multiple 3D points
  81766. */
  81767. var Path3D = /** @class */ (function () {
  81768. /**
  81769. * new Path3D(path, normal, raw)
  81770. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  81771. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  81772. * @param path an array of Vector3, the curve axis of the Path3D
  81773. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  81774. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  81775. */
  81776. function Path3D(
  81777. /**
  81778. * an array of Vector3, the curve axis of the Path3D
  81779. */
  81780. path, firstNormal, raw) {
  81781. if (firstNormal === void 0) { firstNormal = null; }
  81782. this.path = path;
  81783. this._curve = new Array();
  81784. this._distances = new Array();
  81785. this._tangents = new Array();
  81786. this._normals = new Array();
  81787. this._binormals = new Array();
  81788. for (var p = 0; p < path.length; p++) {
  81789. this._curve[p] = path[p].clone(); // hard copy
  81790. }
  81791. this._raw = raw || false;
  81792. this._compute(firstNormal);
  81793. }
  81794. /**
  81795. * Returns the Path3D array of successive Vector3 designing its curve.
  81796. * @returns the Path3D array of successive Vector3 designing its curve.
  81797. */
  81798. Path3D.prototype.getCurve = function () {
  81799. return this._curve;
  81800. };
  81801. /**
  81802. * Returns an array populated with tangent vectors on each Path3D curve point.
  81803. * @returns an array populated with tangent vectors on each Path3D curve point.
  81804. */
  81805. Path3D.prototype.getTangents = function () {
  81806. return this._tangents;
  81807. };
  81808. /**
  81809. * Returns an array populated with normal vectors on each Path3D curve point.
  81810. * @returns an array populated with normal vectors on each Path3D curve point.
  81811. */
  81812. Path3D.prototype.getNormals = function () {
  81813. return this._normals;
  81814. };
  81815. /**
  81816. * Returns an array populated with binormal vectors on each Path3D curve point.
  81817. * @returns an array populated with binormal vectors on each Path3D curve point.
  81818. */
  81819. Path3D.prototype.getBinormals = function () {
  81820. return this._binormals;
  81821. };
  81822. /**
  81823. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  81824. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  81825. */
  81826. Path3D.prototype.getDistances = function () {
  81827. return this._distances;
  81828. };
  81829. /**
  81830. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  81831. * @param path path which all values are copied into the curves points
  81832. * @param firstNormal which should be projected onto the curve
  81833. * @returns the same object updated.
  81834. */
  81835. Path3D.prototype.update = function (path, firstNormal) {
  81836. if (firstNormal === void 0) { firstNormal = null; }
  81837. for (var p = 0; p < path.length; p++) {
  81838. this._curve[p].x = path[p].x;
  81839. this._curve[p].y = path[p].y;
  81840. this._curve[p].z = path[p].z;
  81841. }
  81842. this._compute(firstNormal);
  81843. return this;
  81844. };
  81845. // private function compute() : computes tangents, normals and binormals
  81846. Path3D.prototype._compute = function (firstNormal) {
  81847. var l = this._curve.length;
  81848. // first and last tangents
  81849. this._tangents[0] = this._getFirstNonNullVector(0);
  81850. if (!this._raw) {
  81851. this._tangents[0].normalize();
  81852. }
  81853. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  81854. if (!this._raw) {
  81855. this._tangents[l - 1].normalize();
  81856. }
  81857. // normals and binormals at first point : arbitrary vector with _normalVector()
  81858. var tg0 = this._tangents[0];
  81859. var pp0 = this._normalVector(tg0, firstNormal);
  81860. this._normals[0] = pp0;
  81861. if (!this._raw) {
  81862. this._normals[0].normalize();
  81863. }
  81864. this._binormals[0] = _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(tg0, this._normals[0]);
  81865. if (!this._raw) {
  81866. this._binormals[0].normalize();
  81867. }
  81868. this._distances[0] = 0.0;
  81869. // normals and binormals : next points
  81870. var prev; // previous vector (segment)
  81871. var cur; // current vector (segment)
  81872. var curTang; // current tangent
  81873. // previous normal
  81874. var prevBinor; // previous binormal
  81875. for (var i = 1; i < l; i++) {
  81876. // tangents
  81877. prev = this._getLastNonNullVector(i);
  81878. if (i < l - 1) {
  81879. cur = this._getFirstNonNullVector(i);
  81880. this._tangents[i] = prev.add(cur);
  81881. this._tangents[i].normalize();
  81882. }
  81883. this._distances[i] = this._distances[i - 1] + prev.length();
  81884. // normals and binormals
  81885. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  81886. curTang = this._tangents[i];
  81887. prevBinor = this._binormals[i - 1];
  81888. this._normals[i] = _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(prevBinor, curTang);
  81889. if (!this._raw) {
  81890. this._normals[i].normalize();
  81891. }
  81892. this._binormals[i] = _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(curTang, this._normals[i]);
  81893. if (!this._raw) {
  81894. this._binormals[i].normalize();
  81895. }
  81896. }
  81897. };
  81898. // private function getFirstNonNullVector(index)
  81899. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  81900. Path3D.prototype._getFirstNonNullVector = function (index) {
  81901. var i = 1;
  81902. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  81903. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  81904. i++;
  81905. nNVector = this._curve[index + i].subtract(this._curve[index]);
  81906. }
  81907. return nNVector;
  81908. };
  81909. // private function getLastNonNullVector(index)
  81910. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  81911. Path3D.prototype._getLastNonNullVector = function (index) {
  81912. var i = 1;
  81913. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  81914. while (nLVector.length() === 0 && index > i + 1) {
  81915. i++;
  81916. nLVector = this._curve[index].subtract(this._curve[index - i]);
  81917. }
  81918. return nLVector;
  81919. };
  81920. // private function normalVector(v0, vt, va) :
  81921. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  81922. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  81923. Path3D.prototype._normalVector = function (vt, va) {
  81924. var normal0;
  81925. var tgl = vt.length();
  81926. if (tgl === 0.0) {
  81927. tgl = 1.0;
  81928. }
  81929. if (va === undefined || va === null) {
  81930. var point;
  81931. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, _math_constants__WEBPACK_IMPORTED_MODULE_2__["Epsilon"])) { // search for a point in the plane
  81932. point = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, -1.0, 0.0);
  81933. }
  81934. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, _math_constants__WEBPACK_IMPORTED_MODULE_2__["Epsilon"])) {
  81935. point = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](1.0, 0.0, 0.0);
  81936. }
  81937. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, _math_constants__WEBPACK_IMPORTED_MODULE_2__["Epsilon"])) {
  81938. point = new _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 0.0, 1.0);
  81939. }
  81940. else {
  81941. point = _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  81942. }
  81943. normal0 = _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(vt, point);
  81944. }
  81945. else {
  81946. normal0 = _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(vt, va);
  81947. _math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(normal0, vt, normal0);
  81948. }
  81949. normal0.normalize();
  81950. return normal0;
  81951. };
  81952. return Path3D;
  81953. }());
  81954. /**
  81955. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81956. * A Curve3 is designed from a series of successive Vector3.
  81957. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  81958. */
  81959. var Curve3 = /** @class */ (function () {
  81960. /**
  81961. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81962. * A Curve3 is designed from a series of successive Vector3.
  81963. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  81964. * @param points points which make up the curve
  81965. */
  81966. function Curve3(points) {
  81967. this._length = 0.0;
  81968. this._points = points;
  81969. this._length = this._computeLength(points);
  81970. }
  81971. /**
  81972. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  81973. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  81974. * @param v1 (Vector3) the control point
  81975. * @param v2 (Vector3) the end point of the Quadratic Bezier
  81976. * @param nbPoints (integer) the wanted number of points in the curve
  81977. * @returns the created Curve3
  81978. */
  81979. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  81980. nbPoints = nbPoints > 2 ? nbPoints : 3;
  81981. var bez = new Array();
  81982. var equation = function (t, val0, val1, val2) {
  81983. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  81984. return res;
  81985. };
  81986. for (var i = 0; i <= nbPoints; i++) {
  81987. bez.push(new _math_vector__WEBPACK_IMPORTED_MODULE_1__["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)));
  81988. }
  81989. return new Curve3(bez);
  81990. };
  81991. /**
  81992. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  81993. * @param v0 (Vector3) the origin point of the Cubic Bezier
  81994. * @param v1 (Vector3) the first control point
  81995. * @param v2 (Vector3) the second control point
  81996. * @param v3 (Vector3) the end point of the Cubic Bezier
  81997. * @param nbPoints (integer) the wanted number of points in the curve
  81998. * @returns the created Curve3
  81999. */
  82000. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  82001. nbPoints = nbPoints > 3 ? nbPoints : 4;
  82002. var bez = new Array();
  82003. var equation = function (t, val0, val1, val2, val3) {
  82004. 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;
  82005. return res;
  82006. };
  82007. for (var i = 0; i <= nbPoints; i++) {
  82008. bez.push(new _math_vector__WEBPACK_IMPORTED_MODULE_1__["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)));
  82009. }
  82010. return new Curve3(bez);
  82011. };
  82012. /**
  82013. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82014. * @param p1 (Vector3) the origin point of the Hermite Spline
  82015. * @param t1 (Vector3) the tangent vector at the origin point
  82016. * @param p2 (Vector3) the end point of the Hermite Spline
  82017. * @param t2 (Vector3) the tangent vector at the end point
  82018. * @param nbPoints (integer) the wanted number of points in the curve
  82019. * @returns the created Curve3
  82020. */
  82021. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  82022. var hermite = new Array();
  82023. var step = 1.0 / nbPoints;
  82024. for (var i = 0; i <= nbPoints; i++) {
  82025. hermite.push(_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Hermite(p1, t1, p2, t2, i * step));
  82026. }
  82027. return new Curve3(hermite);
  82028. };
  82029. /**
  82030. * Returns a Curve3 object along a CatmullRom Spline curve :
  82031. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82032. * @param nbPoints (integer) the wanted number of points between each curve control points
  82033. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82034. * @returns the created Curve3
  82035. */
  82036. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  82037. var catmullRom = new Array();
  82038. var step = 1.0 / nbPoints;
  82039. var amount = 0.0;
  82040. if (closed) {
  82041. var pointsCount = points.length;
  82042. for (var i = 0; i < pointsCount; i++) {
  82043. amount = 0;
  82044. for (var c = 0; c < nbPoints; c++) {
  82045. catmullRom.push(_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  82046. amount += step;
  82047. }
  82048. }
  82049. catmullRom.push(catmullRom[0]);
  82050. }
  82051. else {
  82052. var totalPoints = new Array();
  82053. totalPoints.push(points[0].clone());
  82054. Array.prototype.push.apply(totalPoints, points);
  82055. totalPoints.push(points[points.length - 1].clone());
  82056. for (var i = 0; i < totalPoints.length - 3; i++) {
  82057. amount = 0;
  82058. for (var c = 0; c < nbPoints; c++) {
  82059. catmullRom.push(_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  82060. amount += step;
  82061. }
  82062. }
  82063. i--;
  82064. catmullRom.push(_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  82065. }
  82066. return new Curve3(catmullRom);
  82067. };
  82068. /**
  82069. * @returns the Curve3 stored array of successive Vector3
  82070. */
  82071. Curve3.prototype.getPoints = function () {
  82072. return this._points;
  82073. };
  82074. /**
  82075. * @returns the computed length (float) of the curve.
  82076. */
  82077. Curve3.prototype.length = function () {
  82078. return this._length;
  82079. };
  82080. /**
  82081. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82082. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82083. * curveA and curveB keep unchanged.
  82084. * @param curve the curve to continue from this curve
  82085. * @returns the newly constructed curve
  82086. */
  82087. Curve3.prototype.continue = function (curve) {
  82088. var lastPoint = this._points[this._points.length - 1];
  82089. var continuedPoints = this._points.slice();
  82090. var curvePoints = curve.getPoints();
  82091. for (var i = 1; i < curvePoints.length; i++) {
  82092. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  82093. }
  82094. var continuedCurve = new Curve3(continuedPoints);
  82095. return continuedCurve;
  82096. };
  82097. Curve3.prototype._computeLength = function (path) {
  82098. var l = 0;
  82099. for (var i = 1; i < path.length; i++) {
  82100. l += (path[i].subtract(path[i - 1])).length();
  82101. }
  82102. return l;
  82103. };
  82104. return Curve3;
  82105. }());
  82106. /***/ }),
  82107. /***/ "./Maths/math.plane.ts":
  82108. /*!*****************************!*\
  82109. !*** ./Maths/math.plane.ts ***!
  82110. \*****************************/
  82111. /*! exports provided: Plane */
  82112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82113. "use strict";
  82114. __webpack_require__.r(__webpack_exports__);
  82115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  82116. /* harmony import */ var _math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.vector */ "./Maths/math.vector.ts");
  82117. /**
  82118. * Represens a plane by the equation ax + by + cz + d = 0
  82119. */
  82120. var Plane = /** @class */ (function () {
  82121. /**
  82122. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82123. * @param a a component of the plane
  82124. * @param b b component of the plane
  82125. * @param c c component of the plane
  82126. * @param d d component of the plane
  82127. */
  82128. function Plane(a, b, c, d) {
  82129. this.normal = new _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](a, b, c);
  82130. this.d = d;
  82131. }
  82132. /**
  82133. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82134. */
  82135. Plane.prototype.asArray = function () {
  82136. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  82137. };
  82138. // Methods
  82139. /**
  82140. * @returns a new plane copied from the current Plane.
  82141. */
  82142. Plane.prototype.clone = function () {
  82143. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  82144. };
  82145. /**
  82146. * @returns the string "Plane".
  82147. */
  82148. Plane.prototype.getClassName = function () {
  82149. return "Plane";
  82150. };
  82151. /**
  82152. * @returns the Plane hash code.
  82153. */
  82154. Plane.prototype.getHashCode = function () {
  82155. var hash = this.normal.getHashCode();
  82156. hash = (hash * 397) ^ (this.d | 0);
  82157. return hash;
  82158. };
  82159. /**
  82160. * Normalize the current Plane in place.
  82161. * @returns the updated Plane.
  82162. */
  82163. Plane.prototype.normalize = function () {
  82164. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  82165. var magnitude = 0.0;
  82166. if (norm !== 0) {
  82167. magnitude = 1.0 / norm;
  82168. }
  82169. this.normal.x *= magnitude;
  82170. this.normal.y *= magnitude;
  82171. this.normal.z *= magnitude;
  82172. this.d *= magnitude;
  82173. return this;
  82174. };
  82175. /**
  82176. * Applies a transformation the plane and returns the result
  82177. * @param transformation the transformation matrix to be applied to the plane
  82178. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82179. */
  82180. Plane.prototype.transform = function (transformation) {
  82181. var transposedMatrix = Plane._TmpMatrix;
  82182. _math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].TransposeToRef(transformation, transposedMatrix);
  82183. var m = transposedMatrix.m;
  82184. var x = this.normal.x;
  82185. var y = this.normal.y;
  82186. var z = this.normal.z;
  82187. var d = this.d;
  82188. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  82189. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  82190. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  82191. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  82192. return new Plane(normalX, normalY, normalZ, finalD);
  82193. };
  82194. /**
  82195. * Calcualtte the dot product between the point and the plane normal
  82196. * @param point point to calculate the dot product with
  82197. * @returns the dot product (float) of the point coordinates and the plane normal.
  82198. */
  82199. Plane.prototype.dotCoordinate = function (point) {
  82200. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  82201. };
  82202. /**
  82203. * Updates the current Plane from the plane defined by the three given points.
  82204. * @param point1 one of the points used to contruct the plane
  82205. * @param point2 one of the points used to contruct the plane
  82206. * @param point3 one of the points used to contruct the plane
  82207. * @returns the updated Plane.
  82208. */
  82209. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  82210. var x1 = point2.x - point1.x;
  82211. var y1 = point2.y - point1.y;
  82212. var z1 = point2.z - point1.z;
  82213. var x2 = point3.x - point1.x;
  82214. var y2 = point3.y - point1.y;
  82215. var z2 = point3.z - point1.z;
  82216. var yz = (y1 * z2) - (z1 * y2);
  82217. var xz = (z1 * x2) - (x1 * z2);
  82218. var xy = (x1 * y2) - (y1 * x2);
  82219. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  82220. var invPyth;
  82221. if (pyth !== 0) {
  82222. invPyth = 1.0 / pyth;
  82223. }
  82224. else {
  82225. invPyth = 0.0;
  82226. }
  82227. this.normal.x = yz * invPyth;
  82228. this.normal.y = xz * invPyth;
  82229. this.normal.z = xy * invPyth;
  82230. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  82231. return this;
  82232. };
  82233. /**
  82234. * Checks if the plane is facing a given direction
  82235. * @param direction the direction to check if the plane is facing
  82236. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82237. * @returns True is the vector "direction" is the same side than the plane normal.
  82238. */
  82239. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  82240. var dot = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, direction);
  82241. return (dot <= epsilon);
  82242. };
  82243. /**
  82244. * Calculates the distance to a point
  82245. * @param point point to calculate distance to
  82246. * @returns the signed distance (float) from the given point to the Plane.
  82247. */
  82248. Plane.prototype.signedDistanceTo = function (point) {
  82249. return _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(point, this.normal) + this.d;
  82250. };
  82251. // Statics
  82252. /**
  82253. * Creates a plane from an array
  82254. * @param array the array to create a plane from
  82255. * @returns a new Plane from the given array.
  82256. */
  82257. Plane.FromArray = function (array) {
  82258. return new Plane(array[0], array[1], array[2], array[3]);
  82259. };
  82260. /**
  82261. * Creates a plane from three points
  82262. * @param point1 point used to create the plane
  82263. * @param point2 point used to create the plane
  82264. * @param point3 point used to create the plane
  82265. * @returns a new Plane defined by the three given points.
  82266. */
  82267. Plane.FromPoints = function (point1, point2, point3) {
  82268. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  82269. result.copyFromPoints(point1, point2, point3);
  82270. return result;
  82271. };
  82272. /**
  82273. * Creates a plane from an origin point and a normal
  82274. * @param origin origin of the plane to be constructed
  82275. * @param normal normal of the plane to be constructed
  82276. * @returns a new Plane the normal vector to this plane at the given origin point.
  82277. * Note : the vector "normal" is updated because normalized.
  82278. */
  82279. Plane.FromPositionAndNormal = function (origin, normal) {
  82280. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  82281. normal.normalize();
  82282. result.normal = normal;
  82283. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  82284. return result;
  82285. };
  82286. /**
  82287. * Calculates the distance from a plane and a point
  82288. * @param origin origin of the plane to be constructed
  82289. * @param normal normal of the plane to be constructed
  82290. * @param point point to calculate distance to
  82291. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82292. */
  82293. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  82294. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  82295. return _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(point, normal) + d;
  82296. };
  82297. Plane._TmpMatrix = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  82298. return Plane;
  82299. }());
  82300. /***/ }),
  82301. /***/ "./Maths/math.scalar.ts":
  82302. /*!******************************!*\
  82303. !*** ./Maths/math.scalar.ts ***!
  82304. \******************************/
  82305. /*! exports provided: Scalar */
  82306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82307. "use strict";
  82308. __webpack_require__.r(__webpack_exports__);
  82309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  82310. /**
  82311. * Scalar computation library
  82312. */
  82313. var Scalar = /** @class */ (function () {
  82314. function Scalar() {
  82315. }
  82316. /**
  82317. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82318. * @param a number
  82319. * @param b number
  82320. * @param epsilon (default = 1.401298E-45)
  82321. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82322. */
  82323. Scalar.WithinEpsilon = function (a, b, epsilon) {
  82324. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  82325. var num = a - b;
  82326. return -epsilon <= num && num <= epsilon;
  82327. };
  82328. /**
  82329. * Returns a string : the upper case translation of the number i to hexadecimal.
  82330. * @param i number
  82331. * @returns the upper case translation of the number i to hexadecimal.
  82332. */
  82333. Scalar.ToHex = function (i) {
  82334. var str = i.toString(16);
  82335. if (i <= 15) {
  82336. return ("0" + str).toUpperCase();
  82337. }
  82338. return str.toUpperCase();
  82339. };
  82340. /**
  82341. * Returns -1 if value is negative and +1 is value is positive.
  82342. * @param value the value
  82343. * @returns the value itself if it's equal to zero.
  82344. */
  82345. Scalar.Sign = function (value) {
  82346. value = +value; // convert to a number
  82347. if (value === 0 || isNaN(value)) {
  82348. return value;
  82349. }
  82350. return value > 0 ? 1 : -1;
  82351. };
  82352. /**
  82353. * Returns the value itself if it's between min and max.
  82354. * Returns min if the value is lower than min.
  82355. * Returns max if the value is greater than max.
  82356. * @param value the value to clmap
  82357. * @param min the min value to clamp to (default: 0)
  82358. * @param max the max value to clamp to (default: 1)
  82359. * @returns the clamped value
  82360. */
  82361. Scalar.Clamp = function (value, min, max) {
  82362. if (min === void 0) { min = 0; }
  82363. if (max === void 0) { max = 1; }
  82364. return Math.min(max, Math.max(min, value));
  82365. };
  82366. /**
  82367. * the log2 of value.
  82368. * @param value the value to compute log2 of
  82369. * @returns the log2 of value.
  82370. */
  82371. Scalar.Log2 = function (value) {
  82372. return Math.log(value) * Math.LOG2E;
  82373. };
  82374. /**
  82375. * Loops the value, so that it is never larger than length and never smaller than 0.
  82376. *
  82377. * This is similar to the modulo operator but it works with floating point numbers.
  82378. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82379. * With t = 5 and length = 2.5, the result would be 0.0.
  82380. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82381. * @param value the value
  82382. * @param length the length
  82383. * @returns the looped value
  82384. */
  82385. Scalar.Repeat = function (value, length) {
  82386. return value - Math.floor(value / length) * length;
  82387. };
  82388. /**
  82389. * Normalize the value between 0.0 and 1.0 using min and max values
  82390. * @param value value to normalize
  82391. * @param min max to normalize between
  82392. * @param max min to normalize between
  82393. * @returns the normalized value
  82394. */
  82395. Scalar.Normalize = function (value, min, max) {
  82396. return (value - min) / (max - min);
  82397. };
  82398. /**
  82399. * Denormalize the value from 0.0 and 1.0 using min and max values
  82400. * @param normalized value to denormalize
  82401. * @param min max to denormalize between
  82402. * @param max min to denormalize between
  82403. * @returns the denormalized value
  82404. */
  82405. Scalar.Denormalize = function (normalized, min, max) {
  82406. return (normalized * (max - min) + min);
  82407. };
  82408. /**
  82409. * Calculates the shortest difference between two given angles given in degrees.
  82410. * @param current current angle in degrees
  82411. * @param target target angle in degrees
  82412. * @returns the delta
  82413. */
  82414. Scalar.DeltaAngle = function (current, target) {
  82415. var num = Scalar.Repeat(target - current, 360.0);
  82416. if (num > 180.0) {
  82417. num -= 360.0;
  82418. }
  82419. return num;
  82420. };
  82421. /**
  82422. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82423. * @param tx value
  82424. * @param length length
  82425. * @returns The returned value will move back and forth between 0 and length
  82426. */
  82427. Scalar.PingPong = function (tx, length) {
  82428. var t = Scalar.Repeat(tx, length * 2.0);
  82429. return length - Math.abs(t - length);
  82430. };
  82431. /**
  82432. * Interpolates between min and max with smoothing at the limits.
  82433. *
  82434. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82435. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82436. * @param from from
  82437. * @param to to
  82438. * @param tx value
  82439. * @returns the smooth stepped value
  82440. */
  82441. Scalar.SmoothStep = function (from, to, tx) {
  82442. var t = Scalar.Clamp(tx);
  82443. t = -2.0 * t * t * t + 3.0 * t * t;
  82444. return to * t + from * (1.0 - t);
  82445. };
  82446. /**
  82447. * Moves a value current towards target.
  82448. *
  82449. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82450. * Negative values of maxDelta pushes the value away from target.
  82451. * @param current current value
  82452. * @param target target value
  82453. * @param maxDelta max distance to move
  82454. * @returns resulting value
  82455. */
  82456. Scalar.MoveTowards = function (current, target, maxDelta) {
  82457. var result = 0;
  82458. if (Math.abs(target - current) <= maxDelta) {
  82459. result = target;
  82460. }
  82461. else {
  82462. result = current + Scalar.Sign(target - current) * maxDelta;
  82463. }
  82464. return result;
  82465. };
  82466. /**
  82467. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82468. *
  82469. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82470. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82471. * @param current current value
  82472. * @param target target value
  82473. * @param maxDelta max distance to move
  82474. * @returns resulting angle
  82475. */
  82476. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  82477. var num = Scalar.DeltaAngle(current, target);
  82478. var result = 0;
  82479. if (-maxDelta < num && num < maxDelta) {
  82480. result = target;
  82481. }
  82482. else {
  82483. target = current + num;
  82484. result = Scalar.MoveTowards(current, target, maxDelta);
  82485. }
  82486. return result;
  82487. };
  82488. /**
  82489. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82490. * @param start start value
  82491. * @param end target value
  82492. * @param amount amount to lerp between
  82493. * @returns the lerped value
  82494. */
  82495. Scalar.Lerp = function (start, end, amount) {
  82496. return start + ((end - start) * amount);
  82497. };
  82498. /**
  82499. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82500. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82501. * @param start start value
  82502. * @param end target value
  82503. * @param amount amount to lerp between
  82504. * @returns the lerped value
  82505. */
  82506. Scalar.LerpAngle = function (start, end, amount) {
  82507. var num = Scalar.Repeat(end - start, 360.0);
  82508. if (num > 180.0) {
  82509. num -= 360.0;
  82510. }
  82511. return start + num * Scalar.Clamp(amount);
  82512. };
  82513. /**
  82514. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82515. * @param a start value
  82516. * @param b target value
  82517. * @param value value between a and b
  82518. * @returns the inverseLerp value
  82519. */
  82520. Scalar.InverseLerp = function (a, b, value) {
  82521. var result = 0;
  82522. if (a != b) {
  82523. result = Scalar.Clamp((value - a) / (b - a));
  82524. }
  82525. else {
  82526. result = 0.0;
  82527. }
  82528. return result;
  82529. };
  82530. /**
  82531. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82532. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82533. * @param value1 spline value
  82534. * @param tangent1 spline value
  82535. * @param value2 spline value
  82536. * @param tangent2 spline value
  82537. * @param amount input value
  82538. * @returns hermite result
  82539. */
  82540. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  82541. var squared = amount * amount;
  82542. var cubed = amount * squared;
  82543. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  82544. var part2 = (-2.0 * cubed) + (3.0 * squared);
  82545. var part3 = (cubed - (2.0 * squared)) + amount;
  82546. var part4 = cubed - squared;
  82547. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  82548. };
  82549. /**
  82550. * Returns a random float number between and min and max values
  82551. * @param min min value of random
  82552. * @param max max value of random
  82553. * @returns random value
  82554. */
  82555. Scalar.RandomRange = function (min, max) {
  82556. if (min === max) {
  82557. return min;
  82558. }
  82559. return ((Math.random() * (max - min)) + min);
  82560. };
  82561. /**
  82562. * This function returns percentage of a number in a given range.
  82563. *
  82564. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82565. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82566. * @param number to convert to percentage
  82567. * @param min min range
  82568. * @param max max range
  82569. * @returns the percentage
  82570. */
  82571. Scalar.RangeToPercent = function (number, min, max) {
  82572. return ((number - min) / (max - min));
  82573. };
  82574. /**
  82575. * This function returns number that corresponds to the percentage in a given range.
  82576. *
  82577. * PercentToRange(0.34,0,100) will return 34.
  82578. * @param percent to convert to number
  82579. * @param min min range
  82580. * @param max max range
  82581. * @returns the number
  82582. */
  82583. Scalar.PercentToRange = function (percent, min, max) {
  82584. return ((max - min) * percent + min);
  82585. };
  82586. /**
  82587. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82588. * @param angle The angle to normalize in radian.
  82589. * @return The converted angle.
  82590. */
  82591. Scalar.NormalizeRadians = function (angle) {
  82592. // More precise but slower version kept for reference.
  82593. // angle = angle % Tools.TwoPi;
  82594. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  82595. //if (angle > Math.PI) {
  82596. // angle -= Tools.TwoPi;
  82597. //}
  82598. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  82599. return angle;
  82600. };
  82601. /**
  82602. * Two pi constants convenient for computation.
  82603. */
  82604. Scalar.TwoPi = Math.PI * 2;
  82605. return Scalar;
  82606. }());
  82607. /***/ }),
  82608. /***/ "./Maths/math.size.ts":
  82609. /*!****************************!*\
  82610. !*** ./Maths/math.size.ts ***!
  82611. \****************************/
  82612. /*! exports provided: Size */
  82613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82614. "use strict";
  82615. __webpack_require__.r(__webpack_exports__);
  82616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  82617. /**
  82618. * Size containing widht and height
  82619. */
  82620. var Size = /** @class */ (function () {
  82621. /**
  82622. * Creates a Size object from the given width and height (floats).
  82623. * @param width width of the new size
  82624. * @param height height of the new size
  82625. */
  82626. function Size(width, height) {
  82627. this.width = width;
  82628. this.height = height;
  82629. }
  82630. /**
  82631. * Returns a string with the Size width and height
  82632. * @returns a string with the Size width and height
  82633. */
  82634. Size.prototype.toString = function () {
  82635. return "{W: " + this.width + ", H: " + this.height + "}";
  82636. };
  82637. /**
  82638. * "Size"
  82639. * @returns the string "Size"
  82640. */
  82641. Size.prototype.getClassName = function () {
  82642. return "Size";
  82643. };
  82644. /**
  82645. * Returns the Size hash code.
  82646. * @returns a hash code for a unique width and height
  82647. */
  82648. Size.prototype.getHashCode = function () {
  82649. var hash = this.width | 0;
  82650. hash = (hash * 397) ^ (this.height | 0);
  82651. return hash;
  82652. };
  82653. /**
  82654. * Updates the current size from the given one.
  82655. * @param src the given size
  82656. */
  82657. Size.prototype.copyFrom = function (src) {
  82658. this.width = src.width;
  82659. this.height = src.height;
  82660. };
  82661. /**
  82662. * Updates in place the current Size from the given floats.
  82663. * @param width width of the new size
  82664. * @param height height of the new size
  82665. * @returns the updated Size.
  82666. */
  82667. Size.prototype.copyFromFloats = function (width, height) {
  82668. this.width = width;
  82669. this.height = height;
  82670. return this;
  82671. };
  82672. /**
  82673. * Updates in place the current Size from the given floats.
  82674. * @param width width to set
  82675. * @param height height to set
  82676. * @returns the updated Size.
  82677. */
  82678. Size.prototype.set = function (width, height) {
  82679. return this.copyFromFloats(width, height);
  82680. };
  82681. /**
  82682. * Multiplies the width and height by numbers
  82683. * @param w factor to multiple the width by
  82684. * @param h factor to multiple the height by
  82685. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  82686. */
  82687. Size.prototype.multiplyByFloats = function (w, h) {
  82688. return new Size(this.width * w, this.height * h);
  82689. };
  82690. /**
  82691. * Clones the size
  82692. * @returns a new Size copied from the given one.
  82693. */
  82694. Size.prototype.clone = function () {
  82695. return new Size(this.width, this.height);
  82696. };
  82697. /**
  82698. * True if the current Size and the given one width and height are strictly equal.
  82699. * @param other the other size to compare against
  82700. * @returns True if the current Size and the given one width and height are strictly equal.
  82701. */
  82702. Size.prototype.equals = function (other) {
  82703. if (!other) {
  82704. return false;
  82705. }
  82706. return (this.width === other.width) && (this.height === other.height);
  82707. };
  82708. Object.defineProperty(Size.prototype, "surface", {
  82709. /**
  82710. * The surface of the Size : width * height (float).
  82711. */
  82712. get: function () {
  82713. return this.width * this.height;
  82714. },
  82715. enumerable: true,
  82716. configurable: true
  82717. });
  82718. /**
  82719. * Create a new size of zero
  82720. * @returns a new Size set to (0.0, 0.0)
  82721. */
  82722. Size.Zero = function () {
  82723. return new Size(0.0, 0.0);
  82724. };
  82725. /**
  82726. * Sums the width and height of two sizes
  82727. * @param otherSize size to add to this size
  82728. * @returns a new Size set as the addition result of the current Size and the given one.
  82729. */
  82730. Size.prototype.add = function (otherSize) {
  82731. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  82732. return r;
  82733. };
  82734. /**
  82735. * Subtracts the width and height of two
  82736. * @param otherSize size to subtract to this size
  82737. * @returns a new Size set as the subtraction result of the given one from the current Size.
  82738. */
  82739. Size.prototype.subtract = function (otherSize) {
  82740. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  82741. return r;
  82742. };
  82743. /**
  82744. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  82745. * @param start starting size to lerp between
  82746. * @param end end size to lerp between
  82747. * @param amount amount to lerp between the start and end values
  82748. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  82749. */
  82750. Size.Lerp = function (start, end, amount) {
  82751. var w = start.width + ((end.width - start.width) * amount);
  82752. var h = start.height + ((end.height - start.height) * amount);
  82753. return new Size(w, h);
  82754. };
  82755. return Size;
  82756. }());
  82757. /***/ }),
  82758. /***/ "./Maths/math.ts":
  82759. /*!***********************!*\
  82760. !*** ./Maths/math.ts ***!
  82761. \***********************/
  82762. /*! exports provided: Space, Axis, Color3, Color4, TmpColors, ToGammaSpace, ToLinearSpace, Epsilon, Frustum, Plane, Size, Vector2, Vector3, Vector4, Quaternion, Matrix, TmpVectors, Viewport, Orientation, BezierCurve, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex */
  82763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82764. "use strict";
  82765. __webpack_require__.r(__webpack_exports__);
  82766. /* harmony import */ var _math_axis__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.axis */ "./Maths/math.axis.ts");
  82767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math_axis__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  82768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math_axis__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  82769. /* harmony import */ var _math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.color */ "./Maths/math.color.ts");
  82770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  82771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  82772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpColors", function() { return _math_color__WEBPACK_IMPORTED_MODULE_1__["TmpColors"]; });
  82773. /* harmony import */ var _math_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./math.constants */ "./Maths/math.constants.ts");
  82774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math_constants__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]; });
  82775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math_constants__WEBPACK_IMPORTED_MODULE_2__["ToLinearSpace"]; });
  82776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math_constants__WEBPACK_IMPORTED_MODULE_2__["Epsilon"]; });
  82777. /* harmony import */ var _math_frustum__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math.frustum */ "./Maths/math.frustum.ts");
  82778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math_frustum__WEBPACK_IMPORTED_MODULE_3__["Frustum"]; });
  82779. /* harmony import */ var _math_path__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./math.path */ "./Maths/math.path.ts");
  82780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["Orientation"]; });
  82781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["BezierCurve"]; });
  82782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["Angle"]; });
  82783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["Arc2"]; });
  82784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["Path2"]; });
  82785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["Path3D"]; });
  82786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math_path__WEBPACK_IMPORTED_MODULE_4__["Curve3"]; });
  82787. /* harmony import */ var _math_plane__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./math.plane */ "./Maths/math.plane.ts");
  82788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math_plane__WEBPACK_IMPORTED_MODULE_5__["Plane"]; });
  82789. /* harmony import */ var _math_size__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./math.size */ "./Maths/math.size.ts");
  82790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math_size__WEBPACK_IMPORTED_MODULE_6__["Size"]; });
  82791. /* harmony import */ var _math_vector__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./math.vector */ "./Maths/math.vector.ts");
  82792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector2"]; });
  82793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"]; });
  82794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector4"]; });
  82795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math_vector__WEBPACK_IMPORTED_MODULE_7__["Quaternion"]; });
  82796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math_vector__WEBPACK_IMPORTED_MODULE_7__["Matrix"]; });
  82797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpVectors", function() { return _math_vector__WEBPACK_IMPORTED_MODULE_7__["TmpVectors"]; });
  82798. /* harmony import */ var _math_vertexFormat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./math.vertexFormat */ "./Maths/math.vertexFormat.ts");
  82799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math_vertexFormat__WEBPACK_IMPORTED_MODULE_8__["PositionNormalVertex"]; });
  82800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math_vertexFormat__WEBPACK_IMPORTED_MODULE_8__["PositionNormalTextureVertex"]; });
  82801. /* harmony import */ var _math_viewport__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./math.viewport */ "./Maths/math.viewport.ts");
  82802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math_viewport__WEBPACK_IMPORTED_MODULE_9__["Viewport"]; });
  82803. /***/ }),
  82804. /***/ "./Maths/math.vector.ts":
  82805. /*!******************************!*\
  82806. !*** ./Maths/math.vector.ts ***!
  82807. \******************************/
  82808. /*! exports provided: Vector2, Vector3, Vector4, Quaternion, Matrix, TmpVectors */
  82809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82810. "use strict";
  82811. __webpack_require__.r(__webpack_exports__);
  82812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  82813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  82814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  82815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  82816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  82817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmpVectors", function() { return TmpVectors; });
  82818. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  82819. /* harmony import */ var _math_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.constants */ "./Maths/math.constants.ts");
  82820. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  82821. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  82822. /**
  82823. * Class representing a vector containing 2 coordinates
  82824. */
  82825. var Vector2 = /** @class */ (function () {
  82826. /**
  82827. * Creates a new Vector2 from the given x and y coordinates
  82828. * @param x defines the first coordinate
  82829. * @param y defines the second coordinate
  82830. */
  82831. function Vector2(
  82832. /** defines the first coordinate */
  82833. x,
  82834. /** defines the second coordinate */
  82835. y) {
  82836. if (x === void 0) { x = 0; }
  82837. if (y === void 0) { y = 0; }
  82838. this.x = x;
  82839. this.y = y;
  82840. }
  82841. /**
  82842. * Gets a string with the Vector2 coordinates
  82843. * @returns a string with the Vector2 coordinates
  82844. */
  82845. Vector2.prototype.toString = function () {
  82846. return "{X: " + this.x + " Y:" + this.y + "}";
  82847. };
  82848. /**
  82849. * Gets class name
  82850. * @returns the string "Vector2"
  82851. */
  82852. Vector2.prototype.getClassName = function () {
  82853. return "Vector2";
  82854. };
  82855. /**
  82856. * Gets current vector hash code
  82857. * @returns the Vector2 hash code as a number
  82858. */
  82859. Vector2.prototype.getHashCode = function () {
  82860. var hash = this.x | 0;
  82861. hash = (hash * 397) ^ (this.y | 0);
  82862. return hash;
  82863. };
  82864. // Operators
  82865. /**
  82866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82867. * @param array defines the source array
  82868. * @param index defines the offset in source array
  82869. * @returns the current Vector2
  82870. */
  82871. Vector2.prototype.toArray = function (array, index) {
  82872. if (index === void 0) { index = 0; }
  82873. array[index] = this.x;
  82874. array[index + 1] = this.y;
  82875. return this;
  82876. };
  82877. /**
  82878. * Copy the current vector to an array
  82879. * @returns a new array with 2 elements: the Vector2 coordinates.
  82880. */
  82881. Vector2.prototype.asArray = function () {
  82882. var result = new Array();
  82883. this.toArray(result, 0);
  82884. return result;
  82885. };
  82886. /**
  82887. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82888. * @param source defines the source Vector2
  82889. * @returns the current updated Vector2
  82890. */
  82891. Vector2.prototype.copyFrom = function (source) {
  82892. this.x = source.x;
  82893. this.y = source.y;
  82894. return this;
  82895. };
  82896. /**
  82897. * Sets the Vector2 coordinates with the given floats
  82898. * @param x defines the first coordinate
  82899. * @param y defines the second coordinate
  82900. * @returns the current updated Vector2
  82901. */
  82902. Vector2.prototype.copyFromFloats = function (x, y) {
  82903. this.x = x;
  82904. this.y = y;
  82905. return this;
  82906. };
  82907. /**
  82908. * Sets the Vector2 coordinates with the given floats
  82909. * @param x defines the first coordinate
  82910. * @param y defines the second coordinate
  82911. * @returns the current updated Vector2
  82912. */
  82913. Vector2.prototype.set = function (x, y) {
  82914. return this.copyFromFloats(x, y);
  82915. };
  82916. /**
  82917. * Add another vector with the current one
  82918. * @param otherVector defines the other vector
  82919. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82920. */
  82921. Vector2.prototype.add = function (otherVector) {
  82922. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  82923. };
  82924. /**
  82925. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82926. * @param otherVector defines the other vector
  82927. * @param result defines the target vector
  82928. * @returns the unmodified current Vector2
  82929. */
  82930. Vector2.prototype.addToRef = function (otherVector, result) {
  82931. result.x = this.x + otherVector.x;
  82932. result.y = this.y + otherVector.y;
  82933. return this;
  82934. };
  82935. /**
  82936. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82937. * @param otherVector defines the other vector
  82938. * @returns the current updated Vector2
  82939. */
  82940. Vector2.prototype.addInPlace = function (otherVector) {
  82941. this.x += otherVector.x;
  82942. this.y += otherVector.y;
  82943. return this;
  82944. };
  82945. /**
  82946. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82947. * @param otherVector defines the other vector
  82948. * @returns a new Vector2
  82949. */
  82950. Vector2.prototype.addVector3 = function (otherVector) {
  82951. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  82952. };
  82953. /**
  82954. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82955. * @param otherVector defines the other vector
  82956. * @returns a new Vector2
  82957. */
  82958. Vector2.prototype.subtract = function (otherVector) {
  82959. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  82960. };
  82961. /**
  82962. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82963. * @param otherVector defines the other vector
  82964. * @param result defines the target vector
  82965. * @returns the unmodified current Vector2
  82966. */
  82967. Vector2.prototype.subtractToRef = function (otherVector, result) {
  82968. result.x = this.x - otherVector.x;
  82969. result.y = this.y - otherVector.y;
  82970. return this;
  82971. };
  82972. /**
  82973. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82974. * @param otherVector defines the other vector
  82975. * @returns the current updated Vector2
  82976. */
  82977. Vector2.prototype.subtractInPlace = function (otherVector) {
  82978. this.x -= otherVector.x;
  82979. this.y -= otherVector.y;
  82980. return this;
  82981. };
  82982. /**
  82983. * Multiplies in place the current Vector2 coordinates by the given ones
  82984. * @param otherVector defines the other vector
  82985. * @returns the current updated Vector2
  82986. */
  82987. Vector2.prototype.multiplyInPlace = function (otherVector) {
  82988. this.x *= otherVector.x;
  82989. this.y *= otherVector.y;
  82990. return this;
  82991. };
  82992. /**
  82993. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82994. * @param otherVector defines the other vector
  82995. * @returns a new Vector2
  82996. */
  82997. Vector2.prototype.multiply = function (otherVector) {
  82998. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  82999. };
  83000. /**
  83001. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83002. * @param otherVector defines the other vector
  83003. * @param result defines the target vector
  83004. * @returns the unmodified current Vector2
  83005. */
  83006. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  83007. result.x = this.x * otherVector.x;
  83008. result.y = this.y * otherVector.y;
  83009. return this;
  83010. };
  83011. /**
  83012. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83013. * @param x defines the first coordinate
  83014. * @param y defines the second coordinate
  83015. * @returns a new Vector2
  83016. */
  83017. Vector2.prototype.multiplyByFloats = function (x, y) {
  83018. return new Vector2(this.x * x, this.y * y);
  83019. };
  83020. /**
  83021. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83022. * @param otherVector defines the other vector
  83023. * @returns a new Vector2
  83024. */
  83025. Vector2.prototype.divide = function (otherVector) {
  83026. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  83027. };
  83028. /**
  83029. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83030. * @param otherVector defines the other vector
  83031. * @param result defines the target vector
  83032. * @returns the unmodified current Vector2
  83033. */
  83034. Vector2.prototype.divideToRef = function (otherVector, result) {
  83035. result.x = this.x / otherVector.x;
  83036. result.y = this.y / otherVector.y;
  83037. return this;
  83038. };
  83039. /**
  83040. * Divides the current Vector2 coordinates by the given ones
  83041. * @param otherVector defines the other vector
  83042. * @returns the current updated Vector2
  83043. */
  83044. Vector2.prototype.divideInPlace = function (otherVector) {
  83045. return this.divideToRef(otherVector, this);
  83046. };
  83047. /**
  83048. * Gets a new Vector2 with current Vector2 negated coordinates
  83049. * @returns a new Vector2
  83050. */
  83051. Vector2.prototype.negate = function () {
  83052. return new Vector2(-this.x, -this.y);
  83053. };
  83054. /**
  83055. * Multiply the Vector2 coordinates by scale
  83056. * @param scale defines the scaling factor
  83057. * @returns the current updated Vector2
  83058. */
  83059. Vector2.prototype.scaleInPlace = function (scale) {
  83060. this.x *= scale;
  83061. this.y *= scale;
  83062. return this;
  83063. };
  83064. /**
  83065. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83066. * @param scale defines the scaling factor
  83067. * @returns a new Vector2
  83068. */
  83069. Vector2.prototype.scale = function (scale) {
  83070. var result = new Vector2(0, 0);
  83071. this.scaleToRef(scale, result);
  83072. return result;
  83073. };
  83074. /**
  83075. * Scale the current Vector2 values by a factor to a given Vector2
  83076. * @param scale defines the scale factor
  83077. * @param result defines the Vector2 object where to store the result
  83078. * @returns the unmodified current Vector2
  83079. */
  83080. Vector2.prototype.scaleToRef = function (scale, result) {
  83081. result.x = this.x * scale;
  83082. result.y = this.y * scale;
  83083. return this;
  83084. };
  83085. /**
  83086. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83087. * @param scale defines the scale factor
  83088. * @param result defines the Vector2 object where to store the result
  83089. * @returns the unmodified current Vector2
  83090. */
  83091. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  83092. result.x += this.x * scale;
  83093. result.y += this.y * scale;
  83094. return this;
  83095. };
  83096. /**
  83097. * Gets a boolean if two vectors are equals
  83098. * @param otherVector defines the other vector
  83099. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83100. */
  83101. Vector2.prototype.equals = function (otherVector) {
  83102. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  83103. };
  83104. /**
  83105. * Gets a boolean if two vectors are equals (using an epsilon value)
  83106. * @param otherVector defines the other vector
  83107. * @param epsilon defines the minimal distance to consider equality
  83108. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83109. */
  83110. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  83111. if (epsilon === void 0) { epsilon = _math_constants__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; }
  83112. return otherVector && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon);
  83113. };
  83114. /**
  83115. * Gets a new Vector2 from current Vector2 floored values
  83116. * @returns a new Vector2
  83117. */
  83118. Vector2.prototype.floor = function () {
  83119. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  83120. };
  83121. /**
  83122. * Gets a new Vector2 from current Vector2 floored values
  83123. * @returns a new Vector2
  83124. */
  83125. Vector2.prototype.fract = function () {
  83126. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  83127. };
  83128. // Properties
  83129. /**
  83130. * Gets the length of the vector
  83131. * @returns the vector length (float)
  83132. */
  83133. Vector2.prototype.length = function () {
  83134. return Math.sqrt(this.x * this.x + this.y * this.y);
  83135. };
  83136. /**
  83137. * Gets the vector squared length
  83138. * @returns the vector squared length (float)
  83139. */
  83140. Vector2.prototype.lengthSquared = function () {
  83141. return (this.x * this.x + this.y * this.y);
  83142. };
  83143. // Methods
  83144. /**
  83145. * Normalize the vector
  83146. * @returns the current updated Vector2
  83147. */
  83148. Vector2.prototype.normalize = function () {
  83149. var len = this.length();
  83150. if (len === 0) {
  83151. return this;
  83152. }
  83153. var num = 1.0 / len;
  83154. this.x *= num;
  83155. this.y *= num;
  83156. return this;
  83157. };
  83158. /**
  83159. * Gets a new Vector2 copied from the Vector2
  83160. * @returns a new Vector2
  83161. */
  83162. Vector2.prototype.clone = function () {
  83163. return new Vector2(this.x, this.y);
  83164. };
  83165. // Statics
  83166. /**
  83167. * Gets a new Vector2(0, 0)
  83168. * @returns a new Vector2
  83169. */
  83170. Vector2.Zero = function () {
  83171. return new Vector2(0, 0);
  83172. };
  83173. /**
  83174. * Gets a new Vector2(1, 1)
  83175. * @returns a new Vector2
  83176. */
  83177. Vector2.One = function () {
  83178. return new Vector2(1, 1);
  83179. };
  83180. /**
  83181. * Gets a new Vector2 set from the given index element of the given array
  83182. * @param array defines the data source
  83183. * @param offset defines the offset in the data source
  83184. * @returns a new Vector2
  83185. */
  83186. Vector2.FromArray = function (array, offset) {
  83187. if (offset === void 0) { offset = 0; }
  83188. return new Vector2(array[offset], array[offset + 1]);
  83189. };
  83190. /**
  83191. * Sets "result" from the given index element of the given array
  83192. * @param array defines the data source
  83193. * @param offset defines the offset in the data source
  83194. * @param result defines the target vector
  83195. */
  83196. Vector2.FromArrayToRef = function (array, offset, result) {
  83197. result.x = array[offset];
  83198. result.y = array[offset + 1];
  83199. };
  83200. /**
  83201. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83202. * @param value1 defines 1st point of control
  83203. * @param value2 defines 2nd point of control
  83204. * @param value3 defines 3rd point of control
  83205. * @param value4 defines 4th point of control
  83206. * @param amount defines the interpolation factor
  83207. * @returns a new Vector2
  83208. */
  83209. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  83210. var squared = amount * amount;
  83211. var cubed = amount * squared;
  83212. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  83213. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  83214. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  83215. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  83216. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  83217. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  83218. return new Vector2(x, y);
  83219. };
  83220. /**
  83221. * 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".
  83222. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83223. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83224. * @param value defines the value to clamp
  83225. * @param min defines the lower limit
  83226. * @param max defines the upper limit
  83227. * @returns a new Vector2
  83228. */
  83229. Vector2.Clamp = function (value, min, max) {
  83230. var x = value.x;
  83231. x = (x > max.x) ? max.x : x;
  83232. x = (x < min.x) ? min.x : x;
  83233. var y = value.y;
  83234. y = (y > max.y) ? max.y : y;
  83235. y = (y < min.y) ? min.y : y;
  83236. return new Vector2(x, y);
  83237. };
  83238. /**
  83239. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83240. * @param value1 defines the 1st control point
  83241. * @param tangent1 defines the outgoing tangent
  83242. * @param value2 defines the 2nd control point
  83243. * @param tangent2 defines the incoming tangent
  83244. * @param amount defines the interpolation factor
  83245. * @returns a new Vector2
  83246. */
  83247. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  83248. var squared = amount * amount;
  83249. var cubed = amount * squared;
  83250. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  83251. var part2 = (-2.0 * cubed) + (3.0 * squared);
  83252. var part3 = (cubed - (2.0 * squared)) + amount;
  83253. var part4 = cubed - squared;
  83254. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  83255. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  83256. return new Vector2(x, y);
  83257. };
  83258. /**
  83259. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83260. * @param start defines the start vector
  83261. * @param end defines the end vector
  83262. * @param amount defines the interpolation factor
  83263. * @returns a new Vector2
  83264. */
  83265. Vector2.Lerp = function (start, end, amount) {
  83266. var x = start.x + ((end.x - start.x) * amount);
  83267. var y = start.y + ((end.y - start.y) * amount);
  83268. return new Vector2(x, y);
  83269. };
  83270. /**
  83271. * Gets the dot product of the vector "left" and the vector "right"
  83272. * @param left defines first vector
  83273. * @param right defines second vector
  83274. * @returns the dot product (float)
  83275. */
  83276. Vector2.Dot = function (left, right) {
  83277. return left.x * right.x + left.y * right.y;
  83278. };
  83279. /**
  83280. * Returns a new Vector2 equal to the normalized given vector
  83281. * @param vector defines the vector to normalize
  83282. * @returns a new Vector2
  83283. */
  83284. Vector2.Normalize = function (vector) {
  83285. var newVector = vector.clone();
  83286. newVector.normalize();
  83287. return newVector;
  83288. };
  83289. /**
  83290. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83291. * @param left defines 1st vector
  83292. * @param right defines 2nd vector
  83293. * @returns a new Vector2
  83294. */
  83295. Vector2.Minimize = function (left, right) {
  83296. var x = (left.x < right.x) ? left.x : right.x;
  83297. var y = (left.y < right.y) ? left.y : right.y;
  83298. return new Vector2(x, y);
  83299. };
  83300. /**
  83301. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83302. * @param left defines 1st vector
  83303. * @param right defines 2nd vector
  83304. * @returns a new Vector2
  83305. */
  83306. Vector2.Maximize = function (left, right) {
  83307. var x = (left.x > right.x) ? left.x : right.x;
  83308. var y = (left.y > right.y) ? left.y : right.y;
  83309. return new Vector2(x, y);
  83310. };
  83311. /**
  83312. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83313. * @param vector defines the vector to transform
  83314. * @param transformation defines the matrix to apply
  83315. * @returns a new Vector2
  83316. */
  83317. Vector2.Transform = function (vector, transformation) {
  83318. var r = Vector2.Zero();
  83319. Vector2.TransformToRef(vector, transformation, r);
  83320. return r;
  83321. };
  83322. /**
  83323. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83324. * @param vector defines the vector to transform
  83325. * @param transformation defines the matrix to apply
  83326. * @param result defines the target vector
  83327. */
  83328. Vector2.TransformToRef = function (vector, transformation, result) {
  83329. var m = transformation.m;
  83330. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  83331. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  83332. result.x = x;
  83333. result.y = y;
  83334. };
  83335. /**
  83336. * Determines if a given vector is included in a triangle
  83337. * @param p defines the vector to test
  83338. * @param p0 defines 1st triangle point
  83339. * @param p1 defines 2nd triangle point
  83340. * @param p2 defines 3rd triangle point
  83341. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83342. */
  83343. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  83344. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  83345. var sign = a < 0 ? -1 : 1;
  83346. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  83347. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  83348. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  83349. };
  83350. /**
  83351. * Gets the distance between the vectors "value1" and "value2"
  83352. * @param value1 defines first vector
  83353. * @param value2 defines second vector
  83354. * @returns the distance between vectors
  83355. */
  83356. Vector2.Distance = function (value1, value2) {
  83357. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  83358. };
  83359. /**
  83360. * Returns the squared distance between the vectors "value1" and "value2"
  83361. * @param value1 defines first vector
  83362. * @param value2 defines second vector
  83363. * @returns the squared distance between vectors
  83364. */
  83365. Vector2.DistanceSquared = function (value1, value2) {
  83366. var x = value1.x - value2.x;
  83367. var y = value1.y - value2.y;
  83368. return (x * x) + (y * y);
  83369. };
  83370. /**
  83371. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83372. * @param value1 defines first vector
  83373. * @param value2 defines second vector
  83374. * @returns a new Vector2
  83375. */
  83376. Vector2.Center = function (value1, value2) {
  83377. var center = value1.add(value2);
  83378. center.scaleInPlace(0.5);
  83379. return center;
  83380. };
  83381. /**
  83382. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83383. * @param p defines the middle point
  83384. * @param segA defines one point of the segment
  83385. * @param segB defines the other point of the segment
  83386. * @returns the shortest distance
  83387. */
  83388. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  83389. var l2 = Vector2.DistanceSquared(segA, segB);
  83390. if (l2 === 0.0) {
  83391. return Vector2.Distance(p, segA);
  83392. }
  83393. var v = segB.subtract(segA);
  83394. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  83395. var proj = segA.add(v.multiplyByFloats(t, t));
  83396. return Vector2.Distance(p, proj);
  83397. };
  83398. return Vector2;
  83399. }());
  83400. /**
  83401. * Classed used to store (x,y,z) vector representation
  83402. * A Vector3 is the main object used in 3D geometry
  83403. * It can represent etiher the coordinates of a point the space, either a direction
  83404. * Reminder: js uses a left handed forward facing system
  83405. */
  83406. var Vector3 = /** @class */ (function () {
  83407. /**
  83408. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83409. * @param x defines the first coordinates (on X axis)
  83410. * @param y defines the second coordinates (on Y axis)
  83411. * @param z defines the third coordinates (on Z axis)
  83412. */
  83413. function Vector3(
  83414. /**
  83415. * Defines the first coordinates (on X axis)
  83416. */
  83417. x,
  83418. /**
  83419. * Defines the second coordinates (on Y axis)
  83420. */
  83421. y,
  83422. /**
  83423. * Defines the third coordinates (on Z axis)
  83424. */
  83425. z) {
  83426. if (x === void 0) { x = 0; }
  83427. if (y === void 0) { y = 0; }
  83428. if (z === void 0) { z = 0; }
  83429. this.x = x;
  83430. this.y = y;
  83431. this.z = z;
  83432. }
  83433. /**
  83434. * Creates a string representation of the Vector3
  83435. * @returns a string with the Vector3 coordinates.
  83436. */
  83437. Vector3.prototype.toString = function () {
  83438. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  83439. };
  83440. /**
  83441. * Gets the class name
  83442. * @returns the string "Vector3"
  83443. */
  83444. Vector3.prototype.getClassName = function () {
  83445. return "Vector3";
  83446. };
  83447. /**
  83448. * Creates the Vector3 hash code
  83449. * @returns a number which tends to be unique between Vector3 instances
  83450. */
  83451. Vector3.prototype.getHashCode = function () {
  83452. var hash = this.x | 0;
  83453. hash = (hash * 397) ^ (this.y | 0);
  83454. hash = (hash * 397) ^ (this.z | 0);
  83455. return hash;
  83456. };
  83457. // Operators
  83458. /**
  83459. * Creates an array containing three elements : the coordinates of the Vector3
  83460. * @returns a new array of numbers
  83461. */
  83462. Vector3.prototype.asArray = function () {
  83463. var result = [];
  83464. this.toArray(result, 0);
  83465. return result;
  83466. };
  83467. /**
  83468. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83469. * @param array defines the destination array
  83470. * @param index defines the offset in the destination array
  83471. * @returns the current Vector3
  83472. */
  83473. Vector3.prototype.toArray = function (array, index) {
  83474. if (index === void 0) { index = 0; }
  83475. array[index] = this.x;
  83476. array[index + 1] = this.y;
  83477. array[index + 2] = this.z;
  83478. return this;
  83479. };
  83480. /**
  83481. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83482. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83483. */
  83484. Vector3.prototype.toQuaternion = function () {
  83485. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  83486. };
  83487. /**
  83488. * Adds the given vector to the current Vector3
  83489. * @param otherVector defines the second operand
  83490. * @returns the current updated Vector3
  83491. */
  83492. Vector3.prototype.addInPlace = function (otherVector) {
  83493. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  83494. };
  83495. /**
  83496. * Adds the given coordinates to the current Vector3
  83497. * @param x defines the x coordinate of the operand
  83498. * @param y defines the y coordinate of the operand
  83499. * @param z defines the z coordinate of the operand
  83500. * @returns the current updated Vector3
  83501. */
  83502. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  83503. this.x += x;
  83504. this.y += y;
  83505. this.z += z;
  83506. return this;
  83507. };
  83508. /**
  83509. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83510. * @param otherVector defines the second operand
  83511. * @returns the resulting Vector3
  83512. */
  83513. Vector3.prototype.add = function (otherVector) {
  83514. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  83515. };
  83516. /**
  83517. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83518. * @param otherVector defines the second operand
  83519. * @param result defines the Vector3 object where to store the result
  83520. * @returns the current Vector3
  83521. */
  83522. Vector3.prototype.addToRef = function (otherVector, result) {
  83523. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  83524. };
  83525. /**
  83526. * Subtract the given vector from the current Vector3
  83527. * @param otherVector defines the second operand
  83528. * @returns the current updated Vector3
  83529. */
  83530. Vector3.prototype.subtractInPlace = function (otherVector) {
  83531. this.x -= otherVector.x;
  83532. this.y -= otherVector.y;
  83533. this.z -= otherVector.z;
  83534. return this;
  83535. };
  83536. /**
  83537. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83538. * @param otherVector defines the second operand
  83539. * @returns the resulting Vector3
  83540. */
  83541. Vector3.prototype.subtract = function (otherVector) {
  83542. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  83543. };
  83544. /**
  83545. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83546. * @param otherVector defines the second operand
  83547. * @param result defines the Vector3 object where to store the result
  83548. * @returns the current Vector3
  83549. */
  83550. Vector3.prototype.subtractToRef = function (otherVector, result) {
  83551. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  83552. };
  83553. /**
  83554. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83555. * @param x defines the x coordinate of the operand
  83556. * @param y defines the y coordinate of the operand
  83557. * @param z defines the z coordinate of the operand
  83558. * @returns the resulting Vector3
  83559. */
  83560. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  83561. return new Vector3(this.x - x, this.y - y, this.z - z);
  83562. };
  83563. /**
  83564. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83565. * @param x defines the x coordinate of the operand
  83566. * @param y defines the y coordinate of the operand
  83567. * @param z defines the z coordinate of the operand
  83568. * @param result defines the Vector3 object where to store the result
  83569. * @returns the current Vector3
  83570. */
  83571. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  83572. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  83573. };
  83574. /**
  83575. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83576. * @returns a new Vector3
  83577. */
  83578. Vector3.prototype.negate = function () {
  83579. return new Vector3(-this.x, -this.y, -this.z);
  83580. };
  83581. /**
  83582. * Multiplies the Vector3 coordinates by the float "scale"
  83583. * @param scale defines the multiplier factor
  83584. * @returns the current updated Vector3
  83585. */
  83586. Vector3.prototype.scaleInPlace = function (scale) {
  83587. this.x *= scale;
  83588. this.y *= scale;
  83589. this.z *= scale;
  83590. return this;
  83591. };
  83592. /**
  83593. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83594. * @param scale defines the multiplier factor
  83595. * @returns a new Vector3
  83596. */
  83597. Vector3.prototype.scale = function (scale) {
  83598. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  83599. };
  83600. /**
  83601. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83602. * @param scale defines the multiplier factor
  83603. * @param result defines the Vector3 object where to store the result
  83604. * @returns the current Vector3
  83605. */
  83606. Vector3.prototype.scaleToRef = function (scale, result) {
  83607. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  83608. };
  83609. /**
  83610. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83611. * @param scale defines the scale factor
  83612. * @param result defines the Vector3 object where to store the result
  83613. * @returns the unmodified current Vector3
  83614. */
  83615. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  83616. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  83617. };
  83618. /**
  83619. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83620. * @param otherVector defines the second operand
  83621. * @returns true if both vectors are equals
  83622. */
  83623. Vector3.prototype.equals = function (otherVector) {
  83624. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  83625. };
  83626. /**
  83627. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83628. * @param otherVector defines the second operand
  83629. * @param epsilon defines the minimal distance to define values as equals
  83630. * @returns true if both vectors are distant less than epsilon
  83631. */
  83632. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  83633. if (epsilon === void 0) { epsilon = _math_constants__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; }
  83634. return otherVector && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon);
  83635. };
  83636. /**
  83637. * Returns true if the current Vector3 coordinates equals the given floats
  83638. * @param x defines the x coordinate of the operand
  83639. * @param y defines the y coordinate of the operand
  83640. * @param z defines the z coordinate of the operand
  83641. * @returns true if both vectors are equals
  83642. */
  83643. Vector3.prototype.equalsToFloats = function (x, y, z) {
  83644. return this.x === x && this.y === y && this.z === z;
  83645. };
  83646. /**
  83647. * Multiplies the current Vector3 coordinates by the given ones
  83648. * @param otherVector defines the second operand
  83649. * @returns the current updated Vector3
  83650. */
  83651. Vector3.prototype.multiplyInPlace = function (otherVector) {
  83652. this.x *= otherVector.x;
  83653. this.y *= otherVector.y;
  83654. this.z *= otherVector.z;
  83655. return this;
  83656. };
  83657. /**
  83658. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83659. * @param otherVector defines the second operand
  83660. * @returns the new Vector3
  83661. */
  83662. Vector3.prototype.multiply = function (otherVector) {
  83663. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  83664. };
  83665. /**
  83666. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83667. * @param otherVector defines the second operand
  83668. * @param result defines the Vector3 object where to store the result
  83669. * @returns the current Vector3
  83670. */
  83671. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  83672. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  83673. };
  83674. /**
  83675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83676. * @param x defines the x coordinate of the operand
  83677. * @param y defines the y coordinate of the operand
  83678. * @param z defines the z coordinate of the operand
  83679. * @returns the new Vector3
  83680. */
  83681. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  83682. return new Vector3(this.x * x, this.y * y, this.z * z);
  83683. };
  83684. /**
  83685. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83686. * @param otherVector defines the second operand
  83687. * @returns the new Vector3
  83688. */
  83689. Vector3.prototype.divide = function (otherVector) {
  83690. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  83691. };
  83692. /**
  83693. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83694. * @param otherVector defines the second operand
  83695. * @param result defines the Vector3 object where to store the result
  83696. * @returns the current Vector3
  83697. */
  83698. Vector3.prototype.divideToRef = function (otherVector, result) {
  83699. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  83700. };
  83701. /**
  83702. * Divides the current Vector3 coordinates by the given ones.
  83703. * @param otherVector defines the second operand
  83704. * @returns the current updated Vector3
  83705. */
  83706. Vector3.prototype.divideInPlace = function (otherVector) {
  83707. return this.divideToRef(otherVector, this);
  83708. };
  83709. /**
  83710. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83711. * @param other defines the second operand
  83712. * @returns the current updated Vector3
  83713. */
  83714. Vector3.prototype.minimizeInPlace = function (other) {
  83715. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  83716. };
  83717. /**
  83718. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83719. * @param other defines the second operand
  83720. * @returns the current updated Vector3
  83721. */
  83722. Vector3.prototype.maximizeInPlace = function (other) {
  83723. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  83724. };
  83725. /**
  83726. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83727. * @param x defines the x coordinate of the operand
  83728. * @param y defines the y coordinate of the operand
  83729. * @param z defines the z coordinate of the operand
  83730. * @returns the current updated Vector3
  83731. */
  83732. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  83733. if (x < this.x) {
  83734. this.x = x;
  83735. }
  83736. if (y < this.y) {
  83737. this.y = y;
  83738. }
  83739. if (z < this.z) {
  83740. this.z = z;
  83741. }
  83742. return this;
  83743. };
  83744. /**
  83745. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83746. * @param x defines the x coordinate of the operand
  83747. * @param y defines the y coordinate of the operand
  83748. * @param z defines the z coordinate of the operand
  83749. * @returns the current updated Vector3
  83750. */
  83751. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  83752. if (x > this.x) {
  83753. this.x = x;
  83754. }
  83755. if (y > this.y) {
  83756. this.y = y;
  83757. }
  83758. if (z > this.z) {
  83759. this.z = z;
  83760. }
  83761. return this;
  83762. };
  83763. /**
  83764. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83765. * Check if is non uniform within a certain amount of decimal places to account for this
  83766. * @param epsilon the amount the values can differ
  83767. * @returns if the the vector is non uniform to a certain number of decimal places
  83768. */
  83769. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  83770. var absX = Math.abs(this.x);
  83771. var absY = Math.abs(this.y);
  83772. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  83773. return true;
  83774. }
  83775. var absZ = Math.abs(this.z);
  83776. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  83777. return true;
  83778. }
  83779. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  83780. return true;
  83781. }
  83782. return false;
  83783. };
  83784. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  83785. /**
  83786. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83787. */
  83788. get: function () {
  83789. var absX = Math.abs(this.x);
  83790. var absY = Math.abs(this.y);
  83791. if (absX !== absY) {
  83792. return true;
  83793. }
  83794. var absZ = Math.abs(this.z);
  83795. if (absX !== absZ) {
  83796. return true;
  83797. }
  83798. if (absY !== absZ) {
  83799. return true;
  83800. }
  83801. return false;
  83802. },
  83803. enumerable: true,
  83804. configurable: true
  83805. });
  83806. /**
  83807. * Gets a new Vector3 from current Vector3 floored values
  83808. * @returns a new Vector3
  83809. */
  83810. Vector3.prototype.floor = function () {
  83811. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  83812. };
  83813. /**
  83814. * Gets a new Vector3 from current Vector3 floored values
  83815. * @returns a new Vector3
  83816. */
  83817. Vector3.prototype.fract = function () {
  83818. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  83819. };
  83820. // Properties
  83821. /**
  83822. * Gets the length of the Vector3
  83823. * @returns the length of the Vector3
  83824. */
  83825. Vector3.prototype.length = function () {
  83826. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  83827. };
  83828. /**
  83829. * Gets the squared length of the Vector3
  83830. * @returns squared length of the Vector3
  83831. */
  83832. Vector3.prototype.lengthSquared = function () {
  83833. return (this.x * this.x + this.y * this.y + this.z * this.z);
  83834. };
  83835. /**
  83836. * Normalize the current Vector3.
  83837. * Please note that this is an in place operation.
  83838. * @returns the current updated Vector3
  83839. */
  83840. Vector3.prototype.normalize = function () {
  83841. return this.normalizeFromLength(this.length());
  83842. };
  83843. /**
  83844. * Reorders the x y z properties of the vector in place
  83845. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83846. * @returns the current updated vector
  83847. */
  83848. Vector3.prototype.reorderInPlace = function (order) {
  83849. var _this = this;
  83850. order = order.toLowerCase();
  83851. if (order === "xyz") {
  83852. return this;
  83853. }
  83854. MathTmp.Vector3[0].copyFrom(this);
  83855. ["x", "y", "z"].forEach(function (val, i) {
  83856. _this[val] = MathTmp.Vector3[0][order[i]];
  83857. });
  83858. return this;
  83859. };
  83860. /**
  83861. * Rotates the vector around 0,0,0 by a quaternion
  83862. * @param quaternion the rotation quaternion
  83863. * @param result vector to store the result
  83864. * @returns the resulting vector
  83865. */
  83866. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  83867. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  83868. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  83869. return result;
  83870. };
  83871. /**
  83872. * Rotates a vector around a given point
  83873. * @param quaternion the rotation quaternion
  83874. * @param point the point to rotate around
  83875. * @param result vector to store the result
  83876. * @returns the resulting vector
  83877. */
  83878. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  83879. this.subtractToRef(point, MathTmp.Vector3[0]);
  83880. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  83881. point.addToRef(MathTmp.Vector3[0], result);
  83882. return result;
  83883. };
  83884. /**
  83885. * Normalize the current Vector3 with the given input length.
  83886. * Please note that this is an in place operation.
  83887. * @param len the length of the vector
  83888. * @returns the current updated Vector3
  83889. */
  83890. Vector3.prototype.normalizeFromLength = function (len) {
  83891. if (len === 0 || len === 1.0) {
  83892. return this;
  83893. }
  83894. return this.scaleInPlace(1.0 / len);
  83895. };
  83896. /**
  83897. * Normalize the current Vector3 to a new vector
  83898. * @returns the new Vector3
  83899. */
  83900. Vector3.prototype.normalizeToNew = function () {
  83901. var normalized = new Vector3(0, 0, 0);
  83902. this.normalizeToRef(normalized);
  83903. return normalized;
  83904. };
  83905. /**
  83906. * Normalize the current Vector3 to the reference
  83907. * @param reference define the Vector3 to update
  83908. * @returns the updated Vector3
  83909. */
  83910. Vector3.prototype.normalizeToRef = function (reference) {
  83911. var len = this.length();
  83912. if (len === 0 || len === 1.0) {
  83913. return reference.copyFromFloats(this.x, this.y, this.z);
  83914. }
  83915. return this.scaleToRef(1.0 / len, reference);
  83916. };
  83917. /**
  83918. * Creates a new Vector3 copied from the current Vector3
  83919. * @returns the new Vector3
  83920. */
  83921. Vector3.prototype.clone = function () {
  83922. return new Vector3(this.x, this.y, this.z);
  83923. };
  83924. /**
  83925. * Copies the given vector coordinates to the current Vector3 ones
  83926. * @param source defines the source Vector3
  83927. * @returns the current updated Vector3
  83928. */
  83929. Vector3.prototype.copyFrom = function (source) {
  83930. return this.copyFromFloats(source.x, source.y, source.z);
  83931. };
  83932. /**
  83933. * Copies the given floats to the current Vector3 coordinates
  83934. * @param x defines the x coordinate of the operand
  83935. * @param y defines the y coordinate of the operand
  83936. * @param z defines the z coordinate of the operand
  83937. * @returns the current updated Vector3
  83938. */
  83939. Vector3.prototype.copyFromFloats = function (x, y, z) {
  83940. this.x = x;
  83941. this.y = y;
  83942. this.z = z;
  83943. return this;
  83944. };
  83945. /**
  83946. * Copies the given floats to the current Vector3 coordinates
  83947. * @param x defines the x coordinate of the operand
  83948. * @param y defines the y coordinate of the operand
  83949. * @param z defines the z coordinate of the operand
  83950. * @returns the current updated Vector3
  83951. */
  83952. Vector3.prototype.set = function (x, y, z) {
  83953. return this.copyFromFloats(x, y, z);
  83954. };
  83955. /**
  83956. * Copies the given float to the current Vector3 coordinates
  83957. * @param v defines the x, y and z coordinates of the operand
  83958. * @returns the current updated Vector3
  83959. */
  83960. Vector3.prototype.setAll = function (v) {
  83961. this.x = this.y = this.z = v;
  83962. return this;
  83963. };
  83964. // Statics
  83965. /**
  83966. * Get the clip factor between two vectors
  83967. * @param vector0 defines the first operand
  83968. * @param vector1 defines the second operand
  83969. * @param axis defines the axis to use
  83970. * @param size defines the size along the axis
  83971. * @returns the clip factor
  83972. */
  83973. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  83974. var d0 = Vector3.Dot(vector0, axis) - size;
  83975. var d1 = Vector3.Dot(vector1, axis) - size;
  83976. var s = d0 / (d0 - d1);
  83977. return s;
  83978. };
  83979. /**
  83980. * Get angle between two vectors
  83981. * @param vector0 angle between vector0 and vector1
  83982. * @param vector1 angle between vector0 and vector1
  83983. * @param normal direction of the normal
  83984. * @return the angle between vector0 and vector1
  83985. */
  83986. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  83987. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  83988. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  83989. var dot = Vector3.Dot(v0, v1);
  83990. var n = MathTmp.Vector3[3];
  83991. Vector3.CrossToRef(v0, v1, n);
  83992. if (Vector3.Dot(n, normal) > 0) {
  83993. return Math.acos(dot);
  83994. }
  83995. return -Math.acos(dot);
  83996. };
  83997. /**
  83998. * Returns a new Vector3 set from the index "offset" of the given array
  83999. * @param array defines the source array
  84000. * @param offset defines the offset in the source array
  84001. * @returns the new Vector3
  84002. */
  84003. Vector3.FromArray = function (array, offset) {
  84004. if (offset === void 0) { offset = 0; }
  84005. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  84006. };
  84007. /**
  84008. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84009. * This function is deprecated. Use FromArray instead
  84010. * @param array defines the source array
  84011. * @param offset defines the offset in the source array
  84012. * @returns the new Vector3
  84013. */
  84014. Vector3.FromFloatArray = function (array, offset) {
  84015. return Vector3.FromArray(array, offset);
  84016. };
  84017. /**
  84018. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84019. * @param array defines the source array
  84020. * @param offset defines the offset in the source array
  84021. * @param result defines the Vector3 where to store the result
  84022. */
  84023. Vector3.FromArrayToRef = function (array, offset, result) {
  84024. result.x = array[offset];
  84025. result.y = array[offset + 1];
  84026. result.z = array[offset + 2];
  84027. };
  84028. /**
  84029. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84030. * This function is deprecated. Use FromArrayToRef instead.
  84031. * @param array defines the source array
  84032. * @param offset defines the offset in the source array
  84033. * @param result defines the Vector3 where to store the result
  84034. */
  84035. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  84036. return Vector3.FromArrayToRef(array, offset, result);
  84037. };
  84038. /**
  84039. * Sets the given vector "result" with the given floats.
  84040. * @param x defines the x coordinate of the source
  84041. * @param y defines the y coordinate of the source
  84042. * @param z defines the z coordinate of the source
  84043. * @param result defines the Vector3 where to store the result
  84044. */
  84045. Vector3.FromFloatsToRef = function (x, y, z, result) {
  84046. result.copyFromFloats(x, y, z);
  84047. };
  84048. /**
  84049. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84050. * @returns a new empty Vector3
  84051. */
  84052. Vector3.Zero = function () {
  84053. return new Vector3(0.0, 0.0, 0.0);
  84054. };
  84055. /**
  84056. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84057. * @returns a new unit Vector3
  84058. */
  84059. Vector3.One = function () {
  84060. return new Vector3(1.0, 1.0, 1.0);
  84061. };
  84062. /**
  84063. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84064. * @returns a new up Vector3
  84065. */
  84066. Vector3.Up = function () {
  84067. return new Vector3(0.0, 1.0, 0.0);
  84068. };
  84069. Object.defineProperty(Vector3, "UpReadOnly", {
  84070. /**
  84071. * Gets a up Vector3 that must not be updated
  84072. */
  84073. get: function () {
  84074. return Vector3._UpReadOnly;
  84075. },
  84076. enumerable: true,
  84077. configurable: true
  84078. });
  84079. Object.defineProperty(Vector3, "ZeroReadOnly", {
  84080. /**
  84081. * Gets a zero Vector3 that must not be updated
  84082. */
  84083. get: function () {
  84084. return Vector3._ZeroReadOnly;
  84085. },
  84086. enumerable: true,
  84087. configurable: true
  84088. });
  84089. /**
  84090. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84091. * @returns a new down Vector3
  84092. */
  84093. Vector3.Down = function () {
  84094. return new Vector3(0.0, -1.0, 0.0);
  84095. };
  84096. /**
  84097. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84098. * @returns a new forward Vector3
  84099. */
  84100. Vector3.Forward = function () {
  84101. return new Vector3(0.0, 0.0, 1.0);
  84102. };
  84103. /**
  84104. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84105. * @returns a new forward Vector3
  84106. */
  84107. Vector3.Backward = function () {
  84108. return new Vector3(0.0, 0.0, -1.0);
  84109. };
  84110. /**
  84111. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84112. * @returns a new right Vector3
  84113. */
  84114. Vector3.Right = function () {
  84115. return new Vector3(1.0, 0.0, 0.0);
  84116. };
  84117. /**
  84118. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84119. * @returns a new left Vector3
  84120. */
  84121. Vector3.Left = function () {
  84122. return new Vector3(-1.0, 0.0, 0.0);
  84123. };
  84124. /**
  84125. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84126. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84127. * @param vector defines the Vector3 to transform
  84128. * @param transformation defines the transformation matrix
  84129. * @returns the transformed Vector3
  84130. */
  84131. Vector3.TransformCoordinates = function (vector, transformation) {
  84132. var result = Vector3.Zero();
  84133. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  84134. return result;
  84135. };
  84136. /**
  84137. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84138. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84139. * @param vector defines the Vector3 to transform
  84140. * @param transformation defines the transformation matrix
  84141. * @param result defines the Vector3 where to store the result
  84142. */
  84143. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  84144. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  84145. };
  84146. /**
  84147. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84148. * This method computes tranformed coordinates only, not transformed direction vectors
  84149. * @param x define the x coordinate of the source vector
  84150. * @param y define the y coordinate of the source vector
  84151. * @param z define the z coordinate of the source vector
  84152. * @param transformation defines the transformation matrix
  84153. * @param result defines the Vector3 where to store the result
  84154. */
  84155. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  84156. var m = transformation.m;
  84157. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  84158. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  84159. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  84160. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  84161. result.x = rx * rw;
  84162. result.y = ry * rw;
  84163. result.z = rz * rw;
  84164. };
  84165. /**
  84166. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84167. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84168. * @param vector defines the Vector3 to transform
  84169. * @param transformation defines the transformation matrix
  84170. * @returns the new Vector3
  84171. */
  84172. Vector3.TransformNormal = function (vector, transformation) {
  84173. var result = Vector3.Zero();
  84174. Vector3.TransformNormalToRef(vector, transformation, result);
  84175. return result;
  84176. };
  84177. /**
  84178. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84179. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84180. * @param vector defines the Vector3 to transform
  84181. * @param transformation defines the transformation matrix
  84182. * @param result defines the Vector3 where to store the result
  84183. */
  84184. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  84185. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  84186. };
  84187. /**
  84188. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84189. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84190. * @param x define the x coordinate of the source vector
  84191. * @param y define the y coordinate of the source vector
  84192. * @param z define the z coordinate of the source vector
  84193. * @param transformation defines the transformation matrix
  84194. * @param result defines the Vector3 where to store the result
  84195. */
  84196. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  84197. var m = transformation.m;
  84198. result.x = x * m[0] + y * m[4] + z * m[8];
  84199. result.y = x * m[1] + y * m[5] + z * m[9];
  84200. result.z = x * m[2] + y * m[6] + z * m[10];
  84201. };
  84202. /**
  84203. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84204. * @param value1 defines the first control point
  84205. * @param value2 defines the second control point
  84206. * @param value3 defines the third control point
  84207. * @param value4 defines the fourth control point
  84208. * @param amount defines the amount on the spline to use
  84209. * @returns the new Vector3
  84210. */
  84211. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  84212. var squared = amount * amount;
  84213. var cubed = amount * squared;
  84214. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  84215. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  84216. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  84217. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  84218. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  84219. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  84220. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  84221. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  84222. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  84223. return new Vector3(x, y, z);
  84224. };
  84225. /**
  84226. * 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"
  84227. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84228. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84229. * @param value defines the current value
  84230. * @param min defines the lower range value
  84231. * @param max defines the upper range value
  84232. * @returns the new Vector3
  84233. */
  84234. Vector3.Clamp = function (value, min, max) {
  84235. var v = new Vector3();
  84236. Vector3.ClampToRef(value, min, max, v);
  84237. return v;
  84238. };
  84239. /**
  84240. * 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"
  84241. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84242. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84243. * @param value defines the current value
  84244. * @param min defines the lower range value
  84245. * @param max defines the upper range value
  84246. * @param result defines the Vector3 where to store the result
  84247. */
  84248. Vector3.ClampToRef = function (value, min, max, result) {
  84249. var x = value.x;
  84250. x = (x > max.x) ? max.x : x;
  84251. x = (x < min.x) ? min.x : x;
  84252. var y = value.y;
  84253. y = (y > max.y) ? max.y : y;
  84254. y = (y < min.y) ? min.y : y;
  84255. var z = value.z;
  84256. z = (z > max.z) ? max.z : z;
  84257. z = (z < min.z) ? min.z : z;
  84258. result.copyFromFloats(x, y, z);
  84259. };
  84260. /**
  84261. * Checks if a given vector is inside a specific range
  84262. * @param v defines the vector to test
  84263. * @param min defines the minimum range
  84264. * @param max defines the maximum range
  84265. */
  84266. Vector3.CheckExtends = function (v, min, max) {
  84267. min.minimizeInPlace(v);
  84268. max.maximizeInPlace(v);
  84269. };
  84270. /**
  84271. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84272. * @param value1 defines the first control point
  84273. * @param tangent1 defines the first tangent vector
  84274. * @param value2 defines the second control point
  84275. * @param tangent2 defines the second tangent vector
  84276. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84277. * @returns the new Vector3
  84278. */
  84279. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  84280. var squared = amount * amount;
  84281. var cubed = amount * squared;
  84282. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  84283. var part2 = (-2.0 * cubed) + (3.0 * squared);
  84284. var part3 = (cubed - (2.0 * squared)) + amount;
  84285. var part4 = cubed - squared;
  84286. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  84287. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  84288. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  84289. return new Vector3(x, y, z);
  84290. };
  84291. /**
  84292. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84293. * @param start defines the start value
  84294. * @param end defines the end value
  84295. * @param amount max defines amount between both (between 0 and 1)
  84296. * @returns the new Vector3
  84297. */
  84298. Vector3.Lerp = function (start, end, amount) {
  84299. var result = new Vector3(0, 0, 0);
  84300. Vector3.LerpToRef(start, end, amount, result);
  84301. return result;
  84302. };
  84303. /**
  84304. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84305. * @param start defines the start value
  84306. * @param end defines the end value
  84307. * @param amount max defines amount between both (between 0 and 1)
  84308. * @param result defines the Vector3 where to store the result
  84309. */
  84310. Vector3.LerpToRef = function (start, end, amount, result) {
  84311. result.x = start.x + ((end.x - start.x) * amount);
  84312. result.y = start.y + ((end.y - start.y) * amount);
  84313. result.z = start.z + ((end.z - start.z) * amount);
  84314. };
  84315. /**
  84316. * Returns the dot product (float) between the vectors "left" and "right"
  84317. * @param left defines the left operand
  84318. * @param right defines the right operand
  84319. * @returns the dot product
  84320. */
  84321. Vector3.Dot = function (left, right) {
  84322. return (left.x * right.x + left.y * right.y + left.z * right.z);
  84323. };
  84324. /**
  84325. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84326. * The cross product is then orthogonal to both "left" and "right"
  84327. * @param left defines the left operand
  84328. * @param right defines the right operand
  84329. * @returns the cross product
  84330. */
  84331. Vector3.Cross = function (left, right) {
  84332. var result = Vector3.Zero();
  84333. Vector3.CrossToRef(left, right, result);
  84334. return result;
  84335. };
  84336. /**
  84337. * Sets the given vector "result" with the cross product of "left" and "right"
  84338. * The cross product is then orthogonal to both "left" and "right"
  84339. * @param left defines the left operand
  84340. * @param right defines the right operand
  84341. * @param result defines the Vector3 where to store the result
  84342. */
  84343. Vector3.CrossToRef = function (left, right, result) {
  84344. var x = left.y * right.z - left.z * right.y;
  84345. var y = left.z * right.x - left.x * right.z;
  84346. var z = left.x * right.y - left.y * right.x;
  84347. result.copyFromFloats(x, y, z);
  84348. };
  84349. /**
  84350. * Returns a new Vector3 as the normalization of the given vector
  84351. * @param vector defines the Vector3 to normalize
  84352. * @returns the new Vector3
  84353. */
  84354. Vector3.Normalize = function (vector) {
  84355. var result = Vector3.Zero();
  84356. Vector3.NormalizeToRef(vector, result);
  84357. return result;
  84358. };
  84359. /**
  84360. * Sets the given vector "result" with the normalization of the given first vector
  84361. * @param vector defines the Vector3 to normalize
  84362. * @param result defines the Vector3 where to store the result
  84363. */
  84364. Vector3.NormalizeToRef = function (vector, result) {
  84365. vector.normalizeToRef(result);
  84366. };
  84367. /**
  84368. * Project a Vector3 onto screen space
  84369. * @param vector defines the Vector3 to project
  84370. * @param world defines the world matrix to use
  84371. * @param transform defines the transform (view x projection) matrix to use
  84372. * @param viewport defines the screen viewport to use
  84373. * @returns the new Vector3
  84374. */
  84375. Vector3.Project = function (vector, world, transform, viewport) {
  84376. var cw = viewport.width;
  84377. var ch = viewport.height;
  84378. var cx = viewport.x;
  84379. var cy = viewport.y;
  84380. var viewportMatrix = MathTmp.Matrix[1];
  84381. 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);
  84382. var matrix = MathTmp.Matrix[0];
  84383. world.multiplyToRef(transform, matrix);
  84384. matrix.multiplyToRef(viewportMatrix, matrix);
  84385. return Vector3.TransformCoordinates(vector, matrix);
  84386. };
  84387. /** @hidden */
  84388. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  84389. Vector3.TransformCoordinatesToRef(source, matrix, result);
  84390. var m = matrix.m;
  84391. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  84392. if (_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(num, 1.0)) {
  84393. result.scaleInPlace(1.0 / num);
  84394. }
  84395. };
  84396. /**
  84397. * Unproject from screen space to object space
  84398. * @param source defines the screen space Vector3 to use
  84399. * @param viewportWidth defines the current width of the viewport
  84400. * @param viewportHeight defines the current height of the viewport
  84401. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84402. * @param transform defines the transform (view x projection) matrix to use
  84403. * @returns the new Vector3
  84404. */
  84405. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  84406. var matrix = MathTmp.Matrix[0];
  84407. world.multiplyToRef(transform, matrix);
  84408. matrix.invert();
  84409. source.x = source.x / viewportWidth * 2 - 1;
  84410. source.y = -(source.y / viewportHeight * 2 - 1);
  84411. var vector = new Vector3();
  84412. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  84413. return vector;
  84414. };
  84415. /**
  84416. * Unproject from screen space to object space
  84417. * @param source defines the screen space Vector3 to use
  84418. * @param viewportWidth defines the current width of the viewport
  84419. * @param viewportHeight defines the current height of the viewport
  84420. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84421. * @param view defines the view matrix to use
  84422. * @param projection defines the projection matrix to use
  84423. * @returns the new Vector3
  84424. */
  84425. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  84426. var result = Vector3.Zero();
  84427. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  84428. return result;
  84429. };
  84430. /**
  84431. * Unproject from screen space to object space
  84432. * @param source defines the screen space Vector3 to use
  84433. * @param viewportWidth defines the current width of the viewport
  84434. * @param viewportHeight defines the current height of the viewport
  84435. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84436. * @param view defines the view matrix to use
  84437. * @param projection defines the projection matrix to use
  84438. * @param result defines the Vector3 where to store the result
  84439. */
  84440. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  84441. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  84442. };
  84443. /**
  84444. * Unproject from screen space to object space
  84445. * @param sourceX defines the screen space x coordinate to use
  84446. * @param sourceY defines the screen space y coordinate to use
  84447. * @param sourceZ defines the screen space z coordinate to use
  84448. * @param viewportWidth defines the current width of the viewport
  84449. * @param viewportHeight defines the current height of the viewport
  84450. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84451. * @param view defines the view matrix to use
  84452. * @param projection defines the projection matrix to use
  84453. * @param result defines the Vector3 where to store the result
  84454. */
  84455. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  84456. var matrix = MathTmp.Matrix[0];
  84457. world.multiplyToRef(view, matrix);
  84458. matrix.multiplyToRef(projection, matrix);
  84459. matrix.invert();
  84460. var screenSource = MathTmp.Vector3[0];
  84461. screenSource.x = sourceX / viewportWidth * 2 - 1;
  84462. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  84463. screenSource.z = 2 * sourceZ - 1.0;
  84464. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  84465. };
  84466. /**
  84467. * Gets the minimal coordinate values between two Vector3
  84468. * @param left defines the first operand
  84469. * @param right defines the second operand
  84470. * @returns the new Vector3
  84471. */
  84472. Vector3.Minimize = function (left, right) {
  84473. var min = left.clone();
  84474. min.minimizeInPlace(right);
  84475. return min;
  84476. };
  84477. /**
  84478. * Gets the maximal coordinate values between two Vector3
  84479. * @param left defines the first operand
  84480. * @param right defines the second operand
  84481. * @returns the new Vector3
  84482. */
  84483. Vector3.Maximize = function (left, right) {
  84484. var max = left.clone();
  84485. max.maximizeInPlace(right);
  84486. return max;
  84487. };
  84488. /**
  84489. * Returns the distance between the vectors "value1" and "value2"
  84490. * @param value1 defines the first operand
  84491. * @param value2 defines the second operand
  84492. * @returns the distance
  84493. */
  84494. Vector3.Distance = function (value1, value2) {
  84495. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  84496. };
  84497. /**
  84498. * Returns the squared distance between the vectors "value1" and "value2"
  84499. * @param value1 defines the first operand
  84500. * @param value2 defines the second operand
  84501. * @returns the squared distance
  84502. */
  84503. Vector3.DistanceSquared = function (value1, value2) {
  84504. var x = value1.x - value2.x;
  84505. var y = value1.y - value2.y;
  84506. var z = value1.z - value2.z;
  84507. return (x * x) + (y * y) + (z * z);
  84508. };
  84509. /**
  84510. * Returns a new Vector3 located at the center between "value1" and "value2"
  84511. * @param value1 defines the first operand
  84512. * @param value2 defines the second operand
  84513. * @returns the new Vector3
  84514. */
  84515. Vector3.Center = function (value1, value2) {
  84516. var center = value1.add(value2);
  84517. center.scaleInPlace(0.5);
  84518. return center;
  84519. };
  84520. /**
  84521. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84522. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84523. * to something in order to rotate it from its local system to the given target system
  84524. * Note: axis1, axis2 and axis3 are normalized during this operation
  84525. * @param axis1 defines the first axis
  84526. * @param axis2 defines the second axis
  84527. * @param axis3 defines the third axis
  84528. * @returns a new Vector3
  84529. */
  84530. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  84531. var rotation = Vector3.Zero();
  84532. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  84533. return rotation;
  84534. };
  84535. /**
  84536. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84537. * @param axis1 defines the first axis
  84538. * @param axis2 defines the second axis
  84539. * @param axis3 defines the third axis
  84540. * @param ref defines the Vector3 where to store the result
  84541. */
  84542. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  84543. var quat = MathTmp.Quaternion[0];
  84544. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  84545. quat.toEulerAnglesToRef(ref);
  84546. };
  84547. Vector3._UpReadOnly = Vector3.Up();
  84548. Vector3._ZeroReadOnly = Vector3.Zero();
  84549. return Vector3;
  84550. }());
  84551. /**
  84552. * Vector4 class created for EulerAngle class conversion to Quaternion
  84553. */
  84554. var Vector4 = /** @class */ (function () {
  84555. /**
  84556. * Creates a Vector4 object from the given floats.
  84557. * @param x x value of the vector
  84558. * @param y y value of the vector
  84559. * @param z z value of the vector
  84560. * @param w w value of the vector
  84561. */
  84562. function Vector4(
  84563. /** x value of the vector */
  84564. x,
  84565. /** y value of the vector */
  84566. y,
  84567. /** z value of the vector */
  84568. z,
  84569. /** w value of the vector */
  84570. w) {
  84571. this.x = x;
  84572. this.y = y;
  84573. this.z = z;
  84574. this.w = w;
  84575. }
  84576. /**
  84577. * Returns the string with the Vector4 coordinates.
  84578. * @returns a string containing all the vector values
  84579. */
  84580. Vector4.prototype.toString = function () {
  84581. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  84582. };
  84583. /**
  84584. * Returns the string "Vector4".
  84585. * @returns "Vector4"
  84586. */
  84587. Vector4.prototype.getClassName = function () {
  84588. return "Vector4";
  84589. };
  84590. /**
  84591. * Returns the Vector4 hash code.
  84592. * @returns a unique hash code
  84593. */
  84594. Vector4.prototype.getHashCode = function () {
  84595. var hash = this.x | 0;
  84596. hash = (hash * 397) ^ (this.y | 0);
  84597. hash = (hash * 397) ^ (this.z | 0);
  84598. hash = (hash * 397) ^ (this.w | 0);
  84599. return hash;
  84600. };
  84601. // Operators
  84602. /**
  84603. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84604. * @returns the resulting array
  84605. */
  84606. Vector4.prototype.asArray = function () {
  84607. var result = new Array();
  84608. this.toArray(result, 0);
  84609. return result;
  84610. };
  84611. /**
  84612. * Populates the given array from the given index with the Vector4 coordinates.
  84613. * @param array array to populate
  84614. * @param index index of the array to start at (default: 0)
  84615. * @returns the Vector4.
  84616. */
  84617. Vector4.prototype.toArray = function (array, index) {
  84618. if (index === undefined) {
  84619. index = 0;
  84620. }
  84621. array[index] = this.x;
  84622. array[index + 1] = this.y;
  84623. array[index + 2] = this.z;
  84624. array[index + 3] = this.w;
  84625. return this;
  84626. };
  84627. /**
  84628. * Adds the given vector to the current Vector4.
  84629. * @param otherVector the vector to add
  84630. * @returns the updated Vector4.
  84631. */
  84632. Vector4.prototype.addInPlace = function (otherVector) {
  84633. this.x += otherVector.x;
  84634. this.y += otherVector.y;
  84635. this.z += otherVector.z;
  84636. this.w += otherVector.w;
  84637. return this;
  84638. };
  84639. /**
  84640. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84641. * @param otherVector the vector to add
  84642. * @returns the resulting vector
  84643. */
  84644. Vector4.prototype.add = function (otherVector) {
  84645. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  84646. };
  84647. /**
  84648. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84649. * @param otherVector the vector to add
  84650. * @param result the vector to store the result
  84651. * @returns the current Vector4.
  84652. */
  84653. Vector4.prototype.addToRef = function (otherVector, result) {
  84654. result.x = this.x + otherVector.x;
  84655. result.y = this.y + otherVector.y;
  84656. result.z = this.z + otherVector.z;
  84657. result.w = this.w + otherVector.w;
  84658. return this;
  84659. };
  84660. /**
  84661. * Subtract in place the given vector from the current Vector4.
  84662. * @param otherVector the vector to subtract
  84663. * @returns the updated Vector4.
  84664. */
  84665. Vector4.prototype.subtractInPlace = function (otherVector) {
  84666. this.x -= otherVector.x;
  84667. this.y -= otherVector.y;
  84668. this.z -= otherVector.z;
  84669. this.w -= otherVector.w;
  84670. return this;
  84671. };
  84672. /**
  84673. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84674. * @param otherVector the vector to add
  84675. * @returns the new vector with the result
  84676. */
  84677. Vector4.prototype.subtract = function (otherVector) {
  84678. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  84679. };
  84680. /**
  84681. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84682. * @param otherVector the vector to subtract
  84683. * @param result the vector to store the result
  84684. * @returns the current Vector4.
  84685. */
  84686. Vector4.prototype.subtractToRef = function (otherVector, result) {
  84687. result.x = this.x - otherVector.x;
  84688. result.y = this.y - otherVector.y;
  84689. result.z = this.z - otherVector.z;
  84690. result.w = this.w - otherVector.w;
  84691. return this;
  84692. };
  84693. /**
  84694. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84695. */
  84696. /**
  84697. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84698. * @param x value to subtract
  84699. * @param y value to subtract
  84700. * @param z value to subtract
  84701. * @param w value to subtract
  84702. * @returns new vector containing the result
  84703. */
  84704. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  84705. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  84706. };
  84707. /**
  84708. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84709. * @param x value to subtract
  84710. * @param y value to subtract
  84711. * @param z value to subtract
  84712. * @param w value to subtract
  84713. * @param result the vector to store the result in
  84714. * @returns the current Vector4.
  84715. */
  84716. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  84717. result.x = this.x - x;
  84718. result.y = this.y - y;
  84719. result.z = this.z - z;
  84720. result.w = this.w - w;
  84721. return this;
  84722. };
  84723. /**
  84724. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84725. * @returns a new vector with the negated values
  84726. */
  84727. Vector4.prototype.negate = function () {
  84728. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  84729. };
  84730. /**
  84731. * Multiplies the current Vector4 coordinates by scale (float).
  84732. * @param scale the number to scale with
  84733. * @returns the updated Vector4.
  84734. */
  84735. Vector4.prototype.scaleInPlace = function (scale) {
  84736. this.x *= scale;
  84737. this.y *= scale;
  84738. this.z *= scale;
  84739. this.w *= scale;
  84740. return this;
  84741. };
  84742. /**
  84743. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84744. * @param scale the number to scale with
  84745. * @returns a new vector with the result
  84746. */
  84747. Vector4.prototype.scale = function (scale) {
  84748. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  84749. };
  84750. /**
  84751. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84752. * @param scale the number to scale with
  84753. * @param result a vector to store the result in
  84754. * @returns the current Vector4.
  84755. */
  84756. Vector4.prototype.scaleToRef = function (scale, result) {
  84757. result.x = this.x * scale;
  84758. result.y = this.y * scale;
  84759. result.z = this.z * scale;
  84760. result.w = this.w * scale;
  84761. return this;
  84762. };
  84763. /**
  84764. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84765. * @param scale defines the scale factor
  84766. * @param result defines the Vector4 object where to store the result
  84767. * @returns the unmodified current Vector4
  84768. */
  84769. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  84770. result.x += this.x * scale;
  84771. result.y += this.y * scale;
  84772. result.z += this.z * scale;
  84773. result.w += this.w * scale;
  84774. return this;
  84775. };
  84776. /**
  84777. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84778. * @param otherVector the vector to compare against
  84779. * @returns true if they are equal
  84780. */
  84781. Vector4.prototype.equals = function (otherVector) {
  84782. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  84783. };
  84784. /**
  84785. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84786. * @param otherVector vector to compare against
  84787. * @param epsilon (Default: very small number)
  84788. * @returns true if they are equal
  84789. */
  84790. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  84791. if (epsilon === void 0) { epsilon = _math_constants__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; }
  84792. return otherVector
  84793. && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  84794. && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  84795. && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  84796. && _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  84797. };
  84798. /**
  84799. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84800. * @param x x value to compare against
  84801. * @param y y value to compare against
  84802. * @param z z value to compare against
  84803. * @param w w value to compare against
  84804. * @returns true if equal
  84805. */
  84806. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  84807. return this.x === x && this.y === y && this.z === z && this.w === w;
  84808. };
  84809. /**
  84810. * Multiplies in place the current Vector4 by the given one.
  84811. * @param otherVector vector to multiple with
  84812. * @returns the updated Vector4.
  84813. */
  84814. Vector4.prototype.multiplyInPlace = function (otherVector) {
  84815. this.x *= otherVector.x;
  84816. this.y *= otherVector.y;
  84817. this.z *= otherVector.z;
  84818. this.w *= otherVector.w;
  84819. return this;
  84820. };
  84821. /**
  84822. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84823. * @param otherVector vector to multiple with
  84824. * @returns resulting new vector
  84825. */
  84826. Vector4.prototype.multiply = function (otherVector) {
  84827. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  84828. };
  84829. /**
  84830. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84831. * @param otherVector vector to multiple with
  84832. * @param result vector to store the result
  84833. * @returns the current Vector4.
  84834. */
  84835. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  84836. result.x = this.x * otherVector.x;
  84837. result.y = this.y * otherVector.y;
  84838. result.z = this.z * otherVector.z;
  84839. result.w = this.w * otherVector.w;
  84840. return this;
  84841. };
  84842. /**
  84843. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84844. * @param x x value multiply with
  84845. * @param y y value multiply with
  84846. * @param z z value multiply with
  84847. * @param w w value multiply with
  84848. * @returns resulting new vector
  84849. */
  84850. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  84851. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  84852. };
  84853. /**
  84854. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84855. * @param otherVector vector to devide with
  84856. * @returns resulting new vector
  84857. */
  84858. Vector4.prototype.divide = function (otherVector) {
  84859. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  84860. };
  84861. /**
  84862. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84863. * @param otherVector vector to devide with
  84864. * @param result vector to store the result
  84865. * @returns the current Vector4.
  84866. */
  84867. Vector4.prototype.divideToRef = function (otherVector, result) {
  84868. result.x = this.x / otherVector.x;
  84869. result.y = this.y / otherVector.y;
  84870. result.z = this.z / otherVector.z;
  84871. result.w = this.w / otherVector.w;
  84872. return this;
  84873. };
  84874. /**
  84875. * Divides the current Vector3 coordinates by the given ones.
  84876. * @param otherVector vector to devide with
  84877. * @returns the updated Vector3.
  84878. */
  84879. Vector4.prototype.divideInPlace = function (otherVector) {
  84880. return this.divideToRef(otherVector, this);
  84881. };
  84882. /**
  84883. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84884. * @param other defines the second operand
  84885. * @returns the current updated Vector4
  84886. */
  84887. Vector4.prototype.minimizeInPlace = function (other) {
  84888. if (other.x < this.x) {
  84889. this.x = other.x;
  84890. }
  84891. if (other.y < this.y) {
  84892. this.y = other.y;
  84893. }
  84894. if (other.z < this.z) {
  84895. this.z = other.z;
  84896. }
  84897. if (other.w < this.w) {
  84898. this.w = other.w;
  84899. }
  84900. return this;
  84901. };
  84902. /**
  84903. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84904. * @param other defines the second operand
  84905. * @returns the current updated Vector4
  84906. */
  84907. Vector4.prototype.maximizeInPlace = function (other) {
  84908. if (other.x > this.x) {
  84909. this.x = other.x;
  84910. }
  84911. if (other.y > this.y) {
  84912. this.y = other.y;
  84913. }
  84914. if (other.z > this.z) {
  84915. this.z = other.z;
  84916. }
  84917. if (other.w > this.w) {
  84918. this.w = other.w;
  84919. }
  84920. return this;
  84921. };
  84922. /**
  84923. * Gets a new Vector4 from current Vector4 floored values
  84924. * @returns a new Vector4
  84925. */
  84926. Vector4.prototype.floor = function () {
  84927. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  84928. };
  84929. /**
  84930. * Gets a new Vector4 from current Vector3 floored values
  84931. * @returns a new Vector4
  84932. */
  84933. Vector4.prototype.fract = function () {
  84934. 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));
  84935. };
  84936. // Properties
  84937. /**
  84938. * Returns the Vector4 length (float).
  84939. * @returns the length
  84940. */
  84941. Vector4.prototype.length = function () {
  84942. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  84943. };
  84944. /**
  84945. * Returns the Vector4 squared length (float).
  84946. * @returns the length squared
  84947. */
  84948. Vector4.prototype.lengthSquared = function () {
  84949. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  84950. };
  84951. // Methods
  84952. /**
  84953. * Normalizes in place the Vector4.
  84954. * @returns the updated Vector4.
  84955. */
  84956. Vector4.prototype.normalize = function () {
  84957. var len = this.length();
  84958. if (len === 0) {
  84959. return this;
  84960. }
  84961. return this.scaleInPlace(1.0 / len);
  84962. };
  84963. /**
  84964. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84965. * @returns this converted to a new vector3
  84966. */
  84967. Vector4.prototype.toVector3 = function () {
  84968. return new Vector3(this.x, this.y, this.z);
  84969. };
  84970. /**
  84971. * Returns a new Vector4 copied from the current one.
  84972. * @returns the new cloned vector
  84973. */
  84974. Vector4.prototype.clone = function () {
  84975. return new Vector4(this.x, this.y, this.z, this.w);
  84976. };
  84977. /**
  84978. * Updates the current Vector4 with the given one coordinates.
  84979. * @param source the source vector to copy from
  84980. * @returns the updated Vector4.
  84981. */
  84982. Vector4.prototype.copyFrom = function (source) {
  84983. this.x = source.x;
  84984. this.y = source.y;
  84985. this.z = source.z;
  84986. this.w = source.w;
  84987. return this;
  84988. };
  84989. /**
  84990. * Updates the current Vector4 coordinates with the given floats.
  84991. * @param x float to copy from
  84992. * @param y float to copy from
  84993. * @param z float to copy from
  84994. * @param w float to copy from
  84995. * @returns the updated Vector4.
  84996. */
  84997. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  84998. this.x = x;
  84999. this.y = y;
  85000. this.z = z;
  85001. this.w = w;
  85002. return this;
  85003. };
  85004. /**
  85005. * Updates the current Vector4 coordinates with the given floats.
  85006. * @param x float to set from
  85007. * @param y float to set from
  85008. * @param z float to set from
  85009. * @param w float to set from
  85010. * @returns the updated Vector4.
  85011. */
  85012. Vector4.prototype.set = function (x, y, z, w) {
  85013. return this.copyFromFloats(x, y, z, w);
  85014. };
  85015. /**
  85016. * Copies the given float to the current Vector3 coordinates
  85017. * @param v defines the x, y, z and w coordinates of the operand
  85018. * @returns the current updated Vector3
  85019. */
  85020. Vector4.prototype.setAll = function (v) {
  85021. this.x = this.y = this.z = this.w = v;
  85022. return this;
  85023. };
  85024. // Statics
  85025. /**
  85026. * Returns a new Vector4 set from the starting index of the given array.
  85027. * @param array the array to pull values from
  85028. * @param offset the offset into the array to start at
  85029. * @returns the new vector
  85030. */
  85031. Vector4.FromArray = function (array, offset) {
  85032. if (!offset) {
  85033. offset = 0;
  85034. }
  85035. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  85036. };
  85037. /**
  85038. * Updates the given vector "result" from the starting index of the given array.
  85039. * @param array the array to pull values from
  85040. * @param offset the offset into the array to start at
  85041. * @param result the vector to store the result in
  85042. */
  85043. Vector4.FromArrayToRef = function (array, offset, result) {
  85044. result.x = array[offset];
  85045. result.y = array[offset + 1];
  85046. result.z = array[offset + 2];
  85047. result.w = array[offset + 3];
  85048. };
  85049. /**
  85050. * Updates the given vector "result" from the starting index of the given Float32Array.
  85051. * @param array the array to pull values from
  85052. * @param offset the offset into the array to start at
  85053. * @param result the vector to store the result in
  85054. */
  85055. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  85056. Vector4.FromArrayToRef(array, offset, result);
  85057. };
  85058. /**
  85059. * Updates the given vector "result" coordinates from the given floats.
  85060. * @param x float to set from
  85061. * @param y float to set from
  85062. * @param z float to set from
  85063. * @param w float to set from
  85064. * @param result the vector to the floats in
  85065. */
  85066. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  85067. result.x = x;
  85068. result.y = y;
  85069. result.z = z;
  85070. result.w = w;
  85071. };
  85072. /**
  85073. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85074. * @returns the new vector
  85075. */
  85076. Vector4.Zero = function () {
  85077. return new Vector4(0.0, 0.0, 0.0, 0.0);
  85078. };
  85079. /**
  85080. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85081. * @returns the new vector
  85082. */
  85083. Vector4.One = function () {
  85084. return new Vector4(1.0, 1.0, 1.0, 1.0);
  85085. };
  85086. /**
  85087. * Returns a new normalized Vector4 from the given one.
  85088. * @param vector the vector to normalize
  85089. * @returns the vector
  85090. */
  85091. Vector4.Normalize = function (vector) {
  85092. var result = Vector4.Zero();
  85093. Vector4.NormalizeToRef(vector, result);
  85094. return result;
  85095. };
  85096. /**
  85097. * Updates the given vector "result" from the normalization of the given one.
  85098. * @param vector the vector to normalize
  85099. * @param result the vector to store the result in
  85100. */
  85101. Vector4.NormalizeToRef = function (vector, result) {
  85102. result.copyFrom(vector);
  85103. result.normalize();
  85104. };
  85105. /**
  85106. * Returns a vector with the minimum values from the left and right vectors
  85107. * @param left left vector to minimize
  85108. * @param right right vector to minimize
  85109. * @returns a new vector with the minimum of the left and right vector values
  85110. */
  85111. Vector4.Minimize = function (left, right) {
  85112. var min = left.clone();
  85113. min.minimizeInPlace(right);
  85114. return min;
  85115. };
  85116. /**
  85117. * Returns a vector with the maximum values from the left and right vectors
  85118. * @param left left vector to maximize
  85119. * @param right right vector to maximize
  85120. * @returns a new vector with the maximum of the left and right vector values
  85121. */
  85122. Vector4.Maximize = function (left, right) {
  85123. var max = left.clone();
  85124. max.maximizeInPlace(right);
  85125. return max;
  85126. };
  85127. /**
  85128. * Returns the distance (float) between the vectors "value1" and "value2".
  85129. * @param value1 value to calulate the distance between
  85130. * @param value2 value to calulate the distance between
  85131. * @return the distance between the two vectors
  85132. */
  85133. Vector4.Distance = function (value1, value2) {
  85134. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  85135. };
  85136. /**
  85137. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85138. * @param value1 value to calulate the distance between
  85139. * @param value2 value to calulate the distance between
  85140. * @return the distance between the two vectors squared
  85141. */
  85142. Vector4.DistanceSquared = function (value1, value2) {
  85143. var x = value1.x - value2.x;
  85144. var y = value1.y - value2.y;
  85145. var z = value1.z - value2.z;
  85146. var w = value1.w - value2.w;
  85147. return (x * x) + (y * y) + (z * z) + (w * w);
  85148. };
  85149. /**
  85150. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85151. * @param value1 value to calulate the center between
  85152. * @param value2 value to calulate the center between
  85153. * @return the center between the two vectors
  85154. */
  85155. Vector4.Center = function (value1, value2) {
  85156. var center = value1.add(value2);
  85157. center.scaleInPlace(0.5);
  85158. return center;
  85159. };
  85160. /**
  85161. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85162. * This methods computes transformed normalized direction vectors only.
  85163. * @param vector the vector to transform
  85164. * @param transformation the transformation matrix to apply
  85165. * @returns the new vector
  85166. */
  85167. Vector4.TransformNormal = function (vector, transformation) {
  85168. var result = Vector4.Zero();
  85169. Vector4.TransformNormalToRef(vector, transformation, result);
  85170. return result;
  85171. };
  85172. /**
  85173. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85174. * This methods computes transformed normalized direction vectors only.
  85175. * @param vector the vector to transform
  85176. * @param transformation the transformation matrix to apply
  85177. * @param result the vector to store the result in
  85178. */
  85179. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  85180. var m = transformation.m;
  85181. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  85182. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  85183. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  85184. result.x = x;
  85185. result.y = y;
  85186. result.z = z;
  85187. result.w = vector.w;
  85188. };
  85189. /**
  85190. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85191. * This methods computes transformed normalized direction vectors only.
  85192. * @param x value to transform
  85193. * @param y value to transform
  85194. * @param z value to transform
  85195. * @param w value to transform
  85196. * @param transformation the transformation matrix to apply
  85197. * @param result the vector to store the results in
  85198. */
  85199. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  85200. var m = transformation.m;
  85201. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  85202. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  85203. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  85204. result.w = w;
  85205. };
  85206. /**
  85207. * Creates a new Vector4 from a Vector3
  85208. * @param source defines the source data
  85209. * @param w defines the 4th component (default is 0)
  85210. * @returns a new Vector4
  85211. */
  85212. Vector4.FromVector3 = function (source, w) {
  85213. if (w === void 0) { w = 0; }
  85214. return new Vector4(source.x, source.y, source.z, w);
  85215. };
  85216. return Vector4;
  85217. }());
  85218. /**
  85219. * Class used to store quaternion data
  85220. * @see https://en.wikipedia.org/wiki/Quaternion
  85221. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  85222. */
  85223. var Quaternion = /** @class */ (function () {
  85224. /**
  85225. * Creates a new Quaternion from the given floats
  85226. * @param x defines the first component (0 by default)
  85227. * @param y defines the second component (0 by default)
  85228. * @param z defines the third component (0 by default)
  85229. * @param w defines the fourth component (1.0 by default)
  85230. */
  85231. function Quaternion(
  85232. /** defines the first component (0 by default) */
  85233. x,
  85234. /** defines the second component (0 by default) */
  85235. y,
  85236. /** defines the third component (0 by default) */
  85237. z,
  85238. /** defines the fourth component (1.0 by default) */
  85239. w) {
  85240. if (x === void 0) { x = 0.0; }
  85241. if (y === void 0) { y = 0.0; }
  85242. if (z === void 0) { z = 0.0; }
  85243. if (w === void 0) { w = 1.0; }
  85244. this.x = x;
  85245. this.y = y;
  85246. this.z = z;
  85247. this.w = w;
  85248. }
  85249. /**
  85250. * Gets a string representation for the current quaternion
  85251. * @returns a string with the Quaternion coordinates
  85252. */
  85253. Quaternion.prototype.toString = function () {
  85254. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  85255. };
  85256. /**
  85257. * Gets the class name of the quaternion
  85258. * @returns the string "Quaternion"
  85259. */
  85260. Quaternion.prototype.getClassName = function () {
  85261. return "Quaternion";
  85262. };
  85263. /**
  85264. * Gets a hash code for this quaternion
  85265. * @returns the quaternion hash code
  85266. */
  85267. Quaternion.prototype.getHashCode = function () {
  85268. var hash = this.x | 0;
  85269. hash = (hash * 397) ^ (this.y | 0);
  85270. hash = (hash * 397) ^ (this.z | 0);
  85271. hash = (hash * 397) ^ (this.w | 0);
  85272. return hash;
  85273. };
  85274. /**
  85275. * Copy the quaternion to an array
  85276. * @returns a new array populated with 4 elements from the quaternion coordinates
  85277. */
  85278. Quaternion.prototype.asArray = function () {
  85279. return [this.x, this.y, this.z, this.w];
  85280. };
  85281. /**
  85282. * Check if two quaternions are equals
  85283. * @param otherQuaternion defines the second operand
  85284. * @return true if the current quaternion and the given one coordinates are strictly equals
  85285. */
  85286. Quaternion.prototype.equals = function (otherQuaternion) {
  85287. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  85288. };
  85289. /**
  85290. * Clone the current quaternion
  85291. * @returns a new quaternion copied from the current one
  85292. */
  85293. Quaternion.prototype.clone = function () {
  85294. return new Quaternion(this.x, this.y, this.z, this.w);
  85295. };
  85296. /**
  85297. * Copy a quaternion to the current one
  85298. * @param other defines the other quaternion
  85299. * @returns the updated current quaternion
  85300. */
  85301. Quaternion.prototype.copyFrom = function (other) {
  85302. this.x = other.x;
  85303. this.y = other.y;
  85304. this.z = other.z;
  85305. this.w = other.w;
  85306. return this;
  85307. };
  85308. /**
  85309. * Updates the current quaternion with the given float coordinates
  85310. * @param x defines the x coordinate
  85311. * @param y defines the y coordinate
  85312. * @param z defines the z coordinate
  85313. * @param w defines the w coordinate
  85314. * @returns the updated current quaternion
  85315. */
  85316. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  85317. this.x = x;
  85318. this.y = y;
  85319. this.z = z;
  85320. this.w = w;
  85321. return this;
  85322. };
  85323. /**
  85324. * Updates the current quaternion from the given float coordinates
  85325. * @param x defines the x coordinate
  85326. * @param y defines the y coordinate
  85327. * @param z defines the z coordinate
  85328. * @param w defines the w coordinate
  85329. * @returns the updated current quaternion
  85330. */
  85331. Quaternion.prototype.set = function (x, y, z, w) {
  85332. return this.copyFromFloats(x, y, z, w);
  85333. };
  85334. /**
  85335. * Adds two quaternions
  85336. * @param other defines the second operand
  85337. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85338. */
  85339. Quaternion.prototype.add = function (other) {
  85340. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  85341. };
  85342. /**
  85343. * Add a quaternion to the current one
  85344. * @param other defines the quaternion to add
  85345. * @returns the current quaternion
  85346. */
  85347. Quaternion.prototype.addInPlace = function (other) {
  85348. this.x += other.x;
  85349. this.y += other.y;
  85350. this.z += other.z;
  85351. this.w += other.w;
  85352. return this;
  85353. };
  85354. /**
  85355. * Subtract two quaternions
  85356. * @param other defines the second operand
  85357. * @returns a new quaternion as the subtraction result of the given one from the current one
  85358. */
  85359. Quaternion.prototype.subtract = function (other) {
  85360. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  85361. };
  85362. /**
  85363. * Multiplies the current quaternion by a scale factor
  85364. * @param value defines the scale factor
  85365. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85366. */
  85367. Quaternion.prototype.scale = function (value) {
  85368. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  85369. };
  85370. /**
  85371. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85372. * @param scale defines the scale factor
  85373. * @param result defines the Quaternion object where to store the result
  85374. * @returns the unmodified current quaternion
  85375. */
  85376. Quaternion.prototype.scaleToRef = function (scale, result) {
  85377. result.x = this.x * scale;
  85378. result.y = this.y * scale;
  85379. result.z = this.z * scale;
  85380. result.w = this.w * scale;
  85381. return this;
  85382. };
  85383. /**
  85384. * Multiplies in place the current quaternion by a scale factor
  85385. * @param value defines the scale factor
  85386. * @returns the current modified quaternion
  85387. */
  85388. Quaternion.prototype.scaleInPlace = function (value) {
  85389. this.x *= value;
  85390. this.y *= value;
  85391. this.z *= value;
  85392. this.w *= value;
  85393. return this;
  85394. };
  85395. /**
  85396. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85397. * @param scale defines the scale factor
  85398. * @param result defines the Quaternion object where to store the result
  85399. * @returns the unmodified current quaternion
  85400. */
  85401. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  85402. result.x += this.x * scale;
  85403. result.y += this.y * scale;
  85404. result.z += this.z * scale;
  85405. result.w += this.w * scale;
  85406. return this;
  85407. };
  85408. /**
  85409. * Multiplies two quaternions
  85410. * @param q1 defines the second operand
  85411. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85412. */
  85413. Quaternion.prototype.multiply = function (q1) {
  85414. var result = new Quaternion(0, 0, 0, 1.0);
  85415. this.multiplyToRef(q1, result);
  85416. return result;
  85417. };
  85418. /**
  85419. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85420. * @param q1 defines the second operand
  85421. * @param result defines the target quaternion
  85422. * @returns the current quaternion
  85423. */
  85424. Quaternion.prototype.multiplyToRef = function (q1, result) {
  85425. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  85426. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  85427. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  85428. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  85429. result.copyFromFloats(x, y, z, w);
  85430. return this;
  85431. };
  85432. /**
  85433. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85434. * @param q1 defines the second operand
  85435. * @returns the currentupdated quaternion
  85436. */
  85437. Quaternion.prototype.multiplyInPlace = function (q1) {
  85438. this.multiplyToRef(q1, this);
  85439. return this;
  85440. };
  85441. /**
  85442. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85443. * @param ref defines the target quaternion
  85444. * @returns the current quaternion
  85445. */
  85446. Quaternion.prototype.conjugateToRef = function (ref) {
  85447. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  85448. return this;
  85449. };
  85450. /**
  85451. * Conjugates in place (1-q) the current quaternion
  85452. * @returns the current updated quaternion
  85453. */
  85454. Quaternion.prototype.conjugateInPlace = function () {
  85455. this.x *= -1;
  85456. this.y *= -1;
  85457. this.z *= -1;
  85458. return this;
  85459. };
  85460. /**
  85461. * Conjugates in place (1-q) the current quaternion
  85462. * @returns a new quaternion
  85463. */
  85464. Quaternion.prototype.conjugate = function () {
  85465. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  85466. return result;
  85467. };
  85468. /**
  85469. * Gets length of current quaternion
  85470. * @returns the quaternion length (float)
  85471. */
  85472. Quaternion.prototype.length = function () {
  85473. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  85474. };
  85475. /**
  85476. * Normalize in place the current quaternion
  85477. * @returns the current updated quaternion
  85478. */
  85479. Quaternion.prototype.normalize = function () {
  85480. var len = this.length();
  85481. if (len === 0) {
  85482. return this;
  85483. }
  85484. var inv = 1.0 / len;
  85485. this.x *= inv;
  85486. this.y *= inv;
  85487. this.z *= inv;
  85488. this.w *= inv;
  85489. return this;
  85490. };
  85491. /**
  85492. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85493. * @param order is a reserved parameter and is ignore for now
  85494. * @returns a new Vector3 containing the Euler angles
  85495. */
  85496. Quaternion.prototype.toEulerAngles = function (order) {
  85497. if (order === void 0) { order = "YZX"; }
  85498. var result = Vector3.Zero();
  85499. this.toEulerAnglesToRef(result);
  85500. return result;
  85501. };
  85502. /**
  85503. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85504. * @param result defines the vector which will be filled with the Euler angles
  85505. * @param order is a reserved parameter and is ignore for now
  85506. * @returns the current unchanged quaternion
  85507. */
  85508. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  85509. var qz = this.z;
  85510. var qx = this.x;
  85511. var qy = this.y;
  85512. var qw = this.w;
  85513. var sqw = qw * qw;
  85514. var sqz = qz * qz;
  85515. var sqx = qx * qx;
  85516. var sqy = qy * qy;
  85517. var zAxisY = qy * qz - qx * qw;
  85518. var limit = .4999999;
  85519. if (zAxisY < -limit) {
  85520. result.y = 2 * Math.atan2(qy, qw);
  85521. result.x = Math.PI / 2;
  85522. result.z = 0;
  85523. }
  85524. else if (zAxisY > limit) {
  85525. result.y = 2 * Math.atan2(qy, qw);
  85526. result.x = -Math.PI / 2;
  85527. result.z = 0;
  85528. }
  85529. else {
  85530. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  85531. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  85532. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  85533. }
  85534. return this;
  85535. };
  85536. /**
  85537. * Updates the given rotation matrix with the current quaternion values
  85538. * @param result defines the target matrix
  85539. * @returns the current unchanged quaternion
  85540. */
  85541. Quaternion.prototype.toRotationMatrix = function (result) {
  85542. Matrix.FromQuaternionToRef(this, result);
  85543. return this;
  85544. };
  85545. /**
  85546. * Updates the current quaternion from the given rotation matrix values
  85547. * @param matrix defines the source matrix
  85548. * @returns the current updated quaternion
  85549. */
  85550. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  85551. Quaternion.FromRotationMatrixToRef(matrix, this);
  85552. return this;
  85553. };
  85554. // Statics
  85555. /**
  85556. * Creates a new quaternion from a rotation matrix
  85557. * @param matrix defines the source matrix
  85558. * @returns a new quaternion created from the given rotation matrix values
  85559. */
  85560. Quaternion.FromRotationMatrix = function (matrix) {
  85561. var result = new Quaternion();
  85562. Quaternion.FromRotationMatrixToRef(matrix, result);
  85563. return result;
  85564. };
  85565. /**
  85566. * Updates the given quaternion with the given rotation matrix values
  85567. * @param matrix defines the source matrix
  85568. * @param result defines the target quaternion
  85569. */
  85570. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  85571. var data = matrix.m;
  85572. var m11 = data[0], m12 = data[4], m13 = data[8];
  85573. var m21 = data[1], m22 = data[5], m23 = data[9];
  85574. var m31 = data[2], m32 = data[6], m33 = data[10];
  85575. var trace = m11 + m22 + m33;
  85576. var s;
  85577. if (trace > 0) {
  85578. s = 0.5 / Math.sqrt(trace + 1.0);
  85579. result.w = 0.25 / s;
  85580. result.x = (m32 - m23) * s;
  85581. result.y = (m13 - m31) * s;
  85582. result.z = (m21 - m12) * s;
  85583. }
  85584. else if (m11 > m22 && m11 > m33) {
  85585. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  85586. result.w = (m32 - m23) / s;
  85587. result.x = 0.25 * s;
  85588. result.y = (m12 + m21) / s;
  85589. result.z = (m13 + m31) / s;
  85590. }
  85591. else if (m22 > m33) {
  85592. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  85593. result.w = (m13 - m31) / s;
  85594. result.x = (m12 + m21) / s;
  85595. result.y = 0.25 * s;
  85596. result.z = (m23 + m32) / s;
  85597. }
  85598. else {
  85599. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  85600. result.w = (m21 - m12) / s;
  85601. result.x = (m13 + m31) / s;
  85602. result.y = (m23 + m32) / s;
  85603. result.z = 0.25 * s;
  85604. }
  85605. };
  85606. /**
  85607. * Returns the dot product (float) between the quaternions "left" and "right"
  85608. * @param left defines the left operand
  85609. * @param right defines the right operand
  85610. * @returns the dot product
  85611. */
  85612. Quaternion.Dot = function (left, right) {
  85613. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  85614. };
  85615. /**
  85616. * Checks if the two quaternions are close to each other
  85617. * @param quat0 defines the first quaternion to check
  85618. * @param quat1 defines the second quaternion to check
  85619. * @returns true if the two quaternions are close to each other
  85620. */
  85621. Quaternion.AreClose = function (quat0, quat1) {
  85622. var dot = Quaternion.Dot(quat0, quat1);
  85623. return dot >= 0;
  85624. };
  85625. /**
  85626. * Creates an empty quaternion
  85627. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85628. */
  85629. Quaternion.Zero = function () {
  85630. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  85631. };
  85632. /**
  85633. * Inverse a given quaternion
  85634. * @param q defines the source quaternion
  85635. * @returns a new quaternion as the inverted current quaternion
  85636. */
  85637. Quaternion.Inverse = function (q) {
  85638. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  85639. };
  85640. /**
  85641. * Inverse a given quaternion
  85642. * @param q defines the source quaternion
  85643. * @param result the quaternion the result will be stored in
  85644. * @returns the result quaternion
  85645. */
  85646. Quaternion.InverseToRef = function (q, result) {
  85647. result.set(-q.x, -q.y, -q.z, q.w);
  85648. return result;
  85649. };
  85650. /**
  85651. * Creates an identity quaternion
  85652. * @returns the identity quaternion
  85653. */
  85654. Quaternion.Identity = function () {
  85655. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  85656. };
  85657. /**
  85658. * Gets a boolean indicating if the given quaternion is identity
  85659. * @param quaternion defines the quaternion to check
  85660. * @returns true if the quaternion is identity
  85661. */
  85662. Quaternion.IsIdentity = function (quaternion) {
  85663. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  85664. };
  85665. /**
  85666. * Creates a quaternion from a rotation around an axis
  85667. * @param axis defines the axis to use
  85668. * @param angle defines the angle to use
  85669. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85670. */
  85671. Quaternion.RotationAxis = function (axis, angle) {
  85672. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  85673. };
  85674. /**
  85675. * Creates a rotation around an axis and stores it into the given quaternion
  85676. * @param axis defines the axis to use
  85677. * @param angle defines the angle to use
  85678. * @param result defines the target quaternion
  85679. * @returns the target quaternion
  85680. */
  85681. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  85682. var sin = Math.sin(angle / 2);
  85683. axis.normalize();
  85684. result.w = Math.cos(angle / 2);
  85685. result.x = axis.x * sin;
  85686. result.y = axis.y * sin;
  85687. result.z = axis.z * sin;
  85688. return result;
  85689. };
  85690. /**
  85691. * Creates a new quaternion from data stored into an array
  85692. * @param array defines the data source
  85693. * @param offset defines the offset in the source array where the data starts
  85694. * @returns a new quaternion
  85695. */
  85696. Quaternion.FromArray = function (array, offset) {
  85697. if (!offset) {
  85698. offset = 0;
  85699. }
  85700. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  85701. };
  85702. /**
  85703. * Create a quaternion from Euler rotation angles
  85704. * @param x Pitch
  85705. * @param y Yaw
  85706. * @param z Roll
  85707. * @returns the new Quaternion
  85708. */
  85709. Quaternion.FromEulerAngles = function (x, y, z) {
  85710. var q = new Quaternion();
  85711. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  85712. return q;
  85713. };
  85714. /**
  85715. * Updates a quaternion from Euler rotation angles
  85716. * @param x Pitch
  85717. * @param y Yaw
  85718. * @param z Roll
  85719. * @param result the quaternion to store the result
  85720. * @returns the updated quaternion
  85721. */
  85722. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  85723. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  85724. return result;
  85725. };
  85726. /**
  85727. * Create a quaternion from Euler rotation vector
  85728. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85729. * @returns the new Quaternion
  85730. */
  85731. Quaternion.FromEulerVector = function (vec) {
  85732. var q = new Quaternion();
  85733. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  85734. return q;
  85735. };
  85736. /**
  85737. * Updates a quaternion from Euler rotation vector
  85738. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85739. * @param result the quaternion to store the result
  85740. * @returns the updated quaternion
  85741. */
  85742. Quaternion.FromEulerVectorToRef = function (vec, result) {
  85743. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  85744. return result;
  85745. };
  85746. /**
  85747. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85748. * @param yaw defines the rotation around Y axis
  85749. * @param pitch defines the rotation around X axis
  85750. * @param roll defines the rotation around Z axis
  85751. * @returns the new quaternion
  85752. */
  85753. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  85754. var q = new Quaternion();
  85755. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  85756. return q;
  85757. };
  85758. /**
  85759. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85760. * @param yaw defines the rotation around Y axis
  85761. * @param pitch defines the rotation around X axis
  85762. * @param roll defines the rotation around Z axis
  85763. * @param result defines the target quaternion
  85764. */
  85765. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  85766. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  85767. var halfRoll = roll * 0.5;
  85768. var halfPitch = pitch * 0.5;
  85769. var halfYaw = yaw * 0.5;
  85770. var sinRoll = Math.sin(halfRoll);
  85771. var cosRoll = Math.cos(halfRoll);
  85772. var sinPitch = Math.sin(halfPitch);
  85773. var cosPitch = Math.cos(halfPitch);
  85774. var sinYaw = Math.sin(halfYaw);
  85775. var cosYaw = Math.cos(halfYaw);
  85776. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  85777. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  85778. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  85779. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  85780. };
  85781. /**
  85782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85783. * @param alpha defines the rotation around first axis
  85784. * @param beta defines the rotation around second axis
  85785. * @param gamma defines the rotation around third axis
  85786. * @returns the new quaternion
  85787. */
  85788. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  85789. var result = new Quaternion();
  85790. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  85791. return result;
  85792. };
  85793. /**
  85794. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85795. * @param alpha defines the rotation around first axis
  85796. * @param beta defines the rotation around second axis
  85797. * @param gamma defines the rotation around third axis
  85798. * @param result defines the target quaternion
  85799. */
  85800. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  85801. // Produces a quaternion from Euler angles in the z-x-z orientation
  85802. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  85803. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  85804. var halfBeta = beta * 0.5;
  85805. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  85806. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  85807. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  85808. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  85809. };
  85810. /**
  85811. * 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)
  85812. * @param axis1 defines the first axis
  85813. * @param axis2 defines the second axis
  85814. * @param axis3 defines the third axis
  85815. * @returns the new quaternion
  85816. */
  85817. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  85818. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  85819. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  85820. return quat;
  85821. };
  85822. /**
  85823. * 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
  85824. * @param axis1 defines the first axis
  85825. * @param axis2 defines the second axis
  85826. * @param axis3 defines the third axis
  85827. * @param ref defines the target quaternion
  85828. */
  85829. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  85830. var rotMat = MathTmp.Matrix[0];
  85831. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  85832. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  85833. };
  85834. /**
  85835. * Interpolates between two quaternions
  85836. * @param left defines first quaternion
  85837. * @param right defines second quaternion
  85838. * @param amount defines the gradient to use
  85839. * @returns the new interpolated quaternion
  85840. */
  85841. Quaternion.Slerp = function (left, right, amount) {
  85842. var result = Quaternion.Identity();
  85843. Quaternion.SlerpToRef(left, right, amount, result);
  85844. return result;
  85845. };
  85846. /**
  85847. * Interpolates between two quaternions and stores it into a target quaternion
  85848. * @param left defines first quaternion
  85849. * @param right defines second quaternion
  85850. * @param amount defines the gradient to use
  85851. * @param result defines the target quaternion
  85852. */
  85853. Quaternion.SlerpToRef = function (left, right, amount, result) {
  85854. var num2;
  85855. var num3;
  85856. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  85857. var flag = false;
  85858. if (num4 < 0) {
  85859. flag = true;
  85860. num4 = -num4;
  85861. }
  85862. if (num4 > 0.999999) {
  85863. num3 = 1 - amount;
  85864. num2 = flag ? -amount : amount;
  85865. }
  85866. else {
  85867. var num5 = Math.acos(num4);
  85868. var num6 = (1.0 / Math.sin(num5));
  85869. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  85870. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  85871. }
  85872. result.x = (num3 * left.x) + (num2 * right.x);
  85873. result.y = (num3 * left.y) + (num2 * right.y);
  85874. result.z = (num3 * left.z) + (num2 * right.z);
  85875. result.w = (num3 * left.w) + (num2 * right.w);
  85876. };
  85877. /**
  85878. * Interpolate between two quaternions using Hermite interpolation
  85879. * @param value1 defines first quaternion
  85880. * @param tangent1 defines the incoming tangent
  85881. * @param value2 defines second quaternion
  85882. * @param tangent2 defines the outgoing tangent
  85883. * @param amount defines the target quaternion
  85884. * @returns the new interpolated quaternion
  85885. */
  85886. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  85887. var squared = amount * amount;
  85888. var cubed = amount * squared;
  85889. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  85890. var part2 = (-2.0 * cubed) + (3.0 * squared);
  85891. var part3 = (cubed - (2.0 * squared)) + amount;
  85892. var part4 = cubed - squared;
  85893. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  85894. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  85895. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  85896. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  85897. return new Quaternion(x, y, z, w);
  85898. };
  85899. return Quaternion;
  85900. }());
  85901. /**
  85902. * Class used to store matrix data (4x4)
  85903. */
  85904. var Matrix = /** @class */ (function () {
  85905. /**
  85906. * Creates an empty matrix (filled with zeros)
  85907. */
  85908. function Matrix() {
  85909. this._isIdentity = false;
  85910. this._isIdentityDirty = true;
  85911. this._isIdentity3x2 = true;
  85912. this._isIdentity3x2Dirty = true;
  85913. /**
  85914. * Gets the update flag of the matrix which is an unique number for the matrix.
  85915. * It will be incremented every time the matrix data change.
  85916. * You can use it to speed the comparison between two versions of the same matrix.
  85917. */
  85918. this.updateFlag = -1;
  85919. this._m = new Float32Array(16);
  85920. this._updateIdentityStatus(false);
  85921. }
  85922. Object.defineProperty(Matrix.prototype, "m", {
  85923. /**
  85924. * Gets the internal data of the matrix
  85925. */
  85926. get: function () { return this._m; },
  85927. enumerable: true,
  85928. configurable: true
  85929. });
  85930. /** @hidden */
  85931. Matrix.prototype._markAsUpdated = function () {
  85932. this.updateFlag = Matrix._updateFlagSeed++;
  85933. this._isIdentity = false;
  85934. this._isIdentity3x2 = false;
  85935. this._isIdentityDirty = true;
  85936. this._isIdentity3x2Dirty = true;
  85937. };
  85938. /** @hidden */
  85939. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  85940. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  85941. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  85942. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  85943. this.updateFlag = Matrix._updateFlagSeed++;
  85944. this._isIdentity = isIdentity;
  85945. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  85946. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  85947. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  85948. };
  85949. // Properties
  85950. /**
  85951. * Check if the current matrix is identity
  85952. * @returns true is the matrix is the identity matrix
  85953. */
  85954. Matrix.prototype.isIdentity = function () {
  85955. if (this._isIdentityDirty) {
  85956. this._isIdentityDirty = false;
  85957. var m = this._m;
  85958. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  85959. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  85960. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  85961. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  85962. }
  85963. return this._isIdentity;
  85964. };
  85965. /**
  85966. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85967. * @returns true is the matrix is the identity matrix
  85968. */
  85969. Matrix.prototype.isIdentityAs3x2 = function () {
  85970. if (this._isIdentity3x2Dirty) {
  85971. this._isIdentity3x2Dirty = false;
  85972. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  85973. this._isIdentity3x2 = false;
  85974. }
  85975. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  85976. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  85977. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  85978. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  85979. this._isIdentity3x2 = false;
  85980. }
  85981. else {
  85982. this._isIdentity3x2 = true;
  85983. }
  85984. }
  85985. return this._isIdentity3x2;
  85986. };
  85987. /**
  85988. * Gets the determinant of the matrix
  85989. * @returns the matrix determinant
  85990. */
  85991. Matrix.prototype.determinant = function () {
  85992. if (this._isIdentity === true) {
  85993. return 1;
  85994. }
  85995. var m = this._m;
  85996. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  85997. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  85998. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  85999. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  86000. // https://en.wikipedia.org/wiki/Laplace_expansion
  86001. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  86002. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  86003. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  86004. // where
  86005. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  86006. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  86007. //
  86008. // Here we do that for the 1st row.
  86009. var det_22_33 = m22 * m33 - m32 * m23;
  86010. var det_21_33 = m21 * m33 - m31 * m23;
  86011. var det_21_32 = m21 * m32 - m31 * m22;
  86012. var det_20_33 = m20 * m33 - m30 * m23;
  86013. var det_20_32 = m20 * m32 - m22 * m30;
  86014. var det_20_31 = m20 * m31 - m30 * m21;
  86015. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  86016. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  86017. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  86018. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  86019. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  86020. };
  86021. // Methods
  86022. /**
  86023. * Returns the matrix as a Float32Array
  86024. * @returns the matrix underlying array
  86025. */
  86026. Matrix.prototype.toArray = function () {
  86027. return this._m;
  86028. };
  86029. /**
  86030. * Returns the matrix as a Float32Array
  86031. * @returns the matrix underlying array.
  86032. */
  86033. Matrix.prototype.asArray = function () {
  86034. return this._m;
  86035. };
  86036. /**
  86037. * Inverts the current matrix in place
  86038. * @returns the current inverted matrix
  86039. */
  86040. Matrix.prototype.invert = function () {
  86041. this.invertToRef(this);
  86042. return this;
  86043. };
  86044. /**
  86045. * Sets all the matrix elements to zero
  86046. * @returns the current matrix
  86047. */
  86048. Matrix.prototype.reset = function () {
  86049. 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);
  86050. this._updateIdentityStatus(false);
  86051. return this;
  86052. };
  86053. /**
  86054. * Adds the current matrix with a second one
  86055. * @param other defines the matrix to add
  86056. * @returns a new matrix as the addition of the current matrix and the given one
  86057. */
  86058. Matrix.prototype.add = function (other) {
  86059. var result = new Matrix();
  86060. this.addToRef(other, result);
  86061. return result;
  86062. };
  86063. /**
  86064. * Sets the given matrix "result" to the addition of the current matrix and the given one
  86065. * @param other defines the matrix to add
  86066. * @param result defines the target matrix
  86067. * @returns the current matrix
  86068. */
  86069. Matrix.prototype.addToRef = function (other, result) {
  86070. var m = this._m;
  86071. var resultM = result._m;
  86072. var otherM = other.m;
  86073. for (var index = 0; index < 16; index++) {
  86074. resultM[index] = m[index] + otherM[index];
  86075. }
  86076. result._markAsUpdated();
  86077. return this;
  86078. };
  86079. /**
  86080. * Adds in place the given matrix to the current matrix
  86081. * @param other defines the second operand
  86082. * @returns the current updated matrix
  86083. */
  86084. Matrix.prototype.addToSelf = function (other) {
  86085. var m = this._m;
  86086. var otherM = other.m;
  86087. for (var index = 0; index < 16; index++) {
  86088. m[index] += otherM[index];
  86089. }
  86090. this._markAsUpdated();
  86091. return this;
  86092. };
  86093. /**
  86094. * Sets the given matrix to the current inverted Matrix
  86095. * @param other defines the target matrix
  86096. * @returns the unmodified current matrix
  86097. */
  86098. Matrix.prototype.invertToRef = function (other) {
  86099. if (this._isIdentity === true) {
  86100. Matrix.IdentityToRef(other);
  86101. return this;
  86102. }
  86103. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  86104. var m = this._m;
  86105. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  86106. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  86107. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  86108. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  86109. var det_22_33 = m22 * m33 - m32 * m23;
  86110. var det_21_33 = m21 * m33 - m31 * m23;
  86111. var det_21_32 = m21 * m32 - m31 * m22;
  86112. var det_20_33 = m20 * m33 - m30 * m23;
  86113. var det_20_32 = m20 * m32 - m22 * m30;
  86114. var det_20_31 = m20 * m31 - m30 * m21;
  86115. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  86116. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  86117. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  86118. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  86119. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  86120. if (det === 0) {
  86121. // not invertible
  86122. other.copyFrom(this);
  86123. return this;
  86124. }
  86125. var detInv = 1 / det;
  86126. var det_12_33 = m12 * m33 - m32 * m13;
  86127. var det_11_33 = m11 * m33 - m31 * m13;
  86128. var det_11_32 = m11 * m32 - m31 * m12;
  86129. var det_10_33 = m10 * m33 - m30 * m13;
  86130. var det_10_32 = m10 * m32 - m30 * m12;
  86131. var det_10_31 = m10 * m31 - m30 * m11;
  86132. var det_12_23 = m12 * m23 - m22 * m13;
  86133. var det_11_23 = m11 * m23 - m21 * m13;
  86134. var det_11_22 = m11 * m22 - m21 * m12;
  86135. var det_10_23 = m10 * m23 - m20 * m13;
  86136. var det_10_22 = m10 * m22 - m20 * m12;
  86137. var det_10_21 = m10 * m21 - m20 * m11;
  86138. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  86139. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  86140. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  86141. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  86142. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  86143. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  86144. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  86145. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  86146. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  86147. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  86148. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  86149. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  86150. 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);
  86151. return this;
  86152. };
  86153. /**
  86154. * add a value at the specified position in the current Matrix
  86155. * @param index the index of the value within the matrix. between 0 and 15.
  86156. * @param value the value to be added
  86157. * @returns the current updated matrix
  86158. */
  86159. Matrix.prototype.addAtIndex = function (index, value) {
  86160. this._m[index] += value;
  86161. this._markAsUpdated();
  86162. return this;
  86163. };
  86164. /**
  86165. * mutiply the specified position in the current Matrix by a value
  86166. * @param index the index of the value within the matrix. between 0 and 15.
  86167. * @param value the value to be added
  86168. * @returns the current updated matrix
  86169. */
  86170. Matrix.prototype.multiplyAtIndex = function (index, value) {
  86171. this._m[index] *= value;
  86172. this._markAsUpdated();
  86173. return this;
  86174. };
  86175. /**
  86176. * Inserts the translation vector (using 3 floats) in the current matrix
  86177. * @param x defines the 1st component of the translation
  86178. * @param y defines the 2nd component of the translation
  86179. * @param z defines the 3rd component of the translation
  86180. * @returns the current updated matrix
  86181. */
  86182. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  86183. this._m[12] = x;
  86184. this._m[13] = y;
  86185. this._m[14] = z;
  86186. this._markAsUpdated();
  86187. return this;
  86188. };
  86189. /**
  86190. * Adds the translation vector (using 3 floats) in the current matrix
  86191. * @param x defines the 1st component of the translation
  86192. * @param y defines the 2nd component of the translation
  86193. * @param z defines the 3rd component of the translation
  86194. * @returns the current updated matrix
  86195. */
  86196. Matrix.prototype.addTranslationFromFloats = function (x, y, z) {
  86197. this._m[12] += x;
  86198. this._m[13] += y;
  86199. this._m[14] += z;
  86200. this._markAsUpdated();
  86201. return this;
  86202. };
  86203. /**
  86204. * Inserts the translation vector in the current matrix
  86205. * @param vector3 defines the translation to insert
  86206. * @returns the current updated matrix
  86207. */
  86208. Matrix.prototype.setTranslation = function (vector3) {
  86209. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  86210. };
  86211. /**
  86212. * Gets the translation value of the current matrix
  86213. * @returns a new Vector3 as the extracted translation from the matrix
  86214. */
  86215. Matrix.prototype.getTranslation = function () {
  86216. return new Vector3(this._m[12], this._m[13], this._m[14]);
  86217. };
  86218. /**
  86219. * Fill a Vector3 with the extracted translation from the matrix
  86220. * @param result defines the Vector3 where to store the translation
  86221. * @returns the current matrix
  86222. */
  86223. Matrix.prototype.getTranslationToRef = function (result) {
  86224. result.x = this._m[12];
  86225. result.y = this._m[13];
  86226. result.z = this._m[14];
  86227. return this;
  86228. };
  86229. /**
  86230. * Remove rotation and scaling part from the matrix
  86231. * @returns the updated matrix
  86232. */
  86233. Matrix.prototype.removeRotationAndScaling = function () {
  86234. var m = this.m;
  86235. 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);
  86236. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  86237. return this;
  86238. };
  86239. /**
  86240. * Multiply two matrices
  86241. * @param other defines the second operand
  86242. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86243. */
  86244. Matrix.prototype.multiply = function (other) {
  86245. var result = new Matrix();
  86246. this.multiplyToRef(other, result);
  86247. return result;
  86248. };
  86249. /**
  86250. * Copy the current matrix from the given one
  86251. * @param other defines the source matrix
  86252. * @returns the current updated matrix
  86253. */
  86254. Matrix.prototype.copyFrom = function (other) {
  86255. other.copyToArray(this._m);
  86256. var o = other;
  86257. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  86258. return this;
  86259. };
  86260. /**
  86261. * Populates the given array from the starting index with the current matrix values
  86262. * @param array defines the target array
  86263. * @param offset defines the offset in the target array where to start storing values
  86264. * @returns the current matrix
  86265. */
  86266. Matrix.prototype.copyToArray = function (array, offset) {
  86267. if (offset === void 0) { offset = 0; }
  86268. for (var index = 0; index < 16; index++) {
  86269. array[offset + index] = this._m[index];
  86270. }
  86271. return this;
  86272. };
  86273. /**
  86274. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86275. * @param other defines the second operand
  86276. * @param result defines the matrix where to store the multiplication
  86277. * @returns the current matrix
  86278. */
  86279. Matrix.prototype.multiplyToRef = function (other, result) {
  86280. if (this._isIdentity) {
  86281. result.copyFrom(other);
  86282. return this;
  86283. }
  86284. if (other._isIdentity) {
  86285. result.copyFrom(this);
  86286. return this;
  86287. }
  86288. this.multiplyToArray(other, result._m, 0);
  86289. result._markAsUpdated();
  86290. return this;
  86291. };
  86292. /**
  86293. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86294. * @param other defines the second operand
  86295. * @param result defines the array where to store the multiplication
  86296. * @param offset defines the offset in the target array where to start storing values
  86297. * @returns the current matrix
  86298. */
  86299. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  86300. var m = this._m;
  86301. var otherM = other.m;
  86302. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  86303. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  86304. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  86305. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  86306. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  86307. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  86308. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  86309. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  86310. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  86311. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  86312. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  86313. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  86314. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  86315. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  86316. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  86317. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  86318. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  86319. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  86320. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  86321. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  86322. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  86323. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  86324. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  86325. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  86326. return this;
  86327. };
  86328. /**
  86329. * Check equality between this matrix and a second one
  86330. * @param value defines the second matrix to compare
  86331. * @returns true is the current matrix and the given one values are strictly equal
  86332. */
  86333. Matrix.prototype.equals = function (value) {
  86334. var other = value;
  86335. if (!other) {
  86336. return false;
  86337. }
  86338. if (this._isIdentity || other._isIdentity) {
  86339. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  86340. return this._isIdentity && other._isIdentity;
  86341. }
  86342. }
  86343. var m = this.m;
  86344. var om = other.m;
  86345. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  86346. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  86347. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  86348. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  86349. };
  86350. /**
  86351. * Clone the current matrix
  86352. * @returns a new matrix from the current matrix
  86353. */
  86354. Matrix.prototype.clone = function () {
  86355. var matrix = new Matrix();
  86356. matrix.copyFrom(this);
  86357. return matrix;
  86358. };
  86359. /**
  86360. * Returns the name of the current matrix class
  86361. * @returns the string "Matrix"
  86362. */
  86363. Matrix.prototype.getClassName = function () {
  86364. return "Matrix";
  86365. };
  86366. /**
  86367. * Gets the hash code of the current matrix
  86368. * @returns the hash code
  86369. */
  86370. Matrix.prototype.getHashCode = function () {
  86371. var hash = this._m[0] | 0;
  86372. for (var i = 1; i < 16; i++) {
  86373. hash = (hash * 397) ^ (this._m[i] | 0);
  86374. }
  86375. return hash;
  86376. };
  86377. /**
  86378. * Decomposes the current Matrix into a translation, rotation and scaling components
  86379. * @param scale defines the scale vector3 given as a reference to update
  86380. * @param rotation defines the rotation quaternion given as a reference to update
  86381. * @param translation defines the translation vector3 given as a reference to update
  86382. * @returns true if operation was successful
  86383. */
  86384. Matrix.prototype.decompose = function (scale, rotation, translation) {
  86385. if (this._isIdentity) {
  86386. if (translation) {
  86387. translation.setAll(0);
  86388. }
  86389. if (scale) {
  86390. scale.setAll(1);
  86391. }
  86392. if (rotation) {
  86393. rotation.copyFromFloats(0, 0, 0, 1);
  86394. }
  86395. return true;
  86396. }
  86397. var m = this._m;
  86398. if (translation) {
  86399. translation.copyFromFloats(m[12], m[13], m[14]);
  86400. }
  86401. scale = scale || MathTmp.Vector3[0];
  86402. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  86403. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  86404. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  86405. if (this.determinant() <= 0) {
  86406. scale.y *= -1;
  86407. }
  86408. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  86409. if (rotation) {
  86410. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  86411. }
  86412. return false;
  86413. }
  86414. if (rotation) {
  86415. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  86416. 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]);
  86417. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  86418. }
  86419. return true;
  86420. };
  86421. /**
  86422. * Gets specific row of the matrix
  86423. * @param index defines the number of the row to get
  86424. * @returns the index-th row of the current matrix as a new Vector4
  86425. */
  86426. Matrix.prototype.getRow = function (index) {
  86427. if (index < 0 || index > 3) {
  86428. return null;
  86429. }
  86430. var i = index * 4;
  86431. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  86432. };
  86433. /**
  86434. * Sets the index-th row of the current matrix to the vector4 values
  86435. * @param index defines the number of the row to set
  86436. * @param row defines the target vector4
  86437. * @returns the updated current matrix
  86438. */
  86439. Matrix.prototype.setRow = function (index, row) {
  86440. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  86441. };
  86442. /**
  86443. * Compute the transpose of the matrix
  86444. * @returns the new transposed matrix
  86445. */
  86446. Matrix.prototype.transpose = function () {
  86447. return Matrix.Transpose(this);
  86448. };
  86449. /**
  86450. * Compute the transpose of the matrix and store it in a given matrix
  86451. * @param result defines the target matrix
  86452. * @returns the current matrix
  86453. */
  86454. Matrix.prototype.transposeToRef = function (result) {
  86455. Matrix.TransposeToRef(this, result);
  86456. return this;
  86457. };
  86458. /**
  86459. * Sets the index-th row of the current matrix with the given 4 x float values
  86460. * @param index defines the row index
  86461. * @param x defines the x component to set
  86462. * @param y defines the y component to set
  86463. * @param z defines the z component to set
  86464. * @param w defines the w component to set
  86465. * @returns the updated current matrix
  86466. */
  86467. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  86468. if (index < 0 || index > 3) {
  86469. return this;
  86470. }
  86471. var i = index * 4;
  86472. this._m[i + 0] = x;
  86473. this._m[i + 1] = y;
  86474. this._m[i + 2] = z;
  86475. this._m[i + 3] = w;
  86476. this._markAsUpdated();
  86477. return this;
  86478. };
  86479. /**
  86480. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86481. * @param scale defines the scale factor
  86482. * @returns a new matrix
  86483. */
  86484. Matrix.prototype.scale = function (scale) {
  86485. var result = new Matrix();
  86486. this.scaleToRef(scale, result);
  86487. return result;
  86488. };
  86489. /**
  86490. * Scale the current matrix values by a factor to a given result matrix
  86491. * @param scale defines the scale factor
  86492. * @param result defines the matrix to store the result
  86493. * @returns the current matrix
  86494. */
  86495. Matrix.prototype.scaleToRef = function (scale, result) {
  86496. for (var index = 0; index < 16; index++) {
  86497. result._m[index] = this._m[index] * scale;
  86498. }
  86499. result._markAsUpdated();
  86500. return this;
  86501. };
  86502. /**
  86503. * Scale the current matrix values by a factor and add the result to a given matrix
  86504. * @param scale defines the scale factor
  86505. * @param result defines the Matrix to store the result
  86506. * @returns the current matrix
  86507. */
  86508. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  86509. for (var index = 0; index < 16; index++) {
  86510. result._m[index] += this._m[index] * scale;
  86511. }
  86512. result._markAsUpdated();
  86513. return this;
  86514. };
  86515. /**
  86516. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86517. * @param ref matrix to store the result
  86518. */
  86519. Matrix.prototype.toNormalMatrix = function (ref) {
  86520. var tmp = MathTmp.Matrix[0];
  86521. this.invertToRef(tmp);
  86522. tmp.transposeToRef(ref);
  86523. var m = ref._m;
  86524. 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);
  86525. };
  86526. /**
  86527. * Gets only rotation part of the current matrix
  86528. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86529. */
  86530. Matrix.prototype.getRotationMatrix = function () {
  86531. var result = new Matrix();
  86532. this.getRotationMatrixToRef(result);
  86533. return result;
  86534. };
  86535. /**
  86536. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86537. * @param result defines the target matrix to store data to
  86538. * @returns the current matrix
  86539. */
  86540. Matrix.prototype.getRotationMatrixToRef = function (result) {
  86541. var scale = MathTmp.Vector3[0];
  86542. if (!this.decompose(scale)) {
  86543. Matrix.IdentityToRef(result);
  86544. return this;
  86545. }
  86546. var m = this._m;
  86547. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  86548. 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);
  86549. return this;
  86550. };
  86551. /**
  86552. * Toggles model matrix from being right handed to left handed in place and vice versa
  86553. */
  86554. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  86555. var m = this._m;
  86556. m[2] *= -1;
  86557. m[6] *= -1;
  86558. m[8] *= -1;
  86559. m[9] *= -1;
  86560. m[14] *= -1;
  86561. this._markAsUpdated();
  86562. };
  86563. /**
  86564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86565. */
  86566. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  86567. var m = this._m;
  86568. m[8] *= -1;
  86569. m[9] *= -1;
  86570. m[10] *= -1;
  86571. m[11] *= -1;
  86572. this._markAsUpdated();
  86573. };
  86574. // Statics
  86575. /**
  86576. * Creates a matrix from an array
  86577. * @param array defines the source array
  86578. * @param offset defines an offset in the source array
  86579. * @returns a new Matrix set from the starting index of the given array
  86580. */
  86581. Matrix.FromArray = function (array, offset) {
  86582. if (offset === void 0) { offset = 0; }
  86583. var result = new Matrix();
  86584. Matrix.FromArrayToRef(array, offset, result);
  86585. return result;
  86586. };
  86587. /**
  86588. * Copy the content of an array into a given matrix
  86589. * @param array defines the source array
  86590. * @param offset defines an offset in the source array
  86591. * @param result defines the target matrix
  86592. */
  86593. Matrix.FromArrayToRef = function (array, offset, result) {
  86594. for (var index = 0; index < 16; index++) {
  86595. result._m[index] = array[index + offset];
  86596. }
  86597. result._markAsUpdated();
  86598. };
  86599. /**
  86600. * Stores an array into a matrix after having multiplied each component by a given factor
  86601. * @param array defines the source array
  86602. * @param offset defines the offset in the source array
  86603. * @param scale defines the scaling factor
  86604. * @param result defines the target matrix
  86605. */
  86606. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  86607. for (var index = 0; index < 16; index++) {
  86608. result._m[index] = array[index + offset] * scale;
  86609. }
  86610. result._markAsUpdated();
  86611. };
  86612. Object.defineProperty(Matrix, "IdentityReadOnly", {
  86613. /**
  86614. * Gets an identity matrix that must not be updated
  86615. */
  86616. get: function () {
  86617. return Matrix._identityReadOnly;
  86618. },
  86619. enumerable: true,
  86620. configurable: true
  86621. });
  86622. /**
  86623. * Stores a list of values (16) inside a given matrix
  86624. * @param initialM11 defines 1st value of 1st row
  86625. * @param initialM12 defines 2nd value of 1st row
  86626. * @param initialM13 defines 3rd value of 1st row
  86627. * @param initialM14 defines 4th value of 1st row
  86628. * @param initialM21 defines 1st value of 2nd row
  86629. * @param initialM22 defines 2nd value of 2nd row
  86630. * @param initialM23 defines 3rd value of 2nd row
  86631. * @param initialM24 defines 4th value of 2nd row
  86632. * @param initialM31 defines 1st value of 3rd row
  86633. * @param initialM32 defines 2nd value of 3rd row
  86634. * @param initialM33 defines 3rd value of 3rd row
  86635. * @param initialM34 defines 4th value of 3rd row
  86636. * @param initialM41 defines 1st value of 4th row
  86637. * @param initialM42 defines 2nd value of 4th row
  86638. * @param initialM43 defines 3rd value of 4th row
  86639. * @param initialM44 defines 4th value of 4th row
  86640. * @param result defines the target matrix
  86641. */
  86642. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  86643. var m = result._m;
  86644. m[0] = initialM11;
  86645. m[1] = initialM12;
  86646. m[2] = initialM13;
  86647. m[3] = initialM14;
  86648. m[4] = initialM21;
  86649. m[5] = initialM22;
  86650. m[6] = initialM23;
  86651. m[7] = initialM24;
  86652. m[8] = initialM31;
  86653. m[9] = initialM32;
  86654. m[10] = initialM33;
  86655. m[11] = initialM34;
  86656. m[12] = initialM41;
  86657. m[13] = initialM42;
  86658. m[14] = initialM43;
  86659. m[15] = initialM44;
  86660. result._markAsUpdated();
  86661. };
  86662. /**
  86663. * Creates new matrix from a list of values (16)
  86664. * @param initialM11 defines 1st value of 1st row
  86665. * @param initialM12 defines 2nd value of 1st row
  86666. * @param initialM13 defines 3rd value of 1st row
  86667. * @param initialM14 defines 4th value of 1st row
  86668. * @param initialM21 defines 1st value of 2nd row
  86669. * @param initialM22 defines 2nd value of 2nd row
  86670. * @param initialM23 defines 3rd value of 2nd row
  86671. * @param initialM24 defines 4th value of 2nd row
  86672. * @param initialM31 defines 1st value of 3rd row
  86673. * @param initialM32 defines 2nd value of 3rd row
  86674. * @param initialM33 defines 3rd value of 3rd row
  86675. * @param initialM34 defines 4th value of 3rd row
  86676. * @param initialM41 defines 1st value of 4th row
  86677. * @param initialM42 defines 2nd value of 4th row
  86678. * @param initialM43 defines 3rd value of 4th row
  86679. * @param initialM44 defines 4th value of 4th row
  86680. * @returns the new matrix
  86681. */
  86682. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  86683. var result = new Matrix();
  86684. var m = result._m;
  86685. m[0] = initialM11;
  86686. m[1] = initialM12;
  86687. m[2] = initialM13;
  86688. m[3] = initialM14;
  86689. m[4] = initialM21;
  86690. m[5] = initialM22;
  86691. m[6] = initialM23;
  86692. m[7] = initialM24;
  86693. m[8] = initialM31;
  86694. m[9] = initialM32;
  86695. m[10] = initialM33;
  86696. m[11] = initialM34;
  86697. m[12] = initialM41;
  86698. m[13] = initialM42;
  86699. m[14] = initialM43;
  86700. m[15] = initialM44;
  86701. result._markAsUpdated();
  86702. return result;
  86703. };
  86704. /**
  86705. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86706. * @param scale defines the scale vector3
  86707. * @param rotation defines the rotation quaternion
  86708. * @param translation defines the translation vector3
  86709. * @returns a new matrix
  86710. */
  86711. Matrix.Compose = function (scale, rotation, translation) {
  86712. var result = new Matrix();
  86713. Matrix.ComposeToRef(scale, rotation, translation, result);
  86714. return result;
  86715. };
  86716. /**
  86717. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86718. * @param scale defines the scale vector3
  86719. * @param rotation defines the rotation quaternion
  86720. * @param translation defines the translation vector3
  86721. * @param result defines the target matrix
  86722. */
  86723. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  86724. var m = result._m;
  86725. var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
  86726. var x2 = x + x, y2 = y + y, z2 = z + z;
  86727. var xx = x * x2, xy = x * y2, xz = x * z2;
  86728. var yy = y * y2, yz = y * z2, zz = z * z2;
  86729. var wx = w * x2, wy = w * y2, wz = w * z2;
  86730. var sx = scale.x, sy = scale.y, sz = scale.z;
  86731. m[0] = (1 - (yy + zz)) * sx;
  86732. m[1] = (xy + wz) * sx;
  86733. m[2] = (xz - wy) * sx;
  86734. m[3] = 0;
  86735. m[4] = (xy - wz) * sy;
  86736. m[5] = (1 - (xx + zz)) * sy;
  86737. m[6] = (yz + wx) * sy;
  86738. m[7] = 0;
  86739. m[8] = (xz + wy) * sz;
  86740. m[9] = (yz - wx) * sz;
  86741. m[10] = (1 - (xx + yy)) * sz;
  86742. m[11] = 0;
  86743. m[12] = translation.x;
  86744. m[13] = translation.y;
  86745. m[14] = translation.z;
  86746. m[15] = 1;
  86747. result._markAsUpdated();
  86748. };
  86749. /**
  86750. * Creates a new identity matrix
  86751. * @returns a new identity matrix
  86752. */
  86753. Matrix.Identity = function () {
  86754. 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);
  86755. identity._updateIdentityStatus(true);
  86756. return identity;
  86757. };
  86758. /**
  86759. * Creates a new identity matrix and stores the result in a given matrix
  86760. * @param result defines the target matrix
  86761. */
  86762. Matrix.IdentityToRef = function (result) {
  86763. 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);
  86764. result._updateIdentityStatus(true);
  86765. };
  86766. /**
  86767. * Creates a new zero matrix
  86768. * @returns a new zero matrix
  86769. */
  86770. Matrix.Zero = function () {
  86771. 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);
  86772. zero._updateIdentityStatus(false);
  86773. return zero;
  86774. };
  86775. /**
  86776. * Creates a new rotation matrix for "angle" radians around the X axis
  86777. * @param angle defines the angle (in radians) to use
  86778. * @return the new matrix
  86779. */
  86780. Matrix.RotationX = function (angle) {
  86781. var result = new Matrix();
  86782. Matrix.RotationXToRef(angle, result);
  86783. return result;
  86784. };
  86785. /**
  86786. * Creates a new matrix as the invert of a given matrix
  86787. * @param source defines the source matrix
  86788. * @returns the new matrix
  86789. */
  86790. Matrix.Invert = function (source) {
  86791. var result = new Matrix();
  86792. source.invertToRef(result);
  86793. return result;
  86794. };
  86795. /**
  86796. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86797. * @param angle defines the angle (in radians) to use
  86798. * @param result defines the target matrix
  86799. */
  86800. Matrix.RotationXToRef = function (angle, result) {
  86801. var s = Math.sin(angle);
  86802. var c = Math.cos(angle);
  86803. 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);
  86804. result._updateIdentityStatus(c === 1 && s === 0);
  86805. };
  86806. /**
  86807. * Creates a new rotation matrix for "angle" radians around the Y axis
  86808. * @param angle defines the angle (in radians) to use
  86809. * @return the new matrix
  86810. */
  86811. Matrix.RotationY = function (angle) {
  86812. var result = new Matrix();
  86813. Matrix.RotationYToRef(angle, result);
  86814. return result;
  86815. };
  86816. /**
  86817. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86818. * @param angle defines the angle (in radians) to use
  86819. * @param result defines the target matrix
  86820. */
  86821. Matrix.RotationYToRef = function (angle, result) {
  86822. var s = Math.sin(angle);
  86823. var c = Math.cos(angle);
  86824. 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);
  86825. result._updateIdentityStatus(c === 1 && s === 0);
  86826. };
  86827. /**
  86828. * Creates a new rotation matrix for "angle" radians around the Z axis
  86829. * @param angle defines the angle (in radians) to use
  86830. * @return the new matrix
  86831. */
  86832. Matrix.RotationZ = function (angle) {
  86833. var result = new Matrix();
  86834. Matrix.RotationZToRef(angle, result);
  86835. return result;
  86836. };
  86837. /**
  86838. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86839. * @param angle defines the angle (in radians) to use
  86840. * @param result defines the target matrix
  86841. */
  86842. Matrix.RotationZToRef = function (angle, result) {
  86843. var s = Math.sin(angle);
  86844. var c = Math.cos(angle);
  86845. 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);
  86846. result._updateIdentityStatus(c === 1 && s === 0);
  86847. };
  86848. /**
  86849. * Creates a new rotation matrix for "angle" radians around the given axis
  86850. * @param axis defines the axis to use
  86851. * @param angle defines the angle (in radians) to use
  86852. * @return the new matrix
  86853. */
  86854. Matrix.RotationAxis = function (axis, angle) {
  86855. var result = new Matrix();
  86856. Matrix.RotationAxisToRef(axis, angle, result);
  86857. return result;
  86858. };
  86859. /**
  86860. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86861. * @param axis defines the axis to use
  86862. * @param angle defines the angle (in radians) to use
  86863. * @param result defines the target matrix
  86864. */
  86865. Matrix.RotationAxisToRef = function (axis, angle, result) {
  86866. var s = Math.sin(-angle);
  86867. var c = Math.cos(-angle);
  86868. var c1 = 1 - c;
  86869. axis.normalize();
  86870. var m = result._m;
  86871. m[0] = (axis.x * axis.x) * c1 + c;
  86872. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  86873. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  86874. m[3] = 0.0;
  86875. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  86876. m[5] = (axis.y * axis.y) * c1 + c;
  86877. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  86878. m[7] = 0.0;
  86879. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  86880. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  86881. m[10] = (axis.z * axis.z) * c1 + c;
  86882. m[11] = 0.0;
  86883. m[12] = 0.0;
  86884. m[13] = 0.0;
  86885. m[14] = 0.0;
  86886. m[15] = 1.0;
  86887. result._markAsUpdated();
  86888. };
  86889. /**
  86890. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86891. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86892. * @param from defines the vector to align
  86893. * @param to defines the vector to align to
  86894. * @param result defines the target matrix
  86895. */
  86896. Matrix.RotationAlignToRef = function (from, to, result) {
  86897. var v = Vector3.Cross(to, from);
  86898. var c = Vector3.Dot(to, from);
  86899. var k = 1 / (1 + c);
  86900. var m = result._m;
  86901. m[0] = v.x * v.x * k + c;
  86902. m[1] = v.y * v.x * k - v.z;
  86903. m[2] = v.z * v.x * k + v.y;
  86904. m[3] = 0;
  86905. m[4] = v.x * v.y * k + v.z;
  86906. m[5] = v.y * v.y * k + c;
  86907. m[6] = v.z * v.y * k - v.x;
  86908. m[7] = 0;
  86909. m[8] = v.x * v.z * k - v.y;
  86910. m[9] = v.y * v.z * k + v.x;
  86911. m[10] = v.z * v.z * k + c;
  86912. m[11] = 0;
  86913. m[12] = 0;
  86914. m[13] = 0;
  86915. m[14] = 0;
  86916. m[15] = 1;
  86917. result._markAsUpdated();
  86918. };
  86919. /**
  86920. * Creates a rotation matrix
  86921. * @param yaw defines the yaw angle in radians (Y axis)
  86922. * @param pitch defines the pitch angle in radians (X axis)
  86923. * @param roll defines the roll angle in radians (X axis)
  86924. * @returns the new rotation matrix
  86925. */
  86926. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  86927. var result = new Matrix();
  86928. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  86929. return result;
  86930. };
  86931. /**
  86932. * Creates a rotation matrix and stores it in a given matrix
  86933. * @param yaw defines the yaw angle in radians (Y axis)
  86934. * @param pitch defines the pitch angle in radians (X axis)
  86935. * @param roll defines the roll angle in radians (X axis)
  86936. * @param result defines the target matrix
  86937. */
  86938. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  86939. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  86940. MathTmp.Quaternion[0].toRotationMatrix(result);
  86941. };
  86942. /**
  86943. * Creates a scaling matrix
  86944. * @param x defines the scale factor on X axis
  86945. * @param y defines the scale factor on Y axis
  86946. * @param z defines the scale factor on Z axis
  86947. * @returns the new matrix
  86948. */
  86949. Matrix.Scaling = function (x, y, z) {
  86950. var result = new Matrix();
  86951. Matrix.ScalingToRef(x, y, z, result);
  86952. return result;
  86953. };
  86954. /**
  86955. * Creates a scaling matrix and stores it in a given matrix
  86956. * @param x defines the scale factor on X axis
  86957. * @param y defines the scale factor on Y axis
  86958. * @param z defines the scale factor on Z axis
  86959. * @param result defines the target matrix
  86960. */
  86961. Matrix.ScalingToRef = function (x, y, z, result) {
  86962. 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);
  86963. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  86964. };
  86965. /**
  86966. * Creates a translation matrix
  86967. * @param x defines the translation on X axis
  86968. * @param y defines the translation on Y axis
  86969. * @param z defines the translationon Z axis
  86970. * @returns the new matrix
  86971. */
  86972. Matrix.Translation = function (x, y, z) {
  86973. var result = new Matrix();
  86974. Matrix.TranslationToRef(x, y, z, result);
  86975. return result;
  86976. };
  86977. /**
  86978. * Creates a translation matrix and stores it in a given matrix
  86979. * @param x defines the translation on X axis
  86980. * @param y defines the translation on Y axis
  86981. * @param z defines the translationon Z axis
  86982. * @param result defines the target matrix
  86983. */
  86984. Matrix.TranslationToRef = function (x, y, z, result) {
  86985. 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);
  86986. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  86987. };
  86988. /**
  86989. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86990. * @param startValue defines the start value
  86991. * @param endValue defines the end value
  86992. * @param gradient defines the gradient factor
  86993. * @returns the new matrix
  86994. */
  86995. Matrix.Lerp = function (startValue, endValue, gradient) {
  86996. var result = new Matrix();
  86997. Matrix.LerpToRef(startValue, endValue, gradient, result);
  86998. return result;
  86999. };
  87000. /**
  87001. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  87002. * @param startValue defines the start value
  87003. * @param endValue defines the end value
  87004. * @param gradient defines the gradient factor
  87005. * @param result defines the Matrix object where to store data
  87006. */
  87007. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  87008. var resultM = result._m;
  87009. var startM = startValue.m;
  87010. var endM = endValue.m;
  87011. for (var index = 0; index < 16; index++) {
  87012. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  87013. }
  87014. result._markAsUpdated();
  87015. };
  87016. /**
  87017. * Builds a new matrix whose values are computed by:
  87018. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  87019. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  87020. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  87021. * @param startValue defines the first matrix
  87022. * @param endValue defines the second matrix
  87023. * @param gradient defines the gradient between the two matrices
  87024. * @returns the new matrix
  87025. */
  87026. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  87027. var result = new Matrix();
  87028. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  87029. return result;
  87030. };
  87031. /**
  87032. * Update a matrix to values which are computed by:
  87033. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  87034. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  87035. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  87036. * @param startValue defines the first matrix
  87037. * @param endValue defines the second matrix
  87038. * @param gradient defines the gradient between the two matrices
  87039. * @param result defines the target matrix
  87040. */
  87041. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  87042. var startScale = MathTmp.Vector3[0];
  87043. var startRotation = MathTmp.Quaternion[0];
  87044. var startTranslation = MathTmp.Vector3[1];
  87045. startValue.decompose(startScale, startRotation, startTranslation);
  87046. var endScale = MathTmp.Vector3[2];
  87047. var endRotation = MathTmp.Quaternion[1];
  87048. var endTranslation = MathTmp.Vector3[3];
  87049. endValue.decompose(endScale, endRotation, endTranslation);
  87050. var resultScale = MathTmp.Vector3[4];
  87051. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  87052. var resultRotation = MathTmp.Quaternion[2];
  87053. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  87054. var resultTranslation = MathTmp.Vector3[5];
  87055. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  87056. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  87057. };
  87058. /**
  87059. * 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"
  87060. * This function works in left handed mode
  87061. * @param eye defines the final position of the entity
  87062. * @param target defines where the entity should look at
  87063. * @param up defines the up vector for the entity
  87064. * @returns the new matrix
  87065. */
  87066. Matrix.LookAtLH = function (eye, target, up) {
  87067. var result = new Matrix();
  87068. Matrix.LookAtLHToRef(eye, target, up, result);
  87069. return result;
  87070. };
  87071. /**
  87072. * 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".
  87073. * This function works in left handed mode
  87074. * @param eye defines the final position of the entity
  87075. * @param target defines where the entity should look at
  87076. * @param up defines the up vector for the entity
  87077. * @param result defines the target matrix
  87078. */
  87079. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  87080. var xAxis = MathTmp.Vector3[0];
  87081. var yAxis = MathTmp.Vector3[1];
  87082. var zAxis = MathTmp.Vector3[2];
  87083. // Z axis
  87084. target.subtractToRef(eye, zAxis);
  87085. zAxis.normalize();
  87086. // X axis
  87087. Vector3.CrossToRef(up, zAxis, xAxis);
  87088. var xSquareLength = xAxis.lengthSquared();
  87089. if (xSquareLength === 0) {
  87090. xAxis.x = 1.0;
  87091. }
  87092. else {
  87093. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  87094. }
  87095. // Y axis
  87096. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  87097. yAxis.normalize();
  87098. // Eye angles
  87099. var ex = -Vector3.Dot(xAxis, eye);
  87100. var ey = -Vector3.Dot(yAxis, eye);
  87101. var ez = -Vector3.Dot(zAxis, eye);
  87102. 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);
  87103. };
  87104. /**
  87105. * 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"
  87106. * This function works in right handed mode
  87107. * @param eye defines the final position of the entity
  87108. * @param target defines where the entity should look at
  87109. * @param up defines the up vector for the entity
  87110. * @returns the new matrix
  87111. */
  87112. Matrix.LookAtRH = function (eye, target, up) {
  87113. var result = new Matrix();
  87114. Matrix.LookAtRHToRef(eye, target, up, result);
  87115. return result;
  87116. };
  87117. /**
  87118. * 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".
  87119. * This function works in right handed mode
  87120. * @param eye defines the final position of the entity
  87121. * @param target defines where the entity should look at
  87122. * @param up defines the up vector for the entity
  87123. * @param result defines the target matrix
  87124. */
  87125. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  87126. var xAxis = MathTmp.Vector3[0];
  87127. var yAxis = MathTmp.Vector3[1];
  87128. var zAxis = MathTmp.Vector3[2];
  87129. // Z axis
  87130. eye.subtractToRef(target, zAxis);
  87131. zAxis.normalize();
  87132. // X axis
  87133. Vector3.CrossToRef(up, zAxis, xAxis);
  87134. var xSquareLength = xAxis.lengthSquared();
  87135. if (xSquareLength === 0) {
  87136. xAxis.x = 1.0;
  87137. }
  87138. else {
  87139. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  87140. }
  87141. // Y axis
  87142. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  87143. yAxis.normalize();
  87144. // Eye angles
  87145. var ex = -Vector3.Dot(xAxis, eye);
  87146. var ey = -Vector3.Dot(yAxis, eye);
  87147. var ez = -Vector3.Dot(zAxis, eye);
  87148. 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);
  87149. };
  87150. /**
  87151. * Create a left-handed orthographic projection matrix
  87152. * @param width defines the viewport width
  87153. * @param height defines the viewport height
  87154. * @param znear defines the near clip plane
  87155. * @param zfar defines the far clip plane
  87156. * @returns a new matrix as a left-handed orthographic projection matrix
  87157. */
  87158. Matrix.OrthoLH = function (width, height, znear, zfar) {
  87159. var matrix = new Matrix();
  87160. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  87161. return matrix;
  87162. };
  87163. /**
  87164. * Store a left-handed orthographic projection to a given matrix
  87165. * @param width defines the viewport width
  87166. * @param height defines the viewport height
  87167. * @param znear defines the near clip plane
  87168. * @param zfar defines the far clip plane
  87169. * @param result defines the target matrix
  87170. */
  87171. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  87172. var n = znear;
  87173. var f = zfar;
  87174. var a = 2.0 / width;
  87175. var b = 2.0 / height;
  87176. var c = 2.0 / (f - n);
  87177. var d = -(f + n) / (f - n);
  87178. 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);
  87179. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  87180. };
  87181. /**
  87182. * Create a left-handed orthographic projection matrix
  87183. * @param left defines the viewport left coordinate
  87184. * @param right defines the viewport right coordinate
  87185. * @param bottom defines the viewport bottom coordinate
  87186. * @param top defines the viewport top coordinate
  87187. * @param znear defines the near clip plane
  87188. * @param zfar defines the far clip plane
  87189. * @returns a new matrix as a left-handed orthographic projection matrix
  87190. */
  87191. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  87192. var matrix = new Matrix();
  87193. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  87194. return matrix;
  87195. };
  87196. /**
  87197. * Stores a left-handed orthographic projection into a given matrix
  87198. * @param left defines the viewport left coordinate
  87199. * @param right defines the viewport right coordinate
  87200. * @param bottom defines the viewport bottom coordinate
  87201. * @param top defines the viewport top coordinate
  87202. * @param znear defines the near clip plane
  87203. * @param zfar defines the far clip plane
  87204. * @param result defines the target matrix
  87205. */
  87206. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  87207. var n = znear;
  87208. var f = zfar;
  87209. var a = 2.0 / (right - left);
  87210. var b = 2.0 / (top - bottom);
  87211. var c = 2.0 / (f - n);
  87212. var d = -(f + n) / (f - n);
  87213. var i0 = (left + right) / (left - right);
  87214. var i1 = (top + bottom) / (bottom - top);
  87215. 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);
  87216. result._markAsUpdated();
  87217. };
  87218. /**
  87219. * Creates a right-handed orthographic projection matrix
  87220. * @param left defines the viewport left coordinate
  87221. * @param right defines the viewport right coordinate
  87222. * @param bottom defines the viewport bottom coordinate
  87223. * @param top defines the viewport top coordinate
  87224. * @param znear defines the near clip plane
  87225. * @param zfar defines the far clip plane
  87226. * @returns a new matrix as a right-handed orthographic projection matrix
  87227. */
  87228. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  87229. var matrix = new Matrix();
  87230. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  87231. return matrix;
  87232. };
  87233. /**
  87234. * Stores a right-handed orthographic projection into a given matrix
  87235. * @param left defines the viewport left coordinate
  87236. * @param right defines the viewport right coordinate
  87237. * @param bottom defines the viewport bottom coordinate
  87238. * @param top defines the viewport top coordinate
  87239. * @param znear defines the near clip plane
  87240. * @param zfar defines the far clip plane
  87241. * @param result defines the target matrix
  87242. */
  87243. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  87244. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  87245. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  87246. };
  87247. /**
  87248. * Creates a left-handed perspective projection matrix
  87249. * @param width defines the viewport width
  87250. * @param height defines the viewport height
  87251. * @param znear defines the near clip plane
  87252. * @param zfar defines the far clip plane
  87253. * @returns a new matrix as a left-handed perspective projection matrix
  87254. */
  87255. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  87256. var matrix = new Matrix();
  87257. var n = znear;
  87258. var f = zfar;
  87259. var a = 2.0 * n / width;
  87260. var b = 2.0 * n / height;
  87261. var c = (f + n) / (f - n);
  87262. var d = -2.0 * f * n / (f - n);
  87263. 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);
  87264. matrix._updateIdentityStatus(false);
  87265. return matrix;
  87266. };
  87267. /**
  87268. * Creates a left-handed perspective projection matrix
  87269. * @param fov defines the horizontal field of view
  87270. * @param aspect defines the aspect ratio
  87271. * @param znear defines the near clip plane
  87272. * @param zfar defines the far clip plane
  87273. * @returns a new matrix as a left-handed perspective projection matrix
  87274. */
  87275. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  87276. var matrix = new Matrix();
  87277. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  87278. return matrix;
  87279. };
  87280. /**
  87281. * Stores a left-handed perspective projection into a given matrix
  87282. * @param fov defines the horizontal field of view
  87283. * @param aspect defines the aspect ratio
  87284. * @param znear defines the near clip plane
  87285. * @param zfar defines the far clip plane
  87286. * @param result defines the target matrix
  87287. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  87288. */
  87289. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  87290. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  87291. var n = znear;
  87292. var f = zfar;
  87293. var t = 1.0 / (Math.tan(fov * 0.5));
  87294. var a = isVerticalFovFixed ? (t / aspect) : t;
  87295. var b = isVerticalFovFixed ? t : (t * aspect);
  87296. var c = (f + n) / (f - n);
  87297. var d = -2.0 * f * n / (f - n);
  87298. 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);
  87299. result._updateIdentityStatus(false);
  87300. };
  87301. /**
  87302. * Creates a right-handed perspective projection matrix
  87303. * @param fov defines the horizontal field of view
  87304. * @param aspect defines the aspect ratio
  87305. * @param znear defines the near clip plane
  87306. * @param zfar defines the far clip plane
  87307. * @returns a new matrix as a right-handed perspective projection matrix
  87308. */
  87309. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  87310. var matrix = new Matrix();
  87311. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  87312. return matrix;
  87313. };
  87314. /**
  87315. * Stores a right-handed perspective projection into a given matrix
  87316. * @param fov defines the horizontal field of view
  87317. * @param aspect defines the aspect ratio
  87318. * @param znear defines the near clip plane
  87319. * @param zfar defines the far clip plane
  87320. * @param result defines the target matrix
  87321. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  87322. */
  87323. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  87324. //alternatively this could be expressed as:
  87325. // m = PerspectiveFovLHToRef
  87326. // m[10] *= -1.0;
  87327. // m[11] *= -1.0;
  87328. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  87329. var n = znear;
  87330. var f = zfar;
  87331. var t = 1.0 / (Math.tan(fov * 0.5));
  87332. var a = isVerticalFovFixed ? (t / aspect) : t;
  87333. var b = isVerticalFovFixed ? t : (t * aspect);
  87334. var c = -(f + n) / (f - n);
  87335. var d = -2 * f * n / (f - n);
  87336. 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);
  87337. result._updateIdentityStatus(false);
  87338. };
  87339. /**
  87340. * Stores a perspective projection for WebVR info a given matrix
  87341. * @param fov defines the field of view
  87342. * @param znear defines the near clip plane
  87343. * @param zfar defines the far clip plane
  87344. * @param result defines the target matrix
  87345. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  87346. */
  87347. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  87348. if (rightHanded === void 0) { rightHanded = false; }
  87349. var rightHandedFactor = rightHanded ? -1 : 1;
  87350. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  87351. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  87352. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  87353. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  87354. var xScale = 2.0 / (leftTan + rightTan);
  87355. var yScale = 2.0 / (upTan + downTan);
  87356. var m = result._m;
  87357. m[0] = xScale;
  87358. m[1] = m[2] = m[3] = m[4] = 0.0;
  87359. m[5] = yScale;
  87360. m[6] = m[7] = 0.0;
  87361. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  87362. m[9] = -((upTan - downTan) * yScale * 0.5);
  87363. m[10] = -zfar / (znear - zfar);
  87364. m[11] = 1.0 * rightHandedFactor;
  87365. m[12] = m[13] = m[15] = 0.0;
  87366. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  87367. result._markAsUpdated();
  87368. };
  87369. /**
  87370. * Computes a complete transformation matrix
  87371. * @param viewport defines the viewport to use
  87372. * @param world defines the world matrix
  87373. * @param view defines the view matrix
  87374. * @param projection defines the projection matrix
  87375. * @param zmin defines the near clip plane
  87376. * @param zmax defines the far clip plane
  87377. * @returns the transformation matrix
  87378. */
  87379. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  87380. var cw = viewport.width;
  87381. var ch = viewport.height;
  87382. var cx = viewport.x;
  87383. var cy = viewport.y;
  87384. 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);
  87385. var matrix = MathTmp.Matrix[0];
  87386. world.multiplyToRef(view, matrix);
  87387. matrix.multiplyToRef(projection, matrix);
  87388. return matrix.multiply(viewportMatrix);
  87389. };
  87390. /**
  87391. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  87392. * @param matrix defines the matrix to use
  87393. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  87394. */
  87395. Matrix.GetAsMatrix2x2 = function (matrix) {
  87396. var m = matrix.m;
  87397. return new Float32Array([m[0], m[1], m[4], m[5]]);
  87398. };
  87399. /**
  87400. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  87401. * @param matrix defines the matrix to use
  87402. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  87403. */
  87404. Matrix.GetAsMatrix3x3 = function (matrix) {
  87405. var m = matrix.m;
  87406. return new Float32Array([
  87407. m[0], m[1], m[2],
  87408. m[4], m[5], m[6],
  87409. m[8], m[9], m[10]
  87410. ]);
  87411. };
  87412. /**
  87413. * Compute the transpose of a given matrix
  87414. * @param matrix defines the matrix to transpose
  87415. * @returns the new matrix
  87416. */
  87417. Matrix.Transpose = function (matrix) {
  87418. var result = new Matrix();
  87419. Matrix.TransposeToRef(matrix, result);
  87420. return result;
  87421. };
  87422. /**
  87423. * Compute the transpose of a matrix and store it in a target matrix
  87424. * @param matrix defines the matrix to transpose
  87425. * @param result defines the target matrix
  87426. */
  87427. Matrix.TransposeToRef = function (matrix, result) {
  87428. var rm = result._m;
  87429. var mm = matrix.m;
  87430. rm[0] = mm[0];
  87431. rm[1] = mm[4];
  87432. rm[2] = mm[8];
  87433. rm[3] = mm[12];
  87434. rm[4] = mm[1];
  87435. rm[5] = mm[5];
  87436. rm[6] = mm[9];
  87437. rm[7] = mm[13];
  87438. rm[8] = mm[2];
  87439. rm[9] = mm[6];
  87440. rm[10] = mm[10];
  87441. rm[11] = mm[14];
  87442. rm[12] = mm[3];
  87443. rm[13] = mm[7];
  87444. rm[14] = mm[11];
  87445. rm[15] = mm[15];
  87446. // identity-ness does not change when transposing
  87447. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  87448. };
  87449. /**
  87450. * Computes a reflection matrix from a plane
  87451. * @param plane defines the reflection plane
  87452. * @returns a new matrix
  87453. */
  87454. Matrix.Reflection = function (plane) {
  87455. var matrix = new Matrix();
  87456. Matrix.ReflectionToRef(plane, matrix);
  87457. return matrix;
  87458. };
  87459. /**
  87460. * Computes a reflection matrix from a plane
  87461. * @param plane defines the reflection plane
  87462. * @param result defines the target matrix
  87463. */
  87464. Matrix.ReflectionToRef = function (plane, result) {
  87465. plane.normalize();
  87466. var x = plane.normal.x;
  87467. var y = plane.normal.y;
  87468. var z = plane.normal.z;
  87469. var temp = -2 * x;
  87470. var temp2 = -2 * y;
  87471. var temp3 = -2 * z;
  87472. 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);
  87473. };
  87474. /**
  87475. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  87476. * @param xaxis defines the value of the 1st axis
  87477. * @param yaxis defines the value of the 2nd axis
  87478. * @param zaxis defines the value of the 3rd axis
  87479. * @param result defines the target matrix
  87480. */
  87481. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  87482. 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);
  87483. };
  87484. /**
  87485. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  87486. * @param quat defines the quaternion to use
  87487. * @param result defines the target matrix
  87488. */
  87489. Matrix.FromQuaternionToRef = function (quat, result) {
  87490. var xx = quat.x * quat.x;
  87491. var yy = quat.y * quat.y;
  87492. var zz = quat.z * quat.z;
  87493. var xy = quat.x * quat.y;
  87494. var zw = quat.z * quat.w;
  87495. var zx = quat.z * quat.x;
  87496. var yw = quat.y * quat.w;
  87497. var yz = quat.y * quat.z;
  87498. var xw = quat.x * quat.w;
  87499. result._m[0] = 1.0 - (2.0 * (yy + zz));
  87500. result._m[1] = 2.0 * (xy + zw);
  87501. result._m[2] = 2.0 * (zx - yw);
  87502. result._m[3] = 0.0;
  87503. result._m[4] = 2.0 * (xy - zw);
  87504. result._m[5] = 1.0 - (2.0 * (zz + xx));
  87505. result._m[6] = 2.0 * (yz + xw);
  87506. result._m[7] = 0.0;
  87507. result._m[8] = 2.0 * (zx + yw);
  87508. result._m[9] = 2.0 * (yz - xw);
  87509. result._m[10] = 1.0 - (2.0 * (yy + xx));
  87510. result._m[11] = 0.0;
  87511. result._m[12] = 0.0;
  87512. result._m[13] = 0.0;
  87513. result._m[14] = 0.0;
  87514. result._m[15] = 1.0;
  87515. result._markAsUpdated();
  87516. };
  87517. Matrix._updateFlagSeed = 0;
  87518. Matrix._identityReadOnly = Matrix.Identity();
  87519. return Matrix;
  87520. }());
  87521. /**
  87522. * @hidden
  87523. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  87524. */
  87525. var MathTmp = /** @class */ (function () {
  87526. function MathTmp() {
  87527. }
  87528. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(6, Vector3.Zero);
  87529. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, Matrix.Identity);
  87530. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  87531. return MathTmp;
  87532. }());
  87533. /**
  87534. * @hidden
  87535. */
  87536. var TmpVectors = /** @class */ (function () {
  87537. function TmpVectors() {
  87538. }
  87539. TmpVectors.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  87540. TmpVectors.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  87541. TmpVectors.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  87542. TmpVectors.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  87543. TmpVectors.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  87544. return TmpVectors;
  87545. }());
  87546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Vector2"] = Vector2;
  87547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Vector3"] = Vector3;
  87548. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Vector4"] = Vector4;
  87549. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Matrix"] = Matrix;
  87550. /***/ }),
  87551. /***/ "./Maths/math.vertexFormat.ts":
  87552. /*!************************************!*\
  87553. !*** ./Maths/math.vertexFormat.ts ***!
  87554. \************************************/
  87555. /*! exports provided: PositionNormalVertex, PositionNormalTextureVertex */
  87556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87557. "use strict";
  87558. __webpack_require__.r(__webpack_exports__);
  87559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  87560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  87561. /* harmony import */ var _math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.vector */ "./Maths/math.vector.ts");
  87562. /**
  87563. * Contains position and normal vectors for a vertex
  87564. */
  87565. var PositionNormalVertex = /** @class */ (function () {
  87566. /**
  87567. * Creates a PositionNormalVertex
  87568. * @param position the position of the vertex (defaut: 0,0,0)
  87569. * @param normal the normal of the vertex (defaut: 0,1,0)
  87570. */
  87571. function PositionNormalVertex(
  87572. /** the position of the vertex (defaut: 0,0,0) */
  87573. position,
  87574. /** the normal of the vertex (defaut: 0,1,0) */
  87575. normal) {
  87576. if (position === void 0) { position = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  87577. if (normal === void 0) { normal = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(); }
  87578. this.position = position;
  87579. this.normal = normal;
  87580. }
  87581. /**
  87582. * Clones the PositionNormalVertex
  87583. * @returns the cloned PositionNormalVertex
  87584. */
  87585. PositionNormalVertex.prototype.clone = function () {
  87586. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  87587. };
  87588. return PositionNormalVertex;
  87589. }());
  87590. /**
  87591. * Contains position, normal and uv vectors for a vertex
  87592. */
  87593. var PositionNormalTextureVertex = /** @class */ (function () {
  87594. /**
  87595. * Creates a PositionNormalTextureVertex
  87596. * @param position the position of the vertex (defaut: 0,0,0)
  87597. * @param normal the normal of the vertex (defaut: 0,1,0)
  87598. * @param uv the uv of the vertex (default: 0,0)
  87599. */
  87600. function PositionNormalTextureVertex(
  87601. /** the position of the vertex (defaut: 0,0,0) */
  87602. position,
  87603. /** the normal of the vertex (defaut: 0,1,0) */
  87604. normal,
  87605. /** the uv of the vertex (default: 0,0) */
  87606. uv) {
  87607. if (position === void 0) { position = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  87608. if (normal === void 0) { normal = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(); }
  87609. if (uv === void 0) { uv = _math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(); }
  87610. this.position = position;
  87611. this.normal = normal;
  87612. this.uv = uv;
  87613. }
  87614. /**
  87615. * Clones the PositionNormalTextureVertex
  87616. * @returns the cloned PositionNormalTextureVertex
  87617. */
  87618. PositionNormalTextureVertex.prototype.clone = function () {
  87619. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  87620. };
  87621. return PositionNormalTextureVertex;
  87622. }());
  87623. /***/ }),
  87624. /***/ "./Maths/math.viewport.ts":
  87625. /*!********************************!*\
  87626. !*** ./Maths/math.viewport.ts ***!
  87627. \********************************/
  87628. /*! exports provided: Viewport */
  87629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87630. "use strict";
  87631. __webpack_require__.r(__webpack_exports__);
  87632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  87633. /**
  87634. * Class used to represent a viewport on screen
  87635. */
  87636. var Viewport = /** @class */ (function () {
  87637. /**
  87638. * Creates a Viewport object located at (x, y) and sized (width, height)
  87639. * @param x defines viewport left coordinate
  87640. * @param y defines viewport top coordinate
  87641. * @param width defines the viewport width
  87642. * @param height defines the viewport height
  87643. */
  87644. function Viewport(
  87645. /** viewport left coordinate */
  87646. x,
  87647. /** viewport top coordinate */
  87648. y,
  87649. /**viewport width */
  87650. width,
  87651. /** viewport height */
  87652. height) {
  87653. this.x = x;
  87654. this.y = y;
  87655. this.width = width;
  87656. this.height = height;
  87657. }
  87658. /**
  87659. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  87660. * @param renderWidth defines the rendering width
  87661. * @param renderHeight defines the rendering height
  87662. * @returns a new Viewport
  87663. */
  87664. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  87665. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  87666. };
  87667. /**
  87668. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  87669. * @param renderWidth defines the rendering width
  87670. * @param renderHeight defines the rendering height
  87671. * @param ref defines the target viewport
  87672. * @returns the current viewport
  87673. */
  87674. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  87675. ref.x = this.x * renderWidth;
  87676. ref.y = this.y * renderHeight;
  87677. ref.width = this.width * renderWidth;
  87678. ref.height = this.height * renderHeight;
  87679. return this;
  87680. };
  87681. /**
  87682. * Returns a new Viewport copied from the current one
  87683. * @returns a new Viewport
  87684. */
  87685. Viewport.prototype.clone = function () {
  87686. return new Viewport(this.x, this.y, this.width, this.height);
  87687. };
  87688. return Viewport;
  87689. }());
  87690. /***/ }),
  87691. /***/ "./Maths/sphericalPolynomial.ts":
  87692. /*!**************************************!*\
  87693. !*** ./Maths/sphericalPolynomial.ts ***!
  87694. \**************************************/
  87695. /*! exports provided: SphericalHarmonics, SphericalPolynomial */
  87696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87697. "use strict";
  87698. __webpack_require__.r(__webpack_exports__);
  87699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  87700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  87701. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  87702. // https://dickyjim.wordpress.com/2013/09/04/spherical-harmonics-for-beginners/
  87703. // http://silviojemma.com/public/papers/lighting/spherical-harmonic-lighting.pdf
  87704. // https://www.ppsloan.org/publications/StupidSH36.pdf
  87705. // http://cseweb.ucsd.edu/~ravir/papers/envmap/envmap.pdf
  87706. // https://www.ppsloan.org/publications/SHJCGT.pdf
  87707. // https://www.ppsloan.org/publications/shdering.pdf
  87708. // https://google.github.io/filament/Filament.md.html#annex/sphericalharmonics
  87709. // https://patapom.com/blog/SHPortal/
  87710. // https://imdoingitwrong.wordpress.com/2011/04/14/spherical-harmonics-wtf/
  87711. // Using real SH basis:
  87712. // m>0 m m
  87713. // y = sqrt(2) * K * P * cos(m*phi) * cos(theta)
  87714. // l l l
  87715. //
  87716. // m<0 m |m|
  87717. // y = sqrt(2) * K * P * sin(m*phi) * cos(theta)
  87718. // l l l
  87719. //
  87720. // m=0 0 0
  87721. // y = K * P * trigono terms
  87722. // l l l
  87723. //
  87724. // m (2l + 1)(l - |m|)!
  87725. // K = sqrt(------------------)
  87726. // l 4pi(l + |m|)!
  87727. //
  87728. // and P by recursion:
  87729. //
  87730. // P00(x) = 1
  87731. // P01(x) = x
  87732. // Pll(x) = (-1^l)(2l - 1)!!(1-x*x)^(1/2)
  87733. // ((2l - 1)x[Pl-1/m]-(l + m - 1)[Pl-2/m])
  87734. // Plm(x) = ---------------------------------------
  87735. // l - m
  87736. // Leaving the trigonometric terms aside we can precompute the constants to :
  87737. var SH3ylmBasisConstants = [
  87738. Math.sqrt(1 / (4 * Math.PI)),
  87739. -Math.sqrt(3 / (4 * Math.PI)),
  87740. Math.sqrt(3 / (4 * Math.PI)),
  87741. -Math.sqrt(3 / (4 * Math.PI)),
  87742. Math.sqrt(15 / (4 * Math.PI)),
  87743. -Math.sqrt(15 / (4 * Math.PI)),
  87744. Math.sqrt(5 / (16 * Math.PI)),
  87745. -Math.sqrt(15 / (4 * Math.PI)),
  87746. Math.sqrt(15 / (16 * Math.PI)),
  87747. ];
  87748. // cm = cos(m * phi)
  87749. // sm = sin(m * phi)
  87750. // {x,y,z} = {cos(phi)sin(theta), sin(phi)sin(theta), cos(theta)}
  87751. // By recursion on using trigo identities:
  87752. var SH3ylmBasisTrigonometricTerms = [
  87753. function (direction) { return 1; },
  87754. function (direction) { return direction.y; },
  87755. function (direction) { return direction.z; },
  87756. function (direction) { return direction.x; },
  87757. function (direction) { return direction.x * direction.y; },
  87758. function (direction) { return direction.y * direction.z; },
  87759. function (direction) { return 3 * direction.z * direction.z - 1; },
  87760. function (direction) { return direction.x * direction.z; },
  87761. function (direction) { return direction.x * direction.x - direction.y * direction.y; },
  87762. ];
  87763. // Wrap the full compute
  87764. var applySH3 = function (lm, direction) {
  87765. return SH3ylmBasisConstants[lm] * SH3ylmBasisTrigonometricTerms[lm](direction);
  87766. };
  87767. // Derived from the integration of the a kernel convolution to SH.
  87768. // Great explanation here: https://patapom.com/blog/SHPortal/#about-distant-radiance-and-irradiance-environments
  87769. var SHCosKernelConvolution = [
  87770. Math.PI,
  87771. 2 * Math.PI / 3,
  87772. 2 * Math.PI / 3,
  87773. 2 * Math.PI / 3,
  87774. Math.PI / 4,
  87775. Math.PI / 4,
  87776. Math.PI / 4,
  87777. Math.PI / 4,
  87778. Math.PI / 4,
  87779. ];
  87780. /**
  87781. * Class representing spherical harmonics coefficients to the 3rd degree
  87782. */
  87783. var SphericalHarmonics = /** @class */ (function () {
  87784. function SphericalHarmonics() {
  87785. /**
  87786. * Defines whether or not the harmonics have been prescaled for rendering.
  87787. */
  87788. this.preScaled = false;
  87789. /**
  87790. * The l0,0 coefficients of the spherical harmonics
  87791. */
  87792. this.l00 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87793. /**
  87794. * The l1,-1 coefficients of the spherical harmonics
  87795. */
  87796. this.l1_1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87797. /**
  87798. * The l1,0 coefficients of the spherical harmonics
  87799. */
  87800. this.l10 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87801. /**
  87802. * The l1,1 coefficients of the spherical harmonics
  87803. */
  87804. this.l11 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87805. /**
  87806. * The l2,-2 coefficients of the spherical harmonics
  87807. */
  87808. this.l2_2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87809. /**
  87810. * The l2,-1 coefficients of the spherical harmonics
  87811. */
  87812. this.l2_1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87813. /**
  87814. * The l2,0 coefficients of the spherical harmonics
  87815. */
  87816. this.l20 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87817. /**
  87818. * The l2,1 coefficients of the spherical harmonics
  87819. */
  87820. this.l21 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87821. /**
  87822. * The l2,2 coefficients of the spherical harmonics
  87823. */
  87824. this.l22 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87825. }
  87826. /**
  87827. * Adds a light to the spherical harmonics
  87828. * @param direction the direction of the light
  87829. * @param color the color of the light
  87830. * @param deltaSolidAngle the delta solid angle of the light
  87831. */
  87832. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  87833. var colorVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  87834. var c = colorVector.scale(deltaSolidAngle);
  87835. this.l00 = this.l00.add(c.scale(applySH3(0, direction)));
  87836. this.l1_1 = this.l1_1.add(c.scale(applySH3(1, direction)));
  87837. this.l10 = this.l10.add(c.scale(applySH3(2, direction)));
  87838. this.l11 = this.l11.add(c.scale(applySH3(3, direction)));
  87839. this.l2_2 = this.l2_2.add(c.scale(applySH3(4, direction)));
  87840. this.l2_1 = this.l2_1.add(c.scale(applySH3(5, direction)));
  87841. this.l20 = this.l20.add(c.scale(applySH3(6, direction)));
  87842. this.l21 = this.l21.add(c.scale(applySH3(7, direction)));
  87843. this.l22 = this.l22.add(c.scale(applySH3(8, direction)));
  87844. };
  87845. /**
  87846. * Scales the spherical harmonics by the given amount
  87847. * @param scale the amount to scale
  87848. */
  87849. SphericalHarmonics.prototype.scaleInPlace = function (scale) {
  87850. this.l00.scaleInPlace(scale);
  87851. this.l1_1.scaleInPlace(scale);
  87852. this.l10.scaleInPlace(scale);
  87853. this.l11.scaleInPlace(scale);
  87854. this.l2_2.scaleInPlace(scale);
  87855. this.l2_1.scaleInPlace(scale);
  87856. this.l20.scaleInPlace(scale);
  87857. this.l21.scaleInPlace(scale);
  87858. this.l22.scaleInPlace(scale);
  87859. };
  87860. /**
  87861. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  87862. *
  87863. * ```
  87864. * E_lm = A_l * L_lm
  87865. * ```
  87866. *
  87867. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  87868. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  87869. * the scaling factors are given in equation 9.
  87870. */
  87871. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  87872. // Constant (Band 0)
  87873. this.l00.scaleInPlace(SHCosKernelConvolution[0]);
  87874. // Linear (Band 1)
  87875. this.l1_1.scaleInPlace(SHCosKernelConvolution[1]);
  87876. this.l10.scaleInPlace(SHCosKernelConvolution[2]);
  87877. this.l11.scaleInPlace(SHCosKernelConvolution[3]);
  87878. // Quadratic (Band 2)
  87879. this.l2_2.scaleInPlace(SHCosKernelConvolution[4]);
  87880. this.l2_1.scaleInPlace(SHCosKernelConvolution[5]);
  87881. this.l20.scaleInPlace(SHCosKernelConvolution[6]);
  87882. this.l21.scaleInPlace(SHCosKernelConvolution[7]);
  87883. this.l22.scaleInPlace(SHCosKernelConvolution[8]);
  87884. };
  87885. /**
  87886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  87887. *
  87888. * ```
  87889. * L = (1/pi) * E * rho
  87890. * ```
  87891. *
  87892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  87893. */
  87894. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  87895. this.scaleInPlace(1.0 / Math.PI);
  87896. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  87897. // (The pixel shader must apply albedo after texture fetches, etc).
  87898. };
  87899. /**
  87900. * Integrates the reconstruction coefficients directly in to the SH preventing further
  87901. * required operations at run time.
  87902. *
  87903. * This is simply done by scaling back the SH with Ylm constants parameter.
  87904. * The trigonometric part being applied by the shader at run time.
  87905. */
  87906. SphericalHarmonics.prototype.preScaleForRendering = function () {
  87907. this.preScaled = true;
  87908. this.l00.scaleInPlace(SH3ylmBasisConstants[0]);
  87909. this.l1_1.scaleInPlace(SH3ylmBasisConstants[1]);
  87910. this.l10.scaleInPlace(SH3ylmBasisConstants[2]);
  87911. this.l11.scaleInPlace(SH3ylmBasisConstants[3]);
  87912. this.l2_2.scaleInPlace(SH3ylmBasisConstants[4]);
  87913. this.l2_1.scaleInPlace(SH3ylmBasisConstants[5]);
  87914. this.l20.scaleInPlace(SH3ylmBasisConstants[6]);
  87915. this.l21.scaleInPlace(SH3ylmBasisConstants[7]);
  87916. this.l22.scaleInPlace(SH3ylmBasisConstants[8]);
  87917. };
  87918. /**
  87919. * Constructs a spherical harmonics from an array.
  87920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  87921. * @returns the spherical harmonics
  87922. */
  87923. SphericalHarmonics.FromArray = function (data) {
  87924. var sh = new SphericalHarmonics();
  87925. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  87926. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  87927. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  87928. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  87929. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  87930. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  87931. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  87932. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  87933. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.l22);
  87934. return sh;
  87935. };
  87936. // Keep for references.
  87937. /**
  87938. * Gets the spherical harmonics from polynomial
  87939. * @param polynomial the spherical polynomial
  87940. * @returns the spherical harmonics
  87941. */
  87942. SphericalHarmonics.FromPolynomial = function (polynomial) {
  87943. var result = new SphericalHarmonics();
  87944. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  87945. result.l1_1 = polynomial.y.scale(0.977204);
  87946. result.l10 = polynomial.z.scale(0.977204);
  87947. result.l11 = polynomial.x.scale(0.977204);
  87948. result.l2_2 = polynomial.xy.scale(1.16538);
  87949. result.l2_1 = polynomial.yz.scale(1.16538);
  87950. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  87951. result.l21 = polynomial.zx.scale(1.16538);
  87952. result.l22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  87953. result.l1_1.scaleInPlace(-1);
  87954. result.l11.scaleInPlace(-1);
  87955. result.l2_1.scaleInPlace(-1);
  87956. result.l21.scaleInPlace(-1);
  87957. result.scaleInPlace(Math.PI);
  87958. return result;
  87959. };
  87960. return SphericalHarmonics;
  87961. }());
  87962. /**
  87963. * Class representing spherical polynomial coefficients to the 3rd degree
  87964. */
  87965. var SphericalPolynomial = /** @class */ (function () {
  87966. function SphericalPolynomial() {
  87967. /**
  87968. * The x coefficients of the spherical polynomial
  87969. */
  87970. this.x = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87971. /**
  87972. * The y coefficients of the spherical polynomial
  87973. */
  87974. this.y = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87975. /**
  87976. * The z coefficients of the spherical polynomial
  87977. */
  87978. this.z = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87979. /**
  87980. * The xx coefficients of the spherical polynomial
  87981. */
  87982. this.xx = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87983. /**
  87984. * The yy coefficients of the spherical polynomial
  87985. */
  87986. this.yy = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87987. /**
  87988. * The zz coefficients of the spherical polynomial
  87989. */
  87990. this.zz = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87991. /**
  87992. * The xy coefficients of the spherical polynomial
  87993. */
  87994. this.xy = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87995. /**
  87996. * The yz coefficients of the spherical polynomial
  87997. */
  87998. this.yz = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87999. /**
  88000. * The zx coefficients of the spherical polynomial
  88001. */
  88002. this.zx = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88003. }
  88004. Object.defineProperty(SphericalPolynomial.prototype, "preScaledHarmonics", {
  88005. /**
  88006. * The spherical harmonics used to create the polynomials.
  88007. */
  88008. get: function () {
  88009. if (!this._harmonics) {
  88010. this._harmonics = SphericalHarmonics.FromPolynomial(this);
  88011. }
  88012. if (!this._harmonics.preScaled) {
  88013. this._harmonics.preScaleForRendering();
  88014. }
  88015. return this._harmonics;
  88016. },
  88017. enumerable: true,
  88018. configurable: true
  88019. });
  88020. /**
  88021. * Adds an ambient color to the spherical polynomial
  88022. * @param color the color to add
  88023. */
  88024. SphericalPolynomial.prototype.addAmbient = function (color) {
  88025. var colorVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  88026. this.xx = this.xx.add(colorVector);
  88027. this.yy = this.yy.add(colorVector);
  88028. this.zz = this.zz.add(colorVector);
  88029. };
  88030. /**
  88031. * Scales the spherical polynomial by the given amount
  88032. * @param scale the amount to scale
  88033. */
  88034. SphericalPolynomial.prototype.scaleInPlace = function (scale) {
  88035. this.x.scaleInPlace(scale);
  88036. this.y.scaleInPlace(scale);
  88037. this.z.scaleInPlace(scale);
  88038. this.xx.scaleInPlace(scale);
  88039. this.yy.scaleInPlace(scale);
  88040. this.zz.scaleInPlace(scale);
  88041. this.yz.scaleInPlace(scale);
  88042. this.zx.scaleInPlace(scale);
  88043. this.xy.scaleInPlace(scale);
  88044. };
  88045. /**
  88046. * Gets the spherical polynomial from harmonics
  88047. * @param harmonics the spherical harmonics
  88048. * @returns the spherical polynomial
  88049. */
  88050. SphericalPolynomial.FromHarmonics = function (harmonics) {
  88051. var result = new SphericalPolynomial();
  88052. result._harmonics = harmonics;
  88053. result.x = harmonics.l11.scale(1.02333).scale(-1);
  88054. result.y = harmonics.l1_1.scale(1.02333).scale(-1);
  88055. result.z = harmonics.l10.scale(1.02333);
  88056. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.l22.scale(0.429043));
  88057. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.l22.scale(0.429043));
  88058. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  88059. result.yz = harmonics.l2_1.scale(0.858086).scale(-1);
  88060. result.zx = harmonics.l21.scale(0.858086).scale(-1);
  88061. result.xy = harmonics.l2_2.scale(0.858086);
  88062. result.scaleInPlace(1.0 / Math.PI);
  88063. return result;
  88064. };
  88065. /**
  88066. * Constructs a spherical polynomial from an array.
  88067. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  88068. * @returns the spherical polynomial
  88069. */
  88070. SphericalPolynomial.FromArray = function (data) {
  88071. var sp = new SphericalPolynomial();
  88072. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  88073. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  88074. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  88075. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  88076. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  88077. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  88078. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  88079. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  88080. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  88081. return sp;
  88082. };
  88083. return SphericalPolynomial;
  88084. }());
  88085. /***/ }),
  88086. /***/ "./Meshes/Builders/boxBuilder.ts":
  88087. /*!***************************************!*\
  88088. !*** ./Meshes/Builders/boxBuilder.ts ***!
  88089. \***************************************/
  88090. /*! exports provided: BoxBuilder */
  88091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88092. "use strict";
  88093. __webpack_require__.r(__webpack_exports__);
  88094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  88095. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  88096. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  88097. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  88098. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  88099. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox = function (options) {
  88100. var nbFaces = 6;
  88101. 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];
  88102. 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];
  88103. var uvs = [];
  88104. var positions = [];
  88105. var width = options.width || options.size || 1;
  88106. var height = options.height || options.size || 1;
  88107. var depth = options.depth || options.size || 1;
  88108. var wrap = options.wrap || false;
  88109. var topBaseAt = (options.topBaseAt === void 0) ? 1 : options.topBaseAt;
  88110. var bottomBaseAt = (options.bottomBaseAt === void 0) ? 0 : options.bottomBaseAt;
  88111. topBaseAt = (topBaseAt + 4) % 4; // places values as 0 to 3
  88112. bottomBaseAt = (bottomBaseAt + 4) % 4; // places values as 0 to 3
  88113. var topOrder = [2, 0, 3, 1];
  88114. var bottomOrder = [2, 0, 1, 3];
  88115. var topIndex = topOrder[topBaseAt];
  88116. var bottomIndex = bottomOrder[bottomBaseAt];
  88117. 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];
  88118. if (wrap) {
  88119. 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];
  88120. 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];
  88121. var topFaceBase = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]];
  88122. var bottomFaceBase = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]];
  88123. var topFaceOrder = [17, 18, 19, 16];
  88124. var bottomFaceOrder = [22, 23, 20, 21];
  88125. while (topIndex > 0) {
  88126. topFaceBase.unshift(topFaceBase.pop());
  88127. topFaceOrder.unshift(topFaceOrder.pop());
  88128. topIndex--;
  88129. }
  88130. while (bottomIndex > 0) {
  88131. bottomFaceBase.unshift(bottomFaceBase.pop());
  88132. bottomFaceOrder.unshift(bottomFaceOrder.pop());
  88133. bottomIndex--;
  88134. }
  88135. topFaceBase = topFaceBase.flat();
  88136. bottomFaceBase = bottomFaceBase.flat();
  88137. basePositions = basePositions.concat(topFaceBase).concat(bottomFaceBase);
  88138. indices.push(topFaceOrder[0], topFaceOrder[2], topFaceOrder[3], topFaceOrder[0], topFaceOrder[1], topFaceOrder[2]);
  88139. indices.push(bottomFaceOrder[0], bottomFaceOrder[2], bottomFaceOrder[3], bottomFaceOrder[0], bottomFaceOrder[1], bottomFaceOrder[2]);
  88140. }
  88141. var scaleArray = [width / 2, height / 2, depth / 2];
  88142. positions = basePositions.reduce(function (accumulator, currentValue, currentIndex) { return accumulator.concat(currentValue * scaleArray[currentIndex % 3]); }, []);
  88143. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  88144. var faceUV = options.faceUV || new Array(6);
  88145. var faceColors = options.faceColors;
  88146. var colors = [];
  88147. // default face colors and UV if undefined
  88148. for (var f = 0; f < 6; f++) {
  88149. if (faceUV[f] === undefined) {
  88150. faceUV[f] = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  88151. }
  88152. if (faceColors && faceColors[f] === undefined) {
  88153. faceColors[f] = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1);
  88154. }
  88155. }
  88156. // Create each face in turn.
  88157. for (var index = 0; index < nbFaces; index++) {
  88158. uvs.push(faceUV[index].z, faceUV[index].w);
  88159. uvs.push(faceUV[index].x, faceUV[index].w);
  88160. uvs.push(faceUV[index].x, faceUV[index].y);
  88161. uvs.push(faceUV[index].z, faceUV[index].y);
  88162. if (faceColors) {
  88163. for (var c = 0; c < 4; c++) {
  88164. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  88165. }
  88166. }
  88167. }
  88168. // sides
  88169. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  88170. // Result
  88171. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  88172. vertexData.indices = indices;
  88173. vertexData.positions = positions;
  88174. vertexData.normals = normals;
  88175. vertexData.uvs = uvs;
  88176. if (faceColors) {
  88177. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  88178. vertexData.colors = totalColors;
  88179. }
  88180. return vertexData;
  88181. };
  88182. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  88183. if (scene === void 0) { scene = null; }
  88184. var options = {
  88185. size: size,
  88186. sideOrientation: sideOrientation,
  88187. updatable: updatable
  88188. };
  88189. return BoxBuilder.CreateBox(name, options, scene);
  88190. };
  88191. /**
  88192. * Class containing static functions to help procedurally build meshes
  88193. */
  88194. var BoxBuilder = /** @class */ (function () {
  88195. function BoxBuilder() {
  88196. }
  88197. /**
  88198. * Creates a box mesh
  88199. * * The parameter `size` sets the size (float) of each box side (default 1)
  88200. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  88201. * * 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)
  88202. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88204. * * 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
  88205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88206. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  88207. * @param name defines the name of the mesh
  88208. * @param options defines the options used to create the mesh
  88209. * @param scene defines the hosting scene
  88210. * @returns the box mesh
  88211. */
  88212. BoxBuilder.CreateBox = function (name, options, scene) {
  88213. if (scene === void 0) { scene = null; }
  88214. var box = new _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"](name, scene);
  88215. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  88216. box._originalBuilderSideOrientation = options.sideOrientation;
  88217. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox(options);
  88218. vertexData.applyToMesh(box, options.updatable);
  88219. return box;
  88220. };
  88221. return BoxBuilder;
  88222. }());
  88223. /***/ }),
  88224. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  88225. /*!********************************************!*\
  88226. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  88227. \********************************************/
  88228. /*! exports provided: CylinderBuilder */
  88229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88230. "use strict";
  88231. __webpack_require__.r(__webpack_exports__);
  88232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  88233. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  88234. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  88235. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  88236. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  88237. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  88238. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math.axis */ "./Maths/math.axis.ts");
  88239. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateCylinder = function (options) {
  88240. var height = options.height || 2;
  88241. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  88242. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  88243. diameterTop = diameterTop || 0.00001; // Prevent broken normals
  88244. diameterBottom = diameterBottom || 0.00001; // Prevent broken normals
  88245. var tessellation = options.tessellation || 24;
  88246. var subdivisions = options.subdivisions || 1;
  88247. var hasRings = options.hasRings ? true : false;
  88248. var enclose = options.enclose ? true : false;
  88249. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CAP_ALL;
  88250. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  88251. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  88252. var faceUV = options.faceUV || new Array(3);
  88253. var faceColors = options.faceColors;
  88254. // default face colors and UV if undefined
  88255. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  88256. var ringNb = (hasRings) ? subdivisions : 1;
  88257. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  88258. var f;
  88259. for (f = 0; f < surfaceNb; f++) {
  88260. if (faceColors && faceColors[f] === undefined) {
  88261. faceColors[f] = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1);
  88262. }
  88263. }
  88264. for (f = 0; f < surfaceNb; f++) {
  88265. if (faceUV && faceUV[f] === undefined) {
  88266. faceUV[f] = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  88267. }
  88268. }
  88269. var indices = new Array();
  88270. var positions = new Array();
  88271. var normals = new Array();
  88272. var uvs = new Array();
  88273. var colors = new Array();
  88274. var angle_step = Math.PI * 2 * arc / tessellation;
  88275. var angle;
  88276. var h;
  88277. var radius;
  88278. var tan = (diameterBottom - diameterTop) / 2 / height;
  88279. var ringVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88280. var ringNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88281. var ringFirstVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88282. var ringFirstNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88283. var quadNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88284. var Y = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Axis"].Y;
  88285. // positions, normals, uvs
  88286. var i;
  88287. var j;
  88288. var r;
  88289. var ringIdx = 1;
  88290. var s = 1; // surface index
  88291. var cs = 0;
  88292. var v = 0;
  88293. for (i = 0; i <= subdivisions; i++) {
  88294. h = i / subdivisions;
  88295. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  88296. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  88297. for (r = 0; r < ringIdx; r++) {
  88298. if (hasRings) {
  88299. s += r;
  88300. }
  88301. if (enclose) {
  88302. s += 2 * r;
  88303. }
  88304. for (j = 0; j <= tessellation; j++) {
  88305. angle = j * angle_step;
  88306. // position
  88307. ringVertex.x = Math.cos(-angle) * radius;
  88308. ringVertex.y = -height / 2 + h * height;
  88309. ringVertex.z = Math.sin(-angle) * radius;
  88310. // normal
  88311. if (diameterTop === 0 && i === subdivisions) {
  88312. // if no top cap, reuse former normals
  88313. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  88314. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  88315. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  88316. }
  88317. else {
  88318. ringNormal.x = ringVertex.x;
  88319. ringNormal.z = ringVertex.z;
  88320. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  88321. ringNormal.normalize();
  88322. }
  88323. // keep first ring vertex values for enclose
  88324. if (j === 0) {
  88325. ringFirstVertex.copyFrom(ringVertex);
  88326. ringFirstNormal.copyFrom(ringNormal);
  88327. }
  88328. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  88329. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  88330. if (hasRings) {
  88331. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  88332. }
  88333. else {
  88334. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  88335. }
  88336. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  88337. if (faceColors) {
  88338. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  88339. }
  88340. }
  88341. // if enclose, add four vertices and their dedicated normals
  88342. if (arc !== 1 && enclose) {
  88343. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  88344. positions.push(0, ringVertex.y, 0);
  88345. positions.push(0, ringVertex.y, 0);
  88346. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  88347. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  88348. quadNormal.normalize();
  88349. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  88350. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  88351. quadNormal.normalize();
  88352. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  88353. if (hasRings) {
  88354. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  88355. }
  88356. else {
  88357. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  88358. }
  88359. uvs.push(faceUV[s + 1].x, v);
  88360. uvs.push(faceUV[s + 1].z, v);
  88361. if (hasRings) {
  88362. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  88363. }
  88364. else {
  88365. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  88366. }
  88367. uvs.push(faceUV[s + 2].x, v);
  88368. uvs.push(faceUV[s + 2].z, v);
  88369. if (faceColors) {
  88370. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  88371. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  88372. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  88373. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  88374. }
  88375. }
  88376. if (cs !== s) {
  88377. cs = s;
  88378. }
  88379. }
  88380. }
  88381. // indices
  88382. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  88383. var s;
  88384. i = 0;
  88385. for (s = 0; s < subdivisions; s++) {
  88386. var i0 = 0;
  88387. var i1 = 0;
  88388. var i2 = 0;
  88389. var i3 = 0;
  88390. for (j = 0; j < tessellation; j++) {
  88391. i0 = i * (e + 1) + j;
  88392. i1 = (i + 1) * (e + 1) + j;
  88393. i2 = i * (e + 1) + (j + 1);
  88394. i3 = (i + 1) * (e + 1) + (j + 1);
  88395. indices.push(i0, i1, i2);
  88396. indices.push(i3, i2, i1);
  88397. }
  88398. if (arc !== 1 && enclose) { // if enclose, add two quads
  88399. indices.push(i0 + 2, i1 + 2, i2 + 2);
  88400. indices.push(i3 + 2, i2 + 2, i1 + 2);
  88401. indices.push(i0 + 4, i1 + 4, i2 + 4);
  88402. indices.push(i3 + 4, i2 + 4, i1 + 4);
  88403. }
  88404. i = (hasRings) ? (i + 2) : (i + 1);
  88405. }
  88406. // Caps
  88407. var createCylinderCap = function (isTop) {
  88408. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  88409. if (radius === 0) {
  88410. return;
  88411. }
  88412. // Cap positions, normals & uvs
  88413. var angle;
  88414. var circleVector;
  88415. var i;
  88416. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  88417. var c = null;
  88418. if (faceColors) {
  88419. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  88420. }
  88421. // cap center
  88422. var vbase = positions.length / 3;
  88423. var offset = isTop ? height / 2 : -height / 2;
  88424. var center = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  88425. positions.push(center.x, center.y, center.z);
  88426. normals.push(0, isTop ? 1 : -1, 0);
  88427. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  88428. if (c) {
  88429. colors.push(c.r, c.g, c.b, c.a);
  88430. }
  88431. var textureScale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  88432. for (i = 0; i <= tessellation; i++) {
  88433. angle = Math.PI * 2 * i * arc / tessellation;
  88434. var cos = Math.cos(-angle);
  88435. var sin = Math.sin(-angle);
  88436. circleVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  88437. var textureCoordinate = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  88438. positions.push(circleVector.x, circleVector.y, circleVector.z);
  88439. normals.push(0, isTop ? 1 : -1, 0);
  88440. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  88441. if (c) {
  88442. colors.push(c.r, c.g, c.b, c.a);
  88443. }
  88444. }
  88445. // Cap indices
  88446. for (i = 0; i < tessellation; i++) {
  88447. if (!isTop) {
  88448. indices.push(vbase);
  88449. indices.push(vbase + (i + 1));
  88450. indices.push(vbase + (i + 2));
  88451. }
  88452. else {
  88453. indices.push(vbase);
  88454. indices.push(vbase + (i + 2));
  88455. indices.push(vbase + (i + 1));
  88456. }
  88457. }
  88458. };
  88459. // add caps to geometry based on cap parameter
  88460. if ((cap === _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CAP_START)
  88461. || (cap === _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CAP_ALL)) {
  88462. createCylinderCap(false);
  88463. }
  88464. if ((cap === _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CAP_END)
  88465. || (cap === _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CAP_ALL)) {
  88466. createCylinderCap(true);
  88467. }
  88468. // Sides
  88469. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  88470. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  88471. vertexData.indices = indices;
  88472. vertexData.positions = positions;
  88473. vertexData.normals = normals;
  88474. vertexData.uvs = uvs;
  88475. if (faceColors) {
  88476. vertexData.colors = colors;
  88477. }
  88478. return vertexData;
  88479. };
  88480. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  88481. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"])) {
  88482. if (scene !== undefined) {
  88483. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DEFAULTSIDE;
  88484. updatable = scene;
  88485. }
  88486. scene = subdivisions;
  88487. subdivisions = 1;
  88488. }
  88489. var options = {
  88490. height: height,
  88491. diameterTop: diameterTop,
  88492. diameterBottom: diameterBottom,
  88493. tessellation: tessellation,
  88494. subdivisions: subdivisions,
  88495. sideOrientation: sideOrientation,
  88496. updatable: updatable
  88497. };
  88498. return CylinderBuilder.CreateCylinder(name, options, scene);
  88499. };
  88500. /**
  88501. * Class containing static functions to help procedurally build meshes
  88502. */
  88503. var CylinderBuilder = /** @class */ (function () {
  88504. function CylinderBuilder() {
  88505. }
  88506. /**
  88507. * Creates a cylinder or a cone mesh
  88508. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  88509. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  88510. * * 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.
  88511. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  88512. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  88513. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  88514. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  88515. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  88516. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  88517. * * 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).
  88518. * * 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
  88519. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  88520. * * 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
  88521. * * 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.
  88522. * * If `enclose` is false, a ring surface is one element.
  88523. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  88524. * * 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
  88525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88526. * * 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
  88527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88528. * @param name defines the name of the mesh
  88529. * @param options defines the options used to create the mesh
  88530. * @param scene defines the hosting scene
  88531. * @returns the cylinder mesh
  88532. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  88533. */
  88534. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  88535. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"](name, scene);
  88536. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  88537. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  88538. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateCylinder(options);
  88539. vertexData.applyToMesh(cylinder, options.updatable);
  88540. return cylinder;
  88541. };
  88542. return CylinderBuilder;
  88543. }());
  88544. /***/ }),
  88545. /***/ "./Meshes/Builders/decalBuilder.ts":
  88546. /*!*****************************************!*\
  88547. !*** ./Meshes/Builders/decalBuilder.ts ***!
  88548. \*****************************************/
  88549. /*! exports provided: DecalBuilder */
  88550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88551. "use strict";
  88552. __webpack_require__.r(__webpack_exports__);
  88553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  88554. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  88555. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  88556. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  88557. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  88558. /* harmony import */ var _Maths_math_vertexFormat__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.vertexFormat */ "./Maths/math.vertexFormat.ts");
  88559. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  88560. var options = {
  88561. position: position,
  88562. normal: normal,
  88563. size: size,
  88564. angle: angle
  88565. };
  88566. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  88567. };
  88568. /**
  88569. * Class containing static functions to help procedurally build meshes
  88570. */
  88571. var DecalBuilder = /** @class */ (function () {
  88572. function DecalBuilder() {
  88573. }
  88574. /**
  88575. * Creates a decal mesh.
  88576. * 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
  88577. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  88578. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  88579. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  88580. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  88581. * @param name defines the name of the mesh
  88582. * @param sourceMesh defines the mesh where the decal must be applied
  88583. * @param options defines the options used to create the mesh
  88584. * @param scene defines the hosting scene
  88585. * @returns the decal mesh
  88586. * @see https://doc.babylonjs.com/how_to/decals
  88587. */
  88588. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  88589. var indices = sourceMesh.getIndices();
  88590. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  88591. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  88592. var position = options.position || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88593. var normal = options.normal || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  88594. var size = options.size || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  88595. var angle = options.angle || 0;
  88596. // Getting correct rotation
  88597. if (!normal) {
  88598. var target = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  88599. var camera = sourceMesh.getScene().activeCamera;
  88600. var cameraWorldTarget = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  88601. normal = camera.globalPosition.subtract(cameraWorldTarget);
  88602. }
  88603. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  88604. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  88605. var pitch = Math.atan2(normal.y, len);
  88606. // Matrix
  88607. var decalWorldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRoll(yaw, pitch, angle).multiply(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(position.x, position.y, position.z));
  88608. var inverseDecalWorldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  88609. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  88610. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  88611. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  88612. vertexData.indices = [];
  88613. vertexData.positions = [];
  88614. vertexData.normals = [];
  88615. vertexData.uvs = [];
  88616. var currentVertexDataIndex = 0;
  88617. var extractDecalVector3 = function (indexId) {
  88618. var result = new _Maths_math_vertexFormat__WEBPACK_IMPORTED_MODULE_4__["PositionNormalVertex"]();
  88619. if (!indices || !positions || !normals) {
  88620. return result;
  88621. }
  88622. var vertexId = indices[indexId];
  88623. result.position = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  88624. // Send vector to decal local world
  88625. result.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  88626. // Get normal
  88627. result.normal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  88628. result.normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  88629. return result;
  88630. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  88631. var clip = function (vertices, axis) {
  88632. if (vertices.length === 0) {
  88633. return vertices;
  88634. }
  88635. var clipSize = 0.5 * Math.abs(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  88636. var clipVertices = function (v0, v1) {
  88637. var clipFactor = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  88638. return new _Maths_math_vertexFormat__WEBPACK_IMPORTED_MODULE_4__["PositionNormalVertex"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.position, v1.position, clipFactor), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.normal, v1.normal, clipFactor));
  88639. };
  88640. var result = new Array();
  88641. for (var index = 0; index < vertices.length; index += 3) {
  88642. var v1Out;
  88643. var v2Out;
  88644. var v3Out;
  88645. var total = 0;
  88646. var nV1 = null;
  88647. var nV2 = null;
  88648. var nV3 = null;
  88649. var nV4 = null;
  88650. var d1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  88651. var d2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  88652. var d3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  88653. v1Out = d1 > 0;
  88654. v2Out = d2 > 0;
  88655. v3Out = d3 > 0;
  88656. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  88657. switch (total) {
  88658. case 0:
  88659. result.push(vertices[index]);
  88660. result.push(vertices[index + 1]);
  88661. result.push(vertices[index + 2]);
  88662. break;
  88663. case 1:
  88664. if (v1Out) {
  88665. nV1 = vertices[index + 1];
  88666. nV2 = vertices[index + 2];
  88667. nV3 = clipVertices(vertices[index], nV1);
  88668. nV4 = clipVertices(vertices[index], nV2);
  88669. }
  88670. if (v2Out) {
  88671. nV1 = vertices[index];
  88672. nV2 = vertices[index + 2];
  88673. nV3 = clipVertices(vertices[index + 1], nV1);
  88674. nV4 = clipVertices(vertices[index + 1], nV2);
  88675. result.push(nV3);
  88676. result.push(nV2.clone());
  88677. result.push(nV1.clone());
  88678. result.push(nV2.clone());
  88679. result.push(nV3.clone());
  88680. result.push(nV4);
  88681. break;
  88682. }
  88683. if (v3Out) {
  88684. nV1 = vertices[index];
  88685. nV2 = vertices[index + 1];
  88686. nV3 = clipVertices(vertices[index + 2], nV1);
  88687. nV4 = clipVertices(vertices[index + 2], nV2);
  88688. }
  88689. if (nV1 && nV2 && nV3 && nV4) {
  88690. result.push(nV1.clone());
  88691. result.push(nV2.clone());
  88692. result.push(nV3);
  88693. result.push(nV4);
  88694. result.push(nV3.clone());
  88695. result.push(nV2.clone());
  88696. }
  88697. break;
  88698. case 2:
  88699. if (!v1Out) {
  88700. nV1 = vertices[index].clone();
  88701. nV2 = clipVertices(nV1, vertices[index + 1]);
  88702. nV3 = clipVertices(nV1, vertices[index + 2]);
  88703. result.push(nV1);
  88704. result.push(nV2);
  88705. result.push(nV3);
  88706. }
  88707. if (!v2Out) {
  88708. nV1 = vertices[index + 1].clone();
  88709. nV2 = clipVertices(nV1, vertices[index + 2]);
  88710. nV3 = clipVertices(nV1, vertices[index]);
  88711. result.push(nV1);
  88712. result.push(nV2);
  88713. result.push(nV3);
  88714. }
  88715. if (!v3Out) {
  88716. nV1 = vertices[index + 2].clone();
  88717. nV2 = clipVertices(nV1, vertices[index]);
  88718. nV3 = clipVertices(nV1, vertices[index + 1]);
  88719. result.push(nV1);
  88720. result.push(nV2);
  88721. result.push(nV3);
  88722. }
  88723. break;
  88724. case 3:
  88725. break;
  88726. }
  88727. }
  88728. return result;
  88729. };
  88730. for (var index = 0; index < indices.length; index += 3) {
  88731. var faceVertices = new Array();
  88732. faceVertices.push(extractDecalVector3(index));
  88733. faceVertices.push(extractDecalVector3(index + 1));
  88734. faceVertices.push(extractDecalVector3(index + 2));
  88735. // Clip
  88736. faceVertices = clip(faceVertices, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  88737. faceVertices = clip(faceVertices, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  88738. faceVertices = clip(faceVertices, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  88739. faceVertices = clip(faceVertices, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  88740. faceVertices = clip(faceVertices, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  88741. faceVertices = clip(faceVertices, new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  88742. if (faceVertices.length === 0) {
  88743. continue;
  88744. }
  88745. // Add UVs and get back to world
  88746. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  88747. var vertex = faceVertices[vIndex];
  88748. //TODO check for Int32Array | Uint32Array | Uint16Array
  88749. vertexData.indices.push(currentVertexDataIndex);
  88750. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  88751. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  88752. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  88753. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  88754. currentVertexDataIndex++;
  88755. }
  88756. }
  88757. // Return mesh
  88758. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  88759. vertexData.applyToMesh(decal);
  88760. decal.position = position.clone();
  88761. decal.rotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  88762. return decal;
  88763. };
  88764. return DecalBuilder;
  88765. }());
  88766. /***/ }),
  88767. /***/ "./Meshes/Builders/discBuilder.ts":
  88768. /*!****************************************!*\
  88769. !*** ./Meshes/Builders/discBuilder.ts ***!
  88770. \****************************************/
  88771. /*! exports provided: DiscBuilder */
  88772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88773. "use strict";
  88774. __webpack_require__.r(__webpack_exports__);
  88775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  88776. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  88777. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  88778. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  88779. var positions = new Array();
  88780. var indices = new Array();
  88781. var normals = new Array();
  88782. var uvs = new Array();
  88783. var radius = options.radius || 0.5;
  88784. var tessellation = options.tessellation || 64;
  88785. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  88786. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  88787. // positions and uvs
  88788. positions.push(0, 0, 0); // disc center first
  88789. uvs.push(0.5, 0.5);
  88790. var theta = Math.PI * 2 * arc;
  88791. var step = theta / tessellation;
  88792. for (var a = 0; a < theta; a += step) {
  88793. var x = Math.cos(a);
  88794. var y = Math.sin(a);
  88795. var u = (x + 1) / 2;
  88796. var v = (1 - y) / 2;
  88797. positions.push(radius * x, radius * y, 0);
  88798. uvs.push(u, v);
  88799. }
  88800. if (arc === 1) {
  88801. positions.push(positions[3], positions[4], positions[5]); // close the circle
  88802. uvs.push(uvs[2], uvs[3]);
  88803. }
  88804. //indices
  88805. var vertexNb = positions.length / 3;
  88806. for (var i = 1; i < vertexNb - 1; i++) {
  88807. indices.push(i + 1, 0, i);
  88808. }
  88809. // result
  88810. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  88811. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  88812. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  88813. vertexData.indices = indices;
  88814. vertexData.positions = positions;
  88815. vertexData.normals = normals;
  88816. vertexData.uvs = uvs;
  88817. return vertexData;
  88818. };
  88819. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  88820. if (scene === void 0) { scene = null; }
  88821. var options = {
  88822. radius: radius,
  88823. tessellation: tessellation,
  88824. sideOrientation: sideOrientation,
  88825. updatable: updatable
  88826. };
  88827. return DiscBuilder.CreateDisc(name, options, scene);
  88828. };
  88829. /**
  88830. * Class containing static functions to help procedurally build meshes
  88831. */
  88832. var DiscBuilder = /** @class */ (function () {
  88833. function DiscBuilder() {
  88834. }
  88835. /**
  88836. * Creates a plane polygonal mesh. By default, this is a disc
  88837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88838. * * 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
  88839. * * 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
  88840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88841. * * 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
  88842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88843. * @param name defines the name of the mesh
  88844. * @param options defines the options used to create the mesh
  88845. * @param scene defines the hosting scene
  88846. * @returns the plane polygonal mesh
  88847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88848. */
  88849. DiscBuilder.CreateDisc = function (name, options, scene) {
  88850. if (scene === void 0) { scene = null; }
  88851. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  88852. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  88853. disc._originalBuilderSideOrientation = options.sideOrientation;
  88854. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  88855. vertexData.applyToMesh(disc, options.updatable);
  88856. return disc;
  88857. };
  88858. return DiscBuilder;
  88859. }());
  88860. /***/ }),
  88861. /***/ "./Meshes/Builders/groundBuilder.ts":
  88862. /*!******************************************!*\
  88863. !*** ./Meshes/Builders/groundBuilder.ts ***!
  88864. \******************************************/
  88865. /*! exports provided: GroundBuilder */
  88866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88867. "use strict";
  88868. __webpack_require__.r(__webpack_exports__);
  88869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  88870. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  88871. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  88872. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  88873. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  88874. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  88875. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  88876. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  88877. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Maths/math.constants */ "./Maths/math.constants.ts");
  88878. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateGround = function (options) {
  88879. var indices = [];
  88880. var positions = [];
  88881. var normals = [];
  88882. var uvs = [];
  88883. var row, col;
  88884. var width = options.width || 1;
  88885. var height = options.height || 1;
  88886. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  88887. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  88888. for (row = 0; row <= subdivisionsY; row++) {
  88889. for (col = 0; col <= subdivisionsX; col++) {
  88890. var position = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  88891. var normal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  88892. positions.push(position.x, position.y, position.z);
  88893. normals.push(normal.x, normal.y, normal.z);
  88894. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  88895. }
  88896. }
  88897. for (row = 0; row < subdivisionsY; row++) {
  88898. for (col = 0; col < subdivisionsX; col++) {
  88899. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  88900. indices.push(col + 1 + row * (subdivisionsX + 1));
  88901. indices.push(col + row * (subdivisionsX + 1));
  88902. indices.push(col + (row + 1) * (subdivisionsX + 1));
  88903. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  88904. indices.push(col + row * (subdivisionsX + 1));
  88905. }
  88906. }
  88907. // Result
  88908. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  88909. vertexData.indices = indices;
  88910. vertexData.positions = positions;
  88911. vertexData.normals = normals;
  88912. vertexData.uvs = uvs;
  88913. return vertexData;
  88914. };
  88915. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledGround = function (options) {
  88916. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  88917. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  88918. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  88919. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  88920. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  88921. var precision = options.precision || { w: 1, h: 1 };
  88922. var indices = new Array();
  88923. var positions = new Array();
  88924. var normals = new Array();
  88925. var uvs = new Array();
  88926. var row, col, tileRow, tileCol;
  88927. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  88928. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  88929. precision.w = (precision.w < 1) ? 1 : precision.w;
  88930. precision.h = (precision.h < 1) ? 1 : precision.h;
  88931. var tileSize = {
  88932. 'w': (xmax - xmin) / subdivisions.w,
  88933. 'h': (zmax - zmin) / subdivisions.h
  88934. };
  88935. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  88936. // Indices
  88937. var base = positions.length / 3;
  88938. var rowLength = precision.w + 1;
  88939. for (row = 0; row < precision.h; row++) {
  88940. for (col = 0; col < precision.w; col++) {
  88941. var square = [
  88942. base + col + row * rowLength,
  88943. base + (col + 1) + row * rowLength,
  88944. base + (col + 1) + (row + 1) * rowLength,
  88945. base + col + (row + 1) * rowLength
  88946. ];
  88947. indices.push(square[1]);
  88948. indices.push(square[2]);
  88949. indices.push(square[3]);
  88950. indices.push(square[0]);
  88951. indices.push(square[1]);
  88952. indices.push(square[3]);
  88953. }
  88954. }
  88955. // Position, normals and uvs
  88956. var position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88957. var normal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  88958. for (row = 0; row <= precision.h; row++) {
  88959. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  88960. for (col = 0; col <= precision.w; col++) {
  88961. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  88962. position.y = 0;
  88963. positions.push(position.x, position.y, position.z);
  88964. normals.push(normal.x, normal.y, normal.z);
  88965. uvs.push(col / precision.w, row / precision.h);
  88966. }
  88967. }
  88968. }
  88969. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  88970. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  88971. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  88972. }
  88973. }
  88974. // Result
  88975. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  88976. vertexData.indices = indices;
  88977. vertexData.positions = positions;
  88978. vertexData.normals = normals;
  88979. vertexData.uvs = uvs;
  88980. return vertexData;
  88981. };
  88982. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateGroundFromHeightMap = function (options) {
  88983. var indices = [];
  88984. var positions = [];
  88985. var normals = [];
  88986. var uvs = [];
  88987. var row, col;
  88988. var filter = options.colorFilter || new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.59, 0.11);
  88989. var alphaFilter = options.alphaFilter || 0.0;
  88990. var invert = false;
  88991. if (options.minHeight > options.maxHeight) {
  88992. invert = true;
  88993. var temp = options.maxHeight;
  88994. options.maxHeight = options.minHeight;
  88995. options.minHeight = temp;
  88996. }
  88997. // Vertices
  88998. for (row = 0; row <= options.subdivisions; row++) {
  88999. for (col = 0; col <= options.subdivisions; col++) {
  89000. var position = new _Maths_math_vector__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));
  89001. // Compute height
  89002. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  89003. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  89004. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  89005. var r = options.buffer[pos] / 255.0;
  89006. var g = options.buffer[pos + 1] / 255.0;
  89007. var b = options.buffer[pos + 2] / 255.0;
  89008. var a = options.buffer[pos + 3] / 255.0;
  89009. if (invert) {
  89010. r = 1.0 - r;
  89011. g = 1.0 - g;
  89012. b = 1.0 - b;
  89013. }
  89014. var gradient = r * filter.r + g * filter.g + b * filter.b;
  89015. // If our alpha channel is not within our filter then we will assign a 'special' height
  89016. // Then when building the indices, we will ignore any vertex that is using the special height
  89017. if (a >= alphaFilter) {
  89018. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  89019. }
  89020. else {
  89021. position.y = options.minHeight - _Maths_math_constants__WEBPACK_IMPORTED_MODULE_7__["Epsilon"]; // We can't have a height below minHeight, normally.
  89022. }
  89023. // Add vertex
  89024. positions.push(position.x, position.y, position.z);
  89025. normals.push(0, 0, 0);
  89026. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  89027. }
  89028. }
  89029. // Indices
  89030. for (row = 0; row < options.subdivisions; row++) {
  89031. for (col = 0; col < options.subdivisions; col++) {
  89032. // Calculate Indices
  89033. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  89034. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  89035. var idx3 = (col + row * (options.subdivisions + 1));
  89036. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  89037. // Check that all indices are visible (based on our special height)
  89038. // Only display the vertex if all Indices are visible
  89039. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  89040. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  89041. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  89042. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  89043. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  89044. indices.push(idx1);
  89045. indices.push(idx2);
  89046. indices.push(idx3);
  89047. }
  89048. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  89049. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  89050. indices.push(idx4);
  89051. indices.push(idx1);
  89052. indices.push(idx3);
  89053. }
  89054. }
  89055. }
  89056. // Normals
  89057. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  89058. // Result
  89059. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  89060. vertexData.indices = indices;
  89061. vertexData.positions = positions;
  89062. vertexData.normals = normals;
  89063. vertexData.uvs = uvs;
  89064. return vertexData;
  89065. };
  89066. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  89067. var options = {
  89068. width: width,
  89069. height: height,
  89070. subdivisions: subdivisions,
  89071. updatable: updatable
  89072. };
  89073. return GroundBuilder.CreateGround(name, options, scene);
  89074. };
  89075. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  89076. var options = {
  89077. xmin: xmin,
  89078. zmin: zmin,
  89079. xmax: xmax,
  89080. zmax: zmax,
  89081. subdivisions: subdivisions,
  89082. precision: precision,
  89083. updatable: updatable
  89084. };
  89085. return GroundBuilder.CreateTiledGround(name, options, scene);
  89086. };
  89087. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  89088. var options = {
  89089. width: width,
  89090. height: height,
  89091. subdivisions: subdivisions,
  89092. minHeight: minHeight,
  89093. maxHeight: maxHeight,
  89094. updatable: updatable,
  89095. onReady: onReady,
  89096. alphaFilter: alphaFilter
  89097. };
  89098. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  89099. };
  89100. /**
  89101. * Class containing static functions to help procedurally build meshes
  89102. */
  89103. var GroundBuilder = /** @class */ (function () {
  89104. function GroundBuilder() {
  89105. }
  89106. /**
  89107. * Creates a ground mesh
  89108. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  89109. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  89110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89111. * @param name defines the name of the mesh
  89112. * @param options defines the options used to create the mesh
  89113. * @param scene defines the hosting scene
  89114. * @returns the ground mesh
  89115. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  89116. */
  89117. GroundBuilder.CreateGround = function (name, options, scene) {
  89118. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_4__["GroundMesh"](name, scene);
  89119. ground._setReady(false);
  89120. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  89121. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  89122. ground._width = options.width || 1;
  89123. ground._height = options.height || 1;
  89124. ground._maxX = ground._width / 2;
  89125. ground._maxZ = ground._height / 2;
  89126. ground._minX = -ground._maxX;
  89127. ground._minZ = -ground._maxZ;
  89128. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateGround(options);
  89129. vertexData.applyToMesh(ground, options.updatable);
  89130. ground._setReady(true);
  89131. return ground;
  89132. };
  89133. /**
  89134. * Creates a tiled ground mesh
  89135. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  89136. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  89137. * * 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
  89138. * * 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
  89139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89140. * @param name defines the name of the mesh
  89141. * @param options defines the options used to create the mesh
  89142. * @param scene defines the hosting scene
  89143. * @returns the tiled ground mesh
  89144. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  89145. */
  89146. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  89147. if (scene === void 0) { scene = null; }
  89148. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"](name, scene);
  89149. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledGround(options);
  89150. vertexData.applyToMesh(tiledGround, options.updatable);
  89151. return tiledGround;
  89152. };
  89153. /**
  89154. * Creates a ground mesh from a height map
  89155. * * The parameter `url` sets the URL of the height map image resource.
  89156. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  89157. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  89158. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  89159. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  89160. * * 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.
  89161. * * 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).
  89162. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89164. * @param name defines the name of the mesh
  89165. * @param url defines the url to the height map
  89166. * @param options defines the options used to create the mesh
  89167. * @param scene defines the hosting scene
  89168. * @returns the ground mesh
  89169. * @see https://doc.babylonjs.com/babylon101/height_map
  89170. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  89171. */
  89172. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  89173. if (scene === void 0) { scene = null; }
  89174. var width = options.width || 10.0;
  89175. var height = options.height || 10.0;
  89176. var subdivisions = options.subdivisions || 1 | 0;
  89177. var minHeight = options.minHeight || 0.0;
  89178. var maxHeight = options.maxHeight || 1.0;
  89179. var filter = options.colorFilter || new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.59, 0.11);
  89180. var alphaFilter = options.alphaFilter || 0.0;
  89181. var updatable = options.updatable;
  89182. var onReady = options.onReady;
  89183. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  89184. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_4__["GroundMesh"](name, scene);
  89185. ground._subdivisionsX = subdivisions;
  89186. ground._subdivisionsY = subdivisions;
  89187. ground._width = width;
  89188. ground._height = height;
  89189. ground._maxX = ground._width / 2.0;
  89190. ground._maxZ = ground._height / 2.0;
  89191. ground._minX = -ground._maxX;
  89192. ground._minZ = -ground._maxZ;
  89193. ground._setReady(false);
  89194. var onload = function (img) {
  89195. // Getting height map data
  89196. var canvas = document.createElement("canvas");
  89197. var context = canvas.getContext("2d");
  89198. if (!context) {
  89199. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  89200. }
  89201. if (scene.isDisposed) {
  89202. return;
  89203. }
  89204. var bufferWidth = img.width;
  89205. var bufferHeight = img.height;
  89206. canvas.width = bufferWidth;
  89207. canvas.height = bufferHeight;
  89208. context.drawImage(img, 0, 0);
  89209. // Create VertexData from map data
  89210. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  89211. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  89212. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateGroundFromHeightMap({
  89213. width: width, height: height,
  89214. subdivisions: subdivisions,
  89215. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  89216. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  89217. alphaFilter: alphaFilter
  89218. });
  89219. vertexData.applyToMesh(ground, updatable);
  89220. //execute ready callback, if set
  89221. if (onReady) {
  89222. onReady(ground);
  89223. }
  89224. ground._setReady(true);
  89225. };
  89226. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  89227. return ground;
  89228. };
  89229. return GroundBuilder;
  89230. }());
  89231. /***/ }),
  89232. /***/ "./Meshes/Builders/hemisphereBuilder.ts":
  89233. /*!**********************************************!*\
  89234. !*** ./Meshes/Builders/hemisphereBuilder.ts ***!
  89235. \**********************************************/
  89236. /*! exports provided: HemisphereBuilder */
  89237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89238. "use strict";
  89239. __webpack_require__.r(__webpack_exports__);
  89240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return HemisphereBuilder; });
  89241. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  89242. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  89243. /**
  89244. * Creates a hemispheric light
  89245. */
  89246. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateHemisphere = function (name, segments, diameter, scene) {
  89247. var options = {
  89248. segments: segments,
  89249. diameter: diameter
  89250. };
  89251. return HemisphereBuilder.CreateHemisphere(name, options, scene);
  89252. };
  89253. /**
  89254. * Class containing static functions to help procedurally build meshes
  89255. */
  89256. var HemisphereBuilder = /** @class */ (function () {
  89257. function HemisphereBuilder() {
  89258. }
  89259. /**
  89260. * Creates a hemisphere mesh
  89261. * @param name defines the name of the mesh
  89262. * @param options defines the options used to create the mesh
  89263. * @param scene defines the hosting scene
  89264. * @returns the hemisphere mesh
  89265. */
  89266. HemisphereBuilder.CreateHemisphere = function (name, options, scene) {
  89267. if (!options.diameter) {
  89268. options.diameter = 1;
  89269. }
  89270. if (!options.segments) {
  89271. options.segments = 16;
  89272. }
  89273. var halfSphere = _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  89274. var disc = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc("", options.diameter / 2, (options.segments * 3) + (4 - options.segments), scene);
  89275. disc.rotation.x = -Math.PI / 2;
  89276. disc.parent = halfSphere;
  89277. var merged = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].MergeMeshes([disc, halfSphere], true);
  89278. merged.name = name;
  89279. return merged;
  89280. };
  89281. return HemisphereBuilder;
  89282. }());
  89283. /***/ }),
  89284. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  89285. /*!*********************************************!*\
  89286. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  89287. \*********************************************/
  89288. /*! exports provided: IcoSphereBuilder */
  89289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89290. "use strict";
  89291. __webpack_require__.r(__webpack_exports__);
  89292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  89293. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  89294. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  89295. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  89296. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  89297. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  89298. var radius = options.radius || 1;
  89299. var flat = (options.flat === undefined) ? true : options.flat;
  89300. var subdivisions = options.subdivisions || 4;
  89301. var radiusX = options.radiusX || radius;
  89302. var radiusY = options.radiusY || radius;
  89303. var radiusZ = options.radiusZ || radius;
  89304. var t = (1 + Math.sqrt(5)) / 2;
  89305. // 12 vertex x,y,z
  89306. var ico_vertices = [
  89307. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  89308. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  89309. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  89310. ];
  89311. // index of 3 vertex makes a face of icopshere
  89312. var ico_indices = [
  89313. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  89314. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  89315. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  89316. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  89317. ];
  89318. // vertex for uv have aliased position, not for UV
  89319. var vertices_unalias_id = [
  89320. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  89321. // vertex alias
  89322. 0,
  89323. 2,
  89324. 3,
  89325. 3,
  89326. 3,
  89327. 4,
  89328. 7,
  89329. 8,
  89330. 9,
  89331. 9,
  89332. 10,
  89333. 11 // 23: B + 12
  89334. ];
  89335. // uv as integer step (not pixels !)
  89336. var ico_vertexuv = [
  89337. 5, 1, 3, 1, 6, 4, 0, 0,
  89338. 5, 3, 4, 2, 2, 2, 4, 0,
  89339. 2, 0, 1, 1, 6, 0, 6, 2,
  89340. // vertex alias (for same vertex on different faces)
  89341. 0, 4,
  89342. 3, 3,
  89343. 4, 4,
  89344. 3, 1,
  89345. 4, 2,
  89346. 4, 4,
  89347. 0, 2,
  89348. 1, 1,
  89349. 2, 2,
  89350. 3, 3,
  89351. 1, 3,
  89352. 2, 4 // 23: B + 12
  89353. ];
  89354. // Vertices[0, 1, ...9, A, B] : position on UV plane
  89355. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  89356. // First island of uv mapping
  89357. // v = 4h 3+ 2
  89358. // v = 3h 9+ 4
  89359. // v = 2h 9+ 5 B
  89360. // v = 1h 9 1 0
  89361. // v = 0h 3 8 7 A
  89362. // u = 0 1 2 3 4 5 6 *a
  89363. // Second island of uv mapping
  89364. // v = 4h 0+ B+ 4+
  89365. // v = 3h A+ 2+
  89366. // v = 2h 7+ 6 3+
  89367. // v = 1h 8+ 3+
  89368. // v = 0h
  89369. // u = 0 1 2 3 4 5 6 *a
  89370. // Face layout on texture UV mapping
  89371. // ============
  89372. // \ 4 /\ 16 / ======
  89373. // \ / \ / /\ 11 /
  89374. // \/ 7 \/ / \ /
  89375. // ======= / 10 \/
  89376. // /\ 17 /\ =======
  89377. // / \ / \ \ 15 /\
  89378. // / 8 \/ 12 \ \ / \
  89379. // ============ \/ 6 \
  89380. // \ 18 /\ ============
  89381. // \ / \ \ 5 /\ 0 /
  89382. // \/ 13 \ \ / \ /
  89383. // ======= \/ 1 \/
  89384. // =============
  89385. // /\ 19 /\ 2 /\
  89386. // / \ / \ / \
  89387. // / 14 \/ 9 \/ 3 \
  89388. // ===================
  89389. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  89390. var ustep = 138 / 1024;
  89391. var vstep = 239 / 1024;
  89392. var uoffset = 60 / 1024;
  89393. var voffset = 26 / 1024;
  89394. // Second island should have margin, not to touch the first island
  89395. // avoid any borderline artefact in pixel rounding
  89396. var island_u_offset = -40 / 1024;
  89397. var island_v_offset = +20 / 1024;
  89398. // face is either island 0 or 1 :
  89399. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  89400. var island = [
  89401. 0, 0, 0, 0, 1,
  89402. 0, 0, 1, 1, 0,
  89403. 0, 0, 1, 1, 0,
  89404. 0, 1, 1, 1, 0 // 15 - 19
  89405. ];
  89406. var indices = new Array();
  89407. var positions = new Array();
  89408. var normals = new Array();
  89409. var uvs = new Array();
  89410. var current_indice = 0;
  89411. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  89412. var face_vertex_pos = new Array(3);
  89413. var face_vertex_uv = new Array(3);
  89414. var v012;
  89415. for (v012 = 0; v012 < 3; v012++) {
  89416. face_vertex_pos[v012] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89417. face_vertex_uv[v012] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  89418. }
  89419. // create all with normals
  89420. for (var face = 0; face < 20; face++) {
  89421. // 3 vertex per face
  89422. for (v012 = 0; v012 < 3; v012++) {
  89423. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  89424. var v_id = ico_indices[3 * face + v012];
  89425. // vertex have 3D position (x,y,z)
  89426. 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]);
  89427. // Normalize to get normal, then scale to radius
  89428. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  89429. // uv Coordinates from vertex ID
  89430. 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);
  89431. }
  89432. // Subdivide the face (interpolate pos, norm, uv)
  89433. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  89434. // - norm is linear interpolation of vertex corner normal
  89435. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  89436. // - uv is linear interpolation
  89437. //
  89438. // Topology is as below for sub-divide by 2
  89439. // vertex shown as v0,v1,v2
  89440. // interp index is i1 to progress in range [v0,v1[
  89441. // interp index is i2 to progress in range [v0,v2[
  89442. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  89443. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  89444. //
  89445. //
  89446. // i2 v2
  89447. // ^ ^
  89448. // / / \
  89449. // / / \
  89450. // / / \
  89451. // / / (0,1) \
  89452. // / #---------\
  89453. // / / \ (0,0)'/ \
  89454. // / / \ / \
  89455. // / / \ / \
  89456. // / / (0,0) \ / (1,0) \
  89457. // / #---------#---------\
  89458. // v0 v1
  89459. //
  89460. // --------------------> i1
  89461. //
  89462. // interp of (i1,i2):
  89463. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  89464. // along i1 : lerp(x0,x1, i1/(S-i2))
  89465. //
  89466. // centroid of triangle is needed to get help normal computation
  89467. // (c1,c2) are used for centroid location
  89468. var interp_vertex = function (i1, i2, c1, c2) {
  89469. // vertex is interpolated from
  89470. // - face_vertex_pos[0..2]
  89471. // - face_vertex_uv[0..2]
  89472. var pos_x0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  89473. var pos_x1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  89474. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  89475. pos_interp.normalize();
  89476. var vertex_normal;
  89477. if (flat) {
  89478. // in flat mode, recalculate normal as face centroid normal
  89479. var centroid_x0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  89480. var centroid_x1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  89481. vertex_normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  89482. }
  89483. else {
  89484. // in smooth mode, recalculate normal from each single vertex position
  89485. vertex_normal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  89486. }
  89487. // Vertex normal need correction due to X,Y,Z radius scaling
  89488. vertex_normal.x /= radiusX;
  89489. vertex_normal.y /= radiusY;
  89490. vertex_normal.z /= radiusZ;
  89491. vertex_normal.normalize();
  89492. var uv_x0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  89493. var uv_x1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  89494. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  89495. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  89496. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  89497. uvs.push(uv_interp.x, uv_interp.y);
  89498. // push each vertex has member of a face
  89499. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  89500. indices.push(current_indice);
  89501. current_indice++;
  89502. };
  89503. for (var i2 = 0; i2 < subdivisions; i2++) {
  89504. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  89505. // face : (i1,i2) for /\ :
  89506. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  89507. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  89508. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  89509. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  89510. if (i1 + i2 + 1 < subdivisions) {
  89511. // face : (i1,i2)' for \/ :
  89512. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  89513. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  89514. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  89515. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  89516. }
  89517. }
  89518. }
  89519. }
  89520. // Sides
  89521. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  89522. // Result
  89523. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  89524. vertexData.indices = indices;
  89525. vertexData.positions = positions;
  89526. vertexData.normals = normals;
  89527. vertexData.uvs = uvs;
  89528. return vertexData;
  89529. };
  89530. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  89531. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  89532. };
  89533. /**
  89534. * Class containing static functions to help procedurally build meshes
  89535. */
  89536. var IcoSphereBuilder = /** @class */ (function () {
  89537. function IcoSphereBuilder() {
  89538. }
  89539. /**
  89540. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89541. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89542. * * 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`)
  89543. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89544. * * 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
  89545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89546. * * 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
  89547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89548. * @param name defines the name of the mesh
  89549. * @param options defines the options used to create the mesh
  89550. * @param scene defines the hosting scene
  89551. * @returns the icosahedron mesh
  89552. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89553. */
  89554. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  89555. if (scene === void 0) { scene = null; }
  89556. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  89557. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  89558. sphere._originalBuilderSideOrientation = options.sideOrientation;
  89559. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  89560. vertexData.applyToMesh(sphere, options.updatable);
  89561. return sphere;
  89562. };
  89563. return IcoSphereBuilder;
  89564. }());
  89565. /***/ }),
  89566. /***/ "./Meshes/Builders/index.ts":
  89567. /*!**********************************!*\
  89568. !*** ./Meshes/Builders/index.ts ***!
  89569. \**********************************/
  89570. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, TiledBoxBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TiledPlaneBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  89571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89572. "use strict";
  89573. __webpack_require__.r(__webpack_exports__);
  89574. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  89575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  89576. /* harmony import */ var _tiledBoxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tiledBoxBuilder */ "./Meshes/Builders/tiledBoxBuilder.ts");
  89577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledBoxBuilder", function() { return _tiledBoxBuilder__WEBPACK_IMPORTED_MODULE_1__["TiledBoxBuilder"]; });
  89578. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  89579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_2__["DiscBuilder"]; });
  89580. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  89581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_3__["RibbonBuilder"]; });
  89582. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  89583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_4__["SphereBuilder"]; });
  89584. /* harmony import */ var _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  89585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_5__["HemisphereBuilder"]; });
  89586. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  89587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_6__["CylinderBuilder"]; });
  89588. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  89589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusBuilder"]; });
  89590. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  89591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_8__["TorusKnotBuilder"]; });
  89592. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  89593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_9__["LinesBuilder"]; });
  89594. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  89595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_10__["PolygonBuilder"]; });
  89596. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  89597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_11__["ShapeBuilder"]; });
  89598. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  89599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_12__["LatheBuilder"]; });
  89600. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  89601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_13__["PlaneBuilder"]; });
  89602. /* harmony import */ var _tiledPlaneBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tiledPlaneBuilder */ "./Meshes/Builders/tiledPlaneBuilder.ts");
  89603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledPlaneBuilder", function() { return _tiledPlaneBuilder__WEBPACK_IMPORTED_MODULE_14__["TiledPlaneBuilder"]; });
  89604. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  89605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_15__["GroundBuilder"]; });
  89606. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  89607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_16__["TubeBuilder"]; });
  89608. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  89609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  89610. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  89611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_18__["IcoSphereBuilder"]; });
  89612. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  89613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_19__["DecalBuilder"]; });
  89614. /***/ }),
  89615. /***/ "./Meshes/Builders/latheBuilder.ts":
  89616. /*!*****************************************!*\
  89617. !*** ./Meshes/Builders/latheBuilder.ts ***!
  89618. \*****************************************/
  89619. /*! exports provided: LatheBuilder */
  89620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89621. "use strict";
  89622. __webpack_require__.r(__webpack_exports__);
  89623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  89624. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  89625. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  89626. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  89627. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  89628. var options = {
  89629. shape: shape,
  89630. radius: radius,
  89631. tessellation: tessellation,
  89632. sideOrientation: sideOrientation,
  89633. updatable: updatable
  89634. };
  89635. return LatheBuilder.CreateLathe(name, options, scene);
  89636. };
  89637. /**
  89638. * Class containing static functions to help procedurally build meshes
  89639. */
  89640. var LatheBuilder = /** @class */ (function () {
  89641. function LatheBuilder() {
  89642. }
  89643. /**
  89644. * Creates lathe mesh.
  89645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  89646. * * 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
  89647. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  89648. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  89649. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  89650. * * 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
  89651. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  89652. * * 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
  89653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  89656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89657. * @param name defines the name of the mesh
  89658. * @param options defines the options used to create the mesh
  89659. * @param scene defines the hosting scene
  89660. * @returns the lathe mesh
  89661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  89662. */
  89663. LatheBuilder.CreateLathe = function (name, options, scene) {
  89664. if (scene === void 0) { scene = null; }
  89665. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  89666. var closed = (options.closed === undefined) ? true : options.closed;
  89667. var shape = options.shape;
  89668. var radius = options.radius || 1;
  89669. var tessellation = options.tessellation || 64;
  89670. var clip = options.clip || 0;
  89671. var updatable = options.updatable;
  89672. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  89673. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  89674. var pi2 = Math.PI * 2;
  89675. var paths = new Array();
  89676. var invertUV = options.invertUV || false;
  89677. var i = 0;
  89678. var p = 0;
  89679. var step = pi2 / tessellation * arc;
  89680. var rotated;
  89681. var path = new Array();
  89682. for (i = 0; i <= tessellation - clip; i++) {
  89683. var path = [];
  89684. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  89685. path.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  89686. path.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[0].x * radius, shape[0].y, Math.sin(i * step) * shape[0].x * radius));
  89687. }
  89688. for (p = 0; p < shape.length; p++) {
  89689. rotated = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[p].x * radius, shape[p].y, Math.sin(i * step) * shape[p].x * radius);
  89690. path.push(rotated);
  89691. }
  89692. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  89693. path.push(new _Maths_math_vector__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));
  89694. path.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  89695. }
  89696. paths.push(path);
  89697. }
  89698. // lathe ribbon
  89699. 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);
  89700. return lathe;
  89701. };
  89702. return LatheBuilder;
  89703. }());
  89704. /***/ }),
  89705. /***/ "./Meshes/Builders/linesBuilder.ts":
  89706. /*!*****************************************!*\
  89707. !*** ./Meshes/Builders/linesBuilder.ts ***!
  89708. \*****************************************/
  89709. /*! exports provided: LinesBuilder */
  89710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89711. "use strict";
  89712. __webpack_require__.r(__webpack_exports__);
  89713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  89714. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  89715. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  89716. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  89717. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  89718. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  89719. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  89720. var indices = [];
  89721. var positions = [];
  89722. var lines = options.lines;
  89723. var colors = options.colors;
  89724. var vertexColors = [];
  89725. var idx = 0;
  89726. for (var l = 0; l < lines.length; l++) {
  89727. var points = lines[l];
  89728. for (var index = 0; index < points.length; index++) {
  89729. positions.push(points[index].x, points[index].y, points[index].z);
  89730. if (colors) {
  89731. var color = colors[l];
  89732. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  89733. }
  89734. if (index > 0) {
  89735. indices.push(idx - 1);
  89736. indices.push(idx);
  89737. }
  89738. idx++;
  89739. }
  89740. }
  89741. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  89742. vertexData.indices = indices;
  89743. vertexData.positions = positions;
  89744. if (colors) {
  89745. vertexData.colors = vertexColors;
  89746. }
  89747. return vertexData;
  89748. };
  89749. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  89750. var dashSize = options.dashSize || 3;
  89751. var gapSize = options.gapSize || 1;
  89752. var dashNb = options.dashNb || 200;
  89753. var points = options.points;
  89754. var positions = new Array();
  89755. var indices = new Array();
  89756. var curvect = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89757. var lg = 0;
  89758. var nb = 0;
  89759. var shft = 0;
  89760. var dashshft = 0;
  89761. var curshft = 0;
  89762. var idx = 0;
  89763. var i = 0;
  89764. for (i = 0; i < points.length - 1; i++) {
  89765. points[i + 1].subtractToRef(points[i], curvect);
  89766. lg += curvect.length();
  89767. }
  89768. shft = lg / dashNb;
  89769. dashshft = dashSize * shft / (dashSize + gapSize);
  89770. for (i = 0; i < points.length - 1; i++) {
  89771. points[i + 1].subtractToRef(points[i], curvect);
  89772. nb = Math.floor(curvect.length() / shft);
  89773. curvect.normalize();
  89774. for (var j = 0; j < nb; j++) {
  89775. curshft = shft * j;
  89776. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  89777. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  89778. indices.push(idx, idx + 1);
  89779. idx += 2;
  89780. }
  89781. }
  89782. // Result
  89783. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  89784. vertexData.positions = positions;
  89785. vertexData.indices = indices;
  89786. return vertexData;
  89787. };
  89788. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  89789. if (scene === void 0) { scene = null; }
  89790. if (updatable === void 0) { updatable = false; }
  89791. if (instance === void 0) { instance = null; }
  89792. var options = {
  89793. points: points,
  89794. updatable: updatable,
  89795. instance: instance
  89796. };
  89797. return LinesBuilder.CreateLines(name, options, scene);
  89798. };
  89799. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  89800. if (scene === void 0) { scene = null; }
  89801. var options = {
  89802. points: points,
  89803. dashSize: dashSize,
  89804. gapSize: gapSize,
  89805. dashNb: dashNb,
  89806. updatable: updatable,
  89807. instance: instance
  89808. };
  89809. return LinesBuilder.CreateDashedLines(name, options, scene);
  89810. };
  89811. /**
  89812. * Class containing static functions to help procedurally build meshes
  89813. */
  89814. var LinesBuilder = /** @class */ (function () {
  89815. function LinesBuilder() {
  89816. }
  89817. /**
  89818. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  89819. * * 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
  89820. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  89821. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  89822. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  89823. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  89824. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  89825. * * 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
  89826. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  89827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  89829. * @param name defines the name of the new line system
  89830. * @param options defines the options used to create the line system
  89831. * @param scene defines the hosting scene
  89832. * @returns a new line system mesh
  89833. */
  89834. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  89835. var instance = options.instance;
  89836. var lines = options.lines;
  89837. var colors = options.colors;
  89838. if (instance) { // lines update
  89839. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  89840. var vertexColor;
  89841. var lineColors;
  89842. if (colors) {
  89843. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  89844. }
  89845. var i = 0;
  89846. var c = 0;
  89847. for (var l = 0; l < lines.length; l++) {
  89848. var points = lines[l];
  89849. for (var p = 0; p < points.length; p++) {
  89850. positions[i] = points[p].x;
  89851. positions[i + 1] = points[p].y;
  89852. positions[i + 2] = points[p].z;
  89853. if (colors && vertexColor) {
  89854. lineColors = colors[l];
  89855. vertexColor[c] = lineColors[p].r;
  89856. vertexColor[c + 1] = lineColors[p].g;
  89857. vertexColor[c + 2] = lineColors[p].b;
  89858. vertexColor[c + 3] = lineColors[p].a;
  89859. c += 4;
  89860. }
  89861. i += 3;
  89862. }
  89863. }
  89864. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  89865. if (colors && vertexColor) {
  89866. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  89867. }
  89868. return instance;
  89869. }
  89870. // line system creation
  89871. var useVertexColor = (colors) ? true : false;
  89872. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  89873. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  89874. vertexData.applyToMesh(lineSystem, options.updatable);
  89875. return lineSystem;
  89876. };
  89877. /**
  89878. * Creates a line mesh
  89879. * 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
  89880. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  89881. * * The parameter `points` is an array successive Vector3
  89882. * * 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
  89883. * * The optional parameter `colors` is an array of successive Color4, one per line point
  89884. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  89885. * * When updating an instance, remember that only point positions can change, not the number of points
  89886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  89888. * @param name defines the name of the new line system
  89889. * @param options defines the options used to create the line system
  89890. * @param scene defines the hosting scene
  89891. * @returns a new line mesh
  89892. */
  89893. LinesBuilder.CreateLines = function (name, options, scene) {
  89894. if (scene === void 0) { scene = null; }
  89895. var colors = (options.colors) ? [options.colors] : null;
  89896. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  89897. return lines;
  89898. };
  89899. /**
  89900. * Creates a dashed line mesh
  89901. * * 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
  89902. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  89903. * * The parameter `points` is an array successive Vector3
  89904. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  89905. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  89906. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89907. * * 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
  89908. * * When updating an instance, remember that only point positions can change, not the number of points
  89909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89910. * @param name defines the name of the mesh
  89911. * @param options defines the options used to create the mesh
  89912. * @param scene defines the hosting scene
  89913. * @returns the dashed line mesh
  89914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  89915. */
  89916. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  89917. if (scene === void 0) { scene = null; }
  89918. var points = options.points;
  89919. var instance = options.instance;
  89920. var gapSize = options.gapSize || 1;
  89921. var dashSize = options.dashSize || 3;
  89922. if (instance) { // dashed lines update
  89923. var positionFunction = function (positions) {
  89924. var curvect = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89925. var nbSeg = positions.length / 6;
  89926. var lg = 0;
  89927. var nb = 0;
  89928. var shft = 0;
  89929. var dashshft = 0;
  89930. var curshft = 0;
  89931. var p = 0;
  89932. var i = 0;
  89933. var j = 0;
  89934. for (i = 0; i < points.length - 1; i++) {
  89935. points[i + 1].subtractToRef(points[i], curvect);
  89936. lg += curvect.length();
  89937. }
  89938. shft = lg / nbSeg;
  89939. var dashSize = instance._creationDataStorage.dashSize;
  89940. var gapSize = instance._creationDataStorage.gapSize;
  89941. dashshft = dashSize * shft / (dashSize + gapSize);
  89942. for (i = 0; i < points.length - 1; i++) {
  89943. points[i + 1].subtractToRef(points[i], curvect);
  89944. nb = Math.floor(curvect.length() / shft);
  89945. curvect.normalize();
  89946. j = 0;
  89947. while (j < nb && p < positions.length) {
  89948. curshft = shft * j;
  89949. positions[p] = points[i].x + curshft * curvect.x;
  89950. positions[p + 1] = points[i].y + curshft * curvect.y;
  89951. positions[p + 2] = points[i].z + curshft * curvect.z;
  89952. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  89953. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  89954. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  89955. p += 6;
  89956. j++;
  89957. }
  89958. }
  89959. while (p < positions.length) {
  89960. positions[p] = points[i].x;
  89961. positions[p + 1] = points[i].y;
  89962. positions[p + 2] = points[i].z;
  89963. p += 3;
  89964. }
  89965. };
  89966. instance.updateMeshPositions(positionFunction, false);
  89967. return instance;
  89968. }
  89969. // dashed lines creation
  89970. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  89971. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  89972. vertexData.applyToMesh(dashedLines, options.updatable);
  89973. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  89974. dashedLines._creationDataStorage.dashSize = dashSize;
  89975. dashedLines._creationDataStorage.gapSize = gapSize;
  89976. return dashedLines;
  89977. };
  89978. return LinesBuilder;
  89979. }());
  89980. /***/ }),
  89981. /***/ "./Meshes/Builders/planeBuilder.ts":
  89982. /*!*****************************************!*\
  89983. !*** ./Meshes/Builders/planeBuilder.ts ***!
  89984. \*****************************************/
  89985. /*! exports provided: PlaneBuilder */
  89986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89987. "use strict";
  89988. __webpack_require__.r(__webpack_exports__);
  89989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  89990. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  89991. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  89992. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  89993. var indices = [];
  89994. var positions = [];
  89995. var normals = [];
  89996. var uvs = [];
  89997. var width = options.width || options.size || 1;
  89998. var height = options.height || options.size || 1;
  89999. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  90000. // Vertices
  90001. var halfWidth = width / 2.0;
  90002. var halfHeight = height / 2.0;
  90003. positions.push(-halfWidth, -halfHeight, 0);
  90004. normals.push(0, 0, -1.0);
  90005. uvs.push(0.0, 0.0);
  90006. positions.push(halfWidth, -halfHeight, 0);
  90007. normals.push(0, 0, -1.0);
  90008. uvs.push(1.0, 0.0);
  90009. positions.push(halfWidth, halfHeight, 0);
  90010. normals.push(0, 0, -1.0);
  90011. uvs.push(1.0, 1.0);
  90012. positions.push(-halfWidth, halfHeight, 0);
  90013. normals.push(0, 0, -1.0);
  90014. uvs.push(0.0, 1.0);
  90015. // Indices
  90016. indices.push(0);
  90017. indices.push(1);
  90018. indices.push(2);
  90019. indices.push(0);
  90020. indices.push(2);
  90021. indices.push(3);
  90022. // Sides
  90023. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  90024. // Result
  90025. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  90026. vertexData.indices = indices;
  90027. vertexData.positions = positions;
  90028. vertexData.normals = normals;
  90029. vertexData.uvs = uvs;
  90030. return vertexData;
  90031. };
  90032. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  90033. var options = {
  90034. size: size,
  90035. width: size,
  90036. height: size,
  90037. sideOrientation: sideOrientation,
  90038. updatable: updatable
  90039. };
  90040. return PlaneBuilder.CreatePlane(name, options, scene);
  90041. };
  90042. /**
  90043. * Class containing static functions to help procedurally build meshes
  90044. */
  90045. var PlaneBuilder = /** @class */ (function () {
  90046. function PlaneBuilder() {
  90047. }
  90048. /**
  90049. * Creates a plane mesh
  90050. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90051. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90052. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90054. * * 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
  90055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90056. * @param name defines the name of the mesh
  90057. * @param options defines the options used to create the mesh
  90058. * @param scene defines the hosting scene
  90059. * @returns the plane mesh
  90060. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90061. */
  90062. PlaneBuilder.CreatePlane = function (name, options, scene) {
  90063. if (scene === void 0) { scene = null; }
  90064. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  90065. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  90066. plane._originalBuilderSideOrientation = options.sideOrientation;
  90067. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  90068. vertexData.applyToMesh(plane, options.updatable);
  90069. if (options.sourcePlane) {
  90070. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  90071. plane.setDirection(options.sourcePlane.normal.scale(-1));
  90072. }
  90073. return plane;
  90074. };
  90075. return PlaneBuilder;
  90076. }());
  90077. /***/ }),
  90078. /***/ "./Meshes/Builders/polygonBuilder.ts":
  90079. /*!*******************************************!*\
  90080. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  90081. \*******************************************/
  90082. /*! exports provided: PolygonBuilder */
  90083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90084. "use strict";
  90085. __webpack_require__.r(__webpack_exports__);
  90086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  90087. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  90088. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  90089. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  90090. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  90091. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  90092. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  90093. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  90094. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  90095. var faceUV = fUV || new Array(3);
  90096. var faceColors = fColors;
  90097. var colors = [];
  90098. // default face colors and UV if undefined
  90099. for (var f = 0; f < 3; f++) {
  90100. if (faceUV[f] === undefined) {
  90101. faceUV[f] = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  90102. }
  90103. if (faceColors && faceColors[f] === undefined) {
  90104. faceColors[f] = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1);
  90105. }
  90106. }
  90107. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  90108. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  90109. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  90110. var indices = polygon.getIndices();
  90111. // set face colours and textures
  90112. var idx = 0;
  90113. var face = 0;
  90114. for (var index = 0; index < normals.length; index += 3) {
  90115. //Edge Face no. 1
  90116. if (Math.abs(normals[index + 1]) < 0.001) {
  90117. face = 1;
  90118. }
  90119. //Top Face no. 0
  90120. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  90121. face = 0;
  90122. }
  90123. //Bottom Face no. 2
  90124. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  90125. face = 2;
  90126. }
  90127. idx = index / 3;
  90128. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  90129. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  90130. if (faceColors) {
  90131. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  90132. }
  90133. }
  90134. // sides
  90135. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  90136. // Result
  90137. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  90138. vertexData.indices = indices;
  90139. vertexData.positions = positions;
  90140. vertexData.normals = normals;
  90141. vertexData.uvs = uvs;
  90142. if (faceColors) {
  90143. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  90144. vertexData.colors = totalColors;
  90145. }
  90146. return vertexData;
  90147. };
  90148. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  90149. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90150. var options = {
  90151. shape: shape,
  90152. holes: holes,
  90153. updatable: updatable,
  90154. sideOrientation: sideOrientation
  90155. };
  90156. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  90157. };
  90158. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  90159. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90160. var options = {
  90161. shape: shape,
  90162. holes: holes,
  90163. depth: depth,
  90164. updatable: updatable,
  90165. sideOrientation: sideOrientation
  90166. };
  90167. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  90168. };
  90169. /**
  90170. * Class containing static functions to help procedurally build meshes
  90171. */
  90172. var PolygonBuilder = /** @class */ (function () {
  90173. function PolygonBuilder() {
  90174. }
  90175. /**
  90176. * Creates a polygon mesh
  90177. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  90178. * * 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
  90179. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90181. * * 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)
  90182. * * Remember you can only change the shape positions, not their number when updating a polygon
  90183. * @param name defines the name of the mesh
  90184. * @param options defines the options used to create the mesh
  90185. * @param scene defines the hosting scene
  90186. * @param earcutInjection can be used to inject your own earcut reference
  90187. * @returns the polygon mesh
  90188. */
  90189. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  90190. if (scene === void 0) { scene = null; }
  90191. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90192. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  90193. var shape = options.shape;
  90194. var holes = options.holes || [];
  90195. var depth = options.depth || 0;
  90196. var contours = [];
  90197. var hole = [];
  90198. for (var i = 0; i < shape.length; i++) {
  90199. contours[i] = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  90200. }
  90201. var epsilon = 0.00000001;
  90202. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  90203. contours.pop();
  90204. }
  90205. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_4__["PolygonMeshBuilder"](name, contours, scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene, earcutInjection);
  90206. for (var hNb = 0; hNb < holes.length; hNb++) {
  90207. hole = [];
  90208. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  90209. hole.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  90210. }
  90211. polygonTriangulation.addHole(hole);
  90212. }
  90213. var polygon = polygonTriangulation.build(options.updatable, depth);
  90214. polygon._originalBuilderSideOrientation = options.sideOrientation;
  90215. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  90216. vertexData.applyToMesh(polygon, options.updatable);
  90217. return polygon;
  90218. };
  90219. /**
  90220. * Creates an extruded polygon mesh, with depth in the Y direction.
  90221. * * 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)
  90222. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  90223. * @param name defines the name of the mesh
  90224. * @param options defines the options used to create the mesh
  90225. * @param scene defines the hosting scene
  90226. * @param earcutInjection can be used to inject your own earcut reference
  90227. * @returns the polygon mesh
  90228. */
  90229. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  90230. if (scene === void 0) { scene = null; }
  90231. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90232. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  90233. };
  90234. return PolygonBuilder;
  90235. }());
  90236. /***/ }),
  90237. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  90238. /*!**********************************************!*\
  90239. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  90240. \**********************************************/
  90241. /*! exports provided: PolyhedronBuilder */
  90242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90243. "use strict";
  90244. __webpack_require__.r(__webpack_exports__);
  90245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  90246. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  90247. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  90248. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  90249. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  90250. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreatePolyhedron = function (options) {
  90251. // provided polyhedron types :
  90252. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90253. // 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)
  90254. var polyhedra = [];
  90255. 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]] };
  90256. 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]] };
  90257. polyhedra[2] = {
  90258. 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]],
  90259. 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]]
  90260. };
  90261. polyhedra[3] = {
  90262. 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]],
  90263. 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]]
  90264. };
  90265. polyhedra[4] = {
  90266. 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]],
  90267. 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]]
  90268. };
  90269. 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]] };
  90270. 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]] };
  90271. 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]] };
  90272. 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]] };
  90273. 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]] };
  90274. 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]] };
  90275. 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]] };
  90276. 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]] };
  90277. 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]] };
  90278. polyhedra[14] = {
  90279. 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]],
  90280. 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]]
  90281. };
  90282. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  90283. var size = options.size;
  90284. var sizeX = options.sizeX || size || 1;
  90285. var sizeY = options.sizeY || size || 1;
  90286. var sizeZ = options.sizeZ || size || 1;
  90287. var data = options.custom || polyhedra[type];
  90288. var nbfaces = data.face.length;
  90289. var faceUV = options.faceUV || new Array(nbfaces);
  90290. var faceColors = options.faceColors;
  90291. var flat = (options.flat === undefined) ? true : options.flat;
  90292. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  90293. var positions = new Array();
  90294. var indices = new Array();
  90295. var normals = new Array();
  90296. var uvs = new Array();
  90297. var colors = new Array();
  90298. var index = 0;
  90299. var faceIdx = 0; // face cursor in the array "indexes"
  90300. var indexes = new Array();
  90301. var i = 0;
  90302. var f = 0;
  90303. var u, v, ang, x, y, tmp;
  90304. // default face colors and UV if undefined
  90305. if (flat) {
  90306. for (f = 0; f < nbfaces; f++) {
  90307. if (faceColors && faceColors[f] === undefined) {
  90308. faceColors[f] = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1);
  90309. }
  90310. if (faceUV && faceUV[f] === undefined) {
  90311. faceUV[f] = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  90312. }
  90313. }
  90314. }
  90315. if (!flat) {
  90316. for (i = 0; i < data.vertex.length; i++) {
  90317. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  90318. uvs.push(0, 0);
  90319. }
  90320. for (f = 0; f < nbfaces; f++) {
  90321. for (i = 0; i < data.face[f].length - 2; i++) {
  90322. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  90323. }
  90324. }
  90325. }
  90326. else {
  90327. for (f = 0; f < nbfaces; f++) {
  90328. var fl = data.face[f].length; // number of vertices of the current face
  90329. ang = 2 * Math.PI / fl;
  90330. x = 0.5 * Math.tan(ang / 2);
  90331. y = 0.5;
  90332. // positions, uvs, colors
  90333. for (i = 0; i < fl; i++) {
  90334. // positions
  90335. 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);
  90336. indexes.push(index);
  90337. index++;
  90338. // uvs
  90339. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  90340. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  90341. uvs.push(u, v);
  90342. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  90343. y = x * Math.sin(ang) + y * Math.cos(ang);
  90344. x = tmp;
  90345. // colors
  90346. if (faceColors) {
  90347. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  90348. }
  90349. }
  90350. // indices from indexes
  90351. for (i = 0; i < fl - 2; i++) {
  90352. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  90353. }
  90354. faceIdx += fl;
  90355. }
  90356. }
  90357. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  90358. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  90359. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  90360. vertexData.positions = positions;
  90361. vertexData.indices = indices;
  90362. vertexData.normals = normals;
  90363. vertexData.uvs = uvs;
  90364. if (faceColors && flat) {
  90365. vertexData.colors = colors;
  90366. }
  90367. return vertexData;
  90368. };
  90369. _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  90370. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  90371. };
  90372. /**
  90373. * Class containing static functions to help procedurally build meshes
  90374. */
  90375. var PolyhedronBuilder = /** @class */ (function () {
  90376. function PolyhedronBuilder() {
  90377. }
  90378. /**
  90379. * Creates a polyhedron mesh
  90380. * * 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
  90381. * * The parameter `size` (positive float, default 1) sets the polygon size
  90382. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90383. * * 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`
  90384. * * 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
  90385. * * 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)`)
  90386. * * 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
  90387. * * 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
  90388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90389. * * 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
  90390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90391. * @param name defines the name of the mesh
  90392. * @param options defines the options used to create the mesh
  90393. * @param scene defines the hosting scene
  90394. * @returns the polyhedron mesh
  90395. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  90396. */
  90397. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  90398. if (scene === void 0) { scene = null; }
  90399. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"](name, scene);
  90400. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  90401. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  90402. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreatePolyhedron(options);
  90403. vertexData.applyToMesh(polyhedron, options.updatable);
  90404. return polyhedron;
  90405. };
  90406. return PolyhedronBuilder;
  90407. }());
  90408. /***/ }),
  90409. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  90410. /*!******************************************!*\
  90411. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  90412. \******************************************/
  90413. /*! exports provided: RibbonBuilder */
  90414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90415. "use strict";
  90416. __webpack_require__.r(__webpack_exports__);
  90417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  90418. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  90419. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  90420. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  90421. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  90422. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  90423. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  90424. var pathArray = options.pathArray;
  90425. var closeArray = options.closeArray || false;
  90426. var closePath = options.closePath || false;
  90427. var invertUV = options.invertUV || false;
  90428. var defaultOffset = Math.floor(pathArray[0].length / 2);
  90429. var offset = options.offset || defaultOffset;
  90430. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  90431. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  90432. var customUV = options.uvs;
  90433. var customColors = options.colors;
  90434. var positions = [];
  90435. var indices = [];
  90436. var normals = [];
  90437. var uvs = [];
  90438. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  90439. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  90440. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  90441. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  90442. var minlg; // minimal length among all paths from pathArray
  90443. var lg = []; // array of path lengths : nb of vertex per path
  90444. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  90445. var p; // path iterator
  90446. var i; // point iterator
  90447. var j; // point iterator
  90448. // if single path in pathArray
  90449. if (pathArray.length < 2) {
  90450. var ar1 = [];
  90451. var ar2 = [];
  90452. for (i = 0; i < pathArray[0].length - offset; i++) {
  90453. ar1.push(pathArray[0][i]);
  90454. ar2.push(pathArray[0][i + offset]);
  90455. }
  90456. pathArray = [ar1, ar2];
  90457. }
  90458. // positions and horizontal distances (u)
  90459. var idc = 0;
  90460. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  90461. var path;
  90462. var l;
  90463. minlg = pathArray[0].length;
  90464. var vectlg;
  90465. var dist;
  90466. for (p = 0; p < pathArray.length; p++) {
  90467. uTotalDistance[p] = 0;
  90468. us[p] = [0];
  90469. path = pathArray[p];
  90470. l = path.length;
  90471. minlg = (minlg < l) ? minlg : l;
  90472. j = 0;
  90473. while (j < l) {
  90474. positions.push(path[j].x, path[j].y, path[j].z);
  90475. if (j > 0) {
  90476. vectlg = path[j].subtract(path[j - 1]).length();
  90477. dist = vectlg + uTotalDistance[p];
  90478. us[p].push(dist);
  90479. uTotalDistance[p] = dist;
  90480. }
  90481. j++;
  90482. }
  90483. if (closePath) { // an extra hidden vertex is added in the "positions" array
  90484. j--;
  90485. positions.push(path[0].x, path[0].y, path[0].z);
  90486. vectlg = path[j].subtract(path[0]).length();
  90487. dist = vectlg + uTotalDistance[p];
  90488. us[p].push(dist);
  90489. uTotalDistance[p] = dist;
  90490. }
  90491. lg[p] = l + closePathCorr;
  90492. idx[p] = idc;
  90493. idc += (l + closePathCorr);
  90494. }
  90495. // vertical distances (v)
  90496. var path1;
  90497. var path2;
  90498. var vertex1 = null;
  90499. var vertex2 = null;
  90500. for (i = 0; i < minlg + closePathCorr; i++) {
  90501. vTotalDistance[i] = 0;
  90502. vs[i] = [0];
  90503. for (p = 0; p < pathArray.length - 1; p++) {
  90504. path1 = pathArray[p];
  90505. path2 = pathArray[p + 1];
  90506. if (i === minlg) { // closePath
  90507. vertex1 = path1[0];
  90508. vertex2 = path2[0];
  90509. }
  90510. else {
  90511. vertex1 = path1[i];
  90512. vertex2 = path2[i];
  90513. }
  90514. vectlg = vertex2.subtract(vertex1).length();
  90515. dist = vectlg + vTotalDistance[i];
  90516. vs[i].push(dist);
  90517. vTotalDistance[i] = dist;
  90518. }
  90519. if (closeArray && vertex2 && vertex1) {
  90520. path1 = pathArray[p];
  90521. path2 = pathArray[0];
  90522. if (i === minlg) { // closePath
  90523. vertex2 = path2[0];
  90524. }
  90525. vectlg = vertex2.subtract(vertex1).length();
  90526. dist = vectlg + vTotalDistance[i];
  90527. vTotalDistance[i] = dist;
  90528. }
  90529. }
  90530. // uvs
  90531. var u;
  90532. var v;
  90533. if (customUV) {
  90534. for (p = 0; p < customUV.length; p++) {
  90535. uvs.push(customUV[p].x, customUV[p].y);
  90536. }
  90537. }
  90538. else {
  90539. for (p = 0; p < pathArray.length; p++) {
  90540. for (i = 0; i < minlg + closePathCorr; i++) {
  90541. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  90542. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  90543. if (invertUV) {
  90544. uvs.push(v, u);
  90545. }
  90546. else {
  90547. uvs.push(u, v);
  90548. }
  90549. }
  90550. }
  90551. }
  90552. // indices
  90553. p = 0; // path index
  90554. var pi = 0; // positions array index
  90555. var l1 = lg[p] - 1; // path1 length
  90556. var l2 = lg[p + 1] - 1; // path2 length
  90557. var min = (l1 < l2) ? l1 : l2; // current path stop index
  90558. var shft = idx[1] - idx[0]; // shift
  90559. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  90560. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  90561. // 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
  90562. indices.push(pi, pi + shft, pi + 1);
  90563. indices.push(pi + shft + 1, pi + 1, pi + shft);
  90564. pi += 1;
  90565. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  90566. p++;
  90567. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  90568. shft = idx[0] - idx[p];
  90569. l1 = lg[p] - 1;
  90570. l2 = lg[0] - 1;
  90571. }
  90572. else {
  90573. shft = idx[p + 1] - idx[p];
  90574. l1 = lg[p] - 1;
  90575. l2 = lg[p + 1] - 1;
  90576. }
  90577. pi = idx[p];
  90578. min = (l1 < l2) ? l1 + pi : l2 + pi;
  90579. }
  90580. }
  90581. // normals
  90582. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  90583. if (closePath) { // update both the first and last vertex normals to their average value
  90584. var indexFirst = 0;
  90585. var indexLast = 0;
  90586. for (p = 0; p < pathArray.length; p++) {
  90587. indexFirst = idx[p] * 3;
  90588. if (p + 1 < pathArray.length) {
  90589. indexLast = (idx[p + 1] - 1) * 3;
  90590. }
  90591. else {
  90592. indexLast = normals.length - 3;
  90593. }
  90594. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  90595. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  90596. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  90597. normals[indexLast] = normals[indexFirst];
  90598. normals[indexLast + 1] = normals[indexFirst + 1];
  90599. normals[indexLast + 2] = normals[indexFirst + 2];
  90600. }
  90601. }
  90602. // sides
  90603. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  90604. // Colors
  90605. var colors = null;
  90606. if (customColors) {
  90607. colors = new Float32Array(customColors.length * 4);
  90608. for (var c = 0; c < customColors.length; c++) {
  90609. colors[c * 4] = customColors[c].r;
  90610. colors[c * 4 + 1] = customColors[c].g;
  90611. colors[c * 4 + 2] = customColors[c].b;
  90612. colors[c * 4 + 3] = customColors[c].a;
  90613. }
  90614. }
  90615. // Result
  90616. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  90617. var positions32 = new Float32Array(positions);
  90618. var normals32 = new Float32Array(normals);
  90619. var uvs32 = new Float32Array(uvs);
  90620. vertexData.indices = indices;
  90621. vertexData.positions = positions32;
  90622. vertexData.normals = normals32;
  90623. vertexData.uvs = uvs32;
  90624. if (colors) {
  90625. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  90626. }
  90627. if (closePath) {
  90628. vertexData._idx = idx;
  90629. }
  90630. return vertexData;
  90631. };
  90632. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  90633. if (closeArray === void 0) { closeArray = false; }
  90634. if (updatable === void 0) { updatable = false; }
  90635. return RibbonBuilder.CreateRibbon(name, {
  90636. pathArray: pathArray,
  90637. closeArray: closeArray,
  90638. closePath: closePath,
  90639. offset: offset,
  90640. updatable: updatable,
  90641. sideOrientation: sideOrientation,
  90642. instance: instance
  90643. }, scene);
  90644. };
  90645. /**
  90646. * Class containing static functions to help procedurally build meshes
  90647. */
  90648. var RibbonBuilder = /** @class */ (function () {
  90649. function RibbonBuilder() {
  90650. }
  90651. /**
  90652. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  90653. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  90654. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  90655. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  90656. * * 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
  90657. * * 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
  90658. * * 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
  90659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90660. * * 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
  90661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90662. * * 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
  90663. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  90664. * * 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
  90665. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  90666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90667. * @param name defines the name of the mesh
  90668. * @param options defines the options used to create the mesh
  90669. * @param scene defines the hosting scene
  90670. * @returns the ribbon mesh
  90671. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  90672. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90673. */
  90674. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  90675. if (scene === void 0) { scene = null; }
  90676. var pathArray = options.pathArray;
  90677. var closeArray = options.closeArray;
  90678. var closePath = options.closePath;
  90679. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  90680. var instance = options.instance;
  90681. var updatable = options.updatable;
  90682. if (instance) { // existing ribbon instance update
  90683. // positionFunction : ribbon case
  90684. // only pathArray and sideOrientation parameters are taken into account for positions update
  90685. var minimum_1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0].setAll(Number.MAX_VALUE);
  90686. var maximum_1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[1].setAll(-Number.MAX_VALUE);
  90687. var positionFunction = function (positions) {
  90688. var minlg = pathArray[0].length;
  90689. var mesh = instance;
  90690. var i = 0;
  90691. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  90692. for (var si = 1; si <= ns; ++si) {
  90693. for (var p = 0; p < pathArray.length; ++p) {
  90694. var path = pathArray[p];
  90695. var l = path.length;
  90696. minlg = (minlg < l) ? minlg : l;
  90697. for (var j = 0; j < minlg; ++j) {
  90698. var pathPoint = path[j];
  90699. positions[i] = pathPoint.x;
  90700. positions[i + 1] = pathPoint.y;
  90701. positions[i + 2] = pathPoint.z;
  90702. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  90703. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  90704. i += 3;
  90705. }
  90706. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  90707. var pathPoint = path[0];
  90708. positions[i] = pathPoint.x;
  90709. positions[i + 1] = pathPoint.y;
  90710. positions[i + 2] = pathPoint.z;
  90711. i += 3;
  90712. }
  90713. }
  90714. }
  90715. };
  90716. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  90717. positionFunction(positions);
  90718. if (instance._boundingInfo) {
  90719. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  90720. }
  90721. else {
  90722. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  90723. }
  90724. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  90725. if (options.colors) {
  90726. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  90727. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  90728. var color = options.colors[c];
  90729. colors[colorIndex] = color.r;
  90730. colors[colorIndex + 1] = color.g;
  90731. colors[colorIndex + 2] = color.b;
  90732. colors[colorIndex + 3] = color.a;
  90733. }
  90734. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  90735. }
  90736. if (options.uvs) {
  90737. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  90738. for (var i = 0; i < options.uvs.length; i++) {
  90739. uvs[i * 2] = options.uvs[i].x;
  90740. uvs[i * 2 + 1] = options.uvs[i].y;
  90741. }
  90742. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  90743. }
  90744. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  90745. var indices = instance.getIndices();
  90746. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  90747. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  90748. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  90749. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  90750. var indexFirst = 0;
  90751. var indexLast = 0;
  90752. for (var p = 0; p < pathArray.length; p++) {
  90753. indexFirst = instance._creationDataStorage.idx[p] * 3;
  90754. if (p + 1 < pathArray.length) {
  90755. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  90756. }
  90757. else {
  90758. indexLast = normals.length - 3;
  90759. }
  90760. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  90761. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  90762. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  90763. normals[indexLast] = normals[indexFirst];
  90764. normals[indexLast + 1] = normals[indexFirst + 1];
  90765. normals[indexLast + 2] = normals[indexFirst + 2];
  90766. }
  90767. }
  90768. if (!(instance.areNormalsFrozen)) {
  90769. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  90770. }
  90771. }
  90772. return instance;
  90773. }
  90774. else { // new ribbon creation
  90775. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  90776. ribbon._originalBuilderSideOrientation = sideOrientation;
  90777. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  90778. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  90779. if (closePath) {
  90780. ribbon._creationDataStorage.idx = vertexData._idx;
  90781. }
  90782. ribbon._creationDataStorage.closePath = closePath;
  90783. ribbon._creationDataStorage.closeArray = closeArray;
  90784. vertexData.applyToMesh(ribbon, updatable);
  90785. return ribbon;
  90786. }
  90787. };
  90788. return RibbonBuilder;
  90789. }());
  90790. /***/ }),
  90791. /***/ "./Meshes/Builders/shapeBuilder.ts":
  90792. /*!*****************************************!*\
  90793. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  90794. \*****************************************/
  90795. /*! exports provided: ShapeBuilder */
  90796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90797. "use strict";
  90798. __webpack_require__.r(__webpack_exports__);
  90799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  90800. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  90801. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  90802. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  90803. /* harmony import */ var _Maths_math_path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.path */ "./Maths/math.path.ts");
  90804. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  90805. if (scene === void 0) { scene = null; }
  90806. var options = {
  90807. shape: shape,
  90808. path: path,
  90809. scale: scale,
  90810. rotation: rotation,
  90811. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  90812. sideOrientation: sideOrientation,
  90813. instance: instance,
  90814. updatable: updatable
  90815. };
  90816. return ShapeBuilder.ExtrudeShape(name, options, scene);
  90817. };
  90818. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  90819. var options = {
  90820. shape: shape,
  90821. path: path,
  90822. scaleFunction: scaleFunction,
  90823. rotationFunction: rotationFunction,
  90824. ribbonCloseArray: ribbonCloseArray,
  90825. ribbonClosePath: ribbonClosePath,
  90826. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  90827. sideOrientation: sideOrientation,
  90828. instance: instance,
  90829. updatable: updatable
  90830. };
  90831. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  90832. };
  90833. /**
  90834. * Class containing static functions to help procedurally build meshes
  90835. */
  90836. var ShapeBuilder = /** @class */ (function () {
  90837. function ShapeBuilder() {
  90838. }
  90839. /**
  90840. * 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.
  90841. * * 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.
  90842. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  90843. * * 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.
  90844. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  90845. * * 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
  90846. * * 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
  90847. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  90848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90849. * * 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
  90850. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  90851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90852. * @param name defines the name of the mesh
  90853. * @param options defines the options used to create the mesh
  90854. * @param scene defines the hosting scene
  90855. * @returns the extruded shape mesh
  90856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90858. */
  90859. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  90860. if (scene === void 0) { scene = null; }
  90861. var path = options.path;
  90862. var shape = options.shape;
  90863. var scale = options.scale || 1;
  90864. var rotation = options.rotation || 0;
  90865. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  90866. var updatable = options.updatable;
  90867. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  90868. var instance = options.instance || null;
  90869. var invertUV = options.invertUV || false;
  90870. 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);
  90871. };
  90872. /**
  90873. * Creates an custom extruded shape mesh.
  90874. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  90875. * * 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.
  90876. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  90877. * * 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
  90878. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  90879. * * 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
  90880. * * It must returns a float value that will be the scale value applied to the shape on each path point
  90881. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90882. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  90883. * * 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
  90884. * * 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
  90885. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  90886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90887. * * 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
  90888. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90890. * @param name defines the name of the mesh
  90891. * @param options defines the options used to create the mesh
  90892. * @param scene defines the hosting scene
  90893. * @returns the custom extruded shape mesh
  90894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  90895. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90897. */
  90898. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  90899. if (scene === void 0) { scene = null; }
  90900. var path = options.path;
  90901. var shape = options.shape;
  90902. var scaleFunction = options.scaleFunction || (function () { return 1; });
  90903. var rotationFunction = options.rotationFunction || (function () { return 0; });
  90904. var ribbonCloseArray = options.ribbonCloseArray || false;
  90905. var ribbonClosePath = options.ribbonClosePath || false;
  90906. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  90907. var updatable = options.updatable;
  90908. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  90909. var instance = options.instance;
  90910. var invertUV = options.invertUV || false;
  90911. 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);
  90912. };
  90913. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  90914. // extrusion geometry
  90915. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  90916. var tangents = path3D.getTangents();
  90917. var normals = path3D.getNormals();
  90918. var binormals = path3D.getBinormals();
  90919. var distances = path3D.getDistances();
  90920. var angle = 0;
  90921. var returnScale = function () { return scale !== null ? scale : 1; };
  90922. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  90923. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  90924. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  90925. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  90926. var rotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  90927. for (var i = 0; i < curve.length; i++) {
  90928. var shapePath = new Array();
  90929. var angleStep = rotate(i, distances[i]);
  90930. var scaleRatio = scl(i, distances[i]);
  90931. for (var p = 0; p < shape.length; p++) {
  90932. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  90933. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  90934. var rotated = shapePath[p] ? shapePath[p] : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90935. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  90936. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  90937. shapePath[p] = rotated;
  90938. }
  90939. shapePaths[index] = shapePath;
  90940. angle += angleStep;
  90941. index++;
  90942. }
  90943. // cap
  90944. var capPath = function (shapePath) {
  90945. var pointCap = Array();
  90946. var barycenter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90947. var i;
  90948. for (i = 0; i < shapePath.length; i++) {
  90949. barycenter.addInPlace(shapePath[i]);
  90950. }
  90951. barycenter.scaleInPlace(1.0 / shapePath.length);
  90952. for (i = 0; i < shapePath.length; i++) {
  90953. pointCap.push(barycenter);
  90954. }
  90955. return pointCap;
  90956. };
  90957. switch (cap) {
  90958. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  90959. break;
  90960. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  90961. shapePaths[0] = capPath(shapePaths[2]);
  90962. shapePaths[1] = shapePaths[2];
  90963. break;
  90964. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  90965. shapePaths[index] = shapePaths[index - 1];
  90966. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  90967. break;
  90968. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  90969. shapePaths[0] = capPath(shapePaths[2]);
  90970. shapePaths[1] = shapePaths[2];
  90971. shapePaths[index] = shapePaths[index - 1];
  90972. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  90973. break;
  90974. default:
  90975. break;
  90976. }
  90977. return shapePaths;
  90978. };
  90979. var path3D;
  90980. var pathArray;
  90981. if (instance) { // instance update
  90982. var storage = instance._creationDataStorage;
  90983. path3D = storage.path3D.update(curve);
  90984. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  90985. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  90986. return instance;
  90987. }
  90988. // extruded shape creation
  90989. path3D = new _Maths_math_path__WEBPACK_IMPORTED_MODULE_3__["Path3D"](curve);
  90990. var newShapePaths = new Array();
  90991. cap = (cap < 0 || cap > 3) ? 0 : cap;
  90992. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  90993. 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);
  90994. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  90995. extrudedGeneric._creationDataStorage.path3D = path3D;
  90996. extrudedGeneric._creationDataStorage.cap = cap;
  90997. return extrudedGeneric;
  90998. };
  90999. return ShapeBuilder;
  91000. }());
  91001. /***/ }),
  91002. /***/ "./Meshes/Builders/sphereBuilder.ts":
  91003. /*!******************************************!*\
  91004. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  91005. \******************************************/
  91006. /*! exports provided: SphereBuilder */
  91007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91008. "use strict";
  91009. __webpack_require__.r(__webpack_exports__);
  91010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  91011. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  91012. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  91013. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91014. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  91015. var segments = options.segments || 32;
  91016. var diameterX = options.diameterX || options.diameter || 1;
  91017. var diameterY = options.diameterY || options.diameter || 1;
  91018. var diameterZ = options.diameterZ || options.diameter || 1;
  91019. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  91020. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  91021. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  91022. var radius = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  91023. var totalZRotationSteps = 2 + segments;
  91024. var totalYRotationSteps = 2 * totalZRotationSteps;
  91025. var indices = [];
  91026. var positions = [];
  91027. var normals = [];
  91028. var uvs = [];
  91029. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  91030. var normalizedZ = zRotationStep / totalZRotationSteps;
  91031. var angleZ = normalizedZ * Math.PI * slice;
  91032. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  91033. var normalizedY = yRotationStep / totalYRotationSteps;
  91034. var angleY = normalizedY * Math.PI * 2 * arc;
  91035. var rotationZ = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  91036. var rotationY = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  91037. var afterRotZ = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  91038. var complete = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  91039. var vertex = complete.multiply(radius);
  91040. var normal = complete.divide(radius).normalize();
  91041. positions.push(vertex.x, vertex.y, vertex.z);
  91042. normals.push(normal.x, normal.y, normal.z);
  91043. uvs.push(normalizedY, normalizedZ);
  91044. }
  91045. if (zRotationStep > 0) {
  91046. var verticesCount = positions.length / 3;
  91047. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  91048. indices.push((firstIndex));
  91049. indices.push((firstIndex + 1));
  91050. indices.push(firstIndex + totalYRotationSteps + 1);
  91051. indices.push((firstIndex + totalYRotationSteps + 1));
  91052. indices.push((firstIndex + 1));
  91053. indices.push((firstIndex + totalYRotationSteps + 2));
  91054. }
  91055. }
  91056. }
  91057. // Sides
  91058. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  91059. // Result
  91060. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  91061. vertexData.indices = indices;
  91062. vertexData.positions = positions;
  91063. vertexData.normals = normals;
  91064. vertexData.uvs = uvs;
  91065. return vertexData;
  91066. };
  91067. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  91068. var options = {
  91069. segments: segments,
  91070. diameterX: diameter,
  91071. diameterY: diameter,
  91072. diameterZ: diameter,
  91073. sideOrientation: sideOrientation,
  91074. updatable: updatable
  91075. };
  91076. return SphereBuilder.CreateSphere(name, options, scene);
  91077. };
  91078. /**
  91079. * Class containing static functions to help procedurally build meshes
  91080. */
  91081. var SphereBuilder = /** @class */ (function () {
  91082. function SphereBuilder() {
  91083. }
  91084. /**
  91085. * Creates a sphere mesh
  91086. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  91087. * * 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`)
  91088. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  91089. * * 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
  91090. * * 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)
  91091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91092. * * 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
  91093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91094. * @param name defines the name of the mesh
  91095. * @param options defines the options used to create the mesh
  91096. * @param scene defines the hosting scene
  91097. * @returns the sphere mesh
  91098. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  91099. */
  91100. SphereBuilder.CreateSphere = function (name, options, scene) {
  91101. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  91102. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  91103. sphere._originalBuilderSideOrientation = options.sideOrientation;
  91104. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  91105. vertexData.applyToMesh(sphere, options.updatable);
  91106. return sphere;
  91107. };
  91108. return SphereBuilder;
  91109. }());
  91110. /***/ }),
  91111. /***/ "./Meshes/Builders/tiledBoxBuilder.ts":
  91112. /*!********************************************!*\
  91113. !*** ./Meshes/Builders/tiledBoxBuilder.ts ***!
  91114. \********************************************/
  91115. /*! exports provided: TiledBoxBuilder */
  91116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91117. "use strict";
  91118. __webpack_require__.r(__webpack_exports__);
  91119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TiledBoxBuilder", function() { return TiledBoxBuilder; });
  91120. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  91121. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  91122. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  91123. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91124. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledBox = function (options) {
  91125. var nbFaces = 6;
  91126. var faceUV = options.faceUV || new Array(6);
  91127. var faceColors = options.faceColors;
  91128. var flipTile = options.pattern || _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].NO_FLIP;
  91129. var width = options.width || options.size || 1;
  91130. var height = options.height || options.size || 1;
  91131. var depth = options.depth || options.size || 1;
  91132. var tileWidth = options.tileWidth || options.tileSize || 1;
  91133. var tileHeight = options.tileHeight || options.tileSize || 1;
  91134. var alignH = options.alignHorizontal || 0;
  91135. var alignV = options.alignVertical || 0;
  91136. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  91137. // default face colors and UV if undefined
  91138. for (var f = 0; f < nbFaces; f++) {
  91139. if (faceUV[f] === undefined) {
  91140. faceUV[f] = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  91141. }
  91142. if (faceColors && faceColors[f] === undefined) {
  91143. faceColors[f] = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1);
  91144. }
  91145. }
  91146. var halfWidth = width / 2;
  91147. var halfHeight = height / 2;
  91148. var halfDepth = depth / 2;
  91149. var faceVertexData = [];
  91150. for (var f = 0; f < 2; f++) { //front and back
  91151. faceVertexData[f] = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledPlane({
  91152. pattern: flipTile,
  91153. tileWidth: tileWidth,
  91154. tileHeight: tileHeight,
  91155. width: width,
  91156. height: height,
  91157. alignVertical: alignV,
  91158. alignHorizontal: alignH,
  91159. sideOrientation: sideOrientation
  91160. });
  91161. }
  91162. for (var f = 2; f < 4; f++) { //sides
  91163. faceVertexData[f] = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledPlane({
  91164. pattern: flipTile,
  91165. tileWidth: tileWidth,
  91166. tileHeight: tileHeight,
  91167. width: depth,
  91168. height: height,
  91169. alignVertical: alignV,
  91170. alignHorizontal: alignH,
  91171. sideOrientation: sideOrientation
  91172. });
  91173. }
  91174. var baseAlignV = alignV;
  91175. if (alignV === _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].BOTTOM) {
  91176. baseAlignV = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].TOP;
  91177. }
  91178. else if (alignV === _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].TOP) {
  91179. baseAlignV = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].BOTTOM;
  91180. }
  91181. for (var f = 4; f < 6; f++) { //top and bottom
  91182. faceVertexData[f] = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledPlane({
  91183. pattern: flipTile,
  91184. tileWidth: tileWidth,
  91185. tileHeight: tileHeight,
  91186. width: width,
  91187. height: depth,
  91188. alignVertical: baseAlignV,
  91189. alignHorizontal: alignH,
  91190. sideOrientation: sideOrientation
  91191. });
  91192. }
  91193. var positions = [];
  91194. var normals = [];
  91195. var uvs = [];
  91196. var indices = [];
  91197. var colors = [];
  91198. var facePositions = [];
  91199. var faceNormals = [];
  91200. var newFaceUV = [];
  91201. var len = 0;
  91202. var lu = 0;
  91203. var li = 0;
  91204. for (var f = 0; f < nbFaces; f++) {
  91205. var len = faceVertexData[f].positions.length;
  91206. facePositions[f] = [];
  91207. faceNormals[f] = [];
  91208. for (var p = 0; p < len / 3; p++) {
  91209. facePositions[f].push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](faceVertexData[f].positions[3 * p], faceVertexData[f].positions[3 * p + 1], faceVertexData[f].positions[3 * p + 2]));
  91210. faceNormals[f].push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](faceVertexData[f].normals[3 * p], faceVertexData[f].normals[3 * p + 1], faceVertexData[f].normals[3 * p + 2]));
  91211. }
  91212. // uvs
  91213. lu = faceVertexData[f].uvs.length;
  91214. newFaceUV[f] = [];
  91215. for (var i = 0; i < lu; i += 2) {
  91216. newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs[i];
  91217. newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs[i + 1];
  91218. }
  91219. uvs = uvs.concat(newFaceUV[f]);
  91220. indices = indices.concat(faceVertexData[f].indices.map(function (x) { return x + li; }));
  91221. li += facePositions[f].length;
  91222. if (faceColors) {
  91223. for (var c = 0; c < 4; c++) {
  91224. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  91225. }
  91226. }
  91227. }
  91228. var vec0 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, halfDepth);
  91229. var mtrx0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(Math.PI);
  91230. positions = facePositions[0].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx0).add(vec0); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []);
  91231. normals = faceNormals[0].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx0); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []);
  91232. positions = positions.concat(facePositions[1].map(function (entry) { return entry.subtract(vec0); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91233. normals = normals.concat(faceNormals[1].map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91234. var vec2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](halfWidth, 0, 0);
  91235. var mtrx2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(-Math.PI / 2);
  91236. positions = positions.concat(facePositions[2].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx2).add(vec2); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91237. normals = normals.concat(faceNormals[2].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx2); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91238. var mtrx3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(Math.PI / 2);
  91239. positions = positions.concat(facePositions[3].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx3).subtract(vec2); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91240. normals = normals.concat(faceNormals[3].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx3); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91241. var vec4 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, halfHeight, 0);
  91242. var mtrx4 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationX(Math.PI / 2);
  91243. positions = positions.concat(facePositions[4].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx4).add(vec4); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91244. normals = normals.concat(faceNormals[4].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx4); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91245. var mtrx5 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationX(-Math.PI / 2);
  91246. positions = positions.concat(facePositions[5].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx5).subtract(vec4); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91247. normals = normals.concat(faceNormals[5].map(function (entry) { return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(entry, mtrx5); }).map(function (entry) { return [entry.x, entry.y, entry.z]; }).reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []));
  91248. // sides
  91249. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs);
  91250. // Result
  91251. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  91252. vertexData.indices = indices;
  91253. vertexData.positions = positions;
  91254. vertexData.normals = normals;
  91255. vertexData.uvs = uvs;
  91256. if (faceColors) {
  91257. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  91258. vertexData.colors = totalColors;
  91259. }
  91260. return vertexData;
  91261. };
  91262. /**
  91263. * Class containing static functions to help procedurally build meshes
  91264. */
  91265. var TiledBoxBuilder = /** @class */ (function () {
  91266. function TiledBoxBuilder() {
  91267. }
  91268. /**
  91269. * Creates a box mesh
  91270. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  91271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  91272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91273. * * 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
  91274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91275. * @param name defines the name of the mesh
  91276. * @param options defines the options used to create the mesh
  91277. * @param scene defines the hosting scene
  91278. * @returns the box mesh
  91279. */
  91280. TiledBoxBuilder.CreateTiledBox = function (name, options, scene) {
  91281. if (scene === void 0) { scene = null; }
  91282. var box = new _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"](name, scene);
  91283. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  91284. box._originalBuilderSideOrientation = options.sideOrientation;
  91285. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateTiledBox(options);
  91286. vertexData.applyToMesh(box, options.updatable);
  91287. return box;
  91288. };
  91289. return TiledBoxBuilder;
  91290. }());
  91291. /***/ }),
  91292. /***/ "./Meshes/Builders/tiledPlaneBuilder.ts":
  91293. /*!**********************************************!*\
  91294. !*** ./Meshes/Builders/tiledPlaneBuilder.ts ***!
  91295. \**********************************************/
  91296. /*! exports provided: TiledPlaneBuilder */
  91297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91298. "use strict";
  91299. __webpack_require__.r(__webpack_exports__);
  91300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TiledPlaneBuilder", function() { return TiledPlaneBuilder; });
  91301. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  91302. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91303. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateTiledPlane = function (options) {
  91304. var flipTile = options.pattern || _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].NO_FLIP;
  91305. var tileWidth = options.tileWidth || options.tileSize || 1;
  91306. var tileHeight = options.tileHeight || options.tileSize || 1;
  91307. var alignH = options.alignHorizontal || 0;
  91308. var alignV = options.alignVertical || 0;
  91309. var width = options.width || options.size || 1;
  91310. var tilesX = Math.floor(width / tileWidth);
  91311. var offsetX = width - tilesX * tileWidth;
  91312. var height = options.height || options.size || 1;
  91313. var tilesY = Math.floor(height / tileHeight);
  91314. var offsetY = height - tilesY * tileHeight;
  91315. var halfWidth = tileWidth * tilesX / 2;
  91316. var halfHeight = tileHeight * tilesY / 2;
  91317. var adjustX = 0;
  91318. var adjustY = 0;
  91319. var startX = 0;
  91320. var startY = 0;
  91321. var endX = 0;
  91322. var endY = 0;
  91323. //Part Tiles
  91324. if (offsetX > 0 || offsetY > 0) {
  91325. startX = -halfWidth;
  91326. startY = -halfHeight;
  91327. var endX = halfWidth;
  91328. var endY = halfHeight;
  91329. switch (alignH) {
  91330. case _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CENTER:
  91331. offsetX /= 2;
  91332. startX -= offsetX;
  91333. endX += offsetX;
  91334. break;
  91335. case _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].LEFT:
  91336. endX += offsetX;
  91337. adjustX = -offsetX / 2;
  91338. break;
  91339. case _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].RIGHT:
  91340. startX -= offsetX;
  91341. adjustX = offsetX / 2;
  91342. break;
  91343. }
  91344. switch (alignV) {
  91345. case _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CENTER:
  91346. offsetY /= 2;
  91347. startY -= offsetY;
  91348. endY += offsetY;
  91349. break;
  91350. case _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].BOTTOM:
  91351. endY += offsetY;
  91352. adjustY = -offsetY / 2;
  91353. break;
  91354. case _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].TOP:
  91355. startY -= offsetY;
  91356. adjustY = offsetY / 2;
  91357. break;
  91358. }
  91359. }
  91360. var positions = [];
  91361. var normals = [];
  91362. var uvBase = [];
  91363. uvBase[0] = [0, 0, 1, 0, 1, 1, 0, 1];
  91364. uvBase[1] = [0, 0, 1, 0, 1, 1, 0, 1];
  91365. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW) {
  91366. uvBase[1] = [1, 1, 0, 1, 0, 0, 1, 0];
  91367. }
  91368. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW) {
  91369. uvBase[1] = [1, 0, 0, 0, 0, 1, 1, 1];
  91370. }
  91371. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91372. uvBase[1] = [0, 1, 1, 1, 1, 0, 0, 0];
  91373. }
  91374. var uvs = [];
  91375. var colors = [];
  91376. var indices = [];
  91377. var index = 0;
  91378. for (var y = 0; y < tilesY; y++) {
  91379. for (var x = 0; x < tilesX; x++) {
  91380. positions.push(-halfWidth + x * tileWidth + adjustX, -halfHeight + y * tileHeight + adjustY, 0);
  91381. positions.push(-halfWidth + (x + 1) * tileWidth + adjustX, -halfHeight + y * tileHeight + adjustY, 0);
  91382. positions.push(-halfWidth + (x + 1) * tileWidth + adjustX, -halfHeight + (y + 1) * tileHeight + adjustY, 0);
  91383. positions.push(-halfWidth + x * tileWidth + adjustX, -halfHeight + (y + 1) * tileHeight + adjustY, 0);
  91384. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91385. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE) {
  91386. uvs = uvs.concat(uvBase[(x % 2 + y % 2) % 2]);
  91387. }
  91388. else if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91389. uvs = uvs.concat(uvBase[y % 2]);
  91390. }
  91391. else {
  91392. uvs = uvs.concat(uvBase[0]);
  91393. }
  91394. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91395. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91396. index += 4;
  91397. }
  91398. }
  91399. //Part Tiles
  91400. if (offsetX > 0 || offsetY > 0) {
  91401. var partialBottomRow = (offsetY > 0 && (alignV === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CENTER || alignV === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].TOP));
  91402. var partialTopRow = (offsetY > 0 && (alignV === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CENTER || alignV === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].BOTTOM));
  91403. var partialLeftCol = (offsetX > 0 && (alignH === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CENTER || alignH === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].RIGHT));
  91404. var partialRightCol = (offsetX > 0 && (alignH === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CENTER || alignH === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].LEFT));
  91405. var uvPart = [];
  91406. var a, b, c, d;
  91407. //corners
  91408. if (partialBottomRow && partialLeftCol) { //bottom left corner
  91409. positions.push(startX + adjustX, startY + adjustY, 0);
  91410. positions.push(-halfWidth + adjustX, startY + adjustY, 0);
  91411. positions.push(-halfWidth + adjustX, startY + offsetY + adjustY, 0);
  91412. positions.push(startX + adjustX, startY + offsetY + adjustY, 0);
  91413. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91414. index += 4;
  91415. a = 1 - offsetX / tileWidth;
  91416. b = 1 - offsetY / tileHeight;
  91417. c = 1;
  91418. d = 1;
  91419. uvPart = [a, b, c, b, c, d, a, d];
  91420. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW) {
  91421. uvPart = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91422. }
  91423. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW) {
  91424. uvPart = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91425. }
  91426. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91427. uvPart = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91428. }
  91429. uvs = uvs.concat(uvPart);
  91430. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91431. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91432. }
  91433. if (partialBottomRow && partialRightCol) { //bottom right corner
  91434. positions.push(halfWidth + adjustX, startY + adjustY, 0);
  91435. positions.push(endX + adjustX, startY + adjustY, 0);
  91436. positions.push(endX + adjustX, startY + offsetY + adjustY, 0);
  91437. positions.push(halfWidth + adjustX, startY + offsetY + adjustY, 0);
  91438. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91439. index += 4;
  91440. a = 0,
  91441. b = 1 - offsetY / tileHeight;
  91442. c = offsetX / tileWidth;
  91443. d = 1;
  91444. uvPart = [a, b, c, b, c, d, a, d];
  91445. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE && (tilesX % 2) === 0)) {
  91446. uvPart = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91447. }
  91448. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE && (tilesX % 2) === 0)) {
  91449. uvPart = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91450. }
  91451. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE && (tilesX % 2) === 0)) {
  91452. uvPart = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91453. }
  91454. uvs = uvs.concat(uvPart);
  91455. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91456. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91457. }
  91458. if (partialTopRow && partialLeftCol) { //top left corner
  91459. positions.push(startX + adjustX, halfHeight + adjustY, 0);
  91460. positions.push(-halfWidth + adjustX, halfHeight + adjustY, 0);
  91461. positions.push(-halfWidth + adjustX, endY + adjustY, 0);
  91462. positions.push(startX + adjustX, endY + adjustY, 0);
  91463. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91464. index += 4;
  91465. a = 1 - offsetX / tileWidth;
  91466. b = 0;
  91467. c = 1;
  91468. d = offsetY / tileHeight;
  91469. uvPart = [a, b, c, b, c, d, a, d];
  91470. if ((flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW && (tilesY % 2) === 1) || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE && (tilesY % 1) === 0)) {
  91471. uvPart = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91472. }
  91473. if ((flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW && (tilesY % 2) === 1) || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE && (tilesY % 2) === 0)) {
  91474. uvPart = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91475. }
  91476. if ((flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW && (tilesY % 2) === 1) || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE && (tilesY % 2) === 0)) {
  91477. uvPart = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91478. }
  91479. uvs = uvs.concat(uvPart);
  91480. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91481. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91482. }
  91483. if (partialTopRow && partialRightCol) { //top right corner
  91484. positions.push(halfWidth + adjustX, halfHeight + adjustY, 0);
  91485. positions.push(endX + adjustX, halfHeight + adjustY, 0);
  91486. positions.push(endX + adjustX, endY + adjustY, 0);
  91487. positions.push(halfWidth + adjustX, endY + adjustY, 0);
  91488. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91489. index += 4;
  91490. a = 0,
  91491. b = 0;
  91492. c = offsetX / tileWidth;
  91493. d = offsetY / tileHeight;
  91494. uvPart = [a, b, c, b, c, d, a, d];
  91495. if ((flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW && (tilesY % 2) === 1) || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE && (tilesY + tilesX) % 2 === 1)) {
  91496. uvPart = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91497. }
  91498. if ((flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW && (tilesY % 2) === 1) || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE && (tilesY + tilesX) % 2 === 1)) {
  91499. uvPart = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91500. }
  91501. if ((flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW && (tilesY % 2) === 1) || (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE && (tilesY + tilesX) % 2 === 1)) {
  91502. uvPart = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91503. }
  91504. uvs = uvs.concat(uvPart);
  91505. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91506. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91507. }
  91508. //part rows
  91509. if (partialBottomRow) {
  91510. var uvBaseBR = [];
  91511. a = 0;
  91512. b = 1 - offsetY / tileHeight;
  91513. c = 1;
  91514. d = 1;
  91515. uvBaseBR[0] = [a, b, c, b, c, d, a, d];
  91516. uvBaseBR[1] = [a, b, c, b, c, d, a, d];
  91517. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW) {
  91518. uvBaseBR[1] = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91519. }
  91520. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW) {
  91521. uvBaseBR[1] = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91522. }
  91523. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91524. uvBaseBR[1] = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91525. }
  91526. for (var x = 0; x < tilesX; x++) {
  91527. positions.push(-halfWidth + x * tileWidth + adjustX, startY + adjustY, 0);
  91528. positions.push(-halfWidth + (x + 1) * tileWidth + adjustX, startY + adjustY, 0);
  91529. positions.push(-halfWidth + (x + 1) * tileWidth + adjustX, startY + offsetY + adjustY, 0);
  91530. positions.push(-halfWidth + x * tileWidth + adjustX, startY + offsetY + adjustY, 0);
  91531. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91532. index += 4;
  91533. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE) {
  91534. uvs = uvs.concat(uvBaseBR[(x + 1) % 2]);
  91535. }
  91536. else if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91537. uvs = uvs.concat(uvBaseBR[1]);
  91538. }
  91539. else {
  91540. uvs = uvs.concat(uvBaseBR[0]);
  91541. }
  91542. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91543. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91544. }
  91545. }
  91546. if (partialTopRow) {
  91547. var uvBaseTR = [];
  91548. a = 0;
  91549. b = 0;
  91550. c = 1;
  91551. d = offsetY / tileHeight;
  91552. uvBaseTR[0] = [a, b, c, b, c, d, a, d];
  91553. uvBaseTR[1] = [a, b, c, b, c, d, a, d];
  91554. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW) {
  91555. uvBaseTR[1] = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91556. }
  91557. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW) {
  91558. uvBaseTR[1] = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91559. }
  91560. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91561. uvBaseTR[1] = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91562. }
  91563. for (var x = 0; x < tilesX; x++) {
  91564. positions.push(-halfWidth + x * tileWidth + adjustX, endY - offsetY + adjustY, 0);
  91565. positions.push(-halfWidth + (x + 1) * tileWidth + adjustX, endY - offsetY + adjustY, 0);
  91566. positions.push(-halfWidth + (x + 1) * tileWidth + adjustX, endY + adjustY, 0);
  91567. positions.push(-halfWidth + x * tileWidth + adjustX, endY + adjustY, 0);
  91568. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91569. index += 4;
  91570. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE) {
  91571. uvs = uvs.concat(uvBaseTR[(x + tilesY) % 2]);
  91572. }
  91573. else if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91574. uvs = uvs.concat(uvBaseTR[tilesY % 2]);
  91575. }
  91576. else {
  91577. uvs = uvs.concat(uvBaseTR[0]);
  91578. }
  91579. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91580. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91581. }
  91582. }
  91583. if (partialLeftCol) {
  91584. var uvBaseLC = [];
  91585. a = 1 - offsetX / tileWidth;
  91586. b = 0;
  91587. c = 1;
  91588. d = 1;
  91589. uvBaseLC[0] = [a, b, c, b, c, d, a, d];
  91590. uvBaseLC[1] = [a, b, c, b, c, d, a, d];
  91591. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW) {
  91592. uvBaseLC[1] = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91593. }
  91594. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW) {
  91595. uvBaseLC[1] = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91596. }
  91597. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91598. uvBaseLC[1] = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91599. }
  91600. for (var y = 0; y < tilesY; y++) {
  91601. positions.push(startX + adjustX, -halfHeight + y * tileHeight + adjustY, 0);
  91602. positions.push(startX + offsetX + adjustX, -halfHeight + y * tileHeight + adjustY, 0);
  91603. positions.push(startX + offsetX + adjustX, -halfHeight + (y + 1) * tileHeight + adjustY, 0);
  91604. positions.push(startX + adjustX, -halfHeight + (y + 1) * tileHeight + adjustY, 0);
  91605. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91606. index += 4;
  91607. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE) {
  91608. uvs = uvs.concat(uvBaseLC[(y + 1) % 2]);
  91609. }
  91610. else if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91611. uvs = uvs.concat(uvBaseLC[y % 2]);
  91612. }
  91613. else {
  91614. uvs = uvs.concat(uvBaseLC[0]);
  91615. }
  91616. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91617. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91618. }
  91619. }
  91620. if (partialRightCol) {
  91621. var uvBaseRC = [];
  91622. a = 0;
  91623. b = 0;
  91624. c = offsetX / tileHeight;
  91625. d = 1;
  91626. uvBaseRC[0] = [a, b, c, b, c, d, a, d];
  91627. uvBaseRC[1] = [a, b, c, b, c, d, a, d];
  91628. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW) {
  91629. uvBaseRC[1] = [1 - a, 1 - b, 1 - c, 1 - b, 1 - c, 1 - d, 1 - a, 1 - d];
  91630. }
  91631. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW) {
  91632. uvBaseRC[1] = [1 - a, b, 1 - c, b, 1 - c, d, 1 - a, d];
  91633. }
  91634. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91635. uvBaseRC[1] = [a, 1 - b, c, 1 - b, c, 1 - d, a, 1 - d];
  91636. }
  91637. for (var y = 0; y < tilesY; y++) {
  91638. positions.push(endX - offsetX + adjustX, -halfHeight + y * tileHeight + adjustY, 0);
  91639. positions.push(endX + adjustX, -halfHeight + y * tileHeight + adjustY, 0);
  91640. positions.push(endX + adjustX, -halfHeight + (y + 1) * tileHeight + adjustY, 0);
  91641. positions.push(endX - offsetX + adjustX, -halfHeight + (y + 1) * tileHeight + adjustY, 0);
  91642. indices.push(index, index + 1, index + 3, index + 1, index + 2, index + 3);
  91643. index += 4;
  91644. if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_TILE || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_TILE) {
  91645. uvs = uvs.concat(uvBaseRC[(y + tilesX) % 2]);
  91646. }
  91647. else if (flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].ROTATE_ROW || flipTile === _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].FLIP_N_ROTATE_ROW) {
  91648. uvs = uvs.concat(uvBaseRC[y % 2]);
  91649. }
  91650. else {
  91651. uvs = uvs.concat(uvBaseRC[0]);
  91652. }
  91653. colors.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  91654. normals.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
  91655. }
  91656. }
  91657. }
  91658. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  91659. // sides
  91660. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  91661. // Result
  91662. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  91663. vertexData.indices = indices;
  91664. vertexData.positions = positions;
  91665. vertexData.normals = normals;
  91666. vertexData.uvs = uvs;
  91667. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  91668. vertexData.colors = totalColors;
  91669. return vertexData;
  91670. };
  91671. /**
  91672. * Class containing static functions to help procedurally build meshes
  91673. */
  91674. var TiledPlaneBuilder = /** @class */ (function () {
  91675. function TiledPlaneBuilder() {
  91676. }
  91677. /**
  91678. * Creates a tiled plane mesh
  91679. * * The parameter `pattern` will, depending on value, do nothing or
  91680. * * * flip (reflect about central vertical) alternate tiles across and up
  91681. * * * flip every tile on alternate rows
  91682. * * * rotate (180 degs) alternate tiles across and up
  91683. * * * rotate every tile on alternate rows
  91684. * * * flip and rotate alternate tiles across and up
  91685. * * * flip and rotate every tile on alternate rows
  91686. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  91687. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  91688. * * 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
  91689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91690. * * 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)
  91691. * * 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)
  91692. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  91693. * @param name defines the name of the mesh
  91694. * @param options defines the options used to create the mesh
  91695. * @param scene defines the hosting scene
  91696. * @returns the box mesh
  91697. */
  91698. TiledPlaneBuilder.CreateTiledPlane = function (name, options, scene) {
  91699. if (scene === void 0) { scene = null; }
  91700. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  91701. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  91702. plane._originalBuilderSideOrientation = options.sideOrientation;
  91703. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateTiledPlane(options);
  91704. vertexData.applyToMesh(plane, options.updatable);
  91705. return plane;
  91706. };
  91707. return TiledPlaneBuilder;
  91708. }());
  91709. /***/ }),
  91710. /***/ "./Meshes/Builders/torusBuilder.ts":
  91711. /*!*****************************************!*\
  91712. !*** ./Meshes/Builders/torusBuilder.ts ***!
  91713. \*****************************************/
  91714. /*! exports provided: TorusBuilder */
  91715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91716. "use strict";
  91717. __webpack_require__.r(__webpack_exports__);
  91718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  91719. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  91720. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  91721. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91722. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  91723. var indices = [];
  91724. var positions = [];
  91725. var normals = [];
  91726. var uvs = [];
  91727. var diameter = options.diameter || 1;
  91728. var thickness = options.thickness || 0.5;
  91729. var tessellation = options.tessellation || 16;
  91730. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  91731. var stride = tessellation + 1;
  91732. for (var i = 0; i <= tessellation; i++) {
  91733. var u = i / tessellation;
  91734. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  91735. var transform = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(diameter / 2.0, 0, 0).multiply(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(outerAngle));
  91736. for (var j = 0; j <= tessellation; j++) {
  91737. var v = 1 - j / tessellation;
  91738. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  91739. var dx = Math.cos(innerAngle);
  91740. var dy = Math.sin(innerAngle);
  91741. // Create a vertex.
  91742. var normal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  91743. var position = normal.scale(thickness / 2);
  91744. var textureCoordinate = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  91745. position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  91746. normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  91747. positions.push(position.x, position.y, position.z);
  91748. normals.push(normal.x, normal.y, normal.z);
  91749. uvs.push(textureCoordinate.x, textureCoordinate.y);
  91750. // And create indices for two triangles.
  91751. var nextI = (i + 1) % stride;
  91752. var nextJ = (j + 1) % stride;
  91753. indices.push(i * stride + j);
  91754. indices.push(i * stride + nextJ);
  91755. indices.push(nextI * stride + j);
  91756. indices.push(i * stride + nextJ);
  91757. indices.push(nextI * stride + nextJ);
  91758. indices.push(nextI * stride + j);
  91759. }
  91760. }
  91761. // Sides
  91762. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  91763. // Result
  91764. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  91765. vertexData.indices = indices;
  91766. vertexData.positions = positions;
  91767. vertexData.normals = normals;
  91768. vertexData.uvs = uvs;
  91769. return vertexData;
  91770. };
  91771. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  91772. var options = {
  91773. diameter: diameter,
  91774. thickness: thickness,
  91775. tessellation: tessellation,
  91776. sideOrientation: sideOrientation,
  91777. updatable: updatable
  91778. };
  91779. return TorusBuilder.CreateTorus(name, options, scene);
  91780. };
  91781. /**
  91782. * Class containing static functions to help procedurally build meshes
  91783. */
  91784. var TorusBuilder = /** @class */ (function () {
  91785. function TorusBuilder() {
  91786. }
  91787. /**
  91788. * Creates a torus mesh
  91789. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  91790. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  91791. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  91792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91793. * * 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
  91794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91795. * @param name defines the name of the mesh
  91796. * @param options defines the options used to create the mesh
  91797. * @param scene defines the hosting scene
  91798. * @returns the torus mesh
  91799. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  91800. */
  91801. TorusBuilder.CreateTorus = function (name, options, scene) {
  91802. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  91803. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  91804. torus._originalBuilderSideOrientation = options.sideOrientation;
  91805. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  91806. vertexData.applyToMesh(torus, options.updatable);
  91807. return torus;
  91808. };
  91809. return TorusBuilder;
  91810. }());
  91811. /***/ }),
  91812. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  91813. /*!*********************************************!*\
  91814. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  91815. \*********************************************/
  91816. /*! exports provided: TorusKnotBuilder */
  91817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91818. "use strict";
  91819. __webpack_require__.r(__webpack_exports__);
  91820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  91821. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  91822. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  91823. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91824. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  91825. var indices = new Array();
  91826. var positions = new Array();
  91827. var normals = new Array();
  91828. var uvs = new Array();
  91829. var radius = options.radius || 2;
  91830. var tube = options.tube || 0.5;
  91831. var radialSegments = options.radialSegments || 32;
  91832. var tubularSegments = options.tubularSegments || 32;
  91833. var p = options.p || 2;
  91834. var q = options.q || 3;
  91835. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  91836. // Helper
  91837. var getPos = function (angle) {
  91838. var cu = Math.cos(angle);
  91839. var su = Math.sin(angle);
  91840. var quOverP = q / p * angle;
  91841. var cs = Math.cos(quOverP);
  91842. var tx = radius * (2 + cs) * 0.5 * cu;
  91843. var ty = radius * (2 + cs) * su * 0.5;
  91844. var tz = radius * Math.sin(quOverP) * 0.5;
  91845. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  91846. };
  91847. // Vertices
  91848. var i;
  91849. var j;
  91850. for (i = 0; i <= radialSegments; i++) {
  91851. var modI = i % radialSegments;
  91852. var u = modI / radialSegments * 2 * p * Math.PI;
  91853. var p1 = getPos(u);
  91854. var p2 = getPos(u + 0.01);
  91855. var tang = p2.subtract(p1);
  91856. var n = p2.add(p1);
  91857. var bitan = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  91858. n = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  91859. bitan.normalize();
  91860. n.normalize();
  91861. for (j = 0; j < tubularSegments; j++) {
  91862. var modJ = j % tubularSegments;
  91863. var v = modJ / tubularSegments * 2 * Math.PI;
  91864. var cx = -tube * Math.cos(v);
  91865. var cy = tube * Math.sin(v);
  91866. positions.push(p1.x + cx * n.x + cy * bitan.x);
  91867. positions.push(p1.y + cx * n.y + cy * bitan.y);
  91868. positions.push(p1.z + cx * n.z + cy * bitan.z);
  91869. uvs.push(i / radialSegments);
  91870. uvs.push(j / tubularSegments);
  91871. }
  91872. }
  91873. for (i = 0; i < radialSegments; i++) {
  91874. for (j = 0; j < tubularSegments; j++) {
  91875. var jNext = (j + 1) % tubularSegments;
  91876. var a = i * tubularSegments + j;
  91877. var b = (i + 1) * tubularSegments + j;
  91878. var c = (i + 1) * tubularSegments + jNext;
  91879. var d = i * tubularSegments + jNext;
  91880. indices.push(d);
  91881. indices.push(b);
  91882. indices.push(a);
  91883. indices.push(d);
  91884. indices.push(c);
  91885. indices.push(b);
  91886. }
  91887. }
  91888. // Normals
  91889. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  91890. // Sides
  91891. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  91892. // Result
  91893. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  91894. vertexData.indices = indices;
  91895. vertexData.positions = positions;
  91896. vertexData.normals = normals;
  91897. vertexData.uvs = uvs;
  91898. return vertexData;
  91899. };
  91900. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  91901. var options = {
  91902. radius: radius,
  91903. tube: tube,
  91904. radialSegments: radialSegments,
  91905. tubularSegments: tubularSegments,
  91906. p: p,
  91907. q: q,
  91908. sideOrientation: sideOrientation,
  91909. updatable: updatable
  91910. };
  91911. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  91912. };
  91913. /**
  91914. * Class containing static functions to help procedurally build meshes
  91915. */
  91916. var TorusKnotBuilder = /** @class */ (function () {
  91917. function TorusKnotBuilder() {
  91918. }
  91919. /**
  91920. * Creates a torus knot mesh
  91921. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  91922. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  91923. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  91924. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  91925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91926. * * 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
  91927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91928. * @param name defines the name of the mesh
  91929. * @param options defines the options used to create the mesh
  91930. * @param scene defines the hosting scene
  91931. * @returns the torus knot mesh
  91932. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  91933. */
  91934. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  91935. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  91936. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  91937. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  91938. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  91939. vertexData.applyToMesh(torusKnot, options.updatable);
  91940. return torusKnot;
  91941. };
  91942. return TorusKnotBuilder;
  91943. }());
  91944. /***/ }),
  91945. /***/ "./Meshes/Builders/tubeBuilder.ts":
  91946. /*!****************************************!*\
  91947. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  91948. \****************************************/
  91949. /*! exports provided: TubeBuilder */
  91950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91951. "use strict";
  91952. __webpack_require__.r(__webpack_exports__);
  91953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  91954. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  91955. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  91956. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  91957. /* harmony import */ var _Maths_math_path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.path */ "./Maths/math.path.ts");
  91958. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  91959. var options = {
  91960. path: path,
  91961. radius: radius,
  91962. tessellation: tessellation,
  91963. radiusFunction: radiusFunction,
  91964. arc: 1,
  91965. cap: cap,
  91966. updatable: updatable,
  91967. sideOrientation: sideOrientation,
  91968. instance: instance
  91969. };
  91970. return TubeBuilder.CreateTube(name, options, scene);
  91971. };
  91972. /**
  91973. * Class containing static functions to help procedurally build meshes
  91974. */
  91975. var TubeBuilder = /** @class */ (function () {
  91976. function TubeBuilder() {
  91977. }
  91978. /**
  91979. * Creates a tube mesh.
  91980. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  91981. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  91982. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  91983. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  91984. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  91985. * * 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)
  91986. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  91987. * * 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
  91988. * * 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
  91989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91990. * * 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
  91991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91993. * @param name defines the name of the mesh
  91994. * @param options defines the options used to create the mesh
  91995. * @param scene defines the hosting scene
  91996. * @returns the tube mesh
  91997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91998. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  91999. */
  92000. TubeBuilder.CreateTube = function (name, options, scene) {
  92001. if (scene === void 0) { scene = null; }
  92002. var path = options.path;
  92003. var instance = options.instance;
  92004. var radius = 1.0;
  92005. if (options.radius !== undefined) {
  92006. radius = options.radius;
  92007. }
  92008. else if (instance) {
  92009. radius = instance._creationDataStorage.radius;
  92010. }
  92011. var tessellation = options.tessellation || 64 | 0;
  92012. var radiusFunction = options.radiusFunction || null;
  92013. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  92014. var invertUV = options.invertUV || false;
  92015. var updatable = options.updatable;
  92016. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  92017. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  92018. // tube geometry
  92019. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  92020. var tangents = path3D.getTangents();
  92021. var normals = path3D.getNormals();
  92022. var distances = path3D.getDistances();
  92023. var pi2 = Math.PI * 2;
  92024. var step = pi2 / tessellation * arc;
  92025. var returnRadius = function () { return radius; };
  92026. var radiusFunctionFinal = radiusFunction || returnRadius;
  92027. var circlePath;
  92028. var rad;
  92029. var normal;
  92030. var rotated;
  92031. var rotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  92032. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  92033. for (var i = 0; i < path.length; i++) {
  92034. rad = radiusFunctionFinal(i, distances[i]); // current radius
  92035. circlePath = Array(); // current circle array
  92036. normal = normals[i]; // current normal
  92037. for (var t = 0; t < tessellation; t++) {
  92038. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  92039. rotated = circlePath[t] ? circlePath[t] : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  92040. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  92041. rotated.scaleInPlace(rad).addInPlace(path[i]);
  92042. circlePath[t] = rotated;
  92043. }
  92044. circlePaths[index] = circlePath;
  92045. index++;
  92046. }
  92047. // cap
  92048. var capPath = function (nbPoints, pathIndex) {
  92049. var pointCap = Array();
  92050. for (var i = 0; i < nbPoints; i++) {
  92051. pointCap.push(path[pathIndex]);
  92052. }
  92053. return pointCap;
  92054. };
  92055. switch (cap) {
  92056. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  92057. break;
  92058. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  92059. circlePaths[0] = capPath(tessellation, 0);
  92060. circlePaths[1] = circlePaths[2].slice(0);
  92061. break;
  92062. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  92063. circlePaths[index] = circlePaths[index - 1].slice(0);
  92064. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  92065. break;
  92066. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  92067. circlePaths[0] = capPath(tessellation, 0);
  92068. circlePaths[1] = circlePaths[2].slice(0);
  92069. circlePaths[index] = circlePaths[index - 1].slice(0);
  92070. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  92071. break;
  92072. default:
  92073. break;
  92074. }
  92075. return circlePaths;
  92076. };
  92077. var path3D;
  92078. var pathArray;
  92079. if (instance) { // tube update
  92080. var storage = instance._creationDataStorage;
  92081. var arc = options.arc || storage.arc;
  92082. path3D = storage.path3D.update(path);
  92083. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  92084. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  92085. // Update mode, no need to recreate the storage.
  92086. storage.path3D = path3D;
  92087. storage.pathArray = pathArray;
  92088. storage.arc = arc;
  92089. storage.radius = radius;
  92090. return instance;
  92091. }
  92092. // tube creation
  92093. path3D = new _Maths_math_path__WEBPACK_IMPORTED_MODULE_3__["Path3D"](path);
  92094. var newPathArray = new Array();
  92095. cap = (cap < 0 || cap > 3) ? 0 : cap;
  92096. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  92097. 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);
  92098. tube._creationDataStorage.pathArray = pathArray;
  92099. tube._creationDataStorage.path3D = path3D;
  92100. tube._creationDataStorage.tessellation = tessellation;
  92101. tube._creationDataStorage.cap = cap;
  92102. tube._creationDataStorage.arc = options.arc;
  92103. tube._creationDataStorage.radius = radius;
  92104. return tube;
  92105. };
  92106. return TubeBuilder;
  92107. }());
  92108. /***/ }),
  92109. /***/ "./Meshes/Compression/dracoCompression.ts":
  92110. /*!************************************************!*\
  92111. !*** ./Meshes/Compression/dracoCompression.ts ***!
  92112. \************************************************/
  92113. /*! exports provided: DracoCompression */
  92114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92115. "use strict";
  92116. __webpack_require__.r(__webpack_exports__);
  92117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  92118. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  92119. /* harmony import */ var _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/workerPool */ "./Misc/workerPool.ts");
  92120. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92121. function loadScriptAsync(url) {
  92122. if (typeof importScripts === "function") {
  92123. importScripts(url);
  92124. return Promise.resolve();
  92125. }
  92126. else {
  92127. return new Promise(function (resolve, reject) {
  92128. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  92129. resolve();
  92130. }, function (message) {
  92131. reject(new Error(message));
  92132. });
  92133. });
  92134. }
  92135. }
  92136. function loadFileAsync(url) {
  92137. return new Promise(function (resolve, reject) {
  92138. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  92139. resolve(data);
  92140. }, undefined, undefined, true, function (request, exception) {
  92141. reject(exception);
  92142. });
  92143. });
  92144. }
  92145. function createDecoderAsync(wasmUrl, wasmBinary, fallbackUrl) {
  92146. var decoderUrl = (wasmBinary && wasmUrl) || fallbackUrl;
  92147. if (decoderUrl) {
  92148. return loadScriptAsync(decoderUrl).then(function () {
  92149. return new Promise(function (resolve) {
  92150. DracoDecoderModule({ wasmBinary: wasmBinary }).then(function (module) {
  92151. resolve({ module: module });
  92152. });
  92153. });
  92154. });
  92155. }
  92156. return undefined;
  92157. }
  92158. function decodeMesh(decoderModule, dataView, attributes, onIndicesData, onAttributeData) {
  92159. var buffer = new decoderModule.DecoderBuffer();
  92160. buffer.Init(dataView, dataView.byteLength);
  92161. var decoder = new decoderModule.Decoder();
  92162. var geometry;
  92163. var status;
  92164. try {
  92165. var type = decoder.GetEncodedGeometryType(buffer);
  92166. switch (type) {
  92167. case decoderModule.TRIANGULAR_MESH:
  92168. geometry = new decoderModule.Mesh();
  92169. status = decoder.DecodeBufferToMesh(buffer, geometry);
  92170. break;
  92171. case decoderModule.POINT_CLOUD:
  92172. geometry = new decoderModule.PointCloud();
  92173. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  92174. break;
  92175. default:
  92176. throw new Error("Invalid geometry type " + type);
  92177. }
  92178. if (!status.ok() || !geometry.ptr) {
  92179. throw new Error(status.error_msg());
  92180. }
  92181. var numPoints_1 = geometry.num_points();
  92182. if (type === decoderModule.TRIANGULAR_MESH) {
  92183. var numFaces = geometry.num_faces();
  92184. var faceIndices = new decoderModule.DracoInt32Array();
  92185. try {
  92186. var indices = new Uint32Array(numFaces * 3);
  92187. for (var i = 0; i < numFaces; i++) {
  92188. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  92189. var offset = i * 3;
  92190. indices[offset + 0] = faceIndices.GetValue(0);
  92191. indices[offset + 1] = faceIndices.GetValue(1);
  92192. indices[offset + 2] = faceIndices.GetValue(2);
  92193. }
  92194. onIndicesData(indices);
  92195. }
  92196. finally {
  92197. decoderModule.destroy(faceIndices);
  92198. }
  92199. }
  92200. var processAttribute = function (kind, attribute) {
  92201. var dracoData = new decoderModule.DracoFloat32Array();
  92202. try {
  92203. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  92204. var babylonData = new Float32Array(numPoints_1 * attribute.num_components());
  92205. for (var i = 0; i < babylonData.length; i++) {
  92206. babylonData[i] = dracoData.GetValue(i);
  92207. }
  92208. onAttributeData(kind, babylonData);
  92209. }
  92210. finally {
  92211. decoderModule.destroy(dracoData);
  92212. }
  92213. };
  92214. if (attributes) {
  92215. for (var kind in attributes) {
  92216. var id = attributes[kind];
  92217. var attribute = decoder.GetAttributeByUniqueId(geometry, id);
  92218. processAttribute(kind, attribute);
  92219. }
  92220. }
  92221. else {
  92222. var nativeAttributeTypes = {
  92223. "position": "POSITION",
  92224. "normal": "NORMAL",
  92225. "color": "COLOR",
  92226. "uv": "TEX_COORD"
  92227. };
  92228. for (var kind in nativeAttributeTypes) {
  92229. var id = decoder.GetAttributeId(geometry, decoderModule[nativeAttributeTypes[kind]]);
  92230. if (id !== -1) {
  92231. var attribute = decoder.GetAttribute(geometry, id);
  92232. processAttribute(kind, attribute);
  92233. }
  92234. }
  92235. }
  92236. }
  92237. finally {
  92238. if (geometry) {
  92239. decoderModule.destroy(geometry);
  92240. }
  92241. decoderModule.destroy(decoder);
  92242. decoderModule.destroy(buffer);
  92243. }
  92244. }
  92245. /**
  92246. * The worker function that gets converted to a blob url to pass into a worker.
  92247. */
  92248. function worker() {
  92249. var decoderPromise;
  92250. onmessage = function (event) {
  92251. var data = event.data;
  92252. switch (data.id) {
  92253. case "init": {
  92254. var decoder = data.decoder;
  92255. decoderPromise = createDecoderAsync(decoder.wasmUrl, decoder.wasmBinary, decoder.fallbackUrl);
  92256. postMessage("done");
  92257. break;
  92258. }
  92259. case "decodeMesh": {
  92260. if (!decoderPromise) {
  92261. throw new Error("Draco decoder module is not available");
  92262. }
  92263. decoderPromise.then(function (decoder) {
  92264. decodeMesh(decoder.module, data.dataView, data.attributes, function (indices) {
  92265. postMessage({ id: "indices", value: indices }, [indices.buffer]);
  92266. }, function (kind, data) {
  92267. postMessage({ id: kind, value: data }, [data.buffer]);
  92268. });
  92269. postMessage("done");
  92270. });
  92271. break;
  92272. }
  92273. }
  92274. };
  92275. }
  92276. function getAbsoluteUrl(url) {
  92277. if (typeof document !== "object" || typeof url !== "string") {
  92278. return url;
  92279. }
  92280. return _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(url);
  92281. }
  92282. /**
  92283. * Draco compression (https://google.github.io/draco/)
  92284. *
  92285. * This class wraps the Draco module.
  92286. *
  92287. * **Encoder**
  92288. *
  92289. * The encoder is not currently implemented.
  92290. *
  92291. * **Decoder**
  92292. *
  92293. * 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.
  92294. *
  92295. * To update the configuration, use the following code:
  92296. * ```javascript
  92297. * DracoCompression.Configuration = {
  92298. * decoder: {
  92299. * wasmUrl: "<url to the WebAssembly library>",
  92300. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  92301. * fallbackUrl: "<url to the fallback JavaScript library>",
  92302. * }
  92303. * };
  92304. * ```
  92305. *
  92306. * 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.
  92307. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  92308. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  92309. *
  92310. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  92311. * ```javascript
  92312. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  92313. * ```
  92314. *
  92315. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  92316. */
  92317. var DracoCompression = /** @class */ (function () {
  92318. /**
  92319. * Constructor
  92320. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  92321. */
  92322. function DracoCompression(numWorkers) {
  92323. if (numWorkers === void 0) { numWorkers = DracoCompression.DefaultNumWorkers; }
  92324. var decoder = DracoCompression.Configuration.decoder;
  92325. var decoderWasmBinaryPromise = (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object")
  92326. ? loadFileAsync(getAbsoluteUrl(decoder.wasmBinaryUrl))
  92327. : Promise.resolve(undefined);
  92328. if (numWorkers && typeof Worker === "function") {
  92329. this._workerPoolPromise = decoderWasmBinaryPromise.then(function (decoderWasmBinary) {
  92330. var workerContent = "" + loadScriptAsync + createDecoderAsync + decodeMesh + "(" + worker + ")()";
  92331. var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
  92332. var workerPromises = new Array(numWorkers);
  92333. for (var i = 0; i < workerPromises.length; i++) {
  92334. workerPromises[i] = new Promise(function (resolve, reject) {
  92335. var worker = new Worker(workerBlobUrl);
  92336. var onError = function (error) {
  92337. worker.removeEventListener("error", onError);
  92338. worker.removeEventListener("message", onMessage);
  92339. reject(error);
  92340. };
  92341. var onMessage = function (message) {
  92342. if (message.data === "done") {
  92343. worker.removeEventListener("error", onError);
  92344. worker.removeEventListener("message", onMessage);
  92345. resolve(worker);
  92346. }
  92347. };
  92348. worker.addEventListener("error", onError);
  92349. worker.addEventListener("message", onMessage);
  92350. worker.postMessage({
  92351. id: "init",
  92352. decoder: {
  92353. wasmUrl: getAbsoluteUrl(decoder.wasmUrl),
  92354. wasmBinary: decoderWasmBinary,
  92355. fallbackUrl: getAbsoluteUrl(decoder.fallbackUrl)
  92356. }
  92357. });
  92358. });
  92359. }
  92360. return Promise.all(workerPromises).then(function (workers) {
  92361. return new _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__["WorkerPool"](workers);
  92362. });
  92363. });
  92364. }
  92365. else {
  92366. this._decoderModulePromise = decoderWasmBinaryPromise.then(function (decoderWasmBinary) {
  92367. return createDecoderAsync(decoder.wasmUrl, decoderWasmBinary, decoder.fallbackUrl);
  92368. });
  92369. }
  92370. }
  92371. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  92372. /**
  92373. * Returns true if the decoder configuration is available.
  92374. */
  92375. get: function () {
  92376. var decoder = DracoCompression.Configuration.decoder;
  92377. return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") || decoder.fallbackUrl);
  92378. },
  92379. enumerable: true,
  92380. configurable: true
  92381. });
  92382. DracoCompression.GetDefaultNumWorkers = function () {
  92383. if (typeof navigator !== "object" || !navigator.hardwareConcurrency) {
  92384. return 1;
  92385. }
  92386. // Use 50% of the available logical processors but capped at 4.
  92387. return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);
  92388. };
  92389. Object.defineProperty(DracoCompression, "Default", {
  92390. /**
  92391. * Default instance for the draco compression object.
  92392. */
  92393. get: function () {
  92394. if (!DracoCompression._Default) {
  92395. DracoCompression._Default = new DracoCompression();
  92396. }
  92397. return DracoCompression._Default;
  92398. },
  92399. enumerable: true,
  92400. configurable: true
  92401. });
  92402. /**
  92403. * Stop all async operations and release resources.
  92404. */
  92405. DracoCompression.prototype.dispose = function () {
  92406. if (this._workerPoolPromise) {
  92407. this._workerPoolPromise.then(function (workerPool) {
  92408. workerPool.dispose();
  92409. });
  92410. }
  92411. delete this._workerPoolPromise;
  92412. delete this._decoderModulePromise;
  92413. };
  92414. /**
  92415. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  92416. * @returns a promise that resolves when ready
  92417. */
  92418. DracoCompression.prototype.whenReadyAsync = function () {
  92419. if (this._workerPoolPromise) {
  92420. return this._workerPoolPromise.then(function () { });
  92421. }
  92422. if (this._decoderModulePromise) {
  92423. return this._decoderModulePromise.then(function () { });
  92424. }
  92425. return Promise.resolve();
  92426. };
  92427. /**
  92428. * Decode Draco compressed mesh data to vertex data.
  92429. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  92430. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  92431. * @returns A promise that resolves with the decoded vertex data
  92432. */
  92433. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  92434. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  92435. if (this._workerPoolPromise) {
  92436. return this._workerPoolPromise.then(function (workerPool) {
  92437. return new Promise(function (resolve, reject) {
  92438. workerPool.push(function (worker, onComplete) {
  92439. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  92440. var onError = function (error) {
  92441. worker.removeEventListener("error", onError);
  92442. worker.removeEventListener("message", onMessage);
  92443. reject(error);
  92444. onComplete();
  92445. };
  92446. var onMessage = function (message) {
  92447. if (message.data === "done") {
  92448. worker.removeEventListener("error", onError);
  92449. worker.removeEventListener("message", onMessage);
  92450. resolve(vertexData);
  92451. onComplete();
  92452. }
  92453. else if (message.data.id === "indices") {
  92454. vertexData.indices = message.data.value;
  92455. }
  92456. else {
  92457. vertexData.set(message.data.value, message.data.id);
  92458. }
  92459. };
  92460. worker.addEventListener("error", onError);
  92461. worker.addEventListener("message", onMessage);
  92462. var dataViewCopy = new Uint8Array(dataView.byteLength);
  92463. dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));
  92464. worker.postMessage({ id: "decodeMesh", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);
  92465. });
  92466. });
  92467. });
  92468. }
  92469. if (this._decoderModulePromise) {
  92470. return this._decoderModulePromise.then(function (decoder) {
  92471. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  92472. decodeMesh(decoder.module, dataView, attributes, function (indices) {
  92473. vertexData.indices = indices;
  92474. }, function (kind, data) {
  92475. vertexData.set(data, kind);
  92476. });
  92477. return vertexData;
  92478. });
  92479. }
  92480. throw new Error("Draco decoder module is not available");
  92481. };
  92482. /**
  92483. * The configuration. Defaults to the following urls:
  92484. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  92485. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  92486. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  92487. */
  92488. DracoCompression.Configuration = {
  92489. decoder: {
  92490. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  92491. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  92492. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  92493. }
  92494. };
  92495. /**
  92496. * Default number of workers to create when creating the draco compression object.
  92497. */
  92498. DracoCompression.DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();
  92499. DracoCompression._Default = null;
  92500. return DracoCompression;
  92501. }());
  92502. /***/ }),
  92503. /***/ "./Meshes/Compression/index.ts":
  92504. /*!*************************************!*\
  92505. !*** ./Meshes/Compression/index.ts ***!
  92506. \*************************************/
  92507. /*! exports provided: DracoCompression */
  92508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92509. "use strict";
  92510. __webpack_require__.r(__webpack_exports__);
  92511. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  92512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  92513. /***/ }),
  92514. /***/ "./Meshes/WebGL/webGLDataBuffer.ts":
  92515. /*!*****************************************!*\
  92516. !*** ./Meshes/WebGL/webGLDataBuffer.ts ***!
  92517. \*****************************************/
  92518. /*! exports provided: WebGLDataBuffer */
  92519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92520. "use strict";
  92521. __webpack_require__.r(__webpack_exports__);
  92522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return WebGLDataBuffer; });
  92523. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92524. /* harmony import */ var _dataBuffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../dataBuffer */ "./Meshes/dataBuffer.ts");
  92525. /** @hidden */
  92526. var WebGLDataBuffer = /** @class */ (function (_super) {
  92527. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebGLDataBuffer, _super);
  92528. function WebGLDataBuffer(resource) {
  92529. var _this = _super.call(this) || this;
  92530. _this._buffer = resource;
  92531. return _this;
  92532. }
  92533. Object.defineProperty(WebGLDataBuffer.prototype, "underlyingResource", {
  92534. get: function () {
  92535. return this._buffer;
  92536. },
  92537. enumerable: true,
  92538. configurable: true
  92539. });
  92540. return WebGLDataBuffer;
  92541. }(_dataBuffer__WEBPACK_IMPORTED_MODULE_1__["DataBuffer"]));
  92542. /***/ }),
  92543. /***/ "./Meshes/abstractMesh.ts":
  92544. /*!********************************!*\
  92545. !*** ./Meshes/abstractMesh.ts ***!
  92546. \********************************/
  92547. /*! exports provided: AbstractMesh */
  92548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92549. "use strict";
  92550. __webpack_require__.r(__webpack_exports__);
  92551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  92552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92553. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92554. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  92555. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  92556. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92557. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92558. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92559. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  92560. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  92561. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  92562. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92563. /* harmony import */ var _Collisions_meshCollisionData__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Collisions/meshCollisionData */ "./Collisions/meshCollisionData.ts");
  92564. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  92565. /* harmony import */ var _Maths_math_functions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Maths/math.functions */ "./Maths/math.functions.ts");
  92566. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  92567. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  92568. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  92569. /** @hidden */
  92570. var _FacetDataStorage = /** @class */ (function () {
  92571. function _FacetDataStorage() {
  92572. this.facetNb = 0; // facet number
  92573. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  92574. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  92575. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  92576. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  92577. this.bbSize = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  92578. this.subDiv = {
  92579. max: 1,
  92580. X: 1,
  92581. Y: 1,
  92582. Z: 1
  92583. };
  92584. this.facetDepthSort = false; // is the facet depth sort to be computed
  92585. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  92586. }
  92587. return _FacetDataStorage;
  92588. }());
  92589. /**
  92590. * @hidden
  92591. **/
  92592. var _InternalAbstractMeshDataInfo = /** @class */ (function () {
  92593. function _InternalAbstractMeshDataInfo() {
  92594. this._hasVertexAlpha = false;
  92595. this._useVertexColors = true;
  92596. this._numBoneInfluencers = 4;
  92597. this._applyFog = true;
  92598. this._receiveShadows = false;
  92599. this._facetData = new _FacetDataStorage();
  92600. this._visibility = 1.0;
  92601. this._skeleton = null;
  92602. this._layerMask = 0x0FFFFFFF;
  92603. this._computeBonesUsingShaders = true;
  92604. this._isActive = false;
  92605. this._onlyForInstances = false;
  92606. this._isActiveIntermediate = false;
  92607. this._onlyForInstancesIntermediate = false;
  92608. }
  92609. return _InternalAbstractMeshDataInfo;
  92610. }());
  92611. /**
  92612. * Class used to store all common mesh properties
  92613. */
  92614. var AbstractMesh = /** @class */ (function (_super) {
  92615. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  92616. // Constructor
  92617. /**
  92618. * Creates a new AbstractMesh
  92619. * @param name defines the name of the mesh
  92620. * @param scene defines the hosting scene
  92621. */
  92622. function AbstractMesh(name, scene) {
  92623. if (scene === void 0) { scene = null; }
  92624. var _this = _super.call(this, name, scene, false) || this;
  92625. // Internal data
  92626. /** @hidden */
  92627. _this._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo();
  92628. /**
  92629. * The culling strategy to use to check whether the mesh must be rendered or not.
  92630. * This value can be changed at any time and will be used on the next render mesh selection.
  92631. * The possible values are :
  92632. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92633. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92634. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92635. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92636. * Please read each static variable documentation to get details about the culling process.
  92637. * */
  92638. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  92639. // Events
  92640. /**
  92641. * An event triggered when this mesh collides with another one
  92642. */
  92643. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  92644. /**
  92645. * An event triggered when the collision's position changes
  92646. */
  92647. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  92648. /**
  92649. * An event triggered when material is changed
  92650. */
  92651. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  92652. // Properties
  92653. /**
  92654. * Gets or sets the orientation for POV movement & rotation
  92655. */
  92656. _this.definedFacingForward = true;
  92657. /** @hidden */
  92658. _this._occlusionQuery = null;
  92659. /** @hidden */
  92660. _this._renderingGroup = null;
  92661. /** Gets or sets the alpha index used to sort transparent meshes
  92662. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92663. */
  92664. _this.alphaIndex = Number.MAX_VALUE;
  92665. /**
  92666. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92667. */
  92668. _this.isVisible = true;
  92669. /**
  92670. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92671. */
  92672. _this.isPickable = true;
  92673. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92674. _this.showSubMeshesBoundingBox = false;
  92675. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92677. */
  92678. _this.isBlocker = false;
  92679. /**
  92680. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92681. */
  92682. _this.enablePointerMoveEvents = false;
  92683. /**
  92684. * Specifies the rendering group id for this mesh (0 by default)
  92685. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92686. */
  92687. _this.renderingGroupId = 0;
  92688. _this._material = null;
  92689. /** Defines color to use when rendering outline */
  92690. _this.outlineColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__["Color3"].Red();
  92691. /** Define width to use when rendering outline */
  92692. _this.outlineWidth = 0.02;
  92693. /** Defines color to use when rendering overlay */
  92694. _this.overlayColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__["Color3"].Red();
  92695. /** Defines alpha to use when rendering overlay */
  92696. _this.overlayAlpha = 0.5;
  92697. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92698. _this.useOctreeForRenderingSelection = true;
  92699. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92700. _this.useOctreeForPicking = true;
  92701. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92702. _this.useOctreeForCollisions = true;
  92703. /**
  92704. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92705. */
  92706. _this.alwaysSelectAsActiveMesh = false;
  92707. /**
  92708. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92709. */
  92710. _this.doNotSyncBoundingInfo = false;
  92711. /**
  92712. * Gets or sets the current action manager
  92713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92714. */
  92715. _this.actionManager = null;
  92716. // Collisions
  92717. _this._meshCollisionData = new _Collisions_meshCollisionData__WEBPACK_IMPORTED_MODULE_11__["_MeshCollisionData"]();
  92718. /**
  92719. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92721. */
  92722. _this.ellipsoid = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  92723. /**
  92724. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92726. */
  92727. _this.ellipsoidOffset = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  92728. // Edges
  92729. /**
  92730. * Defines edge width used when edgesRenderer is enabled
  92731. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92732. */
  92733. _this.edgesWidth = 1;
  92734. /**
  92735. * Defines edge color used when edgesRenderer is enabled
  92736. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92737. */
  92738. _this.edgesColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_14__["Color4"](1, 0, 0, 1);
  92739. /** @hidden */
  92740. _this._edgesRenderer = null;
  92741. /** @hidden */
  92742. _this._masterMesh = null;
  92743. /** @hidden */
  92744. _this._boundingInfo = null;
  92745. /** @hidden */
  92746. _this._renderId = 0;
  92747. /** @hidden */
  92748. _this._intersectionsInProgress = new Array();
  92749. /** @hidden */
  92750. _this._unIndexed = false;
  92751. /** @hidden */
  92752. _this._lightSources = new Array();
  92753. // Loading properties
  92754. /** @hidden */
  92755. _this._waitingData = {
  92756. lods: null,
  92757. actions: null,
  92758. freezeWorldMatrix: null
  92759. };
  92760. /** @hidden */
  92761. _this._bonesTransformMatrices = null;
  92762. /** @hidden */
  92763. _this._transformMatrixTexture = null;
  92764. /**
  92765. * An event triggered when the mesh is rebuilt.
  92766. */
  92767. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  92768. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  92769. if (collidedMesh === void 0) { collidedMesh = null; }
  92770. newPosition.subtractToRef(_this._meshCollisionData._oldPositionForCollisions, _this._meshCollisionData._diffPositionForCollisions);
  92771. if (_this._meshCollisionData._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  92772. _this.position.addInPlace(_this._meshCollisionData._diffPositionForCollisions);
  92773. }
  92774. if (collidedMesh) {
  92775. _this.onCollideObservable.notifyObservers(collidedMesh);
  92776. }
  92777. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  92778. };
  92779. _this.getScene().addMesh(_this);
  92780. _this._resyncLightSources();
  92781. return _this;
  92782. }
  92783. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  92784. /**
  92785. * No billboard
  92786. */
  92787. get: function () {
  92788. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  92789. },
  92790. enumerable: true,
  92791. configurable: true
  92792. });
  92793. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  92794. /** Billboard on X axis */
  92795. get: function () {
  92796. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  92797. },
  92798. enumerable: true,
  92799. configurable: true
  92800. });
  92801. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  92802. /** Billboard on Y axis */
  92803. get: function () {
  92804. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  92805. },
  92806. enumerable: true,
  92807. configurable: true
  92808. });
  92809. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  92810. /** Billboard on Z axis */
  92811. get: function () {
  92812. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  92813. },
  92814. enumerable: true,
  92815. configurable: true
  92816. });
  92817. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  92818. /** Billboard on all axes */
  92819. get: function () {
  92820. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  92821. },
  92822. enumerable: true,
  92823. configurable: true
  92824. });
  92825. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  92826. /**
  92827. * Gets the number of facets in the mesh
  92828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92829. */
  92830. get: function () {
  92831. return this._internalAbstractMeshDataInfo._facetData.facetNb;
  92832. },
  92833. enumerable: true,
  92834. configurable: true
  92835. });
  92836. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  92837. /**
  92838. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92840. */
  92841. get: function () {
  92842. return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions;
  92843. },
  92844. set: function (nb) {
  92845. this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = nb;
  92846. },
  92847. enumerable: true,
  92848. configurable: true
  92849. });
  92850. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  92851. /**
  92852. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92853. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92855. */
  92856. get: function () {
  92857. return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio;
  92858. },
  92859. set: function (ratio) {
  92860. this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = ratio;
  92861. },
  92862. enumerable: true,
  92863. configurable: true
  92864. });
  92865. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  92866. /**
  92867. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92868. * Works only for updatable meshes.
  92869. * Doesn't work with multi-materials
  92870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92871. */
  92872. get: function () {
  92873. return this._internalAbstractMeshDataInfo._facetData.facetDepthSort;
  92874. },
  92875. set: function (sort) {
  92876. this._internalAbstractMeshDataInfo._facetData.facetDepthSort = sort;
  92877. },
  92878. enumerable: true,
  92879. configurable: true
  92880. });
  92881. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  92882. /**
  92883. * The location (Vector3) where the facet depth sort must be computed from.
  92884. * By default, the active camera position.
  92885. * Used only when facet depth sort is enabled
  92886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92887. */
  92888. get: function () {
  92889. return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom;
  92890. },
  92891. set: function (location) {
  92892. this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = location;
  92893. },
  92894. enumerable: true,
  92895. configurable: true
  92896. });
  92897. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  92898. /**
  92899. * gets a boolean indicating if facetData is enabled
  92900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92901. */
  92902. get: function () {
  92903. return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled;
  92904. },
  92905. enumerable: true,
  92906. configurable: true
  92907. });
  92908. /** @hidden */
  92909. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  92910. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  92911. return false;
  92912. }
  92913. this._markSubMeshesAsMiscDirty();
  92914. return true;
  92915. };
  92916. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  92917. /** Set a function to call when this mesh collides with another one */
  92918. set: function (callback) {
  92919. if (this._meshCollisionData._onCollideObserver) {
  92920. this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver);
  92921. }
  92922. this._meshCollisionData._onCollideObserver = this.onCollideObservable.add(callback);
  92923. },
  92924. enumerable: true,
  92925. configurable: true
  92926. });
  92927. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  92928. /** Set a function to call when the collision's position changes */
  92929. set: function (callback) {
  92930. if (this._meshCollisionData._onCollisionPositionChangeObserver) {
  92931. this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver);
  92932. }
  92933. this._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  92934. },
  92935. enumerable: true,
  92936. configurable: true
  92937. });
  92938. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  92939. /**
  92940. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92941. */
  92942. get: function () {
  92943. return this._internalAbstractMeshDataInfo._visibility;
  92944. },
  92945. /**
  92946. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92947. */
  92948. set: function (value) {
  92949. if (this._internalAbstractMeshDataInfo._visibility === value) {
  92950. return;
  92951. }
  92952. this._internalAbstractMeshDataInfo._visibility = value;
  92953. this._markSubMeshesAsMiscDirty();
  92954. },
  92955. enumerable: true,
  92956. configurable: true
  92957. });
  92958. Object.defineProperty(AbstractMesh.prototype, "material", {
  92959. /** Gets or sets current material */
  92960. get: function () {
  92961. return this._material;
  92962. },
  92963. set: function (value) {
  92964. if (this._material === value) {
  92965. return;
  92966. }
  92967. // remove from material mesh map id needed
  92968. if (this._material && this._material.meshMap) {
  92969. this._material.meshMap[this.uniqueId] = undefined;
  92970. }
  92971. this._material = value;
  92972. if (value && value.meshMap) {
  92973. value.meshMap[this.uniqueId] = this;
  92974. }
  92975. if (this.onMaterialChangedObservable.hasObservers) {
  92976. this.onMaterialChangedObservable.notifyObservers(this);
  92977. }
  92978. if (!this.subMeshes) {
  92979. return;
  92980. }
  92981. this._unBindEffect();
  92982. },
  92983. enumerable: true,
  92984. configurable: true
  92985. });
  92986. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  92987. /**
  92988. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92989. * @see http://doc.babylonjs.com/babylon101/shadows
  92990. */
  92991. get: function () {
  92992. return this._internalAbstractMeshDataInfo._receiveShadows;
  92993. },
  92994. set: function (value) {
  92995. if (this._internalAbstractMeshDataInfo._receiveShadows === value) {
  92996. return;
  92997. }
  92998. this._internalAbstractMeshDataInfo._receiveShadows = value;
  92999. this._markSubMeshesAsLightDirty();
  93000. },
  93001. enumerable: true,
  93002. configurable: true
  93003. });
  93004. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  93005. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93006. get: function () {
  93007. return this._internalAbstractMeshDataInfo._hasVertexAlpha;
  93008. },
  93009. set: function (value) {
  93010. if (this._internalAbstractMeshDataInfo._hasVertexAlpha === value) {
  93011. return;
  93012. }
  93013. this._internalAbstractMeshDataInfo._hasVertexAlpha = value;
  93014. this._markSubMeshesAsAttributesDirty();
  93015. this._markSubMeshesAsMiscDirty();
  93016. },
  93017. enumerable: true,
  93018. configurable: true
  93019. });
  93020. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  93021. /** 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) */
  93022. get: function () {
  93023. return this._internalAbstractMeshDataInfo._useVertexColors;
  93024. },
  93025. set: function (value) {
  93026. if (this._internalAbstractMeshDataInfo._useVertexColors === value) {
  93027. return;
  93028. }
  93029. this._internalAbstractMeshDataInfo._useVertexColors = value;
  93030. this._markSubMeshesAsAttributesDirty();
  93031. },
  93032. enumerable: true,
  93033. configurable: true
  93034. });
  93035. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  93036. /**
  93037. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93038. */
  93039. get: function () {
  93040. return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
  93041. },
  93042. set: function (value) {
  93043. if (this._internalAbstractMeshDataInfo._computeBonesUsingShaders === value) {
  93044. return;
  93045. }
  93046. this._internalAbstractMeshDataInfo._computeBonesUsingShaders = value;
  93047. this._markSubMeshesAsAttributesDirty();
  93048. },
  93049. enumerable: true,
  93050. configurable: true
  93051. });
  93052. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  93053. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93054. get: function () {
  93055. return this._internalAbstractMeshDataInfo._numBoneInfluencers;
  93056. },
  93057. set: function (value) {
  93058. if (this._internalAbstractMeshDataInfo._numBoneInfluencers === value) {
  93059. return;
  93060. }
  93061. this._internalAbstractMeshDataInfo._numBoneInfluencers = value;
  93062. this._markSubMeshesAsAttributesDirty();
  93063. },
  93064. enumerable: true,
  93065. configurable: true
  93066. });
  93067. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  93068. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93069. get: function () {
  93070. return this._internalAbstractMeshDataInfo._applyFog;
  93071. },
  93072. set: function (value) {
  93073. if (this._internalAbstractMeshDataInfo._applyFog === value) {
  93074. return;
  93075. }
  93076. this._internalAbstractMeshDataInfo._applyFog = value;
  93077. this._markSubMeshesAsMiscDirty();
  93078. },
  93079. enumerable: true,
  93080. configurable: true
  93081. });
  93082. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  93083. /**
  93084. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93085. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93086. */
  93087. get: function () {
  93088. return this._internalAbstractMeshDataInfo._layerMask;
  93089. },
  93090. set: function (value) {
  93091. if (value === this._internalAbstractMeshDataInfo._layerMask) {
  93092. return;
  93093. }
  93094. this._internalAbstractMeshDataInfo._layerMask = value;
  93095. this._resyncLightSources();
  93096. },
  93097. enumerable: true,
  93098. configurable: true
  93099. });
  93100. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  93101. /**
  93102. * Gets or sets a collision mask used to mask collisions (default is -1).
  93103. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93104. */
  93105. get: function () {
  93106. return this._meshCollisionData._collisionMask;
  93107. },
  93108. set: function (mask) {
  93109. this._meshCollisionData._collisionMask = !isNaN(mask) ? mask : -1;
  93110. },
  93111. enumerable: true,
  93112. configurable: true
  93113. });
  93114. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  93115. /**
  93116. * Gets or sets the current collision group mask (-1 by default).
  93117. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93118. */
  93119. get: function () {
  93120. return this._meshCollisionData._collisionGroup;
  93121. },
  93122. set: function (mask) {
  93123. this._meshCollisionData._collisionGroup = !isNaN(mask) ? mask : -1;
  93124. },
  93125. enumerable: true,
  93126. configurable: true
  93127. });
  93128. Object.defineProperty(AbstractMesh.prototype, "lightSources", {
  93129. /** Gets the list of lights affecting that mesh */
  93130. get: function () {
  93131. return this._lightSources;
  93132. },
  93133. enumerable: true,
  93134. configurable: true
  93135. });
  93136. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  93137. /** @hidden */
  93138. get: function () {
  93139. return null;
  93140. },
  93141. enumerable: true,
  93142. configurable: true
  93143. });
  93144. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  93145. get: function () {
  93146. return this._internalAbstractMeshDataInfo._skeleton;
  93147. },
  93148. /**
  93149. * Gets or sets a skeleton to apply skining transformations
  93150. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93151. */
  93152. set: function (value) {
  93153. var skeleton = this._internalAbstractMeshDataInfo._skeleton;
  93154. if (skeleton && skeleton.needInitialSkinMatrix) {
  93155. skeleton._unregisterMeshWithPoseMatrix(this);
  93156. }
  93157. if (value && value.needInitialSkinMatrix) {
  93158. value._registerMeshWithPoseMatrix(this);
  93159. }
  93160. this._internalAbstractMeshDataInfo._skeleton = value;
  93161. if (!this._internalAbstractMeshDataInfo._skeleton) {
  93162. this._bonesTransformMatrices = null;
  93163. }
  93164. this._markSubMeshesAsAttributesDirty();
  93165. },
  93166. enumerable: true,
  93167. configurable: true
  93168. });
  93169. /**
  93170. * Returns the string "AbstractMesh"
  93171. * @returns "AbstractMesh"
  93172. */
  93173. AbstractMesh.prototype.getClassName = function () {
  93174. return "AbstractMesh";
  93175. };
  93176. /**
  93177. * Gets a string representation of the current mesh
  93178. * @param fullDetails defines a boolean indicating if full details must be included
  93179. * @returns a string representation of the current mesh
  93180. */
  93181. AbstractMesh.prototype.toString = function (fullDetails) {
  93182. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  93183. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  93184. var skeleton = this._internalAbstractMeshDataInfo._skeleton;
  93185. if (skeleton) {
  93186. ret += ", skeleton: " + skeleton.name;
  93187. }
  93188. if (fullDetails) {
  93189. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  93190. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO");
  93191. }
  93192. return ret;
  93193. };
  93194. /**
  93195. * @hidden
  93196. */
  93197. AbstractMesh.prototype._getEffectiveParent = function () {
  93198. if (this._masterMesh && this.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  93199. return this._masterMesh;
  93200. }
  93201. return _super.prototype._getEffectiveParent.call(this);
  93202. };
  93203. /** @hidden */
  93204. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  93205. if (initialCall === void 0) { initialCall = true; }
  93206. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  93207. if (trigger) {
  93208. if (this.actionManager.hasSpecificTrigger(trigger)) {
  93209. return this.actionManager;
  93210. }
  93211. }
  93212. else {
  93213. return this.actionManager;
  93214. }
  93215. }
  93216. if (!this.parent) {
  93217. return null;
  93218. }
  93219. return this.parent._getActionManagerForTrigger(trigger, false);
  93220. };
  93221. /** @hidden */
  93222. AbstractMesh.prototype._rebuild = function () {
  93223. this.onRebuildObservable.notifyObservers(this);
  93224. if (this._occlusionQuery) {
  93225. this._occlusionQuery = null;
  93226. }
  93227. if (!this.subMeshes) {
  93228. return;
  93229. }
  93230. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  93231. var subMesh = _a[_i];
  93232. subMesh._rebuild();
  93233. }
  93234. };
  93235. /** @hidden */
  93236. AbstractMesh.prototype._resyncLightSources = function () {
  93237. this._lightSources.length = 0;
  93238. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  93239. var light = _a[_i];
  93240. if (!light.isEnabled()) {
  93241. continue;
  93242. }
  93243. if (light.canAffectMesh(this)) {
  93244. this._lightSources.push(light);
  93245. }
  93246. }
  93247. this._markSubMeshesAsLightDirty();
  93248. };
  93249. /** @hidden */
  93250. AbstractMesh.prototype._resyncLighSource = function (light) {
  93251. var isIn = light.isEnabled() && light.canAffectMesh(this);
  93252. var index = this._lightSources.indexOf(light);
  93253. if (index === -1) {
  93254. if (!isIn) {
  93255. return;
  93256. }
  93257. this._lightSources.push(light);
  93258. }
  93259. else {
  93260. if (isIn) {
  93261. return;
  93262. }
  93263. this._lightSources.splice(index, 1);
  93264. }
  93265. this._markSubMeshesAsLightDirty();
  93266. };
  93267. /** @hidden */
  93268. AbstractMesh.prototype._unBindEffect = function () {
  93269. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  93270. var subMesh = _a[_i];
  93271. subMesh.setEffect(null);
  93272. }
  93273. };
  93274. /** @hidden */
  93275. AbstractMesh.prototype._removeLightSource = function (light) {
  93276. var index = this._lightSources.indexOf(light);
  93277. if (index === -1) {
  93278. return;
  93279. }
  93280. this._lightSources.splice(index, 1);
  93281. this._markSubMeshesAsLightDirty();
  93282. };
  93283. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  93284. if (!this.subMeshes) {
  93285. return;
  93286. }
  93287. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  93288. var subMesh = _a[_i];
  93289. if (subMesh._materialDefines) {
  93290. func(subMesh._materialDefines);
  93291. }
  93292. }
  93293. };
  93294. /** @hidden */
  93295. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  93296. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  93297. };
  93298. /** @hidden */
  93299. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  93300. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  93301. };
  93302. /** @hidden */
  93303. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  93304. if (!this.subMeshes) {
  93305. return;
  93306. }
  93307. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  93308. var subMesh = _a[_i];
  93309. var material = subMesh.getMaterial();
  93310. if (material) {
  93311. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  93312. }
  93313. }
  93314. };
  93315. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  93316. /**
  93317. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93318. */
  93319. get: function () {
  93320. return this._scaling;
  93321. },
  93322. set: function (newScaling) {
  93323. this._scaling = newScaling;
  93324. },
  93325. enumerable: true,
  93326. configurable: true
  93327. });
  93328. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  93329. // Methods
  93330. /**
  93331. * Returns true if the mesh is blocked. Implemented by child classes
  93332. */
  93333. get: function () {
  93334. return false;
  93335. },
  93336. enumerable: true,
  93337. configurable: true
  93338. });
  93339. /**
  93340. * Returns the mesh itself by default. Implemented by child classes
  93341. * @param camera defines the camera to use to pick the right LOD level
  93342. * @returns the currentAbstractMesh
  93343. */
  93344. AbstractMesh.prototype.getLOD = function (camera) {
  93345. return this;
  93346. };
  93347. /**
  93348. * Returns 0 by default. Implemented by child classes
  93349. * @returns an integer
  93350. */
  93351. AbstractMesh.prototype.getTotalVertices = function () {
  93352. return 0;
  93353. };
  93354. /**
  93355. * Returns a positive integer : the total number of indices in this mesh geometry.
  93356. * @returns the numner of indices or zero if the mesh has no geometry.
  93357. */
  93358. AbstractMesh.prototype.getTotalIndices = function () {
  93359. return 0;
  93360. };
  93361. /**
  93362. * Returns null by default. Implemented by child classes
  93363. * @returns null
  93364. */
  93365. AbstractMesh.prototype.getIndices = function () {
  93366. return null;
  93367. };
  93368. /**
  93369. * Returns the array of the requested vertex data kind. Implemented by child classes
  93370. * @param kind defines the vertex data kind to use
  93371. * @returns null
  93372. */
  93373. AbstractMesh.prototype.getVerticesData = function (kind) {
  93374. return null;
  93375. };
  93376. /**
  93377. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93378. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93379. * Note that a new underlying VertexBuffer object is created each call.
  93380. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93381. * @param kind defines vertex data kind:
  93382. * * VertexBuffer.PositionKind
  93383. * * VertexBuffer.UVKind
  93384. * * VertexBuffer.UV2Kind
  93385. * * VertexBuffer.UV3Kind
  93386. * * VertexBuffer.UV4Kind
  93387. * * VertexBuffer.UV5Kind
  93388. * * VertexBuffer.UV6Kind
  93389. * * VertexBuffer.ColorKind
  93390. * * VertexBuffer.MatricesIndicesKind
  93391. * * VertexBuffer.MatricesIndicesExtraKind
  93392. * * VertexBuffer.MatricesWeightsKind
  93393. * * VertexBuffer.MatricesWeightsExtraKind
  93394. * @param data defines the data source
  93395. * @param updatable defines if the data must be flagged as updatable (or static)
  93396. * @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
  93397. * @returns the current mesh
  93398. */
  93399. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  93400. return this;
  93401. };
  93402. /**
  93403. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93404. * If the mesh has no geometry, it is simply returned as it is.
  93405. * @param kind defines vertex data kind:
  93406. * * VertexBuffer.PositionKind
  93407. * * VertexBuffer.UVKind
  93408. * * VertexBuffer.UV2Kind
  93409. * * VertexBuffer.UV3Kind
  93410. * * VertexBuffer.UV4Kind
  93411. * * VertexBuffer.UV5Kind
  93412. * * VertexBuffer.UV6Kind
  93413. * * VertexBuffer.ColorKind
  93414. * * VertexBuffer.MatricesIndicesKind
  93415. * * VertexBuffer.MatricesIndicesExtraKind
  93416. * * VertexBuffer.MatricesWeightsKind
  93417. * * VertexBuffer.MatricesWeightsExtraKind
  93418. * @param data defines the data source
  93419. * @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
  93420. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93421. * @returns the current mesh
  93422. */
  93423. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  93424. return this;
  93425. };
  93426. /**
  93427. * Sets the mesh indices,
  93428. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93429. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93430. * @param totalVertices Defines the total number of vertices
  93431. * @returns the current mesh
  93432. */
  93433. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  93434. return this;
  93435. };
  93436. /**
  93437. * Gets a boolean indicating if specific vertex data is present
  93438. * @param kind defines the vertex data kind to use
  93439. * @returns true is data kind is present
  93440. */
  93441. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  93442. return false;
  93443. };
  93444. /**
  93445. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93446. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93447. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93448. * @returns a BoundingInfo
  93449. */
  93450. AbstractMesh.prototype.getBoundingInfo = function () {
  93451. if (this._masterMesh) {
  93452. return this._masterMesh.getBoundingInfo();
  93453. }
  93454. if (!this._boundingInfo) {
  93455. // this._boundingInfo is being created here
  93456. this._updateBoundingInfo();
  93457. }
  93458. // cannot be null.
  93459. return this._boundingInfo;
  93460. };
  93461. /**
  93462. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93463. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93464. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93465. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93466. * @returns the current mesh
  93467. */
  93468. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation, predicate) {
  93469. if (includeDescendants === void 0) { includeDescendants = true; }
  93470. if (ignoreRotation === void 0) { ignoreRotation = false; }
  93471. return _super.prototype.normalizeToUnitCube.call(this, includeDescendants, ignoreRotation, predicate);
  93472. };
  93473. /**
  93474. * Overwrite the current bounding info
  93475. * @param boundingInfo defines the new bounding info
  93476. * @returns the current mesh
  93477. */
  93478. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  93479. this._boundingInfo = boundingInfo;
  93480. return this;
  93481. };
  93482. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  93483. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93484. get: function () {
  93485. 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));
  93486. },
  93487. enumerable: true,
  93488. configurable: true
  93489. });
  93490. /** @hidden */
  93491. AbstractMesh.prototype._preActivate = function () {
  93492. };
  93493. /** @hidden */
  93494. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  93495. };
  93496. /** @hidden */
  93497. AbstractMesh.prototype._activate = function (renderId, intermediateRendering) {
  93498. this._renderId = renderId;
  93499. return true;
  93500. };
  93501. /** @hidden */
  93502. AbstractMesh.prototype._postActivate = function () {
  93503. // Do nothing
  93504. };
  93505. /** @hidden */
  93506. AbstractMesh.prototype._freeze = function () {
  93507. // Do nothing
  93508. };
  93509. /** @hidden */
  93510. AbstractMesh.prototype._unFreeze = function () {
  93511. // Do nothing
  93512. };
  93513. /**
  93514. * Gets the current world matrix
  93515. * @returns a Matrix
  93516. */
  93517. AbstractMesh.prototype.getWorldMatrix = function () {
  93518. if (this._masterMesh && this.billboardMode === _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  93519. return this._masterMesh.getWorldMatrix();
  93520. }
  93521. return _super.prototype.getWorldMatrix.call(this);
  93522. };
  93523. /** @hidden */
  93524. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  93525. if (this._masterMesh) {
  93526. return this._masterMesh._getWorldMatrixDeterminant();
  93527. }
  93528. return _super.prototype._getWorldMatrixDeterminant.call(this);
  93529. };
  93530. Object.defineProperty(AbstractMesh.prototype, "isAnInstance", {
  93531. /**
  93532. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93533. */
  93534. get: function () {
  93535. return false;
  93536. },
  93537. enumerable: true,
  93538. configurable: true
  93539. });
  93540. // ================================== Point of View Movement =================================
  93541. /**
  93542. * Perform relative position change from the point of view of behind the front of the mesh.
  93543. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93544. * Supports definition of mesh facing forward or backward
  93545. * @param amountRight defines the distance on the right axis
  93546. * @param amountUp defines the distance on the up axis
  93547. * @param amountForward defines the distance on the forward axis
  93548. * @returns the current mesh
  93549. */
  93550. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  93551. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  93552. return this;
  93553. };
  93554. /**
  93555. * Calculate relative position change from the point of view of behind the front of the mesh.
  93556. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93557. * Supports definition of mesh facing forward or backward
  93558. * @param amountRight defines the distance on the right axis
  93559. * @param amountUp defines the distance on the up axis
  93560. * @param amountForward defines the distance on the forward axis
  93561. * @returns the new displacement vector
  93562. */
  93563. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  93564. var rotMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  93565. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  93566. rotQuaternion.toRotationMatrix(rotMatrix);
  93567. var translationDelta = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93568. var defForwardMult = this.definedFacingForward ? -1 : 1;
  93569. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  93570. return translationDelta;
  93571. };
  93572. // ================================== Point of View Rotation =================================
  93573. /**
  93574. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93575. * Supports definition of mesh facing forward or backward
  93576. * @param flipBack defines the flip
  93577. * @param twirlClockwise defines the twirl
  93578. * @param tiltRight defines the tilt
  93579. * @returns the current mesh
  93580. */
  93581. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  93582. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  93583. return this;
  93584. };
  93585. /**
  93586. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93587. * Supports definition of mesh facing forward or backward.
  93588. * @param flipBack defines the flip
  93589. * @param twirlClockwise defines the twirl
  93590. * @param tiltRight defines the tilt
  93591. * @returns the new rotation vector
  93592. */
  93593. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  93594. var defForwardMult = this.definedFacingForward ? 1 : -1;
  93595. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  93596. };
  93597. /**
  93598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93599. * This means the mesh underlying bounding box and sphere are recomputed.
  93600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93601. * @returns the current mesh
  93602. */
  93603. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  93604. if (applySkeleton === void 0) { applySkeleton = false; }
  93605. if (this._boundingInfo && this._boundingInfo.isLocked) {
  93606. return this;
  93607. }
  93608. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  93609. return this;
  93610. };
  93611. /** @hidden */
  93612. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  93613. if (data) {
  93614. var extend = Object(_Maths_math_functions__WEBPACK_IMPORTED_MODULE_13__["extractMinAndMax"])(data, 0, this.getTotalVertices(), bias);
  93615. if (this._boundingInfo) {
  93616. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  93617. }
  93618. else {
  93619. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  93620. }
  93621. }
  93622. if (this.subMeshes) {
  93623. for (var index = 0; index < this.subMeshes.length; index++) {
  93624. this.subMeshes[index].refreshBoundingInfo(data);
  93625. }
  93626. }
  93627. this._updateBoundingInfo();
  93628. };
  93629. /** @hidden */
  93630. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  93631. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  93632. if (data && applySkeleton && this.skeleton) {
  93633. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  93634. this._generatePointsArray();
  93635. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  93636. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  93637. if (matricesWeightsData && matricesIndicesData) {
  93638. var needExtras = this.numBoneInfluencers > 4;
  93639. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  93640. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  93641. this.skeleton.prepare();
  93642. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  93643. var tempVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  93644. var finalMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  93645. var tempMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1];
  93646. var matWeightIdx = 0;
  93647. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  93648. finalMatrix.reset();
  93649. var inf;
  93650. var weight;
  93651. for (inf = 0; inf < 4; inf++) {
  93652. weight = matricesWeightsData[matWeightIdx + inf];
  93653. if (weight > 0) {
  93654. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  93655. finalMatrix.addToSelf(tempMatrix);
  93656. }
  93657. }
  93658. if (needExtras) {
  93659. for (inf = 0; inf < 4; inf++) {
  93660. weight = matricesWeightsExtraData[matWeightIdx + inf];
  93661. if (weight > 0) {
  93662. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  93663. finalMatrix.addToSelf(tempMatrix);
  93664. }
  93665. }
  93666. }
  93667. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  93668. tempVector.toArray(data, index);
  93669. if (this._positions) {
  93670. this._positions[index / 3].copyFrom(tempVector);
  93671. }
  93672. }
  93673. }
  93674. }
  93675. return data;
  93676. };
  93677. /** @hidden */
  93678. AbstractMesh.prototype._updateBoundingInfo = function () {
  93679. var effectiveMesh = this._effectiveMesh;
  93680. if (this._boundingInfo) {
  93681. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  93682. }
  93683. else {
  93684. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  93685. }
  93686. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  93687. return this;
  93688. };
  93689. /** @hidden */
  93690. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  93691. if (!this.subMeshes) {
  93692. return this;
  93693. }
  93694. var count = this.subMeshes.length;
  93695. for (var subIndex = 0; subIndex < count; subIndex++) {
  93696. var subMesh = this.subMeshes[subIndex];
  93697. if (count > 1 || !subMesh.IsGlobal) {
  93698. subMesh.updateBoundingInfo(matrix);
  93699. }
  93700. }
  93701. return this;
  93702. };
  93703. /** @hidden */
  93704. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  93705. if (this.doNotSyncBoundingInfo) {
  93706. return;
  93707. }
  93708. // Bounding info
  93709. this._updateBoundingInfo();
  93710. };
  93711. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  93712. /** @hidden */
  93713. get: function () {
  93714. return (this.skeleton && this.skeleton.overrideMesh) || this;
  93715. },
  93716. enumerable: true,
  93717. configurable: true
  93718. });
  93719. /**
  93720. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93721. * A mesh is in the frustum if its bounding box intersects the frustum
  93722. * @param frustumPlanes defines the frustum to test
  93723. * @returns true if the mesh is in the frustum planes
  93724. */
  93725. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  93726. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  93727. };
  93728. /**
  93729. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93730. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93731. * @param frustumPlanes defines the frustum to test
  93732. * @returns true if the mesh is completely in the frustum planes
  93733. */
  93734. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  93735. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  93736. };
  93737. /**
  93738. * True if the mesh intersects another mesh or a SolidParticle object
  93739. * @param mesh defines a target mesh or SolidParticle to test
  93740. * @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)
  93741. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93742. * @returns true if there is an intersection
  93743. */
  93744. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  93745. if (precise === void 0) { precise = false; }
  93746. if (!this._boundingInfo || !mesh._boundingInfo) {
  93747. return false;
  93748. }
  93749. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  93750. return true;
  93751. }
  93752. if (includeDescendants) {
  93753. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  93754. var child = _a[_i];
  93755. if (child.intersectsMesh(mesh, precise, true)) {
  93756. return true;
  93757. }
  93758. }
  93759. }
  93760. return false;
  93761. };
  93762. /**
  93763. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93764. * @param point defines the point to test
  93765. * @returns true if there is an intersection
  93766. */
  93767. AbstractMesh.prototype.intersectsPoint = function (point) {
  93768. if (!this._boundingInfo) {
  93769. return false;
  93770. }
  93771. return this._boundingInfo.intersectsPoint(point);
  93772. };
  93773. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  93774. // Collisions
  93775. /**
  93776. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93777. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93778. */
  93779. get: function () {
  93780. return this._meshCollisionData._checkCollisions;
  93781. },
  93782. set: function (collisionEnabled) {
  93783. this._meshCollisionData._checkCollisions = collisionEnabled;
  93784. },
  93785. enumerable: true,
  93786. configurable: true
  93787. });
  93788. Object.defineProperty(AbstractMesh.prototype, "collider", {
  93789. /**
  93790. * Gets Collider object used to compute collisions (not physics)
  93791. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93792. */
  93793. get: function () {
  93794. return this._meshCollisionData._collider;
  93795. },
  93796. enumerable: true,
  93797. configurable: true
  93798. });
  93799. /**
  93800. * Move the mesh using collision engine
  93801. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93802. * @param displacement defines the requested displacement vector
  93803. * @returns the current mesh
  93804. */
  93805. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  93806. var globalPosition = this.getAbsolutePosition();
  93807. globalPosition.addToRef(this.ellipsoidOffset, this._meshCollisionData._oldPositionForCollisions);
  93808. var coordinator = this.getScene().collisionCoordinator;
  93809. if (!this._meshCollisionData._collider) {
  93810. this._meshCollisionData._collider = coordinator.createCollider();
  93811. }
  93812. this._meshCollisionData._collider._radius = this.ellipsoid;
  93813. coordinator.getNewPosition(this._meshCollisionData._oldPositionForCollisions, displacement, this._meshCollisionData._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  93814. return this;
  93815. };
  93816. // Collisions
  93817. /** @hidden */
  93818. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  93819. this._generatePointsArray();
  93820. if (!this._positions) {
  93821. return this;
  93822. }
  93823. // Transformation
  93824. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  93825. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  93826. subMesh._lastColliderWorldVertices = [];
  93827. subMesh._trianglePlanes = [];
  93828. var start = subMesh.verticesStart;
  93829. var end = (subMesh.verticesStart + subMesh.verticesCount);
  93830. for (var i = start; i < end; i++) {
  93831. subMesh._lastColliderWorldVertices.push(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  93832. }
  93833. }
  93834. // Collide
  93835. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial(), this);
  93836. return this;
  93837. };
  93838. /** @hidden */
  93839. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  93840. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  93841. var len = subMeshes.length;
  93842. for (var index = 0; index < len; index++) {
  93843. var subMesh = subMeshes.data[index];
  93844. // Bounding test
  93845. if (len > 1 && !subMesh._checkCollision(collider)) {
  93846. continue;
  93847. }
  93848. this._collideForSubMesh(subMesh, transformMatrix, collider);
  93849. }
  93850. return this;
  93851. };
  93852. /** @hidden */
  93853. AbstractMesh.prototype._checkCollision = function (collider) {
  93854. // Bounding box test
  93855. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  93856. return this;
  93857. }
  93858. // Transformation matrix
  93859. var collisionsScalingMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  93860. var collisionsTransformMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1];
  93861. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  93862. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  93863. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  93864. return this;
  93865. };
  93866. // Picking
  93867. /** @hidden */
  93868. AbstractMesh.prototype._generatePointsArray = function () {
  93869. return false;
  93870. };
  93871. /**
  93872. * Checks if the passed Ray intersects with the mesh
  93873. * @param ray defines the ray to use
  93874. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93876. * @returns the picking info
  93877. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93878. */
  93879. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  93880. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  93881. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  93882. var boundingInfo = this._boundingInfo;
  93883. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  93884. return pickingInfo;
  93885. }
  93886. if (!this._generatePointsArray()) {
  93887. return pickingInfo;
  93888. }
  93889. var intersectInfo = null;
  93890. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  93891. var len = subMeshes.length;
  93892. for (var index = 0; index < len; index++) {
  93893. var subMesh = subMeshes.data[index];
  93894. // Bounding test
  93895. if (len > 1 && !subMesh.canIntersects(ray)) {
  93896. continue;
  93897. }
  93898. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  93899. if (currentIntersectInfo) {
  93900. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  93901. intersectInfo = currentIntersectInfo;
  93902. intersectInfo.subMeshId = index;
  93903. if (fastCheck) {
  93904. break;
  93905. }
  93906. }
  93907. }
  93908. }
  93909. if (intersectInfo) {
  93910. // Get picked point
  93911. var world = this.getWorldMatrix();
  93912. var worldOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  93913. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
  93914. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  93915. ray.direction.scaleToRef(intersectInfo.distance, direction);
  93916. var worldDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  93917. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  93918. // Return result
  93919. pickingInfo.hit = true;
  93920. pickingInfo.distance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  93921. pickingInfo.pickedPoint = pickedPoint;
  93922. pickingInfo.pickedMesh = this;
  93923. pickingInfo.bu = intersectInfo.bu || 0;
  93924. pickingInfo.bv = intersectInfo.bv || 0;
  93925. pickingInfo.faceId = intersectInfo.faceId;
  93926. pickingInfo.subMeshId = intersectInfo.subMeshId;
  93927. return pickingInfo;
  93928. }
  93929. return pickingInfo;
  93930. };
  93931. /**
  93932. * Clones the current mesh
  93933. * @param name defines the mesh name
  93934. * @param newParent defines the new mesh parent
  93935. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93936. * @returns the new mesh
  93937. */
  93938. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  93939. return null;
  93940. };
  93941. /**
  93942. * Disposes all the submeshes of the current meshnp
  93943. * @returns the current mesh
  93944. */
  93945. AbstractMesh.prototype.releaseSubMeshes = function () {
  93946. if (this.subMeshes) {
  93947. while (this.subMeshes.length) {
  93948. this.subMeshes[0].dispose();
  93949. }
  93950. }
  93951. else {
  93952. this.subMeshes = new Array();
  93953. }
  93954. return this;
  93955. };
  93956. /**
  93957. * Releases resources associated with this abstract mesh.
  93958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93960. */
  93961. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  93962. var _this = this;
  93963. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  93964. var index;
  93965. // mesh map release.
  93966. if (this._scene.useMaterialMeshMap) {
  93967. // remove from material mesh map id needed
  93968. if (this._material && this._material.meshMap) {
  93969. this._material.meshMap[this.uniqueId] = undefined;
  93970. }
  93971. }
  93972. // Smart Array Retainers.
  93973. this.getScene().freeActiveMeshes();
  93974. this.getScene().freeRenderingGroups();
  93975. // Action manager
  93976. if (this.actionManager !== undefined && this.actionManager !== null) {
  93977. this.actionManager.dispose();
  93978. this.actionManager = null;
  93979. }
  93980. // Skeleton
  93981. this._internalAbstractMeshDataInfo._skeleton = null;
  93982. if (this._transformMatrixTexture) {
  93983. this._transformMatrixTexture.dispose();
  93984. this._transformMatrixTexture = null;
  93985. }
  93986. // Intersections in progress
  93987. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  93988. var other = this._intersectionsInProgress[index];
  93989. var pos = other._intersectionsInProgress.indexOf(this);
  93990. other._intersectionsInProgress.splice(pos, 1);
  93991. }
  93992. this._intersectionsInProgress = [];
  93993. // Lights
  93994. var lights = this.getScene().lights;
  93995. lights.forEach(function (light) {
  93996. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  93997. if (meshIndex !== -1) {
  93998. light.includedOnlyMeshes.splice(meshIndex, 1);
  93999. }
  94000. meshIndex = light.excludedMeshes.indexOf(_this);
  94001. if (meshIndex !== -1) {
  94002. light.excludedMeshes.splice(meshIndex, 1);
  94003. }
  94004. // Shadow generators
  94005. var generator = light.getShadowGenerator();
  94006. if (generator) {
  94007. var shadowMap = generator.getShadowMap();
  94008. if (shadowMap && shadowMap.renderList) {
  94009. meshIndex = shadowMap.renderList.indexOf(_this);
  94010. if (meshIndex !== -1) {
  94011. shadowMap.renderList.splice(meshIndex, 1);
  94012. }
  94013. }
  94014. }
  94015. });
  94016. // SubMeshes
  94017. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  94018. this.releaseSubMeshes();
  94019. }
  94020. // Query
  94021. var engine = this.getScene().getEngine();
  94022. if (this._occlusionQuery) {
  94023. this.isOcclusionQueryInProgress = false;
  94024. engine.deleteQuery(this._occlusionQuery);
  94025. this._occlusionQuery = null;
  94026. }
  94027. // Engine
  94028. engine.wipeCaches();
  94029. // Remove from scene
  94030. this.getScene().removeMesh(this);
  94031. if (disposeMaterialAndTextures) {
  94032. if (this.material) {
  94033. if (this.material.getClassName() === "MultiMaterial") {
  94034. this.material.dispose(false, true, true);
  94035. }
  94036. else {
  94037. this.material.dispose(false, true);
  94038. }
  94039. }
  94040. }
  94041. if (!doNotRecurse) {
  94042. // Particles
  94043. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  94044. if (this.getScene().particleSystems[index].emitter === this) {
  94045. this.getScene().particleSystems[index].dispose();
  94046. index--;
  94047. }
  94048. }
  94049. }
  94050. // facet data
  94051. if (this._internalAbstractMeshDataInfo._facetData.facetDataEnabled) {
  94052. this.disableFacetData();
  94053. }
  94054. this.onAfterWorldMatrixUpdateObservable.clear();
  94055. this.onCollideObservable.clear();
  94056. this.onCollisionPositionChangeObservable.clear();
  94057. this.onRebuildObservable.clear();
  94058. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  94059. };
  94060. /**
  94061. * Adds the passed mesh as a child to the current mesh
  94062. * @param mesh defines the child mesh
  94063. * @returns the current mesh
  94064. */
  94065. AbstractMesh.prototype.addChild = function (mesh) {
  94066. mesh.setParent(this);
  94067. return this;
  94068. };
  94069. /**
  94070. * Removes the passed mesh from the current mesh children list
  94071. * @param mesh defines the child mesh
  94072. * @returns the current mesh
  94073. */
  94074. AbstractMesh.prototype.removeChild = function (mesh) {
  94075. mesh.setParent(null);
  94076. return this;
  94077. };
  94078. // Facet data
  94079. /** @hidden */
  94080. AbstractMesh.prototype._initFacetData = function () {
  94081. var data = this._internalAbstractMeshDataInfo._facetData;
  94082. if (!data.facetNormals) {
  94083. data.facetNormals = new Array();
  94084. }
  94085. if (!data.facetPositions) {
  94086. data.facetPositions = new Array();
  94087. }
  94088. if (!data.facetPartitioning) {
  94089. data.facetPartitioning = new Array();
  94090. }
  94091. data.facetNb = (this.getIndices().length / 3) | 0;
  94092. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  94093. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  94094. for (var f = 0; f < data.facetNb; f++) {
  94095. data.facetNormals[f] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94096. data.facetPositions[f] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94097. }
  94098. data.facetDataEnabled = true;
  94099. return this;
  94100. };
  94101. /**
  94102. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94103. * This method can be called within the render loop.
  94104. * 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
  94105. * @returns the current mesh
  94106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94107. */
  94108. AbstractMesh.prototype.updateFacetData = function () {
  94109. var data = this._internalAbstractMeshDataInfo._facetData;
  94110. if (!data.facetDataEnabled) {
  94111. this._initFacetData();
  94112. }
  94113. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  94114. var indices = this.getIndices();
  94115. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  94116. var bInfo = this.getBoundingInfo();
  94117. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  94118. // init arrays, matrix and sort function on first call
  94119. data.facetDepthSortEnabled = true;
  94120. if (indices instanceof Uint16Array) {
  94121. data.depthSortedIndices = new Uint16Array(indices);
  94122. }
  94123. else if (indices instanceof Uint32Array) {
  94124. data.depthSortedIndices = new Uint32Array(indices);
  94125. }
  94126. else {
  94127. var needs32bits = false;
  94128. for (var i = 0; i < indices.length; i++) {
  94129. if (indices[i] > 65535) {
  94130. needs32bits = true;
  94131. break;
  94132. }
  94133. }
  94134. if (needs32bits) {
  94135. data.depthSortedIndices = new Uint32Array(indices);
  94136. }
  94137. else {
  94138. data.depthSortedIndices = new Uint16Array(indices);
  94139. }
  94140. }
  94141. data.facetDepthSortFunction = function (f1, f2) {
  94142. return (f2.sqDistance - f1.sqDistance);
  94143. };
  94144. if (!data.facetDepthSortFrom) {
  94145. var camera = this.getScene().activeCamera;
  94146. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94147. }
  94148. data.depthSortedFacets = [];
  94149. for (var f = 0; f < data.facetNb; f++) {
  94150. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  94151. data.depthSortedFacets.push(depthSortedFacet);
  94152. }
  94153. data.invertedMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  94154. data.facetDepthSortOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94155. }
  94156. data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"]) ? bInfo.maximum.x - bInfo.minimum.x : _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"];
  94157. data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"]) ? bInfo.maximum.y - bInfo.minimum.y : _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"];
  94158. data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"]) ? bInfo.maximum.z - bInfo.minimum.z : _Maths_math_constants__WEBPACK_IMPORTED_MODULE_15__["Epsilon"];
  94159. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  94160. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  94161. data.subDiv.max = data.partitioningSubdivisions;
  94162. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  94163. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  94164. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  94165. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  94166. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  94167. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  94168. // set the parameters for ComputeNormals()
  94169. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  94170. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  94171. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  94172. data.facetParameters.bInfo = bInfo;
  94173. data.facetParameters.bbSize = data.bbSize;
  94174. data.facetParameters.subDiv = data.subDiv;
  94175. data.facetParameters.ratio = this.partitioningBBoxRatio;
  94176. data.facetParameters.depthSort = data.facetDepthSort;
  94177. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  94178. this.computeWorldMatrix(true);
  94179. this._worldMatrix.invertToRef(data.invertedMatrix);
  94180. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  94181. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  94182. }
  94183. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  94184. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  94185. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  94186. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  94187. var l = (data.depthSortedIndices.length / 3) | 0;
  94188. for (var f = 0; f < l; f++) {
  94189. var sind = data.depthSortedFacets[f].ind;
  94190. data.depthSortedIndices[f * 3] = indices[sind];
  94191. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  94192. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  94193. }
  94194. this.updateIndices(data.depthSortedIndices, undefined, true);
  94195. }
  94196. return this;
  94197. };
  94198. /**
  94199. * Returns the facetLocalNormals array.
  94200. * The normals are expressed in the mesh local spac
  94201. * @returns an array of Vector3
  94202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94203. */
  94204. AbstractMesh.prototype.getFacetLocalNormals = function () {
  94205. var facetData = this._internalAbstractMeshDataInfo._facetData;
  94206. if (!facetData.facetNormals) {
  94207. this.updateFacetData();
  94208. }
  94209. return facetData.facetNormals;
  94210. };
  94211. /**
  94212. * Returns the facetLocalPositions array.
  94213. * The facet positions are expressed in the mesh local space
  94214. * @returns an array of Vector3
  94215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94216. */
  94217. AbstractMesh.prototype.getFacetLocalPositions = function () {
  94218. var facetData = this._internalAbstractMeshDataInfo._facetData;
  94219. if (!facetData.facetPositions) {
  94220. this.updateFacetData();
  94221. }
  94222. return facetData.facetPositions;
  94223. };
  94224. /**
  94225. * Returns the facetLocalPartioning array
  94226. * @returns an array of array of numbers
  94227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94228. */
  94229. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  94230. var facetData = this._internalAbstractMeshDataInfo._facetData;
  94231. if (!facetData.facetPartitioning) {
  94232. this.updateFacetData();
  94233. }
  94234. return facetData.facetPartitioning;
  94235. };
  94236. /**
  94237. * Returns the i-th facet position in the world system.
  94238. * This method allocates a new Vector3 per call
  94239. * @param i defines the facet index
  94240. * @returns a new Vector3
  94241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94242. */
  94243. AbstractMesh.prototype.getFacetPosition = function (i) {
  94244. var pos = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94245. this.getFacetPositionToRef(i, pos);
  94246. return pos;
  94247. };
  94248. /**
  94249. * Sets the reference Vector3 with the i-th facet position in the world system
  94250. * @param i defines the facet index
  94251. * @param ref defines the target vector
  94252. * @returns the current mesh
  94253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94254. */
  94255. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  94256. var localPos = (this.getFacetLocalPositions())[i];
  94257. var world = this.getWorldMatrix();
  94258. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  94259. return this;
  94260. };
  94261. /**
  94262. * Returns the i-th facet normal in the world system.
  94263. * This method allocates a new Vector3 per call
  94264. * @param i defines the facet index
  94265. * @returns a new Vector3
  94266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94267. */
  94268. AbstractMesh.prototype.getFacetNormal = function (i) {
  94269. var norm = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94270. this.getFacetNormalToRef(i, norm);
  94271. return norm;
  94272. };
  94273. /**
  94274. * Sets the reference Vector3 with the i-th facet normal in the world system
  94275. * @param i defines the facet index
  94276. * @param ref defines the target vector
  94277. * @returns the current mesh
  94278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94279. */
  94280. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  94281. var localNorm = (this.getFacetLocalNormals())[i];
  94282. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  94283. return this;
  94284. };
  94285. /**
  94286. * 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)
  94287. * @param x defines x coordinate
  94288. * @param y defines y coordinate
  94289. * @param z defines z coordinate
  94290. * @returns the array of facet indexes
  94291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94292. */
  94293. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  94294. var bInfo = this.getBoundingInfo();
  94295. var data = this._internalAbstractMeshDataInfo._facetData;
  94296. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  94297. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  94298. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  94299. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  94300. return null;
  94301. }
  94302. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  94303. };
  94304. /**
  94305. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94306. * @param projected sets as the (x,y,z) world projection on the facet
  94307. * @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
  94308. * @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
  94309. * @param x defines x coordinate
  94310. * @param y defines y coordinate
  94311. * @param z defines z coordinate
  94312. * @returns the face index if found (or null instead)
  94313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94314. */
  94315. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  94316. if (checkFace === void 0) { checkFace = false; }
  94317. if (facing === void 0) { facing = true; }
  94318. var world = this.getWorldMatrix();
  94319. var invMat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[5];
  94320. world.invertToRef(invMat);
  94321. var invVect = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[8];
  94322. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  94323. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  94324. if (projected) {
  94325. // tranform the local computed projected vector to world coordinates
  94326. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  94327. }
  94328. return closest;
  94329. };
  94330. /**
  94331. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94332. * @param projected sets as the (x,y,z) local projection on the facet
  94333. * @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
  94334. * @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
  94335. * @param x defines x coordinate
  94336. * @param y defines y coordinate
  94337. * @param z defines z coordinate
  94338. * @returns the face index if found (or null instead)
  94339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94340. */
  94341. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  94342. if (checkFace === void 0) { checkFace = false; }
  94343. if (facing === void 0) { facing = true; }
  94344. var closest = null;
  94345. var tmpx = 0.0;
  94346. var tmpy = 0.0;
  94347. var tmpz = 0.0;
  94348. var d = 0.0; // tmp dot facet normal * facet position
  94349. var t0 = 0.0;
  94350. var projx = 0.0;
  94351. var projy = 0.0;
  94352. var projz = 0.0;
  94353. // Get all the facets in the same partitioning block than (x, y, z)
  94354. var facetPositions = this.getFacetLocalPositions();
  94355. var facetNormals = this.getFacetLocalNormals();
  94356. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  94357. if (!facetsInBlock) {
  94358. return null;
  94359. }
  94360. // Get the closest facet to (x, y, z)
  94361. var shortest = Number.MAX_VALUE; // init distance vars
  94362. var tmpDistance = shortest;
  94363. var fib; // current facet in the block
  94364. var norm; // current facet normal
  94365. var p0; // current facet barycenter position
  94366. // loop on all the facets in the current partitioning block
  94367. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  94368. fib = facetsInBlock[idx];
  94369. norm = facetNormals[fib];
  94370. p0 = facetPositions[fib];
  94371. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  94372. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  94373. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  94374. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  94375. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  94376. projx = x + norm.x * t0;
  94377. projy = y + norm.y * t0;
  94378. projz = z + norm.z * t0;
  94379. tmpx = projx - x;
  94380. tmpy = projy - y;
  94381. tmpz = projz - z;
  94382. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  94383. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  94384. shortest = tmpDistance;
  94385. closest = fib;
  94386. if (projected) {
  94387. projected.x = projx;
  94388. projected.y = projy;
  94389. projected.z = projz;
  94390. }
  94391. }
  94392. }
  94393. }
  94394. return closest;
  94395. };
  94396. /**
  94397. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94398. * @returns the parameters
  94399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94400. */
  94401. AbstractMesh.prototype.getFacetDataParameters = function () {
  94402. return this._internalAbstractMeshDataInfo._facetData.facetParameters;
  94403. };
  94404. /**
  94405. * Disables the feature FacetData and frees the related memory
  94406. * @returns the current mesh
  94407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94408. */
  94409. AbstractMesh.prototype.disableFacetData = function () {
  94410. var facetData = this._internalAbstractMeshDataInfo._facetData;
  94411. if (facetData.facetDataEnabled) {
  94412. facetData.facetDataEnabled = false;
  94413. facetData.facetPositions = new Array();
  94414. facetData.facetNormals = new Array();
  94415. facetData.facetPartitioning = new Array();
  94416. facetData.facetParameters = null;
  94417. facetData.depthSortedIndices = new Uint32Array(0);
  94418. }
  94419. return this;
  94420. };
  94421. /**
  94422. * Updates the AbstractMesh indices array
  94423. * @param indices defines the data source
  94424. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94425. * @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)
  94426. * @returns the current mesh
  94427. */
  94428. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  94429. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  94430. return this;
  94431. };
  94432. /**
  94433. * Creates new normals data for the mesh
  94434. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94435. * @returns the current mesh
  94436. */
  94437. AbstractMesh.prototype.createNormals = function (updatable) {
  94438. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  94439. var indices = this.getIndices();
  94440. var normals;
  94441. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  94442. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  94443. }
  94444. else {
  94445. normals = [];
  94446. }
  94447. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  94448. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  94449. return this;
  94450. };
  94451. /**
  94452. * Align the mesh with a normal
  94453. * @param normal defines the normal to use
  94454. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94455. * @returns the current mesh
  94456. */
  94457. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  94458. if (!upDirection) {
  94459. upDirection = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_16__["Axis"].Y;
  94460. }
  94461. var axisX = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  94462. var axisZ = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
  94463. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  94464. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  94465. if (this.rotationQuaternion) {
  94466. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  94467. }
  94468. else {
  94469. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  94470. }
  94471. return this;
  94472. };
  94473. /** @hidden */
  94474. AbstractMesh.prototype._checkOcclusionQuery = function () {
  94475. return false;
  94476. };
  94477. /**
  94478. * Disables the mesh edge rendering mode
  94479. * @returns the currentAbstractMesh
  94480. */
  94481. AbstractMesh.prototype.disableEdgesRendering = function () {
  94482. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("EdgesRenderer");
  94483. };
  94484. /**
  94485. * Enables the edge rendering mode on the mesh.
  94486. * This mode makes the mesh edges visible
  94487. * @param epsilon defines the maximal distance between two angles to detect a face
  94488. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94489. * @returns the currentAbstractMesh
  94490. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94491. */
  94492. AbstractMesh.prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  94493. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("EdgesRenderer");
  94494. };
  94495. /** No occlusion */
  94496. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  94497. /** Occlusion set to optimisitic */
  94498. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  94499. /** Occlusion set to strict */
  94500. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  94501. /** Use an accurante occlusion algorithm */
  94502. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  94503. /** Use a conservative occlusion algorithm */
  94504. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  94505. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94506. * Test order :
  94507. * Is the bounding sphere outside the frustum ?
  94508. * If not, are the bounding box vertices outside the frustum ?
  94509. * It not, then the cullable object is in the frustum.
  94510. */
  94511. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  94512. /** Culling strategy : Bounding Sphere Only.
  94513. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94514. * It's also less accurate than the standard because some not visible objects can still be selected.
  94515. * Test : is the bounding sphere outside the frustum ?
  94516. * If not, then the cullable object is in the frustum.
  94517. */
  94518. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  94519. /** Culling strategy : Optimistic Inclusion.
  94520. * This in an inclusion test first, then the standard exclusion test.
  94521. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94522. * 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.
  94523. * Anyway, it's as accurate as the standard strategy.
  94524. * Test :
  94525. * Is the cullable object bounding sphere center in the frustum ?
  94526. * If not, apply the default culling strategy.
  94527. */
  94528. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  94529. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94530. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94531. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94532. * 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.
  94533. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94534. * Test :
  94535. * Is the cullable object bounding sphere center in the frustum ?
  94536. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94537. */
  94538. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  94539. return AbstractMesh;
  94540. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  94541. /***/ }),
  94542. /***/ "./Meshes/buffer.ts":
  94543. /*!**************************!*\
  94544. !*** ./Meshes/buffer.ts ***!
  94545. \**************************/
  94546. /*! exports provided: Buffer, VertexBuffer */
  94547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94548. "use strict";
  94549. __webpack_require__.r(__webpack_exports__);
  94550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  94551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  94552. /**
  94553. * Class used to store data that will be store in GPU memory
  94554. */
  94555. var Buffer = /** @class */ (function () {
  94556. /**
  94557. * Constructor
  94558. * @param engine the engine
  94559. * @param data the data to use for this buffer
  94560. * @param updatable whether the data is updatable
  94561. * @param stride the stride (optional)
  94562. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  94563. * @param instanced whether the buffer is instanced (optional)
  94564. * @param useBytes set to true if the stride in in bytes (optional)
  94565. */
  94566. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  94567. if (stride === void 0) { stride = 0; }
  94568. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  94569. if (instanced === void 0) { instanced = false; }
  94570. if (useBytes === void 0) { useBytes = false; }
  94571. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  94572. this._engine = engine.getScene().getEngine();
  94573. }
  94574. else {
  94575. this._engine = engine;
  94576. }
  94577. this._updatable = updatable;
  94578. this._instanced = instanced;
  94579. this._data = data;
  94580. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  94581. if (!postponeInternalCreation) { // by default
  94582. this.create();
  94583. }
  94584. }
  94585. /**
  94586. * Create a new VertexBuffer based on the current buffer
  94587. * @param kind defines the vertex buffer kind (position, normal, etc.)
  94588. * @param offset defines offset in the buffer (0 by default)
  94589. * @param size defines the size in floats of attributes (position is 3 for instance)
  94590. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  94591. * @param instanced defines if the vertex buffer contains indexed data
  94592. * @param useBytes defines if the offset and stride are in bytes
  94593. * @returns the new vertex buffer
  94594. */
  94595. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  94596. if (useBytes === void 0) { useBytes = false; }
  94597. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  94598. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  94599. // a lot of these parameters are ignored as they are overriden by the buffer
  94600. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  94601. };
  94602. // Properties
  94603. /**
  94604. * Gets a boolean indicating if the Buffer is updatable?
  94605. * @returns true if the buffer is updatable
  94606. */
  94607. Buffer.prototype.isUpdatable = function () {
  94608. return this._updatable;
  94609. };
  94610. /**
  94611. * Gets current buffer's data
  94612. * @returns a DataArray or null
  94613. */
  94614. Buffer.prototype.getData = function () {
  94615. return this._data;
  94616. };
  94617. /**
  94618. * Gets underlying native buffer
  94619. * @returns underlying native buffer
  94620. */
  94621. Buffer.prototype.getBuffer = function () {
  94622. return this._buffer;
  94623. };
  94624. /**
  94625. * Gets the stride in float32 units (i.e. byte stride / 4).
  94626. * May not be an integer if the byte stride is not divisible by 4.
  94627. * DEPRECATED. Use byteStride instead.
  94628. * @returns the stride in float32 units
  94629. */
  94630. Buffer.prototype.getStrideSize = function () {
  94631. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  94632. };
  94633. // Methods
  94634. /**
  94635. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  94636. * @param data defines the data to store
  94637. */
  94638. Buffer.prototype.create = function (data) {
  94639. if (data === void 0) { data = null; }
  94640. if (!data && this._buffer) {
  94641. return; // nothing to do
  94642. }
  94643. data = data || this._data;
  94644. if (!data) {
  94645. return;
  94646. }
  94647. if (!this._buffer) { // create buffer
  94648. if (this._updatable) {
  94649. this._buffer = this._engine.createDynamicVertexBuffer(data);
  94650. this._data = data;
  94651. }
  94652. else {
  94653. this._buffer = this._engine.createVertexBuffer(data);
  94654. }
  94655. }
  94656. else if (this._updatable) { // update buffer
  94657. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  94658. this._data = data;
  94659. }
  94660. };
  94661. /** @hidden */
  94662. Buffer.prototype._rebuild = function () {
  94663. this._buffer = null;
  94664. this.create(this._data);
  94665. };
  94666. /**
  94667. * Update current buffer data
  94668. * @param data defines the data to store
  94669. */
  94670. Buffer.prototype.update = function (data) {
  94671. this.create(data);
  94672. };
  94673. /**
  94674. * Updates the data directly.
  94675. * @param data the new data
  94676. * @param offset the new offset
  94677. * @param vertexCount the vertex count (optional)
  94678. * @param useBytes set to true if the offset is in bytes
  94679. */
  94680. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  94681. if (useBytes === void 0) { useBytes = false; }
  94682. if (!this._buffer) {
  94683. return;
  94684. }
  94685. if (this._updatable) { // update buffer
  94686. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  94687. this._data = null;
  94688. }
  94689. };
  94690. /**
  94691. * Release all resources
  94692. */
  94693. Buffer.prototype.dispose = function () {
  94694. if (!this._buffer) {
  94695. return;
  94696. }
  94697. if (this._engine._releaseBuffer(this._buffer)) {
  94698. this._buffer = null;
  94699. }
  94700. };
  94701. return Buffer;
  94702. }());
  94703. /**
  94704. * Specialized buffer used to store vertex data
  94705. */
  94706. var VertexBuffer = /** @class */ (function () {
  94707. /**
  94708. * Constructor
  94709. * @param engine the engine
  94710. * @param data the data to use for this vertex buffer
  94711. * @param kind the vertex buffer kind
  94712. * @param updatable whether the data is updatable
  94713. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  94714. * @param stride the stride (optional)
  94715. * @param instanced whether the buffer is instanced (optional)
  94716. * @param offset the offset of the data (optional)
  94717. * @param size the number of components (optional)
  94718. * @param type the type of the component (optional)
  94719. * @param normalized whether the data contains normalized data (optional)
  94720. * @param useBytes set to true if stride and offset are in bytes (optional)
  94721. */
  94722. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  94723. if (normalized === void 0) { normalized = false; }
  94724. if (useBytes === void 0) { useBytes = false; }
  94725. if (data instanceof Buffer) {
  94726. this._buffer = data;
  94727. this._ownsBuffer = false;
  94728. }
  94729. else {
  94730. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  94731. this._ownsBuffer = true;
  94732. }
  94733. this._kind = kind;
  94734. if (type == undefined) {
  94735. var data_1 = this.getData();
  94736. this.type = VertexBuffer.FLOAT;
  94737. if (data_1 instanceof Int8Array) {
  94738. this.type = VertexBuffer.BYTE;
  94739. }
  94740. else if (data_1 instanceof Uint8Array) {
  94741. this.type = VertexBuffer.UNSIGNED_BYTE;
  94742. }
  94743. else if (data_1 instanceof Int16Array) {
  94744. this.type = VertexBuffer.SHORT;
  94745. }
  94746. else if (data_1 instanceof Uint16Array) {
  94747. this.type = VertexBuffer.UNSIGNED_SHORT;
  94748. }
  94749. else if (data_1 instanceof Int32Array) {
  94750. this.type = VertexBuffer.INT;
  94751. }
  94752. else if (data_1 instanceof Uint32Array) {
  94753. this.type = VertexBuffer.UNSIGNED_INT;
  94754. }
  94755. }
  94756. else {
  94757. this.type = type;
  94758. }
  94759. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  94760. if (useBytes) {
  94761. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  94762. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  94763. this.byteOffset = offset || 0;
  94764. }
  94765. else {
  94766. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  94767. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  94768. this.byteOffset = (offset || 0) * typeByteLength;
  94769. }
  94770. this.normalized = normalized;
  94771. this._instanced = instanced !== undefined ? instanced : false;
  94772. this._instanceDivisor = instanced ? 1 : 0;
  94773. }
  94774. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  94775. /**
  94776. * Gets or sets the instance divisor when in instanced mode
  94777. */
  94778. get: function () {
  94779. return this._instanceDivisor;
  94780. },
  94781. set: function (value) {
  94782. this._instanceDivisor = value;
  94783. if (value == 0) {
  94784. this._instanced = false;
  94785. }
  94786. else {
  94787. this._instanced = true;
  94788. }
  94789. },
  94790. enumerable: true,
  94791. configurable: true
  94792. });
  94793. /** @hidden */
  94794. VertexBuffer.prototype._rebuild = function () {
  94795. if (!this._buffer) {
  94796. return;
  94797. }
  94798. this._buffer._rebuild();
  94799. };
  94800. /**
  94801. * Returns the kind of the VertexBuffer (string)
  94802. * @returns a string
  94803. */
  94804. VertexBuffer.prototype.getKind = function () {
  94805. return this._kind;
  94806. };
  94807. // Properties
  94808. /**
  94809. * Gets a boolean indicating if the VertexBuffer is updatable?
  94810. * @returns true if the buffer is updatable
  94811. */
  94812. VertexBuffer.prototype.isUpdatable = function () {
  94813. return this._buffer.isUpdatable();
  94814. };
  94815. /**
  94816. * Gets current buffer's data
  94817. * @returns a DataArray or null
  94818. */
  94819. VertexBuffer.prototype.getData = function () {
  94820. return this._buffer.getData();
  94821. };
  94822. /**
  94823. * Gets underlying native buffer
  94824. * @returns underlying native buffer
  94825. */
  94826. VertexBuffer.prototype.getBuffer = function () {
  94827. return this._buffer.getBuffer();
  94828. };
  94829. /**
  94830. * Gets the stride in float32 units (i.e. byte stride / 4).
  94831. * May not be an integer if the byte stride is not divisible by 4.
  94832. * DEPRECATED. Use byteStride instead.
  94833. * @returns the stride in float32 units
  94834. */
  94835. VertexBuffer.prototype.getStrideSize = function () {
  94836. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  94837. };
  94838. /**
  94839. * Returns the offset as a multiple of the type byte length.
  94840. * DEPRECATED. Use byteOffset instead.
  94841. * @returns the offset in bytes
  94842. */
  94843. VertexBuffer.prototype.getOffset = function () {
  94844. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  94845. };
  94846. /**
  94847. * Returns the number of components per vertex attribute (integer)
  94848. * @returns the size in float
  94849. */
  94850. VertexBuffer.prototype.getSize = function () {
  94851. return this._size;
  94852. };
  94853. /**
  94854. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  94855. * @returns true if this buffer is instanced
  94856. */
  94857. VertexBuffer.prototype.getIsInstanced = function () {
  94858. return this._instanced;
  94859. };
  94860. /**
  94861. * Returns the instancing divisor, zero for non-instanced (integer).
  94862. * @returns a number
  94863. */
  94864. VertexBuffer.prototype.getInstanceDivisor = function () {
  94865. return this._instanceDivisor;
  94866. };
  94867. // Methods
  94868. /**
  94869. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  94870. * @param data defines the data to store
  94871. */
  94872. VertexBuffer.prototype.create = function (data) {
  94873. this._buffer.create(data);
  94874. };
  94875. /**
  94876. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  94877. * This function will create a new buffer if the current one is not updatable
  94878. * @param data defines the data to store
  94879. */
  94880. VertexBuffer.prototype.update = function (data) {
  94881. this._buffer.update(data);
  94882. };
  94883. /**
  94884. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  94885. * Returns the directly updated WebGLBuffer.
  94886. * @param data the new data
  94887. * @param offset the new offset
  94888. * @param useBytes set to true if the offset is in bytes
  94889. */
  94890. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  94891. if (useBytes === void 0) { useBytes = false; }
  94892. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  94893. };
  94894. /**
  94895. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  94896. */
  94897. VertexBuffer.prototype.dispose = function () {
  94898. if (this._ownsBuffer) {
  94899. this._buffer.dispose();
  94900. }
  94901. };
  94902. /**
  94903. * Enumerates each value of this vertex buffer as numbers.
  94904. * @param count the number of values to enumerate
  94905. * @param callback the callback function called for each value
  94906. */
  94907. VertexBuffer.prototype.forEach = function (count, callback) {
  94908. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  94909. };
  94910. /**
  94911. * Deduces the stride given a kind.
  94912. * @param kind The kind string to deduce
  94913. * @returns The deduced stride
  94914. */
  94915. VertexBuffer.DeduceStride = function (kind) {
  94916. switch (kind) {
  94917. case VertexBuffer.UVKind:
  94918. case VertexBuffer.UV2Kind:
  94919. case VertexBuffer.UV3Kind:
  94920. case VertexBuffer.UV4Kind:
  94921. case VertexBuffer.UV5Kind:
  94922. case VertexBuffer.UV6Kind:
  94923. return 2;
  94924. case VertexBuffer.NormalKind:
  94925. case VertexBuffer.PositionKind:
  94926. return 3;
  94927. case VertexBuffer.ColorKind:
  94928. case VertexBuffer.MatricesIndicesKind:
  94929. case VertexBuffer.MatricesIndicesExtraKind:
  94930. case VertexBuffer.MatricesWeightsKind:
  94931. case VertexBuffer.MatricesWeightsExtraKind:
  94932. case VertexBuffer.TangentKind:
  94933. return 4;
  94934. default:
  94935. throw new Error("Invalid kind '" + kind + "'");
  94936. }
  94937. };
  94938. /**
  94939. * Gets the byte length of the given type.
  94940. * @param type the type
  94941. * @returns the number of bytes
  94942. */
  94943. VertexBuffer.GetTypeByteLength = function (type) {
  94944. switch (type) {
  94945. case VertexBuffer.BYTE:
  94946. case VertexBuffer.UNSIGNED_BYTE:
  94947. return 1;
  94948. case VertexBuffer.SHORT:
  94949. case VertexBuffer.UNSIGNED_SHORT:
  94950. return 2;
  94951. case VertexBuffer.INT:
  94952. case VertexBuffer.UNSIGNED_INT:
  94953. case VertexBuffer.FLOAT:
  94954. return 4;
  94955. default:
  94956. throw new Error("Invalid type '" + type + "'");
  94957. }
  94958. };
  94959. /**
  94960. * Enumerates each value of the given parameters as numbers.
  94961. * @param data the data to enumerate
  94962. * @param byteOffset the byte offset of the data
  94963. * @param byteStride the byte stride of the data
  94964. * @param componentCount the number of components per element
  94965. * @param componentType the type of the component
  94966. * @param count the number of values to enumerate
  94967. * @param normalized whether the data is normalized
  94968. * @param callback the callback function called for each value
  94969. */
  94970. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  94971. if (data instanceof Array) {
  94972. var offset = byteOffset / 4;
  94973. var stride = byteStride / 4;
  94974. for (var index = 0; index < count; index += componentCount) {
  94975. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  94976. callback(data[offset + componentIndex], index + componentIndex);
  94977. }
  94978. offset += stride;
  94979. }
  94980. }
  94981. else {
  94982. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  94983. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  94984. for (var index = 0; index < count; index += componentCount) {
  94985. var componentByteOffset = byteOffset;
  94986. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  94987. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  94988. callback(value, index + componentIndex);
  94989. componentByteOffset += componentByteLength;
  94990. }
  94991. byteOffset += byteStride;
  94992. }
  94993. }
  94994. };
  94995. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  94996. switch (type) {
  94997. case VertexBuffer.BYTE: {
  94998. var value = dataView.getInt8(byteOffset);
  94999. if (normalized) {
  95000. value = Math.max(value / 127, -1);
  95001. }
  95002. return value;
  95003. }
  95004. case VertexBuffer.UNSIGNED_BYTE: {
  95005. var value = dataView.getUint8(byteOffset);
  95006. if (normalized) {
  95007. value = value / 255;
  95008. }
  95009. return value;
  95010. }
  95011. case VertexBuffer.SHORT: {
  95012. var value = dataView.getInt16(byteOffset, true);
  95013. if (normalized) {
  95014. value = Math.max(value / 32767, -1);
  95015. }
  95016. return value;
  95017. }
  95018. case VertexBuffer.UNSIGNED_SHORT: {
  95019. var value = dataView.getUint16(byteOffset, true);
  95020. if (normalized) {
  95021. value = value / 65535;
  95022. }
  95023. return value;
  95024. }
  95025. case VertexBuffer.INT: {
  95026. return dataView.getInt32(byteOffset, true);
  95027. }
  95028. case VertexBuffer.UNSIGNED_INT: {
  95029. return dataView.getUint32(byteOffset, true);
  95030. }
  95031. case VertexBuffer.FLOAT: {
  95032. return dataView.getFloat32(byteOffset, true);
  95033. }
  95034. default: {
  95035. throw new Error("Invalid component type " + type);
  95036. }
  95037. }
  95038. };
  95039. /**
  95040. * The byte type.
  95041. */
  95042. VertexBuffer.BYTE = 5120;
  95043. /**
  95044. * The unsigned byte type.
  95045. */
  95046. VertexBuffer.UNSIGNED_BYTE = 5121;
  95047. /**
  95048. * The short type.
  95049. */
  95050. VertexBuffer.SHORT = 5122;
  95051. /**
  95052. * The unsigned short type.
  95053. */
  95054. VertexBuffer.UNSIGNED_SHORT = 5123;
  95055. /**
  95056. * The integer type.
  95057. */
  95058. VertexBuffer.INT = 5124;
  95059. /**
  95060. * The unsigned integer type.
  95061. */
  95062. VertexBuffer.UNSIGNED_INT = 5125;
  95063. /**
  95064. * The float type.
  95065. */
  95066. VertexBuffer.FLOAT = 5126;
  95067. // Enums
  95068. /**
  95069. * Positions
  95070. */
  95071. VertexBuffer.PositionKind = "position";
  95072. /**
  95073. * Normals
  95074. */
  95075. VertexBuffer.NormalKind = "normal";
  95076. /**
  95077. * Tangents
  95078. */
  95079. VertexBuffer.TangentKind = "tangent";
  95080. /**
  95081. * Texture coordinates
  95082. */
  95083. VertexBuffer.UVKind = "uv";
  95084. /**
  95085. * Texture coordinates 2
  95086. */
  95087. VertexBuffer.UV2Kind = "uv2";
  95088. /**
  95089. * Texture coordinates 3
  95090. */
  95091. VertexBuffer.UV3Kind = "uv3";
  95092. /**
  95093. * Texture coordinates 4
  95094. */
  95095. VertexBuffer.UV4Kind = "uv4";
  95096. /**
  95097. * Texture coordinates 5
  95098. */
  95099. VertexBuffer.UV5Kind = "uv5";
  95100. /**
  95101. * Texture coordinates 6
  95102. */
  95103. VertexBuffer.UV6Kind = "uv6";
  95104. /**
  95105. * Colors
  95106. */
  95107. VertexBuffer.ColorKind = "color";
  95108. /**
  95109. * Matrix indices (for bones)
  95110. */
  95111. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  95112. /**
  95113. * Matrix weights (for bones)
  95114. */
  95115. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  95116. /**
  95117. * Additional matrix indices (for bones)
  95118. */
  95119. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  95120. /**
  95121. * Additional matrix weights (for bones)
  95122. */
  95123. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  95124. return VertexBuffer;
  95125. }());
  95126. /***/ }),
  95127. /***/ "./Meshes/csg.ts":
  95128. /*!***********************!*\
  95129. !*** ./Meshes/csg.ts ***!
  95130. \***********************/
  95131. /*! exports provided: CSG */
  95132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95133. "use strict";
  95134. __webpack_require__.r(__webpack_exports__);
  95135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  95136. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  95137. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  95138. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  95139. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95140. /**
  95141. * Unique ID when we import meshes from Babylon to CSG
  95142. */
  95143. var currentCSGMeshId = 0;
  95144. /**
  95145. * Represents a vertex of a polygon. Use your own vertex class instead of this
  95146. * one to provide additional features like texture coordinates and vertex
  95147. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  95148. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  95149. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  95150. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  95151. * is not used anywhere else.
  95152. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  95153. */
  95154. var Vertex = /** @class */ (function () {
  95155. /**
  95156. * Initializes the vertex
  95157. * @param pos The position of the vertex
  95158. * @param normal The normal of the vertex
  95159. * @param uv The texture coordinate of the vertex
  95160. */
  95161. function Vertex(
  95162. /**
  95163. * The position of the vertex
  95164. */
  95165. pos,
  95166. /**
  95167. * The normal of the vertex
  95168. */
  95169. normal,
  95170. /**
  95171. * The texture coordinate of the vertex
  95172. */
  95173. uv) {
  95174. this.pos = pos;
  95175. this.normal = normal;
  95176. this.uv = uv;
  95177. }
  95178. /**
  95179. * Make a clone, or deep copy, of the vertex
  95180. * @returns A new Vertex
  95181. */
  95182. Vertex.prototype.clone = function () {
  95183. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  95184. };
  95185. /**
  95186. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  95187. * orientation of a polygon is flipped.
  95188. */
  95189. Vertex.prototype.flip = function () {
  95190. this.normal = this.normal.scale(-1);
  95191. };
  95192. /**
  95193. * Create a new vertex between this vertex and `other` by linearly
  95194. * interpolating all properties using a parameter of `t`. Subclasses should
  95195. * override this to interpolate additional properties.
  95196. * @param other the vertex to interpolate against
  95197. * @param t The factor used to linearly interpolate between the vertices
  95198. */
  95199. Vertex.prototype.interpolate = function (other, t) {
  95200. return new Vertex(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(this.pos, other.pos, t), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(this.normal, other.normal, t), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(this.uv, other.uv, t));
  95201. };
  95202. return Vertex;
  95203. }());
  95204. /**
  95205. * Represents a plane in 3D space.
  95206. */
  95207. var Plane = /** @class */ (function () {
  95208. /**
  95209. * Initializes the plane
  95210. * @param normal The normal for the plane
  95211. * @param w
  95212. */
  95213. function Plane(normal, w) {
  95214. this.normal = normal;
  95215. this.w = w;
  95216. }
  95217. /**
  95218. * Construct a plane from three points
  95219. * @param a Point a
  95220. * @param b Point b
  95221. * @param c Point c
  95222. */
  95223. Plane.FromPoints = function (a, b, c) {
  95224. var v0 = c.subtract(a);
  95225. var v1 = b.subtract(a);
  95226. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  95227. return null;
  95228. }
  95229. var n = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  95230. return new Plane(n, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  95231. };
  95232. /**
  95233. * Clone, or make a deep copy of the plane
  95234. * @returns a new Plane
  95235. */
  95236. Plane.prototype.clone = function () {
  95237. return new Plane(this.normal.clone(), this.w);
  95238. };
  95239. /**
  95240. * Flip the face of the plane
  95241. */
  95242. Plane.prototype.flip = function () {
  95243. this.normal.scaleInPlace(-1);
  95244. this.w = -this.w;
  95245. };
  95246. /**
  95247. * Split `polygon` by this plane if needed, then put the polygon or polygon
  95248. * fragments in the appropriate lists. Coplanar polygons go into either
  95249. `* coplanarFront` or `coplanarBack` depending on their orientation with
  95250. * respect to this plane. Polygons in front or in back of this plane go into
  95251. * either `front` or `back`
  95252. * @param polygon The polygon to be split
  95253. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  95254. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  95255. * @param front Will contain the polygons in front of the plane
  95256. * @param back Will contain the polygons begind the plane
  95257. */
  95258. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  95259. var COPLANAR = 0;
  95260. var FRONT = 1;
  95261. var BACK = 2;
  95262. var SPANNING = 3;
  95263. // Classify each point as well as the entire polygon into one of the above
  95264. // four classes.
  95265. var polygonType = 0;
  95266. var types = [];
  95267. var i;
  95268. var t;
  95269. for (i = 0; i < polygon.vertices.length; i++) {
  95270. t = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  95271. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  95272. polygonType |= type;
  95273. types.push(type);
  95274. }
  95275. // Put the polygon in the correct list, splitting it when necessary
  95276. switch (polygonType) {
  95277. case COPLANAR:
  95278. (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  95279. break;
  95280. case FRONT:
  95281. front.push(polygon);
  95282. break;
  95283. case BACK:
  95284. back.push(polygon);
  95285. break;
  95286. case SPANNING:
  95287. var f = [], b = [];
  95288. for (i = 0; i < polygon.vertices.length; i++) {
  95289. var j = (i + 1) % polygon.vertices.length;
  95290. var ti = types[i], tj = types[j];
  95291. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  95292. if (ti !== BACK) {
  95293. f.push(vi);
  95294. }
  95295. if (ti !== FRONT) {
  95296. b.push(ti !== BACK ? vi.clone() : vi);
  95297. }
  95298. if ((ti | tj) === SPANNING) {
  95299. t = (this.w - _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, vi.pos)) / _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, vj.pos.subtract(vi.pos));
  95300. var v = vi.interpolate(vj, t);
  95301. f.push(v);
  95302. b.push(v.clone());
  95303. }
  95304. }
  95305. var poly;
  95306. if (f.length >= 3) {
  95307. poly = new Polygon(f, polygon.shared);
  95308. if (poly.plane) {
  95309. front.push(poly);
  95310. }
  95311. }
  95312. if (b.length >= 3) {
  95313. poly = new Polygon(b, polygon.shared);
  95314. if (poly.plane) {
  95315. back.push(poly);
  95316. }
  95317. }
  95318. break;
  95319. }
  95320. };
  95321. /**
  95322. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  95323. * point is on the plane
  95324. */
  95325. Plane.EPSILON = 1e-5;
  95326. return Plane;
  95327. }());
  95328. /**
  95329. * Represents a convex polygon. The vertices used to initialize a polygon must
  95330. * be coplanar and form a convex loop.
  95331. *
  95332. * Each convex polygon has a `shared` property, which is shared between all
  95333. * polygons that are clones of each other or were split from the same polygon.
  95334. * This can be used to define per-polygon properties (such as surface color)
  95335. */
  95336. var Polygon = /** @class */ (function () {
  95337. /**
  95338. * Initializes the polygon
  95339. * @param vertices The vertices of the polygon
  95340. * @param shared The properties shared across all polygons
  95341. */
  95342. function Polygon(vertices, shared) {
  95343. this.vertices = vertices;
  95344. this.shared = shared;
  95345. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  95346. }
  95347. /**
  95348. * Clones, or makes a deep copy, or the polygon
  95349. */
  95350. Polygon.prototype.clone = function () {
  95351. var vertices = this.vertices.map(function (v) { return v.clone(); });
  95352. return new Polygon(vertices, this.shared);
  95353. };
  95354. /**
  95355. * Flips the faces of the polygon
  95356. */
  95357. Polygon.prototype.flip = function () {
  95358. this.vertices.reverse().map(function (v) { v.flip(); });
  95359. this.plane.flip();
  95360. };
  95361. return Polygon;
  95362. }());
  95363. /**
  95364. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  95365. * by picking a polygon to split along. That polygon (and all other coplanar
  95366. * polygons) are added directly to that node and the other polygons are added to
  95367. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  95368. * no distinction between internal and leaf nodes
  95369. */
  95370. var Node = /** @class */ (function () {
  95371. /**
  95372. * Initializes the node
  95373. * @param polygons A collection of polygons held in the node
  95374. */
  95375. function Node(polygons) {
  95376. this.plane = null;
  95377. this.front = null;
  95378. this.back = null;
  95379. this.polygons = new Array();
  95380. if (polygons) {
  95381. this.build(polygons);
  95382. }
  95383. }
  95384. /**
  95385. * Clones, or makes a deep copy, of the node
  95386. * @returns The cloned node
  95387. */
  95388. Node.prototype.clone = function () {
  95389. var node = new Node();
  95390. node.plane = this.plane && this.plane.clone();
  95391. node.front = this.front && this.front.clone();
  95392. node.back = this.back && this.back.clone();
  95393. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  95394. return node;
  95395. };
  95396. /**
  95397. * Convert solid space to empty space and empty space to solid space
  95398. */
  95399. Node.prototype.invert = function () {
  95400. for (var i = 0; i < this.polygons.length; i++) {
  95401. this.polygons[i].flip();
  95402. }
  95403. if (this.plane) {
  95404. this.plane.flip();
  95405. }
  95406. if (this.front) {
  95407. this.front.invert();
  95408. }
  95409. if (this.back) {
  95410. this.back.invert();
  95411. }
  95412. var temp = this.front;
  95413. this.front = this.back;
  95414. this.back = temp;
  95415. };
  95416. /**
  95417. * Recursively remove all polygons in `polygons` that are inside this BSP
  95418. * tree.
  95419. * @param polygons Polygons to remove from the BSP
  95420. * @returns Polygons clipped from the BSP
  95421. */
  95422. Node.prototype.clipPolygons = function (polygons) {
  95423. if (!this.plane) {
  95424. return polygons.slice();
  95425. }
  95426. var front = new Array(), back = new Array();
  95427. for (var i = 0; i < polygons.length; i++) {
  95428. this.plane.splitPolygon(polygons[i], front, back, front, back);
  95429. }
  95430. if (this.front) {
  95431. front = this.front.clipPolygons(front);
  95432. }
  95433. if (this.back) {
  95434. back = this.back.clipPolygons(back);
  95435. }
  95436. else {
  95437. back = [];
  95438. }
  95439. return front.concat(back);
  95440. };
  95441. /**
  95442. * Remove all polygons in this BSP tree that are inside the other BSP tree
  95443. * `bsp`.
  95444. * @param bsp BSP containing polygons to remove from this BSP
  95445. */
  95446. Node.prototype.clipTo = function (bsp) {
  95447. this.polygons = bsp.clipPolygons(this.polygons);
  95448. if (this.front) {
  95449. this.front.clipTo(bsp);
  95450. }
  95451. if (this.back) {
  95452. this.back.clipTo(bsp);
  95453. }
  95454. };
  95455. /**
  95456. * Return a list of all polygons in this BSP tree
  95457. * @returns List of all polygons in this BSP tree
  95458. */
  95459. Node.prototype.allPolygons = function () {
  95460. var polygons = this.polygons.slice();
  95461. if (this.front) {
  95462. polygons = polygons.concat(this.front.allPolygons());
  95463. }
  95464. if (this.back) {
  95465. polygons = polygons.concat(this.back.allPolygons());
  95466. }
  95467. return polygons;
  95468. };
  95469. /**
  95470. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  95471. * new polygons are filtered down to the bottom of the tree and become new
  95472. * nodes there. Each set of polygons is partitioned using the first polygon
  95473. * (no heuristic is used to pick a good split)
  95474. * @param polygons Polygons used to construct the BSP tree
  95475. */
  95476. Node.prototype.build = function (polygons) {
  95477. if (!polygons.length) {
  95478. return;
  95479. }
  95480. if (!this.plane) {
  95481. this.plane = polygons[0].plane.clone();
  95482. }
  95483. var front = new Array(), back = new Array();
  95484. for (var i = 0; i < polygons.length; i++) {
  95485. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  95486. }
  95487. if (front.length) {
  95488. if (!this.front) {
  95489. this.front = new Node();
  95490. }
  95491. this.front.build(front);
  95492. }
  95493. if (back.length) {
  95494. if (!this.back) {
  95495. this.back = new Node();
  95496. }
  95497. this.back.build(back);
  95498. }
  95499. };
  95500. return Node;
  95501. }());
  95502. /**
  95503. * Class for building Constructive Solid Geometry
  95504. */
  95505. var CSG = /** @class */ (function () {
  95506. function CSG() {
  95507. this.polygons = new Array();
  95508. }
  95509. /**
  95510. * Convert the Mesh to CSG
  95511. * @param mesh The Mesh to convert to CSG
  95512. * @returns A new CSG from the Mesh
  95513. */
  95514. CSG.FromMesh = function (mesh) {
  95515. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  95516. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  95517. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  95518. mesh.computeWorldMatrix(true);
  95519. matrix = mesh.getWorldMatrix();
  95520. meshPosition = mesh.position.clone();
  95521. meshRotation = mesh.rotation.clone();
  95522. if (mesh.rotationQuaternion) {
  95523. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  95524. }
  95525. meshScaling = mesh.scaling.clone();
  95526. }
  95527. else {
  95528. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  95529. }
  95530. 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);
  95531. var subMeshes = mesh.subMeshes;
  95532. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  95533. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  95534. vertices = [];
  95535. for (var j = 0; j < 3; j++) {
  95536. var sourceNormal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[indices[i + j] * 3], normals[indices[i + j] * 3 + 1], normals[indices[i + j] * 3 + 2]);
  95537. uv = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  95538. var sourcePosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[indices[i + j] * 3], positions[indices[i + j] * 3 + 1], positions[indices[i + j] * 3 + 2]);
  95539. position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  95540. normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  95541. vertex = new Vertex(position, normal, uv);
  95542. vertices.push(vertex);
  95543. }
  95544. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  95545. // To handle the case of degenerated triangle
  95546. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  95547. if (polygon.plane) {
  95548. polygons.push(polygon);
  95549. }
  95550. }
  95551. }
  95552. var csg = CSG.FromPolygons(polygons);
  95553. csg.matrix = matrix;
  95554. csg.position = meshPosition;
  95555. csg.rotation = meshRotation;
  95556. csg.scaling = meshScaling;
  95557. csg.rotationQuaternion = meshRotationQuaternion;
  95558. currentCSGMeshId++;
  95559. return csg;
  95560. };
  95561. /**
  95562. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  95563. * @param polygons Polygons used to construct a CSG solid
  95564. */
  95565. CSG.FromPolygons = function (polygons) {
  95566. var csg = new CSG();
  95567. csg.polygons = polygons;
  95568. return csg;
  95569. };
  95570. /**
  95571. * Clones, or makes a deep copy, of the CSG
  95572. * @returns A new CSG
  95573. */
  95574. CSG.prototype.clone = function () {
  95575. var csg = new CSG();
  95576. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  95577. csg.copyTransformAttributes(this);
  95578. return csg;
  95579. };
  95580. /**
  95581. * Unions this CSG with another CSG
  95582. * @param csg The CSG to union against this CSG
  95583. * @returns The unioned CSG
  95584. */
  95585. CSG.prototype.union = function (csg) {
  95586. var a = new Node(this.clone().polygons);
  95587. var b = new Node(csg.clone().polygons);
  95588. a.clipTo(b);
  95589. b.clipTo(a);
  95590. b.invert();
  95591. b.clipTo(a);
  95592. b.invert();
  95593. a.build(b.allPolygons());
  95594. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  95595. };
  95596. /**
  95597. * Unions this CSG with another CSG in place
  95598. * @param csg The CSG to union against this CSG
  95599. */
  95600. CSG.prototype.unionInPlace = function (csg) {
  95601. var a = new Node(this.polygons);
  95602. var b = new Node(csg.polygons);
  95603. a.clipTo(b);
  95604. b.clipTo(a);
  95605. b.invert();
  95606. b.clipTo(a);
  95607. b.invert();
  95608. a.build(b.allPolygons());
  95609. this.polygons = a.allPolygons();
  95610. };
  95611. /**
  95612. * Subtracts this CSG with another CSG
  95613. * @param csg The CSG to subtract against this CSG
  95614. * @returns A new CSG
  95615. */
  95616. CSG.prototype.subtract = function (csg) {
  95617. var a = new Node(this.clone().polygons);
  95618. var b = new Node(csg.clone().polygons);
  95619. a.invert();
  95620. a.clipTo(b);
  95621. b.clipTo(a);
  95622. b.invert();
  95623. b.clipTo(a);
  95624. b.invert();
  95625. a.build(b.allPolygons());
  95626. a.invert();
  95627. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  95628. };
  95629. /**
  95630. * Subtracts this CSG with another CSG in place
  95631. * @param csg The CSG to subtact against this CSG
  95632. */
  95633. CSG.prototype.subtractInPlace = function (csg) {
  95634. var a = new Node(this.polygons);
  95635. var b = new Node(csg.polygons);
  95636. a.invert();
  95637. a.clipTo(b);
  95638. b.clipTo(a);
  95639. b.invert();
  95640. b.clipTo(a);
  95641. b.invert();
  95642. a.build(b.allPolygons());
  95643. a.invert();
  95644. this.polygons = a.allPolygons();
  95645. };
  95646. /**
  95647. * Intersect this CSG with another CSG
  95648. * @param csg The CSG to intersect against this CSG
  95649. * @returns A new CSG
  95650. */
  95651. CSG.prototype.intersect = function (csg) {
  95652. var a = new Node(this.clone().polygons);
  95653. var b = new Node(csg.clone().polygons);
  95654. a.invert();
  95655. b.clipTo(a);
  95656. b.invert();
  95657. a.clipTo(b);
  95658. b.clipTo(a);
  95659. a.build(b.allPolygons());
  95660. a.invert();
  95661. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  95662. };
  95663. /**
  95664. * Intersects this CSG with another CSG in place
  95665. * @param csg The CSG to intersect against this CSG
  95666. */
  95667. CSG.prototype.intersectInPlace = function (csg) {
  95668. var a = new Node(this.polygons);
  95669. var b = new Node(csg.polygons);
  95670. a.invert();
  95671. b.clipTo(a);
  95672. b.invert();
  95673. a.clipTo(b);
  95674. b.clipTo(a);
  95675. a.build(b.allPolygons());
  95676. a.invert();
  95677. this.polygons = a.allPolygons();
  95678. };
  95679. /**
  95680. * Return a new CSG solid with solid and empty space switched. This solid is
  95681. * not modified.
  95682. * @returns A new CSG solid with solid and empty space switched
  95683. */
  95684. CSG.prototype.inverse = function () {
  95685. var csg = this.clone();
  95686. csg.inverseInPlace();
  95687. return csg;
  95688. };
  95689. /**
  95690. * Inverses the CSG in place
  95691. */
  95692. CSG.prototype.inverseInPlace = function () {
  95693. this.polygons.map(function (p) { p.flip(); });
  95694. };
  95695. /**
  95696. * This is used to keep meshes transformations so they can be restored
  95697. * when we build back a Babylon Mesh
  95698. * NB : All CSG operations are performed in world coordinates
  95699. * @param csg The CSG to copy the transform attributes from
  95700. * @returns This CSG
  95701. */
  95702. CSG.prototype.copyTransformAttributes = function (csg) {
  95703. this.matrix = csg.matrix;
  95704. this.position = csg.position;
  95705. this.rotation = csg.rotation;
  95706. this.scaling = csg.scaling;
  95707. this.rotationQuaternion = csg.rotationQuaternion;
  95708. return this;
  95709. };
  95710. /**
  95711. * Build Raw mesh from CSG
  95712. * Coordinates here are in world space
  95713. * @param name The name of the mesh geometry
  95714. * @param scene The Scene
  95715. * @param keepSubMeshes Specifies if the submeshes should be kept
  95716. * @returns A new Mesh
  95717. */
  95718. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  95719. var matrix = this.matrix.clone();
  95720. matrix.invert();
  95721. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene), vertices = [], indices = [], normals = [], uvs = [], vertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), uv = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), polygons = this.polygons, polygonIndices = [0, 0, 0], polygon, vertice_dict = {}, vertex_idx, currentIndex = 0, subMesh_dict = {}, subMesh_obj;
  95722. if (keepSubMeshes) {
  95723. // Sort Polygons, since subMeshes are indices range
  95724. polygons.sort(function (a, b) {
  95725. if (a.shared.meshId === b.shared.meshId) {
  95726. return a.shared.subMeshId - b.shared.subMeshId;
  95727. }
  95728. else {
  95729. return a.shared.meshId - b.shared.meshId;
  95730. }
  95731. });
  95732. }
  95733. for (var i = 0, il = polygons.length; i < il; i++) {
  95734. polygon = polygons[i];
  95735. // Building SubMeshes
  95736. if (!subMesh_dict[polygon.shared.meshId]) {
  95737. subMesh_dict[polygon.shared.meshId] = {};
  95738. }
  95739. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  95740. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  95741. indexStart: +Infinity,
  95742. indexEnd: -Infinity,
  95743. materialIndex: polygon.shared.materialIndex
  95744. };
  95745. }
  95746. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  95747. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  95748. polygonIndices[0] = 0;
  95749. polygonIndices[1] = j - 1;
  95750. polygonIndices[2] = j;
  95751. for (var k = 0; k < 3; k++) {
  95752. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  95753. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  95754. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  95755. var localVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  95756. var localNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  95757. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  95758. // Check if 2 points can be merged
  95759. if (!(typeof vertex_idx !== 'undefined' &&
  95760. normals[vertex_idx * 3] === localNormal.x &&
  95761. normals[vertex_idx * 3 + 1] === localNormal.y &&
  95762. normals[vertex_idx * 3 + 2] === localNormal.z &&
  95763. uvs[vertex_idx * 2] === uv.x &&
  95764. uvs[vertex_idx * 2 + 1] === uv.y)) {
  95765. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  95766. uvs.push(uv.x, uv.y);
  95767. normals.push(normal.x, normal.y, normal.z);
  95768. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  95769. }
  95770. indices.push(vertex_idx);
  95771. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  95772. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  95773. currentIndex++;
  95774. }
  95775. }
  95776. }
  95777. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  95778. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  95779. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  95780. mesh.setIndices(indices, null);
  95781. if (keepSubMeshes) {
  95782. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  95783. var materialIndexOffset = 0, materialMaxIndex;
  95784. mesh.subMeshes = new Array();
  95785. for (var m in subMesh_dict) {
  95786. materialMaxIndex = -1;
  95787. for (var sm in subMesh_dict[m]) {
  95788. subMesh_obj = subMesh_dict[m][sm];
  95789. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  95790. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  95791. }
  95792. materialIndexOffset += ++materialMaxIndex;
  95793. }
  95794. }
  95795. return mesh;
  95796. };
  95797. /**
  95798. * Build Mesh from CSG taking material and transforms into account
  95799. * @param name The name of the Mesh
  95800. * @param material The material of the Mesh
  95801. * @param scene The Scene
  95802. * @param keepSubMeshes Specifies if submeshes should be kept
  95803. * @returns The new Mesh
  95804. */
  95805. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  95806. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  95807. mesh.material = material;
  95808. mesh.position.copyFrom(this.position);
  95809. mesh.rotation.copyFrom(this.rotation);
  95810. if (this.rotationQuaternion) {
  95811. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  95812. }
  95813. mesh.scaling.copyFrom(this.scaling);
  95814. mesh.computeWorldMatrix(true);
  95815. return mesh;
  95816. };
  95817. return CSG;
  95818. }());
  95819. /***/ }),
  95820. /***/ "./Meshes/dataBuffer.ts":
  95821. /*!******************************!*\
  95822. !*** ./Meshes/dataBuffer.ts ***!
  95823. \******************************/
  95824. /*! exports provided: DataBuffer */
  95825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95826. "use strict";
  95827. __webpack_require__.r(__webpack_exports__);
  95828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return DataBuffer; });
  95829. /**
  95830. * Class used to store gfx data (like WebGLBuffer)
  95831. */
  95832. var DataBuffer = /** @class */ (function () {
  95833. function DataBuffer() {
  95834. /**
  95835. * Gets or sets the number of objects referencing this buffer
  95836. */
  95837. this.references = 0;
  95838. /** Gets or sets the size of the underlying buffer */
  95839. this.capacity = 0;
  95840. /**
  95841. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  95842. */
  95843. this.is32Bits = false;
  95844. }
  95845. Object.defineProperty(DataBuffer.prototype, "underlyingResource", {
  95846. /**
  95847. * Gets the underlying buffer
  95848. */
  95849. get: function () {
  95850. return null;
  95851. },
  95852. enumerable: true,
  95853. configurable: true
  95854. });
  95855. return DataBuffer;
  95856. }());
  95857. /***/ }),
  95858. /***/ "./Meshes/geometry.ts":
  95859. /*!****************************!*\
  95860. !*** ./Meshes/geometry.ts ***!
  95861. \****************************/
  95862. /*! exports provided: Geometry */
  95863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95864. "use strict";
  95865. __webpack_require__.r(__webpack_exports__);
  95866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  95867. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  95868. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  95869. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  95870. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  95871. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  95872. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  95873. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  95874. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95875. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  95876. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  95877. /* harmony import */ var _Maths_math_functions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Maths/math.functions */ "./Maths/math.functions.ts");
  95878. /**
  95879. * Class used to store geometry data (vertex buffers + index buffer)
  95880. */
  95881. var Geometry = /** @class */ (function () {
  95882. /**
  95883. * Creates a new geometry
  95884. * @param id defines the unique ID
  95885. * @param scene defines the hosting scene
  95886. * @param vertexData defines the VertexData used to get geometry data
  95887. * @param updatable defines if geometry must be updatable (false by default)
  95888. * @param mesh defines the mesh that will be associated with the geometry
  95889. */
  95890. function Geometry(id, scene, vertexData, updatable, mesh) {
  95891. if (updatable === void 0) { updatable = false; }
  95892. if (mesh === void 0) { mesh = null; }
  95893. /**
  95894. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95895. */
  95896. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  95897. this._totalVertices = 0;
  95898. this._isDisposed = false;
  95899. this._indexBufferIsUpdatable = false;
  95900. this.id = id;
  95901. this.uniqueId = scene.getUniqueId();
  95902. this._engine = scene.getEngine();
  95903. this._meshes = [];
  95904. this._scene = scene;
  95905. //Init vertex buffer cache
  95906. this._vertexBuffers = {};
  95907. this._indices = [];
  95908. this._updatable = updatable;
  95909. // vertexData
  95910. if (vertexData) {
  95911. this.setAllVerticesData(vertexData, updatable);
  95912. }
  95913. else {
  95914. this._totalVertices = 0;
  95915. this._indices = [];
  95916. }
  95917. if (this._engine.getCaps().vertexArrayObject) {
  95918. this._vertexArrayObjects = {};
  95919. }
  95920. // applyToMesh
  95921. if (mesh) {
  95922. this.applyToMesh(mesh);
  95923. mesh.computeWorldMatrix(true);
  95924. }
  95925. }
  95926. Object.defineProperty(Geometry.prototype, "boundingBias", {
  95927. /**
  95928. * 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
  95929. */
  95930. get: function () {
  95931. return this._boundingBias;
  95932. },
  95933. /**
  95934. * 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
  95935. */
  95936. set: function (value) {
  95937. if (this._boundingBias) {
  95938. this._boundingBias.copyFrom(value);
  95939. }
  95940. else {
  95941. this._boundingBias = value.clone();
  95942. }
  95943. this._updateBoundingInfo(true, null);
  95944. },
  95945. enumerable: true,
  95946. configurable: true
  95947. });
  95948. /**
  95949. * Static function used to attach a new empty geometry to a mesh
  95950. * @param mesh defines the mesh to attach the geometry to
  95951. * @returns the new Geometry
  95952. */
  95953. Geometry.CreateGeometryForMesh = function (mesh) {
  95954. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  95955. geometry.applyToMesh(mesh);
  95956. return geometry;
  95957. };
  95958. Object.defineProperty(Geometry.prototype, "extend", {
  95959. /**
  95960. * Gets the current extend of the geometry
  95961. */
  95962. get: function () {
  95963. return this._extend;
  95964. },
  95965. enumerable: true,
  95966. configurable: true
  95967. });
  95968. /**
  95969. * Gets the hosting scene
  95970. * @returns the hosting Scene
  95971. */
  95972. Geometry.prototype.getScene = function () {
  95973. return this._scene;
  95974. };
  95975. /**
  95976. * Gets the hosting engine
  95977. * @returns the hosting Engine
  95978. */
  95979. Geometry.prototype.getEngine = function () {
  95980. return this._engine;
  95981. };
  95982. /**
  95983. * Defines if the geometry is ready to use
  95984. * @returns true if the geometry is ready to be used
  95985. */
  95986. Geometry.prototype.isReady = function () {
  95987. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  95988. };
  95989. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  95990. /**
  95991. * Gets a value indicating that the geometry should not be serialized
  95992. */
  95993. get: function () {
  95994. for (var index = 0; index < this._meshes.length; index++) {
  95995. if (!this._meshes[index].doNotSerialize) {
  95996. return false;
  95997. }
  95998. }
  95999. return true;
  96000. },
  96001. enumerable: true,
  96002. configurable: true
  96003. });
  96004. /** @hidden */
  96005. Geometry.prototype._rebuild = function () {
  96006. if (this._vertexArrayObjects) {
  96007. this._vertexArrayObjects = {};
  96008. }
  96009. // Index buffer
  96010. if (this._meshes.length !== 0 && this._indices) {
  96011. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  96012. }
  96013. // Vertex buffers
  96014. for (var key in this._vertexBuffers) {
  96015. var vertexBuffer = this._vertexBuffers[key];
  96016. vertexBuffer._rebuild();
  96017. }
  96018. };
  96019. /**
  96020. * Affects all geometry data in one call
  96021. * @param vertexData defines the geometry data
  96022. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96023. */
  96024. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  96025. vertexData.applyToGeometry(this, updatable);
  96026. this.notifyUpdate();
  96027. };
  96028. /**
  96029. * Set specific vertex data
  96030. * @param kind defines the data kind (Position, normal, etc...)
  96031. * @param data defines the vertex data to use
  96032. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96033. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96034. */
  96035. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  96036. if (updatable === void 0) { updatable = false; }
  96037. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  96038. this.setVerticesBuffer(buffer);
  96039. };
  96040. /**
  96041. * Removes a specific vertex data
  96042. * @param kind defines the data kind (Position, normal, etc...)
  96043. */
  96044. Geometry.prototype.removeVerticesData = function (kind) {
  96045. if (this._vertexBuffers[kind]) {
  96046. this._vertexBuffers[kind].dispose();
  96047. delete this._vertexBuffers[kind];
  96048. }
  96049. };
  96050. /**
  96051. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96052. * @param buffer defines the vertex buffer to use
  96053. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96054. */
  96055. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  96056. if (totalVertices === void 0) { totalVertices = null; }
  96057. var kind = buffer.getKind();
  96058. if (this._vertexBuffers[kind]) {
  96059. this._vertexBuffers[kind].dispose();
  96060. }
  96061. this._vertexBuffers[kind] = buffer;
  96062. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  96063. var data = buffer.getData();
  96064. if (totalVertices != null) {
  96065. this._totalVertices = totalVertices;
  96066. }
  96067. else {
  96068. if (data != null) {
  96069. this._totalVertices = data.length / (buffer.byteStride / 4);
  96070. }
  96071. }
  96072. this._updateExtend(data);
  96073. this._resetPointsArrayCache();
  96074. var meshes = this._meshes;
  96075. var numOfMeshes = meshes.length;
  96076. for (var index = 0; index < numOfMeshes; index++) {
  96077. var mesh = meshes[index];
  96078. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  96079. mesh._createGlobalSubMesh(false);
  96080. mesh.computeWorldMatrix(true);
  96081. }
  96082. }
  96083. this.notifyUpdate(kind);
  96084. if (this._vertexArrayObjects) {
  96085. this._disposeVertexArrayObjects();
  96086. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  96087. }
  96088. };
  96089. /**
  96090. * Update a specific vertex buffer
  96091. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96092. * It will do nothing if the buffer is not updatable
  96093. * @param kind defines the data kind (Position, normal, etc...)
  96094. * @param data defines the data to use
  96095. * @param offset defines the offset in the target buffer where to store the data
  96096. * @param useBytes set to true if the offset is in bytes
  96097. */
  96098. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  96099. if (useBytes === void 0) { useBytes = false; }
  96100. var vertexBuffer = this.getVertexBuffer(kind);
  96101. if (!vertexBuffer) {
  96102. return;
  96103. }
  96104. vertexBuffer.updateDirectly(data, offset, useBytes);
  96105. this.notifyUpdate(kind);
  96106. };
  96107. /**
  96108. * Update a specific vertex buffer
  96109. * This function will create a new buffer if the current one is not updatable
  96110. * @param kind defines the data kind (Position, normal, etc...)
  96111. * @param data defines the data to use
  96112. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96113. */
  96114. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  96115. if (updateExtends === void 0) { updateExtends = false; }
  96116. var vertexBuffer = this.getVertexBuffer(kind);
  96117. if (!vertexBuffer) {
  96118. return;
  96119. }
  96120. vertexBuffer.update(data);
  96121. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  96122. this._updateBoundingInfo(updateExtends, data);
  96123. }
  96124. this.notifyUpdate(kind);
  96125. };
  96126. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  96127. if (updateExtends) {
  96128. this._updateExtend(data);
  96129. }
  96130. this._resetPointsArrayCache();
  96131. if (updateExtends) {
  96132. var meshes = this._meshes;
  96133. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  96134. var mesh = meshes_1[_i];
  96135. if (mesh._boundingInfo) {
  96136. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  96137. }
  96138. else {
  96139. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  96140. }
  96141. var subMeshes = mesh.subMeshes;
  96142. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  96143. var subMesh = subMeshes_1[_a];
  96144. subMesh.refreshBoundingInfo();
  96145. }
  96146. }
  96147. }
  96148. };
  96149. /** @hidden */
  96150. Geometry.prototype._bind = function (effect, indexToBind) {
  96151. if (!effect) {
  96152. return;
  96153. }
  96154. if (indexToBind === undefined) {
  96155. indexToBind = this._indexBuffer;
  96156. }
  96157. var vbs = this.getVertexBuffers();
  96158. if (!vbs) {
  96159. return;
  96160. }
  96161. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  96162. this._engine.bindBuffers(vbs, indexToBind, effect);
  96163. return;
  96164. }
  96165. // Using VAO
  96166. if (!this._vertexArrayObjects[effect.key]) {
  96167. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  96168. }
  96169. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  96170. };
  96171. /**
  96172. * Gets total number of vertices
  96173. * @returns the total number of vertices
  96174. */
  96175. Geometry.prototype.getTotalVertices = function () {
  96176. if (!this.isReady()) {
  96177. return 0;
  96178. }
  96179. return this._totalVertices;
  96180. };
  96181. /**
  96182. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96183. * @param kind defines the data kind (Position, normal, etc...)
  96184. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96185. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96186. * @returns a float array containing vertex data
  96187. */
  96188. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  96189. var vertexBuffer = this.getVertexBuffer(kind);
  96190. if (!vertexBuffer) {
  96191. return null;
  96192. }
  96193. var data = vertexBuffer.getData();
  96194. if (!data) {
  96195. return null;
  96196. }
  96197. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  96198. var count = this._totalVertices * vertexBuffer.getSize();
  96199. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  96200. var copy_1 = [];
  96201. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  96202. return copy_1;
  96203. }
  96204. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  96205. if (data instanceof Array) {
  96206. var offset = vertexBuffer.byteOffset / 4;
  96207. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data, offset, offset + count);
  96208. }
  96209. else if (data instanceof ArrayBuffer) {
  96210. return new Float32Array(data, vertexBuffer.byteOffset, count);
  96211. }
  96212. else {
  96213. var offset = data.byteOffset + vertexBuffer.byteOffset;
  96214. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  96215. var result = new Float32Array(count);
  96216. var source = new Float32Array(data.buffer, offset, count);
  96217. result.set(source);
  96218. return result;
  96219. }
  96220. return new Float32Array(data.buffer, offset, count);
  96221. }
  96222. }
  96223. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  96224. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data);
  96225. }
  96226. return data;
  96227. };
  96228. /**
  96229. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96230. * @param kind defines the data kind (Position, normal, etc...)
  96231. * @returns true if the vertex buffer with the specified kind is updatable
  96232. */
  96233. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  96234. var vb = this._vertexBuffers[kind];
  96235. if (!vb) {
  96236. return false;
  96237. }
  96238. return vb.isUpdatable();
  96239. };
  96240. /**
  96241. * Gets a specific vertex buffer
  96242. * @param kind defines the data kind (Position, normal, etc...)
  96243. * @returns a VertexBuffer
  96244. */
  96245. Geometry.prototype.getVertexBuffer = function (kind) {
  96246. if (!this.isReady()) {
  96247. return null;
  96248. }
  96249. return this._vertexBuffers[kind];
  96250. };
  96251. /**
  96252. * Returns all vertex buffers
  96253. * @return an object holding all vertex buffers indexed by kind
  96254. */
  96255. Geometry.prototype.getVertexBuffers = function () {
  96256. if (!this.isReady()) {
  96257. return null;
  96258. }
  96259. return this._vertexBuffers;
  96260. };
  96261. /**
  96262. * Gets a boolean indicating if specific vertex buffer is present
  96263. * @param kind defines the data kind (Position, normal, etc...)
  96264. * @returns true if data is present
  96265. */
  96266. Geometry.prototype.isVerticesDataPresent = function (kind) {
  96267. if (!this._vertexBuffers) {
  96268. if (this._delayInfo) {
  96269. return this._delayInfo.indexOf(kind) !== -1;
  96270. }
  96271. return false;
  96272. }
  96273. return this._vertexBuffers[kind] !== undefined;
  96274. };
  96275. /**
  96276. * Gets a list of all attached data kinds (Position, normal, etc...)
  96277. * @returns a list of string containing all kinds
  96278. */
  96279. Geometry.prototype.getVerticesDataKinds = function () {
  96280. var result = [];
  96281. var kind;
  96282. if (!this._vertexBuffers && this._delayInfo) {
  96283. for (kind in this._delayInfo) {
  96284. result.push(kind);
  96285. }
  96286. }
  96287. else {
  96288. for (kind in this._vertexBuffers) {
  96289. result.push(kind);
  96290. }
  96291. }
  96292. return result;
  96293. };
  96294. /**
  96295. * Update index buffer
  96296. * @param indices defines the indices to store in the index buffer
  96297. * @param offset defines the offset in the target buffer where to store the data
  96298. * @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)
  96299. */
  96300. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  96301. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  96302. if (!this._indexBuffer) {
  96303. return;
  96304. }
  96305. if (!this._indexBufferIsUpdatable) {
  96306. this.setIndices(indices, null, true);
  96307. }
  96308. else {
  96309. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  96310. if (!gpuMemoryOnly) {
  96311. this._indices = indices.slice();
  96312. }
  96313. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  96314. if (needToUpdateSubMeshes) {
  96315. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  96316. var mesh = _a[_i];
  96317. mesh._createGlobalSubMesh(true);
  96318. }
  96319. }
  96320. }
  96321. };
  96322. /**
  96323. * Creates a new index buffer
  96324. * @param indices defines the indices to store in the index buffer
  96325. * @param totalVertices defines the total number of vertices (could be null)
  96326. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96327. */
  96328. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  96329. if (totalVertices === void 0) { totalVertices = null; }
  96330. if (updatable === void 0) { updatable = false; }
  96331. if (this._indexBuffer) {
  96332. this._engine._releaseBuffer(this._indexBuffer);
  96333. }
  96334. this._disposeVertexArrayObjects();
  96335. this._indices = indices;
  96336. this._indexBufferIsUpdatable = updatable;
  96337. if (this._meshes.length !== 0 && this._indices) {
  96338. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  96339. }
  96340. if (totalVertices != undefined) { // including null and undefined
  96341. this._totalVertices = totalVertices;
  96342. }
  96343. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  96344. var mesh = _a[_i];
  96345. mesh._createGlobalSubMesh(true);
  96346. }
  96347. this.notifyUpdate();
  96348. };
  96349. /**
  96350. * Return the total number of indices
  96351. * @returns the total number of indices
  96352. */
  96353. Geometry.prototype.getTotalIndices = function () {
  96354. if (!this.isReady()) {
  96355. return 0;
  96356. }
  96357. return this._indices.length;
  96358. };
  96359. /**
  96360. * Gets the index buffer array
  96361. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96362. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96363. * @returns the index buffer array
  96364. */
  96365. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  96366. if (!this.isReady()) {
  96367. return null;
  96368. }
  96369. var orig = this._indices;
  96370. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  96371. return orig;
  96372. }
  96373. else {
  96374. var len = orig.length;
  96375. var copy = [];
  96376. for (var i = 0; i < len; i++) {
  96377. copy.push(orig[i]);
  96378. }
  96379. return copy;
  96380. }
  96381. };
  96382. /**
  96383. * Gets the index buffer
  96384. * @return the index buffer
  96385. */
  96386. Geometry.prototype.getIndexBuffer = function () {
  96387. if (!this.isReady()) {
  96388. return null;
  96389. }
  96390. return this._indexBuffer;
  96391. };
  96392. /** @hidden */
  96393. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  96394. if (effect === void 0) { effect = null; }
  96395. if (!effect || !this._vertexArrayObjects) {
  96396. return;
  96397. }
  96398. if (this._vertexArrayObjects[effect.key]) {
  96399. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  96400. delete this._vertexArrayObjects[effect.key];
  96401. }
  96402. };
  96403. /**
  96404. * Release the associated resources for a specific mesh
  96405. * @param mesh defines the source mesh
  96406. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96407. */
  96408. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  96409. var meshes = this._meshes;
  96410. var index = meshes.indexOf(mesh);
  96411. if (index === -1) {
  96412. return;
  96413. }
  96414. meshes.splice(index, 1);
  96415. mesh._geometry = null;
  96416. if (meshes.length === 0 && shouldDispose) {
  96417. this.dispose();
  96418. }
  96419. };
  96420. /**
  96421. * Apply current geometry to a given mesh
  96422. * @param mesh defines the mesh to apply geometry to
  96423. */
  96424. Geometry.prototype.applyToMesh = function (mesh) {
  96425. if (mesh._geometry === this) {
  96426. return;
  96427. }
  96428. var previousGeometry = mesh._geometry;
  96429. if (previousGeometry) {
  96430. previousGeometry.releaseForMesh(mesh);
  96431. }
  96432. var meshes = this._meshes;
  96433. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  96434. mesh._geometry = this;
  96435. this._scene.pushGeometry(this);
  96436. meshes.push(mesh);
  96437. if (this.isReady()) {
  96438. this._applyToMesh(mesh);
  96439. }
  96440. else {
  96441. mesh._boundingInfo = this._boundingInfo;
  96442. }
  96443. };
  96444. Geometry.prototype._updateExtend = function (data) {
  96445. if (data === void 0) { data = null; }
  96446. if (!data) {
  96447. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  96448. }
  96449. this._extend = Object(_Maths_math_functions__WEBPACK_IMPORTED_MODULE_10__["extractMinAndMax"])(data, 0, this._totalVertices, this.boundingBias, 3);
  96450. };
  96451. Geometry.prototype._applyToMesh = function (mesh) {
  96452. var numOfMeshes = this._meshes.length;
  96453. // vertexBuffers
  96454. for (var kind in this._vertexBuffers) {
  96455. if (numOfMeshes === 1) {
  96456. this._vertexBuffers[kind].create();
  96457. }
  96458. var buffer = this._vertexBuffers[kind].getBuffer();
  96459. if (buffer) {
  96460. buffer.references = numOfMeshes;
  96461. }
  96462. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  96463. if (!this._extend) {
  96464. this._updateExtend();
  96465. }
  96466. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  96467. mesh._createGlobalSubMesh(false);
  96468. //bounding info was just created again, world matrix should be applied again.
  96469. mesh._updateBoundingInfo();
  96470. }
  96471. }
  96472. // indexBuffer
  96473. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  96474. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  96475. }
  96476. if (this._indexBuffer) {
  96477. this._indexBuffer.references = numOfMeshes;
  96478. }
  96479. // morphTargets
  96480. mesh._syncGeometryWithMorphTargetManager();
  96481. // instances
  96482. mesh.synchronizeInstances();
  96483. };
  96484. Geometry.prototype.notifyUpdate = function (kind) {
  96485. if (this.onGeometryUpdated) {
  96486. this.onGeometryUpdated(this, kind);
  96487. }
  96488. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  96489. var mesh = _a[_i];
  96490. mesh._markSubMeshesAsAttributesDirty();
  96491. }
  96492. };
  96493. /**
  96494. * Load the geometry if it was flagged as delay loaded
  96495. * @param scene defines the hosting scene
  96496. * @param onLoaded defines a callback called when the geometry is loaded
  96497. */
  96498. Geometry.prototype.load = function (scene, onLoaded) {
  96499. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING) {
  96500. return;
  96501. }
  96502. if (this.isReady()) {
  96503. if (onLoaded) {
  96504. onLoaded();
  96505. }
  96506. return;
  96507. }
  96508. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING;
  96509. this._queueLoad(scene, onLoaded);
  96510. };
  96511. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  96512. var _this = this;
  96513. if (!this.delayLoadingFile) {
  96514. return;
  96515. }
  96516. scene._addPendingData(this);
  96517. scene._loadFile(this.delayLoadingFile, function (data) {
  96518. if (!_this._delayLoadingFunction) {
  96519. return;
  96520. }
  96521. _this._delayLoadingFunction(JSON.parse(data), _this);
  96522. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  96523. _this._delayInfo = [];
  96524. scene._removePendingData(_this);
  96525. var meshes = _this._meshes;
  96526. var numOfMeshes = meshes.length;
  96527. for (var index = 0; index < numOfMeshes; index++) {
  96528. _this._applyToMesh(meshes[index]);
  96529. }
  96530. if (onLoaded) {
  96531. onLoaded();
  96532. }
  96533. }, undefined, true);
  96534. };
  96535. /**
  96536. * Invert the geometry to move from a right handed system to a left handed one.
  96537. */
  96538. Geometry.prototype.toLeftHanded = function () {
  96539. // Flip faces
  96540. var tIndices = this.getIndices(false);
  96541. if (tIndices != null && tIndices.length > 0) {
  96542. for (var i = 0; i < tIndices.length; i += 3) {
  96543. var tTemp = tIndices[i + 0];
  96544. tIndices[i + 0] = tIndices[i + 2];
  96545. tIndices[i + 2] = tTemp;
  96546. }
  96547. this.setIndices(tIndices);
  96548. }
  96549. // Negate position.z
  96550. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false);
  96551. if (tPositions != null && tPositions.length > 0) {
  96552. for (var i = 0; i < tPositions.length; i += 3) {
  96553. tPositions[i + 2] = -tPositions[i + 2];
  96554. }
  96555. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, tPositions, false);
  96556. }
  96557. // Negate normal.z
  96558. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, false);
  96559. if (tNormals != null && tNormals.length > 0) {
  96560. for (var i = 0; i < tNormals.length; i += 3) {
  96561. tNormals[i + 2] = -tNormals[i + 2];
  96562. }
  96563. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, tNormals, false);
  96564. }
  96565. };
  96566. // Cache
  96567. /** @hidden */
  96568. Geometry.prototype._resetPointsArrayCache = function () {
  96569. this._positions = null;
  96570. };
  96571. /** @hidden */
  96572. Geometry.prototype._generatePointsArray = function () {
  96573. if (this._positions) {
  96574. return true;
  96575. }
  96576. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  96577. if (!data || data.length === 0) {
  96578. return false;
  96579. }
  96580. this._positions = [];
  96581. for (var index = 0; index < data.length; index += 3) {
  96582. this._positions.push(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  96583. }
  96584. return true;
  96585. };
  96586. /**
  96587. * Gets a value indicating if the geometry is disposed
  96588. * @returns true if the geometry was disposed
  96589. */
  96590. Geometry.prototype.isDisposed = function () {
  96591. return this._isDisposed;
  96592. };
  96593. Geometry.prototype._disposeVertexArrayObjects = function () {
  96594. if (this._vertexArrayObjects) {
  96595. for (var kind in this._vertexArrayObjects) {
  96596. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  96597. }
  96598. this._vertexArrayObjects = {};
  96599. }
  96600. };
  96601. /**
  96602. * Free all associated resources
  96603. */
  96604. Geometry.prototype.dispose = function () {
  96605. var meshes = this._meshes;
  96606. var numOfMeshes = meshes.length;
  96607. var index;
  96608. for (index = 0; index < numOfMeshes; index++) {
  96609. this.releaseForMesh(meshes[index]);
  96610. }
  96611. this._meshes = [];
  96612. this._disposeVertexArrayObjects();
  96613. for (var kind in this._vertexBuffers) {
  96614. this._vertexBuffers[kind].dispose();
  96615. }
  96616. this._vertexBuffers = {};
  96617. this._totalVertices = 0;
  96618. if (this._indexBuffer) {
  96619. this._engine._releaseBuffer(this._indexBuffer);
  96620. }
  96621. this._indexBuffer = null;
  96622. this._indices = [];
  96623. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  96624. this.delayLoadingFile = null;
  96625. this._delayLoadingFunction = null;
  96626. this._delayInfo = [];
  96627. this._boundingInfo = null;
  96628. this._scene.removeGeometry(this);
  96629. this._isDisposed = true;
  96630. };
  96631. /**
  96632. * Clone the current geometry into a new geometry
  96633. * @param id defines the unique ID of the new geometry
  96634. * @returns a new geometry object
  96635. */
  96636. Geometry.prototype.copy = function (id) {
  96637. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  96638. vertexData.indices = [];
  96639. var indices = this.getIndices();
  96640. if (indices) {
  96641. for (var index = 0; index < indices.length; index++) {
  96642. vertexData.indices.push(indices[index]);
  96643. }
  96644. }
  96645. var updatable = false;
  96646. var stopChecking = false;
  96647. var kind;
  96648. for (kind in this._vertexBuffers) {
  96649. // using slice() to make a copy of the array and not just reference it
  96650. var data = this.getVerticesData(kind);
  96651. if (data) {
  96652. if (data instanceof Float32Array) {
  96653. vertexData.set(new Float32Array(data), kind);
  96654. }
  96655. else {
  96656. vertexData.set(data.slice(0), kind);
  96657. }
  96658. if (!stopChecking) {
  96659. var vb = this.getVertexBuffer(kind);
  96660. if (vb) {
  96661. updatable = vb.isUpdatable();
  96662. stopChecking = !updatable;
  96663. }
  96664. }
  96665. }
  96666. }
  96667. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  96668. geometry.delayLoadState = this.delayLoadState;
  96669. geometry.delayLoadingFile = this.delayLoadingFile;
  96670. geometry._delayLoadingFunction = this._delayLoadingFunction;
  96671. for (kind in this._delayInfo) {
  96672. geometry._delayInfo = geometry._delayInfo || [];
  96673. geometry._delayInfo.push(kind);
  96674. }
  96675. // Bounding info
  96676. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  96677. return geometry;
  96678. };
  96679. /**
  96680. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96681. * @return a JSON representation of the current geometry data (without the vertices data)
  96682. */
  96683. Geometry.prototype.serialize = function () {
  96684. var serializationObject = {};
  96685. serializationObject.id = this.id;
  96686. serializationObject.updatable = this._updatable;
  96687. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].HasTags(this)) {
  96688. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].GetTags(this);
  96689. }
  96690. return serializationObject;
  96691. };
  96692. Geometry.prototype.toNumberArray = function (origin) {
  96693. if (Array.isArray(origin)) {
  96694. return origin;
  96695. }
  96696. else {
  96697. return Array.prototype.slice.call(origin);
  96698. }
  96699. };
  96700. /**
  96701. * Serialize all vertices data into a JSON oject
  96702. * @returns a JSON representation of the current geometry data
  96703. */
  96704. Geometry.prototype.serializeVerticeData = function () {
  96705. var serializationObject = this.serialize();
  96706. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  96707. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  96708. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  96709. serializationObject.positions._updatable = true;
  96710. }
  96711. }
  96712. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  96713. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  96714. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  96715. serializationObject.normals._updatable = true;
  96716. }
  96717. }
  96718. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  96719. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  96720. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  96721. serializationObject.tangets._updatable = true;
  96722. }
  96723. }
  96724. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  96725. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind));
  96726. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  96727. serializationObject.uvs._updatable = true;
  96728. }
  96729. }
  96730. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  96731. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind));
  96732. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  96733. serializationObject.uv2s._updatable = true;
  96734. }
  96735. }
  96736. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  96737. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind));
  96738. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  96739. serializationObject.uv3s._updatable = true;
  96740. }
  96741. }
  96742. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  96743. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind));
  96744. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  96745. serializationObject.uv4s._updatable = true;
  96746. }
  96747. }
  96748. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  96749. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind));
  96750. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  96751. serializationObject.uv5s._updatable = true;
  96752. }
  96753. }
  96754. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  96755. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind));
  96756. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  96757. serializationObject.uv6s._updatable = true;
  96758. }
  96759. }
  96760. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  96761. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind));
  96762. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  96763. serializationObject.colors._updatable = true;
  96764. }
  96765. }
  96766. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  96767. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind));
  96768. serializationObject.matricesIndices._isExpanded = true;
  96769. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  96770. serializationObject.matricesIndices._updatable = true;
  96771. }
  96772. }
  96773. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  96774. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind));
  96775. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  96776. serializationObject.matricesWeights._updatable = true;
  96777. }
  96778. }
  96779. serializationObject.indices = this.toNumberArray(this.getIndices());
  96780. return serializationObject;
  96781. };
  96782. // Statics
  96783. /**
  96784. * Extracts a clone of a mesh geometry
  96785. * @param mesh defines the source mesh
  96786. * @param id defines the unique ID of the new geometry object
  96787. * @returns the new geometry object
  96788. */
  96789. Geometry.ExtractFromMesh = function (mesh, id) {
  96790. var geometry = mesh._geometry;
  96791. if (!geometry) {
  96792. return null;
  96793. }
  96794. return geometry.copy(id);
  96795. };
  96796. /**
  96797. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96798. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96799. * Be aware Math.random() could cause collisions, but:
  96800. * "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"
  96801. * @returns a string containing a new GUID
  96802. */
  96803. Geometry.RandomId = function () {
  96804. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].RandomId();
  96805. };
  96806. /** @hidden */
  96807. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  96808. var scene = mesh.getScene();
  96809. // Geometry
  96810. var geometryId = parsedGeometry.geometryId;
  96811. if (geometryId) {
  96812. var geometry = scene.getGeometryByID(geometryId);
  96813. if (geometry) {
  96814. geometry.applyToMesh(mesh);
  96815. }
  96816. }
  96817. else if (parsedGeometry instanceof ArrayBuffer) {
  96818. var binaryInfo = mesh._binaryInfo;
  96819. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  96820. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  96821. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positionsData, false);
  96822. }
  96823. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  96824. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  96825. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normalsData, false);
  96826. }
  96827. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  96828. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  96829. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, tangentsData, false);
  96830. }
  96831. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  96832. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  96833. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvsData, false);
  96834. }
  96835. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  96836. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  96837. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, uvs2Data, false);
  96838. }
  96839. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  96840. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  96841. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, uvs3Data, false);
  96842. }
  96843. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  96844. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  96845. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, uvs4Data, false);
  96846. }
  96847. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  96848. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  96849. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, uvs5Data, false);
  96850. }
  96851. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  96852. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  96853. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, uvs6Data, false);
  96854. }
  96855. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  96856. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  96857. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  96858. }
  96859. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  96860. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  96861. var floatIndices = [];
  96862. for (var i = 0; i < matricesIndicesData.length; i++) {
  96863. var index = matricesIndicesData[i];
  96864. floatIndices.push(index & 0x000000FF);
  96865. floatIndices.push((index & 0x0000FF00) >> 8);
  96866. floatIndices.push((index & 0x00FF0000) >> 16);
  96867. floatIndices.push(index >> 24);
  96868. }
  96869. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  96870. }
  96871. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  96872. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  96873. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  96874. }
  96875. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  96876. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  96877. mesh.setIndices(indicesData, null);
  96878. }
  96879. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  96880. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  96881. mesh.subMeshes = [];
  96882. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  96883. var materialIndex = subMeshesData[(i * 5) + 0];
  96884. var verticesStart = subMeshesData[(i * 5) + 1];
  96885. var verticesCount = subMeshesData[(i * 5) + 2];
  96886. var indexStart = subMeshesData[(i * 5) + 3];
  96887. var indexCount = subMeshesData[(i * 5) + 4];
  96888. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  96889. }
  96890. }
  96891. }
  96892. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  96893. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  96894. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  96895. if (parsedGeometry.tangents) {
  96896. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  96897. }
  96898. if (parsedGeometry.uvs) {
  96899. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  96900. }
  96901. if (parsedGeometry.uvs2) {
  96902. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  96903. }
  96904. if (parsedGeometry.uvs3) {
  96905. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  96906. }
  96907. if (parsedGeometry.uvs4) {
  96908. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  96909. }
  96910. if (parsedGeometry.uvs5) {
  96911. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  96912. }
  96913. if (parsedGeometry.uvs6) {
  96914. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  96915. }
  96916. if (parsedGeometry.colors) {
  96917. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"].CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), parsedGeometry.colors._updatable);
  96918. }
  96919. if (parsedGeometry.matricesIndices) {
  96920. if (!parsedGeometry.matricesIndices._isExpanded) {
  96921. var floatIndices = [];
  96922. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  96923. var matricesIndex = parsedGeometry.matricesIndices[i];
  96924. floatIndices.push(matricesIndex & 0x000000FF);
  96925. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  96926. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  96927. floatIndices.push(matricesIndex >> 24);
  96928. }
  96929. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  96930. }
  96931. else {
  96932. delete parsedGeometry.matricesIndices._isExpanded;
  96933. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  96934. }
  96935. }
  96936. if (parsedGeometry.matricesIndicesExtra) {
  96937. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  96938. var floatIndices = [];
  96939. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  96940. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  96941. floatIndices.push(matricesIndex & 0x000000FF);
  96942. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  96943. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  96944. floatIndices.push(matricesIndex >> 24);
  96945. }
  96946. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  96947. }
  96948. else {
  96949. delete parsedGeometry.matricesIndices._isExpanded;
  96950. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  96951. }
  96952. }
  96953. if (parsedGeometry.matricesWeights) {
  96954. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  96955. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  96956. }
  96957. if (parsedGeometry.matricesWeightsExtra) {
  96958. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  96959. }
  96960. mesh.setIndices(parsedGeometry.indices, null);
  96961. }
  96962. // SubMeshes
  96963. if (parsedGeometry.subMeshes) {
  96964. mesh.subMeshes = [];
  96965. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  96966. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  96967. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  96968. }
  96969. }
  96970. // Flat shading
  96971. if (mesh._shouldGenerateFlatShading) {
  96972. mesh.convertToFlatShadedMesh();
  96973. delete mesh._shouldGenerateFlatShading;
  96974. }
  96975. // Update
  96976. mesh.computeWorldMatrix(true);
  96977. scene.onMeshImportedObservable.notifyObservers(mesh);
  96978. };
  96979. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  96980. var epsilon = 1e-3;
  96981. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  96982. return;
  96983. }
  96984. var noInfluenceBoneIndex = 0.0;
  96985. if (parsedGeometry.skeletonId > -1) {
  96986. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  96987. if (!skeleton) {
  96988. return;
  96989. }
  96990. noInfluenceBoneIndex = skeleton.bones.length;
  96991. }
  96992. else {
  96993. return;
  96994. }
  96995. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  96996. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  96997. var matricesWeights = parsedGeometry.matricesWeights;
  96998. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  96999. var influencers = parsedGeometry.numBoneInfluencer;
  97000. var size = matricesWeights.length;
  97001. for (var i = 0; i < size; i += 4) {
  97002. var weight = 0.0;
  97003. var firstZeroWeight = -1;
  97004. for (var j = 0; j < 4; j++) {
  97005. var w = matricesWeights[i + j];
  97006. weight += w;
  97007. if (w < epsilon && firstZeroWeight < 0) {
  97008. firstZeroWeight = j;
  97009. }
  97010. }
  97011. if (matricesWeightsExtra) {
  97012. for (var j = 0; j < 4; j++) {
  97013. var w = matricesWeightsExtra[i + j];
  97014. weight += w;
  97015. if (w < epsilon && firstZeroWeight < 0) {
  97016. firstZeroWeight = j + 4;
  97017. }
  97018. }
  97019. }
  97020. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  97021. firstZeroWeight = influencers - 1;
  97022. }
  97023. if (weight > epsilon) {
  97024. var mweight = 1.0 / weight;
  97025. for (var j = 0; j < 4; j++) {
  97026. matricesWeights[i + j] *= mweight;
  97027. }
  97028. if (matricesWeightsExtra) {
  97029. for (var j = 0; j < 4; j++) {
  97030. matricesWeightsExtra[i + j] *= mweight;
  97031. }
  97032. }
  97033. }
  97034. else {
  97035. if (firstZeroWeight >= 4) {
  97036. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  97037. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  97038. }
  97039. else {
  97040. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  97041. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  97042. }
  97043. }
  97044. }
  97045. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  97046. if (parsedGeometry.matricesWeightsExtra) {
  97047. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  97048. }
  97049. };
  97050. /**
  97051. * Create a new geometry from persisted data (Using .babylon file format)
  97052. * @param parsedVertexData defines the persisted data
  97053. * @param scene defines the hosting scene
  97054. * @param rootUrl defines the root url to use to load assets (like delayed data)
  97055. * @returns the new geometry object
  97056. */
  97057. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  97058. if (scene.getGeometryByID(parsedVertexData.id)) {
  97059. return null; // null since geometry could be something else than a box...
  97060. }
  97061. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  97062. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  97063. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  97064. }
  97065. if (parsedVertexData.delayLoadingFile) {
  97066. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  97067. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  97068. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMinimum), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMaximum));
  97069. geometry._delayInfo = [];
  97070. if (parsedVertexData.hasUVs) {
  97071. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind);
  97072. }
  97073. if (parsedVertexData.hasUVs2) {
  97074. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind);
  97075. }
  97076. if (parsedVertexData.hasUVs3) {
  97077. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind);
  97078. }
  97079. if (parsedVertexData.hasUVs4) {
  97080. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind);
  97081. }
  97082. if (parsedVertexData.hasUVs5) {
  97083. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind);
  97084. }
  97085. if (parsedVertexData.hasUVs6) {
  97086. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind);
  97087. }
  97088. if (parsedVertexData.hasColors) {
  97089. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  97090. }
  97091. if (parsedVertexData.hasMatricesIndices) {
  97092. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  97093. }
  97094. if (parsedVertexData.hasMatricesWeights) {
  97095. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  97096. }
  97097. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData;
  97098. }
  97099. else {
  97100. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  97101. }
  97102. scene.pushGeometry(geometry, true);
  97103. return geometry;
  97104. };
  97105. return Geometry;
  97106. }());
  97107. /***/ }),
  97108. /***/ "./Meshes/groundMesh.ts":
  97109. /*!******************************!*\
  97110. !*** ./Meshes/groundMesh.ts ***!
  97111. \******************************/
  97112. /*! exports provided: GroundMesh */
  97113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97114. "use strict";
  97115. __webpack_require__.r(__webpack_exports__);
  97116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  97117. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97118. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  97119. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  97120. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  97121. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  97122. return GroundMesh.Parse(parsedMesh, scene);
  97123. };
  97124. /**
  97125. * Mesh representing the gorund
  97126. */
  97127. var GroundMesh = /** @class */ (function (_super) {
  97128. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  97129. function GroundMesh(name, scene) {
  97130. var _this = _super.call(this, name, scene) || this;
  97131. /** If octree should be generated */
  97132. _this.generateOctree = false;
  97133. return _this;
  97134. }
  97135. /**
  97136. * "GroundMesh"
  97137. * @returns "GroundMesh"
  97138. */
  97139. GroundMesh.prototype.getClassName = function () {
  97140. return "GroundMesh";
  97141. };
  97142. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  97143. /**
  97144. * The minimum of x and y subdivisions
  97145. */
  97146. get: function () {
  97147. return Math.min(this._subdivisionsX, this._subdivisionsY);
  97148. },
  97149. enumerable: true,
  97150. configurable: true
  97151. });
  97152. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  97153. /**
  97154. * X subdivisions
  97155. */
  97156. get: function () {
  97157. return this._subdivisionsX;
  97158. },
  97159. enumerable: true,
  97160. configurable: true
  97161. });
  97162. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  97163. /**
  97164. * Y subdivisions
  97165. */
  97166. get: function () {
  97167. return this._subdivisionsY;
  97168. },
  97169. enumerable: true,
  97170. configurable: true
  97171. });
  97172. /**
  97173. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97174. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97175. * @param chunksCount the number of subdivisions for x and y
  97176. * @param octreeBlocksSize (Default: 32)
  97177. */
  97178. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  97179. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  97180. this._subdivisionsX = chunksCount;
  97181. this._subdivisionsY = chunksCount;
  97182. this.subdivide(chunksCount);
  97183. // Call the octree system optimization if it is defined.
  97184. var thisAsAny = this;
  97185. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  97186. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  97187. }
  97188. };
  97189. /**
  97190. * Returns a height (y) value in the Worl system :
  97191. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97192. * @param x x coordinate
  97193. * @param z z coordinate
  97194. * @returns the ground y position if (x, z) are outside the ground surface.
  97195. */
  97196. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  97197. var world = this.getWorldMatrix();
  97198. var invMat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[5];
  97199. world.invertToRef(invMat);
  97200. var tmpVect = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[8];
  97201. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  97202. x = tmpVect.x;
  97203. z = tmpVect.z;
  97204. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  97205. return this.position.y;
  97206. }
  97207. if (!this._heightQuads || this._heightQuads.length == 0) {
  97208. this._initHeightQuads();
  97209. this._computeHeightQuads();
  97210. }
  97211. var facet = this._getFacetAt(x, z);
  97212. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  97213. // return y in the World system
  97214. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  97215. return tmpVect.y;
  97216. };
  97217. /**
  97218. * Returns a normalized vector (Vector3) orthogonal to the ground
  97219. * at the ground coordinates (x, z) expressed in the World system.
  97220. * @param x x coordinate
  97221. * @param z z coordinate
  97222. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97223. */
  97224. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  97225. var normal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  97226. this.getNormalAtCoordinatesToRef(x, z, normal);
  97227. return normal;
  97228. };
  97229. /**
  97230. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97231. * at the ground coordinates (x, z) expressed in the World system.
  97232. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97233. * @param x x coordinate
  97234. * @param z z coordinate
  97235. * @param ref vector to store the result
  97236. * @returns the GroundMesh.
  97237. */
  97238. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  97239. var world = this.getWorldMatrix();
  97240. var tmpMat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[5];
  97241. world.invertToRef(tmpMat);
  97242. var tmpVect = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[8];
  97243. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  97244. x = tmpVect.x;
  97245. z = tmpVect.z;
  97246. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  97247. return this;
  97248. }
  97249. if (!this._heightQuads || this._heightQuads.length == 0) {
  97250. this._initHeightQuads();
  97251. this._computeHeightQuads();
  97252. }
  97253. var facet = this._getFacetAt(x, z);
  97254. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  97255. return this;
  97256. };
  97257. /**
  97258. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97259. * if the ground has been updated.
  97260. * This can be used in the render loop.
  97261. * @returns the GroundMesh.
  97262. */
  97263. GroundMesh.prototype.updateCoordinateHeights = function () {
  97264. if (!this._heightQuads || this._heightQuads.length == 0) {
  97265. this._initHeightQuads();
  97266. }
  97267. this._computeHeightQuads();
  97268. return this;
  97269. };
  97270. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  97271. GroundMesh.prototype._getFacetAt = function (x, z) {
  97272. // retrieve col and row from x, z coordinates in the ground local system
  97273. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  97274. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  97275. var quad = this._heightQuads[row * this._subdivisionsX + col];
  97276. var facet;
  97277. if (z < quad.slope.x * x + quad.slope.y) {
  97278. facet = quad.facet1;
  97279. }
  97280. else {
  97281. facet = quad.facet2;
  97282. }
  97283. return facet;
  97284. };
  97285. // Creates and populates the heightMap array with "facet" elements :
  97286. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  97287. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  97288. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  97289. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  97290. // Returns the GroundMesh.
  97291. GroundMesh.prototype._initHeightQuads = function () {
  97292. var subdivisionsX = this._subdivisionsX;
  97293. var subdivisionsY = this._subdivisionsY;
  97294. this._heightQuads = new Array();
  97295. for (var row = 0; row < subdivisionsY; row++) {
  97296. for (var col = 0; col < subdivisionsX; col++) {
  97297. var quad = { slope: _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), facet1: new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0.0, 0.0, 0.0, 0.0), facet2: new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0.0, 0.0, 0.0, 0.0) };
  97298. this._heightQuads[row * subdivisionsX + col] = quad;
  97299. }
  97300. }
  97301. return this;
  97302. };
  97303. // Compute each quad element values and update the the heightMap array :
  97304. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  97305. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  97306. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  97307. // Returns the GroundMesh.
  97308. GroundMesh.prototype._computeHeightQuads = function () {
  97309. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  97310. if (!positions) {
  97311. return this;
  97312. }
  97313. var v1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[3];
  97314. var v2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[2];
  97315. var v3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  97316. var v4 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  97317. var v1v2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[4];
  97318. var v1v3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[5];
  97319. var v1v4 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[6];
  97320. var norm1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[7];
  97321. var norm2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[8];
  97322. var i = 0;
  97323. var j = 0;
  97324. var k = 0;
  97325. var cd = 0; // 2D slope coefficient : z = cd * x + h
  97326. var h = 0;
  97327. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  97328. var d2 = 0;
  97329. var subdivisionsX = this._subdivisionsX;
  97330. var subdivisionsY = this._subdivisionsY;
  97331. for (var row = 0; row < subdivisionsY; row++) {
  97332. for (var col = 0; col < subdivisionsX; col++) {
  97333. i = col * 3;
  97334. j = row * (subdivisionsX + 1) * 3;
  97335. k = (row + 1) * (subdivisionsX + 1) * 3;
  97336. v1.x = positions[j + i];
  97337. v1.y = positions[j + i + 1];
  97338. v1.z = positions[j + i + 2];
  97339. v2.x = positions[j + i + 3];
  97340. v2.y = positions[j + i + 4];
  97341. v2.z = positions[j + i + 5];
  97342. v3.x = positions[k + i];
  97343. v3.y = positions[k + i + 1];
  97344. v3.z = positions[k + i + 2];
  97345. v4.x = positions[k + i + 3];
  97346. v4.y = positions[k + i + 4];
  97347. v4.z = positions[k + i + 5];
  97348. // 2D slope V1V4
  97349. cd = (v4.z - v1.z) / (v4.x - v1.x);
  97350. h = v1.z - cd * v1.x; // v1 belongs to the slope
  97351. // facet equations :
  97352. // we compute each facet normal vector
  97353. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  97354. // we compute the value d by applying the equation to v1 which belongs to the plane
  97355. // then we store the facet equation in a Vector4
  97356. v2.subtractToRef(v1, v1v2);
  97357. v3.subtractToRef(v1, v1v3);
  97358. v4.subtractToRef(v1, v1v4);
  97359. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  97360. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  97361. norm1.normalize();
  97362. norm2.normalize();
  97363. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  97364. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  97365. var quad = this._heightQuads[row * subdivisionsX + col];
  97366. quad.slope.copyFromFloats(cd, h);
  97367. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  97368. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  97369. }
  97370. }
  97371. return this;
  97372. };
  97373. /**
  97374. * Serializes this ground mesh
  97375. * @param serializationObject object to write serialization to
  97376. */
  97377. GroundMesh.prototype.serialize = function (serializationObject) {
  97378. _super.prototype.serialize.call(this, serializationObject);
  97379. serializationObject.subdivisionsX = this._subdivisionsX;
  97380. serializationObject.subdivisionsY = this._subdivisionsY;
  97381. serializationObject.minX = this._minX;
  97382. serializationObject.maxX = this._maxX;
  97383. serializationObject.minZ = this._minZ;
  97384. serializationObject.maxZ = this._maxZ;
  97385. serializationObject.width = this._width;
  97386. serializationObject.height = this._height;
  97387. };
  97388. /**
  97389. * Parses a serialized ground mesh
  97390. * @param parsedMesh the serialized mesh
  97391. * @param scene the scene to create the ground mesh in
  97392. * @returns the created ground mesh
  97393. */
  97394. GroundMesh.Parse = function (parsedMesh, scene) {
  97395. var result = new GroundMesh(parsedMesh.name, scene);
  97396. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  97397. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  97398. result._minX = parsedMesh.minX;
  97399. result._maxX = parsedMesh.maxX;
  97400. result._minZ = parsedMesh.minZ;
  97401. result._maxZ = parsedMesh.maxZ;
  97402. result._width = parsedMesh.width;
  97403. result._height = parsedMesh.height;
  97404. return result;
  97405. };
  97406. return GroundMesh;
  97407. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  97408. /***/ }),
  97409. /***/ "./Meshes/index.ts":
  97410. /*!*************************!*\
  97411. !*** ./Meshes/index.ts ***!
  97412. \*************************/
  97413. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, MeshLODLevel, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DataBuffer, WebGLDataBuffer, DracoCompression, TiledBoxBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TiledPlaneBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  97414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97415. "use strict";
  97416. __webpack_require__.r(__webpack_exports__);
  97417. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  97418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  97419. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  97420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  97421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  97422. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  97423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  97424. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  97425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  97426. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  97427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  97428. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  97429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  97430. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  97431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  97432. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  97433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  97434. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  97435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  97436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  97437. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  97438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  97439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  97440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  97441. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  97442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  97443. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  97444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  97445. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  97446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  97447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  97448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  97449. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  97450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  97451. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  97452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  97453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  97454. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  97455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  97456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  97457. /* harmony import */ var _meshLODLevel__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./meshLODLevel */ "./Meshes/meshLODLevel.ts");
  97458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _meshLODLevel__WEBPACK_IMPORTED_MODULE_16__["MeshLODLevel"]; });
  97459. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  97460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_17__["TransformNode"]; });
  97461. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  97462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["BoxBuilder"]; });
  97463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["SphereBuilder"]; });
  97464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["CylinderBuilder"]; });
  97465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TorusBuilder"]; });
  97466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["LinesBuilder"]; });
  97467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["PlaneBuilder"]; });
  97468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["GroundBuilder"]; });
  97469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledBoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TiledBoxBuilder"]; });
  97470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["DiscBuilder"]; });
  97471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["RibbonBuilder"]; });
  97472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["HemisphereBuilder"]; });
  97473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TorusKnotBuilder"]; });
  97474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["PolygonBuilder"]; });
  97475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["ShapeBuilder"]; });
  97476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["LatheBuilder"]; });
  97477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledPlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TiledPlaneBuilder"]; });
  97478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TubeBuilder"]; });
  97479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["PolyhedronBuilder"]; });
  97480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["IcoSphereBuilder"]; });
  97481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["DecalBuilder"]; });
  97482. /* harmony import */ var _dataBuffer__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./dataBuffer */ "./Meshes/dataBuffer.ts");
  97483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return _dataBuffer__WEBPACK_IMPORTED_MODULE_19__["DataBuffer"]; });
  97484. /* harmony import */ var _WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./WebGL/webGLDataBuffer */ "./Meshes/WebGL/webGLDataBuffer.ts");
  97485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return _WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_20__["WebGLDataBuffer"]; });
  97486. /***/ }),
  97487. /***/ "./Meshes/instancedMesh.ts":
  97488. /*!*********************************!*\
  97489. !*** ./Meshes/instancedMesh.ts ***!
  97490. \*********************************/
  97491. /*! exports provided: InstancedMesh */
  97492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97493. "use strict";
  97494. __webpack_require__.r(__webpack_exports__);
  97495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  97496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97497. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  97498. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97499. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  97500. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  97501. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  97502. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  97503. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  97504. return new InstancedMesh(name, mesh);
  97505. };
  97506. /**
  97507. * Creates an instance based on a source mesh.
  97508. */
  97509. var InstancedMesh = /** @class */ (function (_super) {
  97510. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  97511. function InstancedMesh(name, source) {
  97512. var _this = _super.call(this, name, source.getScene()) || this;
  97513. /** @hidden */
  97514. _this._indexInSourceMeshInstanceArray = -1;
  97515. source.addInstance(_this);
  97516. _this._sourceMesh = source;
  97517. _this._unIndexed = source._unIndexed;
  97518. _this.position.copyFrom(source.position);
  97519. _this.rotation.copyFrom(source.rotation);
  97520. _this.scaling.copyFrom(source.scaling);
  97521. if (source.rotationQuaternion) {
  97522. _this.rotationQuaternion = source.rotationQuaternion.clone();
  97523. }
  97524. _this.infiniteDistance = source.infiniteDistance;
  97525. _this.setPivotMatrix(source.getPivotMatrix());
  97526. _this.refreshBoundingInfo();
  97527. _this._syncSubMeshes();
  97528. return _this;
  97529. }
  97530. /**
  97531. * Returns the string "InstancedMesh".
  97532. */
  97533. InstancedMesh.prototype.getClassName = function () {
  97534. return "InstancedMesh";
  97535. };
  97536. Object.defineProperty(InstancedMesh.prototype, "lightSources", {
  97537. /** Gets the list of lights affecting that mesh */
  97538. get: function () {
  97539. return this._sourceMesh._lightSources;
  97540. },
  97541. enumerable: true,
  97542. configurable: true
  97543. });
  97544. InstancedMesh.prototype._resyncLightSources = function () {
  97545. // Do nothing as all the work will be done by source mesh
  97546. };
  97547. InstancedMesh.prototype._resyncLighSource = function (light) {
  97548. // Do nothing as all the work will be done by source mesh
  97549. };
  97550. InstancedMesh.prototype._removeLightSource = function (light) {
  97551. // Do nothing as all the work will be done by source mesh
  97552. };
  97553. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  97554. // Methods
  97555. /**
  97556. * If the source mesh receives shadows
  97557. */
  97558. get: function () {
  97559. return this._sourceMesh.receiveShadows;
  97560. },
  97561. enumerable: true,
  97562. configurable: true
  97563. });
  97564. Object.defineProperty(InstancedMesh.prototype, "material", {
  97565. /**
  97566. * The material of the source mesh
  97567. */
  97568. get: function () {
  97569. return this._sourceMesh.material;
  97570. },
  97571. enumerable: true,
  97572. configurable: true
  97573. });
  97574. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  97575. /**
  97576. * Visibility of the source mesh
  97577. */
  97578. get: function () {
  97579. return this._sourceMesh.visibility;
  97580. },
  97581. enumerable: true,
  97582. configurable: true
  97583. });
  97584. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  97585. /**
  97586. * Skeleton of the source mesh
  97587. */
  97588. get: function () {
  97589. return this._sourceMesh.skeleton;
  97590. },
  97591. enumerable: true,
  97592. configurable: true
  97593. });
  97594. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  97595. /**
  97596. * Rendering ground id of the source mesh
  97597. */
  97598. get: function () {
  97599. return this._sourceMesh.renderingGroupId;
  97600. },
  97601. set: function (value) {
  97602. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  97603. return;
  97604. }
  97605. //no-op with warning
  97606. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  97607. },
  97608. enumerable: true,
  97609. configurable: true
  97610. });
  97611. /**
  97612. * Returns the total number of vertices (integer).
  97613. */
  97614. InstancedMesh.prototype.getTotalVertices = function () {
  97615. return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;
  97616. };
  97617. /**
  97618. * Returns a positive integer : the total number of indices in this mesh geometry.
  97619. * @returns the numner of indices or zero if the mesh has no geometry.
  97620. */
  97621. InstancedMesh.prototype.getTotalIndices = function () {
  97622. return this._sourceMesh.getTotalIndices();
  97623. };
  97624. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  97625. /**
  97626. * The source mesh of the instance
  97627. */
  97628. get: function () {
  97629. return this._sourceMesh;
  97630. },
  97631. enumerable: true,
  97632. configurable: true
  97633. });
  97634. /**
  97635. * Is this node ready to be used/rendered
  97636. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97637. * @return {boolean} is it ready
  97638. */
  97639. InstancedMesh.prototype.isReady = function (completeCheck) {
  97640. if (completeCheck === void 0) { completeCheck = false; }
  97641. return this._sourceMesh.isReady(completeCheck, true);
  97642. };
  97643. /**
  97644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97645. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97646. * @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.
  97647. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97648. */
  97649. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  97650. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  97651. };
  97652. /**
  97653. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97654. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97655. * The `data` are either a numeric array either a Float32Array.
  97656. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97657. * 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).
  97658. * Note that a new underlying VertexBuffer object is created each call.
  97659. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97660. *
  97661. * Possible `kind` values :
  97662. * - VertexBuffer.PositionKind
  97663. * - VertexBuffer.UVKind
  97664. * - VertexBuffer.UV2Kind
  97665. * - VertexBuffer.UV3Kind
  97666. * - VertexBuffer.UV4Kind
  97667. * - VertexBuffer.UV5Kind
  97668. * - VertexBuffer.UV6Kind
  97669. * - VertexBuffer.ColorKind
  97670. * - VertexBuffer.MatricesIndicesKind
  97671. * - VertexBuffer.MatricesIndicesExtraKind
  97672. * - VertexBuffer.MatricesWeightsKind
  97673. * - VertexBuffer.MatricesWeightsExtraKind
  97674. *
  97675. * Returns the Mesh.
  97676. */
  97677. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  97678. if (this.sourceMesh) {
  97679. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  97680. }
  97681. return this.sourceMesh;
  97682. };
  97683. /**
  97684. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97685. * If the mesh has no geometry, it is simply returned as it is.
  97686. * The `data` are either a numeric array either a Float32Array.
  97687. * No new underlying VertexBuffer object is created.
  97688. * 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.
  97689. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97690. *
  97691. * Possible `kind` values :
  97692. * - VertexBuffer.PositionKind
  97693. * - VertexBuffer.UVKind
  97694. * - VertexBuffer.UV2Kind
  97695. * - VertexBuffer.UV3Kind
  97696. * - VertexBuffer.UV4Kind
  97697. * - VertexBuffer.UV5Kind
  97698. * - VertexBuffer.UV6Kind
  97699. * - VertexBuffer.ColorKind
  97700. * - VertexBuffer.MatricesIndicesKind
  97701. * - VertexBuffer.MatricesIndicesExtraKind
  97702. * - VertexBuffer.MatricesWeightsKind
  97703. * - VertexBuffer.MatricesWeightsExtraKind
  97704. *
  97705. * Returns the Mesh.
  97706. */
  97707. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  97708. if (this.sourceMesh) {
  97709. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  97710. }
  97711. return this.sourceMesh;
  97712. };
  97713. /**
  97714. * Sets the mesh indices.
  97715. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97716. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97717. * This method creates a new index buffer each call.
  97718. * Returns the Mesh.
  97719. */
  97720. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  97721. if (totalVertices === void 0) { totalVertices = null; }
  97722. if (this.sourceMesh) {
  97723. this.sourceMesh.setIndices(indices, totalVertices);
  97724. }
  97725. return this.sourceMesh;
  97726. };
  97727. /**
  97728. * Boolean : True if the mesh owns the requested kind of data.
  97729. */
  97730. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  97731. return this._sourceMesh.isVerticesDataPresent(kind);
  97732. };
  97733. /**
  97734. * Returns an array of indices (IndicesArray).
  97735. */
  97736. InstancedMesh.prototype.getIndices = function () {
  97737. return this._sourceMesh.getIndices();
  97738. };
  97739. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  97740. get: function () {
  97741. return this._sourceMesh._positions;
  97742. },
  97743. enumerable: true,
  97744. configurable: true
  97745. });
  97746. /**
  97747. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97748. * This means the mesh underlying bounding box and sphere are recomputed.
  97749. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97750. * @returns the current mesh
  97751. */
  97752. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  97753. if (applySkeleton === void 0) { applySkeleton = false; }
  97754. if (this._boundingInfo && this._boundingInfo.isLocked) {
  97755. return this;
  97756. }
  97757. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  97758. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  97759. return this;
  97760. };
  97761. /** @hidden */
  97762. InstancedMesh.prototype._preActivate = function () {
  97763. if (this._currentLOD) {
  97764. this._currentLOD._preActivate();
  97765. }
  97766. return this;
  97767. };
  97768. /** @hidden */
  97769. InstancedMesh.prototype._activate = function (renderId, intermediateRendering) {
  97770. if (!this._sourceMesh.subMeshes) {
  97771. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Instances should only be created for meshes with geometry.");
  97772. }
  97773. if (this._currentLOD) {
  97774. this._currentLOD._registerInstanceForRenderId(this, renderId);
  97775. if (intermediateRendering) {
  97776. if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {
  97777. this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;
  97778. return true;
  97779. }
  97780. }
  97781. else {
  97782. if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {
  97783. this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;
  97784. return true;
  97785. }
  97786. }
  97787. }
  97788. return false;
  97789. };
  97790. /** @hidden */
  97791. InstancedMesh.prototype._postActivate = function () {
  97792. if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {
  97793. this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);
  97794. }
  97795. };
  97796. InstancedMesh.prototype.getWorldMatrix = function () {
  97797. if (this._currentLOD && this._currentLOD.billboardMode !== _transformNode__WEBPACK_IMPORTED_MODULE_6__["TransformNode"].BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
  97798. var tempMaster = this._currentLOD._masterMesh;
  97799. this._currentLOD._masterMesh = this;
  97800. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(true));
  97801. this._currentLOD._masterMesh = tempMaster;
  97802. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0];
  97803. }
  97804. return _super.prototype.getWorldMatrix.call(this);
  97805. };
  97806. Object.defineProperty(InstancedMesh.prototype, "isAnInstance", {
  97807. get: function () {
  97808. return true;
  97809. },
  97810. enumerable: true,
  97811. configurable: true
  97812. });
  97813. /**
  97814. * Returns the current associated LOD AbstractMesh.
  97815. */
  97816. InstancedMesh.prototype.getLOD = function (camera) {
  97817. if (!camera) {
  97818. return this;
  97819. }
  97820. var boundingInfo = this.getBoundingInfo();
  97821. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  97822. if (this._currentLOD === this.sourceMesh) {
  97823. return this.sourceMesh;
  97824. }
  97825. return this._currentLOD;
  97826. };
  97827. /** @hidden */
  97828. InstancedMesh.prototype._syncSubMeshes = function () {
  97829. this.releaseSubMeshes();
  97830. if (this._sourceMesh.subMeshes) {
  97831. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  97832. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  97833. }
  97834. }
  97835. return this;
  97836. };
  97837. /** @hidden */
  97838. InstancedMesh.prototype._generatePointsArray = function () {
  97839. return this._sourceMesh._generatePointsArray();
  97840. };
  97841. /**
  97842. * Creates a new InstancedMesh from the current mesh.
  97843. * - name (string) : the cloned mesh name
  97844. * - newParent (optional Node) : the optional Node to parent the clone to.
  97845. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97846. *
  97847. * Returns the clone.
  97848. */
  97849. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  97850. var result = this._sourceMesh.createInstance(name);
  97851. // Deep copy
  97852. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_5__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  97853. // Bounding info
  97854. this.refreshBoundingInfo();
  97855. // Parent
  97856. if (newParent) {
  97857. result.parent = newParent;
  97858. }
  97859. if (!doNotCloneChildren) {
  97860. // Children
  97861. for (var index = 0; index < this.getScene().meshes.length; index++) {
  97862. var mesh = this.getScene().meshes[index];
  97863. if (mesh.parent === this) {
  97864. mesh.clone(mesh.name, result);
  97865. }
  97866. }
  97867. }
  97868. result.computeWorldMatrix(true);
  97869. return result;
  97870. };
  97871. /**
  97872. * Disposes the InstancedMesh.
  97873. * Returns nothing.
  97874. */
  97875. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  97876. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  97877. // Remove from mesh
  97878. this._sourceMesh.removeInstance(this);
  97879. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  97880. };
  97881. return InstancedMesh;
  97882. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]));
  97883. /***/ }),
  97884. /***/ "./Meshes/linesMesh.ts":
  97885. /*!*****************************!*\
  97886. !*** ./Meshes/linesMesh.ts ***!
  97887. \*****************************/
  97888. /*! exports provided: LinesMesh, InstancedLinesMesh */
  97889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97890. "use strict";
  97891. __webpack_require__.r(__webpack_exports__);
  97892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  97893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  97894. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97895. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  97896. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  97897. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  97898. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  97899. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  97900. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  97901. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  97902. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  97903. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  97904. /**
  97905. * Line mesh
  97906. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97907. */
  97908. var LinesMesh = /** @class */ (function (_super) {
  97909. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  97910. /**
  97911. * Creates a new LinesMesh
  97912. * @param name defines the name
  97913. * @param scene defines the hosting scene
  97914. * @param parent defines the parent mesh if any
  97915. * @param source defines the optional source LinesMesh used to clone data from
  97916. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97917. * When false, achieved by calling a clone(), also passing False.
  97918. * This will make creation of children, recursive.
  97919. * @param useVertexColor defines if this LinesMesh supports vertex color
  97920. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97921. */
  97922. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  97923. /**
  97924. * If vertex color should be applied to the mesh
  97925. */
  97926. useVertexColor,
  97927. /**
  97928. * If vertex alpha should be applied to the mesh
  97929. */
  97930. useVertexAlpha) {
  97931. if (scene === void 0) { scene = null; }
  97932. if (parent === void 0) { parent = null; }
  97933. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  97934. _this.useVertexColor = useVertexColor;
  97935. _this.useVertexAlpha = useVertexAlpha;
  97936. /**
  97937. * Color of the line (Default: White)
  97938. */
  97939. _this.color = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  97940. /**
  97941. * Alpha of the line (Default: 1)
  97942. */
  97943. _this.alpha = 1;
  97944. if (source) {
  97945. _this.color = source.color.clone();
  97946. _this.alpha = source.alpha;
  97947. _this.useVertexColor = source.useVertexColor;
  97948. _this.useVertexAlpha = source.useVertexAlpha;
  97949. }
  97950. _this.intersectionThreshold = 0.1;
  97951. var defines = [];
  97952. var options = {
  97953. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  97954. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  97955. needAlphaBlending: true,
  97956. defines: defines
  97957. };
  97958. if (useVertexAlpha === false) {
  97959. options.needAlphaBlending = false;
  97960. }
  97961. if (!useVertexColor) {
  97962. options.uniforms.push("color");
  97963. _this.color4 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"]();
  97964. }
  97965. else {
  97966. options.defines.push("#define VERTEXCOLOR");
  97967. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  97968. }
  97969. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  97970. return _this;
  97971. }
  97972. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  97973. var define = "#define " + label;
  97974. var index = this._colorShader.options.defines.indexOf(define);
  97975. if (index !== -1) {
  97976. return;
  97977. }
  97978. this._colorShader.options.defines.push(define);
  97979. };
  97980. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  97981. var define = "#define " + label;
  97982. var index = this._colorShader.options.defines.indexOf(define);
  97983. if (index === -1) {
  97984. return;
  97985. }
  97986. this._colorShader.options.defines.splice(index, 1);
  97987. };
  97988. LinesMesh.prototype.isReady = function () {
  97989. var scene = this.getScene();
  97990. // Clip planes
  97991. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  97992. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  97993. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  97994. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  97995. if (!this._colorShader.isReady()) {
  97996. return false;
  97997. }
  97998. return _super.prototype.isReady.call(this);
  97999. };
  98000. /**
  98001. * Returns the string "LineMesh"
  98002. */
  98003. LinesMesh.prototype.getClassName = function () {
  98004. return "LinesMesh";
  98005. };
  98006. Object.defineProperty(LinesMesh.prototype, "material", {
  98007. /**
  98008. * @hidden
  98009. */
  98010. get: function () {
  98011. return this._colorShader;
  98012. },
  98013. /**
  98014. * @hidden
  98015. */
  98016. set: function (value) {
  98017. // Do nothing
  98018. },
  98019. enumerable: true,
  98020. configurable: true
  98021. });
  98022. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  98023. /**
  98024. * @hidden
  98025. */
  98026. get: function () {
  98027. return false;
  98028. },
  98029. enumerable: true,
  98030. configurable: true
  98031. });
  98032. /** @hidden */
  98033. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  98034. if (!this._geometry) {
  98035. return this;
  98036. }
  98037. var colorEffect = this._colorShader.getEffect();
  98038. // VBOs
  98039. var indexToBind = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
  98040. this._geometry._bind(colorEffect, indexToBind);
  98041. // Color
  98042. if (!this.useVertexColor) {
  98043. var _a = this.color, r = _a.r, g = _a.g, b = _a.b;
  98044. this.color4.set(r, g, b, this.alpha);
  98045. this._colorShader.setColor4("color", this.color4);
  98046. }
  98047. // Clip planes
  98048. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  98049. return this;
  98050. };
  98051. /** @hidden */
  98052. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  98053. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  98054. return this;
  98055. }
  98056. var engine = this.getScene().getEngine();
  98057. // Draw order
  98058. if (this._unIndexed) {
  98059. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  98060. }
  98061. else {
  98062. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  98063. }
  98064. return this;
  98065. };
  98066. /**
  98067. * Disposes of the line mesh
  98068. * @param doNotRecurse If children should be disposed
  98069. */
  98070. LinesMesh.prototype.dispose = function (doNotRecurse) {
  98071. this._colorShader.dispose(false, false, true);
  98072. _super.prototype.dispose.call(this, doNotRecurse);
  98073. };
  98074. /**
  98075. * Returns a new LineMesh object cloned from the current one.
  98076. */
  98077. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  98078. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  98079. };
  98080. /**
  98081. * Creates a new InstancedLinesMesh object from the mesh model.
  98082. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98083. * @param name defines the name of the new instance
  98084. * @returns a new InstancedLinesMesh
  98085. */
  98086. LinesMesh.prototype.createInstance = function (name) {
  98087. return new InstancedLinesMesh(name, this);
  98088. };
  98089. return LinesMesh;
  98090. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  98091. /**
  98092. * Creates an instance based on a source LinesMesh
  98093. */
  98094. var InstancedLinesMesh = /** @class */ (function (_super) {
  98095. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  98096. function InstancedLinesMesh(name, source) {
  98097. var _this = _super.call(this, name, source) || this;
  98098. _this.intersectionThreshold = source.intersectionThreshold;
  98099. return _this;
  98100. }
  98101. /**
  98102. * Returns the string "InstancedLinesMesh".
  98103. */
  98104. InstancedLinesMesh.prototype.getClassName = function () {
  98105. return "InstancedLinesMesh";
  98106. };
  98107. return InstancedLinesMesh;
  98108. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  98109. /***/ }),
  98110. /***/ "./Meshes/mesh.ts":
  98111. /*!************************!*\
  98112. !*** ./Meshes/mesh.ts ***!
  98113. \************************/
  98114. /*! exports provided: _CreationDataStorage, _InstancesBatch, Mesh */
  98115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98116. "use strict";
  98117. __webpack_require__.r(__webpack_exports__);
  98118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  98119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  98120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  98121. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98122. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  98123. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  98124. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  98125. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  98126. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  98127. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  98128. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../node */ "./node.ts");
  98129. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  98130. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  98131. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  98132. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  98133. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  98134. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  98135. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  98136. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  98137. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  98138. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98139. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  98140. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98141. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  98142. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  98143. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  98144. /* harmony import */ var _meshLODLevel__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./meshLODLevel */ "./Meshes/meshLODLevel.ts");
  98145. /**
  98146. * @hidden
  98147. **/
  98148. var _CreationDataStorage = /** @class */ (function () {
  98149. function _CreationDataStorage() {
  98150. }
  98151. return _CreationDataStorage;
  98152. }());
  98153. /**
  98154. * @hidden
  98155. **/
  98156. var _InstanceDataStorage = /** @class */ (function () {
  98157. function _InstanceDataStorage() {
  98158. this.visibleInstances = {};
  98159. this.batchCache = new _InstancesBatch();
  98160. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  98161. }
  98162. return _InstanceDataStorage;
  98163. }());
  98164. /**
  98165. * @hidden
  98166. **/
  98167. var _InstancesBatch = /** @class */ (function () {
  98168. function _InstancesBatch() {
  98169. this.mustReturn = false;
  98170. this.visibleInstances = new Array();
  98171. this.renderSelf = new Array();
  98172. this.hardwareInstancedRendering = new Array();
  98173. }
  98174. return _InstancesBatch;
  98175. }());
  98176. /**
  98177. * @hidden
  98178. **/
  98179. var _InternalMeshDataInfo = /** @class */ (function () {
  98180. function _InternalMeshDataInfo() {
  98181. this._areNormalsFrozen = false; // Will be used by ribbons mainly
  98182. // Will be used to save a source mesh reference, If any
  98183. this._source = null;
  98184. // Will be used to for fast cloned mesh lookup
  98185. this.meshMap = null;
  98186. this._preActivateId = -1;
  98187. this._LODLevels = new Array();
  98188. // Morph
  98189. this._morphTargetManager = null;
  98190. }
  98191. return _InternalMeshDataInfo;
  98192. }());
  98193. /**
  98194. * Class used to represent renderable models
  98195. */
  98196. var Mesh = /** @class */ (function (_super) {
  98197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  98198. /**
  98199. * @constructor
  98200. * @param name The value used by scene.getMeshByName() to do a lookup.
  98201. * @param scene The scene to add this mesh to.
  98202. * @param parent The parent of this mesh, if it has one
  98203. * @param source An optional Mesh from which geometry is shared, cloned.
  98204. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98205. * When false, achieved by calling a clone(), also passing False.
  98206. * This will make creation of children, recursive.
  98207. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98208. */
  98209. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  98210. if (scene === void 0) { scene = null; }
  98211. if (parent === void 0) { parent = null; }
  98212. if (source === void 0) { source = null; }
  98213. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  98214. var _this = _super.call(this, name, scene) || this;
  98215. // Internal data
  98216. _this._internalMeshDataInfo = new _InternalMeshDataInfo();
  98217. // Members
  98218. /**
  98219. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98220. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98221. */
  98222. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NONE;
  98223. /**
  98224. * Gets the list of instances created from this mesh
  98225. * it is not supposed to be modified manually.
  98226. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98227. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98228. */
  98229. _this.instances = new Array();
  98230. // Private
  98231. /** @hidden */
  98232. _this._creationDataStorage = null;
  98233. /** @hidden */
  98234. _this._geometry = null;
  98235. /** @hidden */
  98236. _this._instanceDataStorage = new _InstanceDataStorage();
  98237. _this._effectiveMaterial = null;
  98238. /** @hidden */
  98239. _this._shouldGenerateFlatShading = false;
  98240. // Use by builder only to know what orientation were the mesh build in.
  98241. /** @hidden */
  98242. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  98243. /**
  98244. * Use this property to change the original side orientation defined at construction time
  98245. */
  98246. _this.overrideMaterialSideOrientation = null;
  98247. scene = _this.getScene();
  98248. if (source) {
  98249. // Geometry
  98250. if (source._geometry) {
  98251. source._geometry.applyToMesh(_this);
  98252. }
  98253. // Deep copy
  98254. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  98255. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  98256. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  98257. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  98258. "onDisposeObservable", "lightSources"
  98259. ], ["_poseMatrix"]);
  98260. // Source mesh
  98261. _this._internalMeshDataInfo._source = source;
  98262. if (scene.useClonedMeshhMap) {
  98263. if (!source._internalMeshDataInfo.meshMap) {
  98264. source._internalMeshDataInfo.meshMap = {};
  98265. }
  98266. source._internalMeshDataInfo.meshMap[_this.uniqueId] = _this;
  98267. }
  98268. // Construction Params
  98269. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  98270. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  98271. _this._creationDataStorage = source._creationDataStorage;
  98272. // Animation ranges
  98273. if (source._ranges) {
  98274. var ranges = source._ranges;
  98275. for (var name in ranges) {
  98276. if (!ranges.hasOwnProperty(name)) {
  98277. continue;
  98278. }
  98279. if (!ranges[name]) {
  98280. continue;
  98281. }
  98282. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  98283. }
  98284. }
  98285. // Metadata
  98286. if (source.metadata && source.metadata.clone) {
  98287. _this.metadata = source.metadata.clone();
  98288. }
  98289. else {
  98290. _this.metadata = source.metadata;
  98291. }
  98292. // Tags
  98293. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  98294. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  98295. }
  98296. // Parent
  98297. _this.parent = source.parent;
  98298. // Pivot
  98299. _this.setPivotMatrix(source.getPivotMatrix());
  98300. _this.id = name + "." + source.id;
  98301. // Material
  98302. _this.material = source.material;
  98303. var index;
  98304. if (!doNotCloneChildren) {
  98305. // Children
  98306. var directDescendants = source.getDescendants(true);
  98307. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  98308. var child = directDescendants[index_1];
  98309. if (child.clone) {
  98310. child.clone(name + "." + child.name, _this);
  98311. }
  98312. }
  98313. }
  98314. // Physics clone
  98315. if (scene.getPhysicsEngine) {
  98316. var physicsEngine = scene.getPhysicsEngine();
  98317. if (clonePhysicsImpostor && physicsEngine) {
  98318. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  98319. if (impostor) {
  98320. _this.physicsImpostor = impostor.clone(_this);
  98321. }
  98322. }
  98323. }
  98324. // Particles
  98325. for (index = 0; index < scene.particleSystems.length; index++) {
  98326. var system = scene.particleSystems[index];
  98327. if (system.emitter === source) {
  98328. system.clone(system.name, _this);
  98329. }
  98330. }
  98331. _this.refreshBoundingInfo();
  98332. _this.computeWorldMatrix(true);
  98333. }
  98334. // Parent
  98335. if (parent !== null) {
  98336. _this.parent = parent;
  98337. }
  98338. _this._instanceDataStorage.hardwareInstancedRendering = _this.getEngine().getCaps().instancedArrays;
  98339. return _this;
  98340. }
  98341. /**
  98342. * Gets the default side orientation.
  98343. * @param orientation the orientation to value to attempt to get
  98344. * @returns the default orientation
  98345. * @hidden
  98346. */
  98347. Mesh._GetDefaultSideOrientation = function (orientation) {
  98348. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  98349. };
  98350. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  98351. /**
  98352. * An event triggered before rendering the mesh
  98353. */
  98354. get: function () {
  98355. if (!this._internalMeshDataInfo._onBeforeRenderObservable) {
  98356. this._internalMeshDataInfo._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  98357. }
  98358. return this._internalMeshDataInfo._onBeforeRenderObservable;
  98359. },
  98360. enumerable: true,
  98361. configurable: true
  98362. });
  98363. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  98364. /**
  98365. * An event triggered before binding the mesh
  98366. */
  98367. get: function () {
  98368. if (!this._internalMeshDataInfo._onBeforeBindObservable) {
  98369. this._internalMeshDataInfo._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  98370. }
  98371. return this._internalMeshDataInfo._onBeforeBindObservable;
  98372. },
  98373. enumerable: true,
  98374. configurable: true
  98375. });
  98376. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  98377. /**
  98378. * An event triggered after rendering the mesh
  98379. */
  98380. get: function () {
  98381. if (!this._internalMeshDataInfo._onAfterRenderObservable) {
  98382. this._internalMeshDataInfo._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  98383. }
  98384. return this._internalMeshDataInfo._onAfterRenderObservable;
  98385. },
  98386. enumerable: true,
  98387. configurable: true
  98388. });
  98389. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  98390. /**
  98391. * An event triggered before drawing the mesh
  98392. */
  98393. get: function () {
  98394. if (!this._internalMeshDataInfo._onBeforeDrawObservable) {
  98395. this._internalMeshDataInfo._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  98396. }
  98397. return this._internalMeshDataInfo._onBeforeDrawObservable;
  98398. },
  98399. enumerable: true,
  98400. configurable: true
  98401. });
  98402. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  98403. /**
  98404. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98405. */
  98406. set: function (callback) {
  98407. if (this._onBeforeDrawObserver) {
  98408. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  98409. }
  98410. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  98411. },
  98412. enumerable: true,
  98413. configurable: true
  98414. });
  98415. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  98416. /**
  98417. * Gets or sets the morph target manager
  98418. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98419. */
  98420. get: function () {
  98421. return this._internalMeshDataInfo._morphTargetManager;
  98422. },
  98423. set: function (value) {
  98424. if (this._internalMeshDataInfo._morphTargetManager === value) {
  98425. return;
  98426. }
  98427. this._internalMeshDataInfo._morphTargetManager = value;
  98428. this._syncGeometryWithMorphTargetManager();
  98429. },
  98430. enumerable: true,
  98431. configurable: true
  98432. });
  98433. Object.defineProperty(Mesh.prototype, "source", {
  98434. /**
  98435. * Gets the source mesh (the one used to clone this one from)
  98436. */
  98437. get: function () {
  98438. return this._internalMeshDataInfo._source;
  98439. },
  98440. enumerable: true,
  98441. configurable: true
  98442. });
  98443. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  98444. /**
  98445. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98446. */
  98447. get: function () {
  98448. return this._unIndexed;
  98449. },
  98450. set: function (value) {
  98451. if (this._unIndexed !== value) {
  98452. this._unIndexed = value;
  98453. this._markSubMeshesAsAttributesDirty();
  98454. }
  98455. },
  98456. enumerable: true,
  98457. configurable: true
  98458. });
  98459. // Methods
  98460. /**
  98461. * Gets the class name
  98462. * @returns the string "Mesh".
  98463. */
  98464. Mesh.prototype.getClassName = function () {
  98465. return "Mesh";
  98466. };
  98467. Object.defineProperty(Mesh.prototype, "_isMesh", {
  98468. /** @hidden */
  98469. get: function () {
  98470. return true;
  98471. },
  98472. enumerable: true,
  98473. configurable: true
  98474. });
  98475. /**
  98476. * Returns a description of this mesh
  98477. * @param fullDetails define if full details about this mesh must be used
  98478. * @returns a descriptive string representing this mesh
  98479. */
  98480. Mesh.prototype.toString = function (fullDetails) {
  98481. var ret = _super.prototype.toString.call(this, fullDetails);
  98482. ret += ", n vertices: " + this.getTotalVertices();
  98483. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  98484. if (this.animations) {
  98485. for (var i = 0; i < this.animations.length; i++) {
  98486. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  98487. }
  98488. }
  98489. if (fullDetails) {
  98490. if (this._geometry) {
  98491. var ib = this.getIndices();
  98492. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind);
  98493. if (vb && ib) {
  98494. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  98495. }
  98496. }
  98497. else {
  98498. ret += ", flat shading: UNKNOWN";
  98499. }
  98500. }
  98501. return ret;
  98502. };
  98503. /** @hidden */
  98504. Mesh.prototype._unBindEffect = function () {
  98505. _super.prototype._unBindEffect.call(this);
  98506. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  98507. var instance = _a[_i];
  98508. instance._unBindEffect();
  98509. }
  98510. };
  98511. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  98512. /**
  98513. * Gets a boolean indicating if this mesh has LOD
  98514. */
  98515. get: function () {
  98516. return this._internalMeshDataInfo._LODLevels.length > 0;
  98517. },
  98518. enumerable: true,
  98519. configurable: true
  98520. });
  98521. /**
  98522. * Gets the list of MeshLODLevel associated with the current mesh
  98523. * @returns an array of MeshLODLevel
  98524. */
  98525. Mesh.prototype.getLODLevels = function () {
  98526. return this._internalMeshDataInfo._LODLevels;
  98527. };
  98528. Mesh.prototype._sortLODLevels = function () {
  98529. this._internalMeshDataInfo._LODLevels.sort(function (a, b) {
  98530. if (a.distance < b.distance) {
  98531. return 1;
  98532. }
  98533. if (a.distance > b.distance) {
  98534. return -1;
  98535. }
  98536. return 0;
  98537. });
  98538. };
  98539. /**
  98540. * Add a mesh as LOD level triggered at the given distance.
  98541. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98542. * @param distance The distance from the center of the object to show this level
  98543. * @param mesh The mesh to be added as LOD level (can be null)
  98544. * @return This mesh (for chaining)
  98545. */
  98546. Mesh.prototype.addLODLevel = function (distance, mesh) {
  98547. if (mesh && mesh._masterMesh) {
  98548. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  98549. return this;
  98550. }
  98551. var level = new _meshLODLevel__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"](distance, mesh);
  98552. this._internalMeshDataInfo._LODLevels.push(level);
  98553. if (mesh) {
  98554. mesh._masterMesh = this;
  98555. }
  98556. this._sortLODLevels();
  98557. return this;
  98558. };
  98559. /**
  98560. * Returns the LOD level mesh at the passed distance or null if not found.
  98561. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98562. * @param distance The distance from the center of the object to show this level
  98563. * @returns a Mesh or `null`
  98564. */
  98565. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  98566. var internalDataInfo = this._internalMeshDataInfo;
  98567. for (var index = 0; index < internalDataInfo._LODLevels.length; index++) {
  98568. var level = internalDataInfo._LODLevels[index];
  98569. if (level.distance === distance) {
  98570. return level.mesh;
  98571. }
  98572. }
  98573. return null;
  98574. };
  98575. /**
  98576. * Remove a mesh from the LOD array
  98577. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98578. * @param mesh defines the mesh to be removed
  98579. * @return This mesh (for chaining)
  98580. */
  98581. Mesh.prototype.removeLODLevel = function (mesh) {
  98582. var internalDataInfo = this._internalMeshDataInfo;
  98583. for (var index = 0; index < internalDataInfo._LODLevels.length; index++) {
  98584. if (internalDataInfo._LODLevels[index].mesh === mesh) {
  98585. internalDataInfo._LODLevels.splice(index, 1);
  98586. if (mesh) {
  98587. mesh._masterMesh = null;
  98588. }
  98589. }
  98590. }
  98591. this._sortLODLevels();
  98592. return this;
  98593. };
  98594. /**
  98595. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98597. * @param camera defines the camera to use to compute distance
  98598. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98599. * @return This mesh (for chaining)
  98600. */
  98601. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  98602. var internalDataInfo = this._internalMeshDataInfo;
  98603. if (!internalDataInfo._LODLevels || internalDataInfo._LODLevels.length === 0) {
  98604. return this;
  98605. }
  98606. var bSphere;
  98607. if (boundingSphere) {
  98608. bSphere = boundingSphere;
  98609. }
  98610. else {
  98611. var boundingInfo = this.getBoundingInfo();
  98612. bSphere = boundingInfo.boundingSphere;
  98613. }
  98614. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  98615. if (internalDataInfo._LODLevels[internalDataInfo._LODLevels.length - 1].distance > distanceToCamera) {
  98616. if (this.onLODLevelSelection) {
  98617. this.onLODLevelSelection(distanceToCamera, this, internalDataInfo._LODLevels[internalDataInfo._LODLevels.length - 1].mesh);
  98618. }
  98619. return this;
  98620. }
  98621. for (var index = 0; index < internalDataInfo._LODLevels.length; index++) {
  98622. var level = internalDataInfo._LODLevels[index];
  98623. if (level.distance < distanceToCamera) {
  98624. if (level.mesh) {
  98625. level.mesh._preActivate();
  98626. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  98627. }
  98628. if (this.onLODLevelSelection) {
  98629. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  98630. }
  98631. return level.mesh;
  98632. }
  98633. }
  98634. if (this.onLODLevelSelection) {
  98635. this.onLODLevelSelection(distanceToCamera, this, this);
  98636. }
  98637. return this;
  98638. };
  98639. Object.defineProperty(Mesh.prototype, "geometry", {
  98640. /**
  98641. * Gets the mesh internal Geometry object
  98642. */
  98643. get: function () {
  98644. return this._geometry;
  98645. },
  98646. enumerable: true,
  98647. configurable: true
  98648. });
  98649. /**
  98650. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98651. * @returns the total number of vertices
  98652. */
  98653. Mesh.prototype.getTotalVertices = function () {
  98654. if (this._geometry === null || this._geometry === undefined) {
  98655. return 0;
  98656. }
  98657. return this._geometry.getTotalVertices();
  98658. };
  98659. /**
  98660. * Returns the content of an associated vertex buffer
  98661. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98662. * - VertexBuffer.PositionKind
  98663. * - VertexBuffer.UVKind
  98664. * - VertexBuffer.UV2Kind
  98665. * - VertexBuffer.UV3Kind
  98666. * - VertexBuffer.UV4Kind
  98667. * - VertexBuffer.UV5Kind
  98668. * - VertexBuffer.UV6Kind
  98669. * - VertexBuffer.ColorKind
  98670. * - VertexBuffer.MatricesIndicesKind
  98671. * - VertexBuffer.MatricesIndicesExtraKind
  98672. * - VertexBuffer.MatricesWeightsKind
  98673. * - VertexBuffer.MatricesWeightsExtraKind
  98674. * @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
  98675. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98676. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98677. */
  98678. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  98679. if (!this._geometry) {
  98680. return null;
  98681. }
  98682. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  98683. };
  98684. /**
  98685. * Returns the mesh VertexBuffer object from the requested `kind`
  98686. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98687. * - VertexBuffer.PositionKind
  98688. * - VertexBuffer.NormalKind
  98689. * - VertexBuffer.UVKind
  98690. * - VertexBuffer.UV2Kind
  98691. * - VertexBuffer.UV3Kind
  98692. * - VertexBuffer.UV4Kind
  98693. * - VertexBuffer.UV5Kind
  98694. * - VertexBuffer.UV6Kind
  98695. * - VertexBuffer.ColorKind
  98696. * - VertexBuffer.MatricesIndicesKind
  98697. * - VertexBuffer.MatricesIndicesExtraKind
  98698. * - VertexBuffer.MatricesWeightsKind
  98699. * - VertexBuffer.MatricesWeightsExtraKind
  98700. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  98701. */
  98702. Mesh.prototype.getVertexBuffer = function (kind) {
  98703. if (!this._geometry) {
  98704. return null;
  98705. }
  98706. return this._geometry.getVertexBuffer(kind);
  98707. };
  98708. /**
  98709. * Tests if a specific vertex buffer is associated with this mesh
  98710. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98711. * - VertexBuffer.PositionKind
  98712. * - VertexBuffer.NormalKind
  98713. * - VertexBuffer.UVKind
  98714. * - VertexBuffer.UV2Kind
  98715. * - VertexBuffer.UV3Kind
  98716. * - VertexBuffer.UV4Kind
  98717. * - VertexBuffer.UV5Kind
  98718. * - VertexBuffer.UV6Kind
  98719. * - VertexBuffer.ColorKind
  98720. * - VertexBuffer.MatricesIndicesKind
  98721. * - VertexBuffer.MatricesIndicesExtraKind
  98722. * - VertexBuffer.MatricesWeightsKind
  98723. * - VertexBuffer.MatricesWeightsExtraKind
  98724. * @returns a boolean
  98725. */
  98726. Mesh.prototype.isVerticesDataPresent = function (kind) {
  98727. if (!this._geometry) {
  98728. if (this._delayInfo) {
  98729. return this._delayInfo.indexOf(kind) !== -1;
  98730. }
  98731. return false;
  98732. }
  98733. return this._geometry.isVerticesDataPresent(kind);
  98734. };
  98735. /**
  98736. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98737. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98738. * - VertexBuffer.PositionKind
  98739. * - VertexBuffer.UVKind
  98740. * - VertexBuffer.UV2Kind
  98741. * - VertexBuffer.UV3Kind
  98742. * - VertexBuffer.UV4Kind
  98743. * - VertexBuffer.UV5Kind
  98744. * - VertexBuffer.UV6Kind
  98745. * - VertexBuffer.ColorKind
  98746. * - VertexBuffer.MatricesIndicesKind
  98747. * - VertexBuffer.MatricesIndicesExtraKind
  98748. * - VertexBuffer.MatricesWeightsKind
  98749. * - VertexBuffer.MatricesWeightsExtraKind
  98750. * @returns a boolean
  98751. */
  98752. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  98753. if (!this._geometry) {
  98754. if (this._delayInfo) {
  98755. return this._delayInfo.indexOf(kind) !== -1;
  98756. }
  98757. return false;
  98758. }
  98759. return this._geometry.isVertexBufferUpdatable(kind);
  98760. };
  98761. /**
  98762. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98764. * - VertexBuffer.PositionKind
  98765. * - VertexBuffer.NormalKind
  98766. * - VertexBuffer.UVKind
  98767. * - VertexBuffer.UV2Kind
  98768. * - VertexBuffer.UV3Kind
  98769. * - VertexBuffer.UV4Kind
  98770. * - VertexBuffer.UV5Kind
  98771. * - VertexBuffer.UV6Kind
  98772. * - VertexBuffer.ColorKind
  98773. * - VertexBuffer.MatricesIndicesKind
  98774. * - VertexBuffer.MatricesIndicesExtraKind
  98775. * - VertexBuffer.MatricesWeightsKind
  98776. * - VertexBuffer.MatricesWeightsExtraKind
  98777. * @returns an array of strings
  98778. */
  98779. Mesh.prototype.getVerticesDataKinds = function () {
  98780. if (!this._geometry) {
  98781. var result = new Array();
  98782. if (this._delayInfo) {
  98783. this._delayInfo.forEach(function (kind) {
  98784. result.push(kind);
  98785. });
  98786. }
  98787. return result;
  98788. }
  98789. return this._geometry.getVerticesDataKinds();
  98790. };
  98791. /**
  98792. * Returns a positive integer : the total number of indices in this mesh geometry.
  98793. * @returns the numner of indices or zero if the mesh has no geometry.
  98794. */
  98795. Mesh.prototype.getTotalIndices = function () {
  98796. if (!this._geometry) {
  98797. return 0;
  98798. }
  98799. return this._geometry.getTotalIndices();
  98800. };
  98801. /**
  98802. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98803. * @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.
  98804. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98805. * @returns the indices array or an empty array if the mesh has no geometry
  98806. */
  98807. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  98808. if (!this._geometry) {
  98809. return [];
  98810. }
  98811. return this._geometry.getIndices(copyWhenShared, forceCopy);
  98812. };
  98813. Object.defineProperty(Mesh.prototype, "isBlocked", {
  98814. get: function () {
  98815. return this._masterMesh !== null && this._masterMesh !== undefined;
  98816. },
  98817. enumerable: true,
  98818. configurable: true
  98819. });
  98820. /**
  98821. * Determine if the current mesh is ready to be rendered
  98822. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98823. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98824. * @returns true if all associated assets are ready (material, textures, shaders)
  98825. */
  98826. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  98827. if (completeCheck === void 0) { completeCheck = false; }
  98828. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  98829. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  98830. return false;
  98831. }
  98832. if (!_super.prototype.isReady.call(this, completeCheck)) {
  98833. return false;
  98834. }
  98835. if (!this.subMeshes || this.subMeshes.length === 0) {
  98836. return true;
  98837. }
  98838. if (!completeCheck) {
  98839. return true;
  98840. }
  98841. var engine = this.getEngine();
  98842. var scene = this.getScene();
  98843. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  98844. this.computeWorldMatrix();
  98845. var mat = this.material || scene.defaultMaterial;
  98846. if (mat) {
  98847. if (mat._storeEffectOnSubMeshes) {
  98848. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  98849. var subMesh = _a[_i];
  98850. var effectiveMaterial = subMesh.getMaterial();
  98851. if (effectiveMaterial) {
  98852. if (effectiveMaterial._storeEffectOnSubMeshes) {
  98853. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  98854. return false;
  98855. }
  98856. }
  98857. else {
  98858. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  98859. return false;
  98860. }
  98861. }
  98862. }
  98863. }
  98864. }
  98865. else {
  98866. if (!mat.isReady(this, hardwareInstancedRendering)) {
  98867. return false;
  98868. }
  98869. }
  98870. }
  98871. // Shadows
  98872. for (var _b = 0, _c = this.lightSources; _b < _c.length; _b++) {
  98873. var light = _c[_b];
  98874. var generator = light.getShadowGenerator();
  98875. if (generator) {
  98876. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  98877. var subMesh = _e[_d];
  98878. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  98879. return false;
  98880. }
  98881. }
  98882. }
  98883. }
  98884. // LOD
  98885. for (var _f = 0, _g = this._internalMeshDataInfo._LODLevels; _f < _g.length; _f++) {
  98886. var lod = _g[_f];
  98887. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  98888. return false;
  98889. }
  98890. }
  98891. return true;
  98892. };
  98893. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  98894. /**
  98895. * 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.
  98896. */
  98897. get: function () {
  98898. return this._internalMeshDataInfo._areNormalsFrozen;
  98899. },
  98900. enumerable: true,
  98901. configurable: true
  98902. });
  98903. /**
  98904. * 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.
  98905. * @returns the current mesh
  98906. */
  98907. Mesh.prototype.freezeNormals = function () {
  98908. this._internalMeshDataInfo._areNormalsFrozen = true;
  98909. return this;
  98910. };
  98911. /**
  98912. * 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
  98913. * @returns the current mesh
  98914. */
  98915. Mesh.prototype.unfreezeNormals = function () {
  98916. this._internalMeshDataInfo._areNormalsFrozen = false;
  98917. return this;
  98918. };
  98919. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  98920. /**
  98921. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98922. */
  98923. set: function (count) {
  98924. this._instanceDataStorage.overridenInstanceCount = count;
  98925. },
  98926. enumerable: true,
  98927. configurable: true
  98928. });
  98929. // Methods
  98930. /** @hidden */
  98931. Mesh.prototype._preActivate = function () {
  98932. var internalDataInfo = this._internalMeshDataInfo;
  98933. var sceneRenderId = this.getScene().getRenderId();
  98934. if (internalDataInfo._preActivateId === sceneRenderId) {
  98935. return this;
  98936. }
  98937. internalDataInfo._preActivateId = sceneRenderId;
  98938. this._instanceDataStorage.visibleInstances = null;
  98939. return this;
  98940. };
  98941. /** @hidden */
  98942. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  98943. if (this._instanceDataStorage.visibleInstances) {
  98944. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  98945. }
  98946. return this;
  98947. };
  98948. /** @hidden */
  98949. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  98950. if (!this._instanceDataStorage.visibleInstances) {
  98951. this._instanceDataStorage.visibleInstances = {
  98952. defaultRenderId: renderId,
  98953. selfDefaultRenderId: this._renderId
  98954. };
  98955. }
  98956. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  98957. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  98958. }
  98959. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  98960. return this;
  98961. };
  98962. /**
  98963. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98964. * This means the mesh underlying bounding box and sphere are recomputed.
  98965. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98966. * @returns the current mesh
  98967. */
  98968. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  98969. if (applySkeleton === void 0) { applySkeleton = false; }
  98970. if (this._boundingInfo && this._boundingInfo.isLocked) {
  98971. return this;
  98972. }
  98973. var bias = this.geometry ? this.geometry.boundingBias : null;
  98974. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  98975. return this;
  98976. };
  98977. /** @hidden */
  98978. Mesh.prototype._createGlobalSubMesh = function (force) {
  98979. var totalVertices = this.getTotalVertices();
  98980. if (!totalVertices || !this.getIndices()) {
  98981. return null;
  98982. }
  98983. // Check if we need to recreate the submeshes
  98984. if (this.subMeshes && this.subMeshes.length > 0) {
  98985. var ib = this.getIndices();
  98986. if (!ib) {
  98987. return null;
  98988. }
  98989. var totalIndices = ib.length;
  98990. var needToRecreate = false;
  98991. if (force) {
  98992. needToRecreate = true;
  98993. }
  98994. else {
  98995. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  98996. var submesh = _a[_i];
  98997. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  98998. needToRecreate = true;
  98999. break;
  99000. }
  99001. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  99002. needToRecreate = true;
  99003. break;
  99004. }
  99005. }
  99006. }
  99007. if (!needToRecreate) {
  99008. return this.subMeshes[0];
  99009. }
  99010. }
  99011. this.releaseSubMeshes();
  99012. return new _subMesh__WEBPACK_IMPORTED_MODULE_12__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  99013. };
  99014. /**
  99015. * This function will subdivide the mesh into multiple submeshes
  99016. * @param count defines the expected number of submeshes
  99017. */
  99018. Mesh.prototype.subdivide = function (count) {
  99019. if (count < 1) {
  99020. return;
  99021. }
  99022. var totalIndices = this.getTotalIndices();
  99023. var subdivisionSize = (totalIndices / count) | 0;
  99024. var offset = 0;
  99025. // Ensure that subdivisionSize is a multiple of 3
  99026. while (subdivisionSize % 3 !== 0) {
  99027. subdivisionSize++;
  99028. }
  99029. this.releaseSubMeshes();
  99030. for (var index = 0; index < count; index++) {
  99031. if (offset >= totalIndices) {
  99032. break;
  99033. }
  99034. _subMesh__WEBPACK_IMPORTED_MODULE_12__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  99035. offset += subdivisionSize;
  99036. }
  99037. this.synchronizeInstances();
  99038. };
  99039. /**
  99040. * Copy a FloatArray into a specific associated vertex buffer
  99041. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99042. * - VertexBuffer.PositionKind
  99043. * - VertexBuffer.UVKind
  99044. * - VertexBuffer.UV2Kind
  99045. * - VertexBuffer.UV3Kind
  99046. * - VertexBuffer.UV4Kind
  99047. * - VertexBuffer.UV5Kind
  99048. * - VertexBuffer.UV6Kind
  99049. * - VertexBuffer.ColorKind
  99050. * - VertexBuffer.MatricesIndicesKind
  99051. * - VertexBuffer.MatricesIndicesExtraKind
  99052. * - VertexBuffer.MatricesWeightsKind
  99053. * - VertexBuffer.MatricesWeightsExtraKind
  99054. * @param data defines the data source
  99055. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99056. * @param stride defines the data stride size (can be null)
  99057. * @returns the current mesh
  99058. */
  99059. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  99060. if (updatable === void 0) { updatable = false; }
  99061. if (!this._geometry) {
  99062. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]();
  99063. vertexData.set(data, kind);
  99064. var scene = this.getScene();
  99065. new _geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  99066. }
  99067. else {
  99068. this._geometry.setVerticesData(kind, data, updatable, stride);
  99069. }
  99070. return this;
  99071. };
  99072. /**
  99073. * Flags an associated vertex buffer as updatable
  99074. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99075. * - VertexBuffer.PositionKind
  99076. * - VertexBuffer.UVKind
  99077. * - VertexBuffer.UV2Kind
  99078. * - VertexBuffer.UV3Kind
  99079. * - VertexBuffer.UV4Kind
  99080. * - VertexBuffer.UV5Kind
  99081. * - VertexBuffer.UV6Kind
  99082. * - VertexBuffer.ColorKind
  99083. * - VertexBuffer.MatricesIndicesKind
  99084. * - VertexBuffer.MatricesIndicesExtraKind
  99085. * - VertexBuffer.MatricesWeightsKind
  99086. * - VertexBuffer.MatricesWeightsExtraKind
  99087. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99088. */
  99089. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  99090. if (updatable === void 0) { updatable = true; }
  99091. var vb = this.getVertexBuffer(kind);
  99092. if (!vb || vb.isUpdatable() === updatable) {
  99093. return;
  99094. }
  99095. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  99096. };
  99097. /**
  99098. * Sets the mesh global Vertex Buffer
  99099. * @param buffer defines the buffer to use
  99100. * @returns the current mesh
  99101. */
  99102. Mesh.prototype.setVerticesBuffer = function (buffer) {
  99103. if (!this._geometry) {
  99104. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"].CreateGeometryForMesh(this);
  99105. }
  99106. this._geometry.setVerticesBuffer(buffer);
  99107. return this;
  99108. };
  99109. /**
  99110. * Update a specific associated vertex buffer
  99111. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99112. * - VertexBuffer.PositionKind
  99113. * - VertexBuffer.UVKind
  99114. * - VertexBuffer.UV2Kind
  99115. * - VertexBuffer.UV3Kind
  99116. * - VertexBuffer.UV4Kind
  99117. * - VertexBuffer.UV5Kind
  99118. * - VertexBuffer.UV6Kind
  99119. * - VertexBuffer.ColorKind
  99120. * - VertexBuffer.MatricesIndicesKind
  99121. * - VertexBuffer.MatricesIndicesExtraKind
  99122. * - VertexBuffer.MatricesWeightsKind
  99123. * - VertexBuffer.MatricesWeightsExtraKind
  99124. * @param data defines the data source
  99125. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99126. * @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)
  99127. * @returns the current mesh
  99128. */
  99129. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  99130. if (!this._geometry) {
  99131. return this;
  99132. }
  99133. if (!makeItUnique) {
  99134. this._geometry.updateVerticesData(kind, data, updateExtends);
  99135. }
  99136. else {
  99137. this.makeGeometryUnique();
  99138. this.updateVerticesData(kind, data, updateExtends, false);
  99139. }
  99140. return this;
  99141. };
  99142. /**
  99143. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99144. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99145. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99146. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99147. * @returns the current mesh
  99148. */
  99149. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  99150. if (computeNormals === void 0) { computeNormals = true; }
  99151. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind);
  99152. if (!positions) {
  99153. return this;
  99154. }
  99155. positionFunction(positions);
  99156. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, positions, false, false);
  99157. if (computeNormals) {
  99158. var indices = this.getIndices();
  99159. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind);
  99160. if (!normals) {
  99161. return this;
  99162. }
  99163. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ComputeNormals(positions, indices, normals);
  99164. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, normals, false, false);
  99165. }
  99166. return this;
  99167. };
  99168. /**
  99169. * Creates a un-shared specific occurence of the geometry for the mesh.
  99170. * @returns the current mesh
  99171. */
  99172. Mesh.prototype.makeGeometryUnique = function () {
  99173. if (!this._geometry) {
  99174. return this;
  99175. }
  99176. var oldGeometry = this._geometry;
  99177. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"].RandomId());
  99178. oldGeometry.releaseForMesh(this, true);
  99179. geometry.applyToMesh(this);
  99180. return this;
  99181. };
  99182. /**
  99183. * Set the index buffer of this mesh
  99184. * @param indices defines the source data
  99185. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99186. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99187. * @returns the current mesh
  99188. */
  99189. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  99190. if (totalVertices === void 0) { totalVertices = null; }
  99191. if (updatable === void 0) { updatable = false; }
  99192. if (!this._geometry) {
  99193. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]();
  99194. vertexData.indices = indices;
  99195. var scene = this.getScene();
  99196. new _geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  99197. }
  99198. else {
  99199. this._geometry.setIndices(indices, totalVertices, updatable);
  99200. }
  99201. return this;
  99202. };
  99203. /**
  99204. * Update the current index buffer
  99205. * @param indices defines the source data
  99206. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99207. * @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)
  99208. * @returns the current mesh
  99209. */
  99210. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  99211. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  99212. if (!this._geometry) {
  99213. return this;
  99214. }
  99215. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  99216. return this;
  99217. };
  99218. /**
  99219. * Invert the geometry to move from a right handed system to a left handed one.
  99220. * @returns the current mesh
  99221. */
  99222. Mesh.prototype.toLeftHanded = function () {
  99223. if (!this._geometry) {
  99224. return this;
  99225. }
  99226. this._geometry.toLeftHanded();
  99227. return this;
  99228. };
  99229. /** @hidden */
  99230. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  99231. if (!this._geometry) {
  99232. return this;
  99233. }
  99234. var engine = this.getScene().getEngine();
  99235. // Wireframe
  99236. var indexToBind;
  99237. if (this._unIndexed) {
  99238. indexToBind = null;
  99239. }
  99240. else {
  99241. switch (fillMode) {
  99242. case _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].PointFillMode:
  99243. indexToBind = null;
  99244. break;
  99245. case _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].WireFrameFillMode:
  99246. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  99247. break;
  99248. default:
  99249. case _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].TriangleFillMode:
  99250. indexToBind = this._geometry.getIndexBuffer();
  99251. break;
  99252. }
  99253. }
  99254. // VBOs
  99255. this._geometry._bind(effect, indexToBind);
  99256. return this;
  99257. };
  99258. /** @hidden */
  99259. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  99260. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  99261. return this;
  99262. }
  99263. if (this._internalMeshDataInfo._onBeforeDrawObservable) {
  99264. this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
  99265. }
  99266. var scene = this.getScene();
  99267. var engine = scene.getEngine();
  99268. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].PointFillMode) {
  99269. // or triangles as points
  99270. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  99271. }
  99272. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].WireFrameFillMode) {
  99273. // Triangles as wireframe
  99274. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  99275. }
  99276. else {
  99277. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  99278. }
  99279. return this;
  99280. };
  99281. /**
  99282. * Registers for this mesh a javascript function called just before the rendering process
  99283. * @param func defines the function to call before rendering this mesh
  99284. * @returns the current mesh
  99285. */
  99286. Mesh.prototype.registerBeforeRender = function (func) {
  99287. this.onBeforeRenderObservable.add(func);
  99288. return this;
  99289. };
  99290. /**
  99291. * Disposes a previously registered javascript function called before the rendering
  99292. * @param func defines the function to remove
  99293. * @returns the current mesh
  99294. */
  99295. Mesh.prototype.unregisterBeforeRender = function (func) {
  99296. this.onBeforeRenderObservable.removeCallback(func);
  99297. return this;
  99298. };
  99299. /**
  99300. * Registers for this mesh a javascript function called just after the rendering is complete
  99301. * @param func defines the function to call after rendering this mesh
  99302. * @returns the current mesh
  99303. */
  99304. Mesh.prototype.registerAfterRender = function (func) {
  99305. this.onAfterRenderObservable.add(func);
  99306. return this;
  99307. };
  99308. /**
  99309. * Disposes a previously registered javascript function called after the rendering.
  99310. * @param func defines the function to remove
  99311. * @returns the current mesh
  99312. */
  99313. Mesh.prototype.unregisterAfterRender = function (func) {
  99314. this.onAfterRenderObservable.removeCallback(func);
  99315. return this;
  99316. };
  99317. /** @hidden */
  99318. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  99319. if (this._instanceDataStorage.isFrozen && this._instanceDataStorage.previousBatch) {
  99320. return this._instanceDataStorage.previousBatch;
  99321. }
  99322. var scene = this.getScene();
  99323. var isInIntermediateRendering = scene._isInIntermediateRendering();
  99324. var onlyForInstances = isInIntermediateRendering ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances;
  99325. var batchCache = this._instanceDataStorage.batchCache;
  99326. batchCache.mustReturn = false;
  99327. batchCache.renderSelf[subMeshId] = !onlyForInstances && this.isEnabled() && this.isVisible;
  99328. batchCache.visibleInstances[subMeshId] = null;
  99329. if (this._instanceDataStorage.visibleInstances) {
  99330. var visibleInstances = this._instanceDataStorage.visibleInstances;
  99331. var currentRenderId = scene.getRenderId();
  99332. var defaultRenderId = (isInIntermediateRendering ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  99333. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  99334. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  99335. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  99336. }
  99337. }
  99338. batchCache.hardwareInstancedRendering[subMeshId] = this._instanceDataStorage.hardwareInstancedRendering && (batchCache.visibleInstances[subMeshId] !== null) && (batchCache.visibleInstances[subMeshId] !== undefined);
  99339. this._instanceDataStorage.previousBatch = batchCache;
  99340. return batchCache;
  99341. };
  99342. /** @hidden */
  99343. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  99344. var visibleInstances = batch.visibleInstances[subMesh._id];
  99345. if (!visibleInstances) {
  99346. return this;
  99347. }
  99348. var instanceStorage = this._instanceDataStorage;
  99349. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  99350. var instancesBuffer = instanceStorage.instancesBuffer;
  99351. var matricesCount = visibleInstances.length + 1;
  99352. var bufferSize = matricesCount * 16 * 4;
  99353. while (instanceStorage.instancesBufferSize < bufferSize) {
  99354. instanceStorage.instancesBufferSize *= 2;
  99355. }
  99356. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  99357. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  99358. }
  99359. var offset = 0;
  99360. var instancesCount = 0;
  99361. var world = this._effectiveMesh.getWorldMatrix();
  99362. if (batch.renderSelf[subMesh._id]) {
  99363. world.copyToArray(instanceStorage.instancesData, offset);
  99364. offset += 16;
  99365. instancesCount++;
  99366. }
  99367. if (visibleInstances) {
  99368. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  99369. var instance = visibleInstances[instanceIndex];
  99370. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  99371. offset += 16;
  99372. instancesCount++;
  99373. }
  99374. }
  99375. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  99376. if (instancesBuffer) {
  99377. instancesBuffer.dispose();
  99378. }
  99379. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_8__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  99380. instanceStorage.instancesBuffer = instancesBuffer;
  99381. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  99382. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  99383. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  99384. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  99385. }
  99386. else {
  99387. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  99388. }
  99389. this._bind(subMesh, effect, fillMode);
  99390. this._draw(subMesh, fillMode, instancesCount);
  99391. engine.unbindInstanceAttributes();
  99392. return this;
  99393. };
  99394. /** @hidden */
  99395. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  99396. var scene = this.getScene();
  99397. var engine = scene.getEngine();
  99398. if (hardwareInstancedRendering) {
  99399. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  99400. }
  99401. else {
  99402. if (batch.renderSelf[subMesh._id]) {
  99403. // Draw
  99404. if (onBeforeDraw) {
  99405. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  99406. }
  99407. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  99408. }
  99409. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  99410. if (visibleInstancesForSubMesh) {
  99411. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  99412. var instance = visibleInstancesForSubMesh[instanceIndex];
  99413. // World
  99414. var world = instance.getWorldMatrix();
  99415. if (onBeforeDraw) {
  99416. onBeforeDraw(true, world, effectiveMaterial);
  99417. }
  99418. // Draw
  99419. this._draw(subMesh, fillMode);
  99420. }
  99421. }
  99422. }
  99423. return this;
  99424. };
  99425. /** @hidden */
  99426. Mesh.prototype._rebuild = function () {
  99427. if (this._instanceDataStorage.instancesBuffer) {
  99428. // Dispose instance buffer to be recreated in _renderWithInstances when rendered
  99429. this._instanceDataStorage.instancesBuffer.dispose();
  99430. this._instanceDataStorage.instancesBuffer = null;
  99431. }
  99432. _super.prototype._rebuild.call(this);
  99433. };
  99434. /** @hidden */
  99435. Mesh.prototype._freeze = function () {
  99436. if (!this.subMeshes) {
  99437. return;
  99438. }
  99439. // Prepare batches
  99440. for (var index = 0; index < this.subMeshes.length; index++) {
  99441. this._getInstancesRenderList(index);
  99442. }
  99443. this._effectiveMaterial = null;
  99444. this._instanceDataStorage.isFrozen = true;
  99445. };
  99446. /** @hidden */
  99447. Mesh.prototype._unFreeze = function () {
  99448. this._instanceDataStorage.isFrozen = false;
  99449. this._instanceDataStorage.previousBatch = null;
  99450. };
  99451. /**
  99452. * 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
  99453. * @param subMesh defines the subMesh to render
  99454. * @param enableAlphaMode defines if alpha mode can be changed
  99455. * @returns the current mesh
  99456. */
  99457. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  99458. var scene = this.getScene();
  99459. if (scene._isInIntermediateRendering()) {
  99460. this._internalAbstractMeshDataInfo._isActiveIntermediate = false;
  99461. }
  99462. else {
  99463. this._internalAbstractMeshDataInfo._isActive = false;
  99464. }
  99465. if (this._checkOcclusionQuery()) {
  99466. return this;
  99467. }
  99468. // Managing instances
  99469. var batch = this._getInstancesRenderList(subMesh._id);
  99470. if (batch.mustReturn) {
  99471. return this;
  99472. }
  99473. // Checking geometry state
  99474. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  99475. return this;
  99476. }
  99477. if (this._internalMeshDataInfo._onBeforeRenderObservable) {
  99478. this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
  99479. }
  99480. var engine = scene.getEngine();
  99481. var hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id];
  99482. var instanceDataStorage = this._instanceDataStorage;
  99483. var material = subMesh.getMaterial();
  99484. if (!material) {
  99485. return this;
  99486. }
  99487. // Material
  99488. if (!instanceDataStorage.isFrozen || !this._effectiveMaterial || this._effectiveMaterial !== material) {
  99489. this._effectiveMaterial = material;
  99490. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  99491. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  99492. return this;
  99493. }
  99494. }
  99495. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  99496. return this;
  99497. }
  99498. }
  99499. // Alpha mode
  99500. if (enableAlphaMode) {
  99501. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  99502. }
  99503. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  99504. var step = _a[_i];
  99505. step.action(this, subMesh, batch);
  99506. }
  99507. var effect;
  99508. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  99509. effect = subMesh.effect;
  99510. }
  99511. else {
  99512. effect = this._effectiveMaterial.getEffect();
  99513. }
  99514. if (!effect) {
  99515. return this;
  99516. }
  99517. var effectiveMesh = this._effectiveMesh;
  99518. var sideOrientation;
  99519. if (!instanceDataStorage.isFrozen) {
  99520. sideOrientation = this.overrideMaterialSideOrientation;
  99521. if (sideOrientation == null) {
  99522. sideOrientation = this._effectiveMaterial.sideOrientation;
  99523. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  99524. sideOrientation = (sideOrientation === _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].ClockWiseSideOrientation ? _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].CounterClockWiseSideOrientation : _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].ClockWiseSideOrientation);
  99525. }
  99526. }
  99527. instanceDataStorage.sideOrientation = sideOrientation;
  99528. }
  99529. else {
  99530. sideOrientation = instanceDataStorage.sideOrientation;
  99531. }
  99532. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  99533. if (this._effectiveMaterial.forceDepthWrite) {
  99534. engine.setDepthWrite(true);
  99535. }
  99536. // Bind
  99537. var fillMode = scene.forcePointsCloud ? _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].PointFillMode : (scene.forceWireframe ? _Materials_material__WEBPACK_IMPORTED_MODULE_14__["Material"].WireFrameFillMode : this._effectiveMaterial.fillMode);
  99538. if (this._internalMeshDataInfo._onBeforeBindObservable) {
  99539. this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this);
  99540. }
  99541. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  99542. this._bind(subMesh, effect, fillMode);
  99543. }
  99544. var world = effectiveMesh.getWorldMatrix();
  99545. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  99546. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  99547. }
  99548. else {
  99549. this._effectiveMaterial.bind(world, this);
  99550. }
  99551. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  99552. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  99553. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  99554. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  99555. }
  99556. // Draw
  99557. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  99558. // Unbind
  99559. this._effectiveMaterial.unbind();
  99560. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  99561. var step = _c[_b];
  99562. step.action(this, subMesh, batch);
  99563. }
  99564. if (this._internalMeshDataInfo._onAfterRenderObservable) {
  99565. this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this);
  99566. }
  99567. return this;
  99568. };
  99569. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  99570. if (isInstance && effectiveMaterial) {
  99571. effectiveMaterial.bindOnlyWorldMatrix(world);
  99572. }
  99573. };
  99574. /**
  99575. * Renormalize the mesh and patch it up if there are no weights
  99576. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99577. * However in the case of zero weights then we set just a single influence to 1.
  99578. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99579. */
  99580. Mesh.prototype.cleanMatrixWeights = function () {
  99581. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind)) {
  99582. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsExtraKind)) {
  99583. this.normalizeSkinWeightsAndExtra();
  99584. }
  99585. else {
  99586. this.normalizeSkinFourWeights();
  99587. }
  99588. }
  99589. };
  99590. // faster 4 weight version.
  99591. Mesh.prototype.normalizeSkinFourWeights = function () {
  99592. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind);
  99593. var numWeights = matricesWeights.length;
  99594. for (var a = 0; a < numWeights; a += 4) {
  99595. // accumulate weights
  99596. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  99597. // check for invalid weight and just set it to 1.
  99598. if (t === 0) {
  99599. matricesWeights[a] = 1;
  99600. }
  99601. else {
  99602. // renormalize so everything adds to 1 use reciprical
  99603. var recip = 1 / t;
  99604. matricesWeights[a] *= recip;
  99605. matricesWeights[a + 1] *= recip;
  99606. matricesWeights[a + 2] *= recip;
  99607. matricesWeights[a + 3] *= recip;
  99608. }
  99609. }
  99610. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  99611. };
  99612. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  99613. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  99614. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsExtraKind);
  99615. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind);
  99616. var numWeights = matricesWeights.length;
  99617. for (var a = 0; a < numWeights; a += 4) {
  99618. // accumulate weights
  99619. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  99620. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  99621. // check for invalid weight and just set it to 1.
  99622. if (t === 0) {
  99623. matricesWeights[a] = 1;
  99624. }
  99625. else {
  99626. // renormalize so everything adds to 1 use reciprical
  99627. var recip = 1 / t;
  99628. matricesWeights[a] *= recip;
  99629. matricesWeights[a + 1] *= recip;
  99630. matricesWeights[a + 2] *= recip;
  99631. matricesWeights[a + 3] *= recip;
  99632. // same goes for extras
  99633. matricesWeightsExtra[a] *= recip;
  99634. matricesWeightsExtra[a + 1] *= recip;
  99635. matricesWeightsExtra[a + 2] *= recip;
  99636. matricesWeightsExtra[a + 3] *= recip;
  99637. }
  99638. }
  99639. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  99640. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  99641. };
  99642. /**
  99643. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99644. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99645. * the user know there was an issue with importing the mesh
  99646. * @returns a validation object with skinned, valid and report string
  99647. */
  99648. Mesh.prototype.validateSkinning = function () {
  99649. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsExtraKind);
  99650. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind);
  99651. if (matricesWeights === null || this.skeleton == null) {
  99652. return { skinned: false, valid: true, report: "not skinned" };
  99653. }
  99654. var numWeights = matricesWeights.length;
  99655. var numberNotSorted = 0;
  99656. var missingWeights = 0;
  99657. var maxUsedWeights = 0;
  99658. var numberNotNormalized = 0;
  99659. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  99660. var usedWeightCounts = new Array();
  99661. for (var a = 0; a <= numInfluences; a++) {
  99662. usedWeightCounts[a] = 0;
  99663. }
  99664. var toleranceEpsilon = 0.001;
  99665. for (var a = 0; a < numWeights; a += 4) {
  99666. var lastWeight = matricesWeights[a];
  99667. var t = lastWeight;
  99668. var usedWeights = t === 0 ? 0 : 1;
  99669. for (var b = 1; b < numInfluences; b++) {
  99670. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  99671. if (d > lastWeight) {
  99672. numberNotSorted++;
  99673. }
  99674. if (d !== 0) {
  99675. usedWeights++;
  99676. }
  99677. t += d;
  99678. lastWeight = d;
  99679. }
  99680. // count the buffer weights usage
  99681. usedWeightCounts[usedWeights]++;
  99682. // max influences
  99683. if (usedWeights > maxUsedWeights) {
  99684. maxUsedWeights = usedWeights;
  99685. }
  99686. // check for invalid weight and just set it to 1.
  99687. if (t === 0) {
  99688. missingWeights++;
  99689. }
  99690. else {
  99691. // renormalize so everything adds to 1 use reciprical
  99692. var recip = 1 / t;
  99693. var tolerance = 0;
  99694. for (b = 0; b < numInfluences; b++) {
  99695. if (b < 4) {
  99696. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  99697. }
  99698. else {
  99699. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  99700. }
  99701. }
  99702. // arbitary epsilon value for dicdating not normalized
  99703. if (tolerance > toleranceEpsilon) {
  99704. numberNotNormalized++;
  99705. }
  99706. }
  99707. }
  99708. // validate bone indices are in range of the skeleton
  99709. var numBones = this.skeleton.bones.length;
  99710. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesIndicesKind);
  99711. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesIndicesExtraKind);
  99712. var numBadBoneIndices = 0;
  99713. for (var a = 0; a < numWeights; a++) {
  99714. for (var b = 0; b < numInfluences; b++) {
  99715. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  99716. if (index >= numBones || index < 0) {
  99717. numBadBoneIndices++;
  99718. }
  99719. }
  99720. }
  99721. // log mesh stats
  99722. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  99723. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  99724. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  99725. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  99726. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  99727. };
  99728. /** @hidden */
  99729. Mesh.prototype._checkDelayState = function () {
  99730. var scene = this.getScene();
  99731. if (this._geometry) {
  99732. this._geometry.load(scene);
  99733. }
  99734. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  99735. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING;
  99736. this._queueLoad(scene);
  99737. }
  99738. return this;
  99739. };
  99740. Mesh.prototype._queueLoad = function (scene) {
  99741. var _this = this;
  99742. scene._addPendingData(this);
  99743. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  99744. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  99745. if (data instanceof ArrayBuffer) {
  99746. _this._delayLoadingFunction(data, _this);
  99747. }
  99748. else {
  99749. _this._delayLoadingFunction(JSON.parse(data), _this);
  99750. }
  99751. _this.instances.forEach(function (instance) {
  99752. instance.refreshBoundingInfo();
  99753. instance._syncSubMeshes();
  99754. });
  99755. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADED;
  99756. scene._removePendingData(_this);
  99757. }, function () { }, scene.offlineProvider, getBinaryData);
  99758. return this;
  99759. };
  99760. /**
  99761. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99762. * A mesh is in the frustum if its bounding box intersects the frustum
  99763. * @param frustumPlanes defines the frustum to test
  99764. * @returns true if the mesh is in the frustum planes
  99765. */
  99766. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  99767. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  99768. return false;
  99769. }
  99770. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  99771. return false;
  99772. }
  99773. this._checkDelayState();
  99774. return true;
  99775. };
  99776. /**
  99777. * Sets the mesh material by the material or multiMaterial `id` property
  99778. * @param id is a string identifying the material or the multiMaterial
  99779. * @returns the current mesh
  99780. */
  99781. Mesh.prototype.setMaterialByID = function (id) {
  99782. var materials = this.getScene().materials;
  99783. var index;
  99784. for (index = materials.length - 1; index > -1; index--) {
  99785. if (materials[index].id === id) {
  99786. this.material = materials[index];
  99787. return this;
  99788. }
  99789. }
  99790. // Multi
  99791. var multiMaterials = this.getScene().multiMaterials;
  99792. for (index = multiMaterials.length - 1; index > -1; index--) {
  99793. if (multiMaterials[index].id === id) {
  99794. this.material = multiMaterials[index];
  99795. return this;
  99796. }
  99797. }
  99798. return this;
  99799. };
  99800. /**
  99801. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99802. * @returns an array of IAnimatable
  99803. */
  99804. Mesh.prototype.getAnimatables = function () {
  99805. var results = new Array();
  99806. if (this.material) {
  99807. results.push(this.material);
  99808. }
  99809. if (this.skeleton) {
  99810. results.push(this.skeleton);
  99811. }
  99812. return results;
  99813. };
  99814. /**
  99815. * Modifies the mesh geometry according to the passed transformation matrix.
  99816. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99817. * The mesh normals are modified using the same transformation.
  99818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99819. * @param transform defines the transform matrix to use
  99820. * @see http://doc.babylonjs.com/resources/baking_transformations
  99821. * @returns the current mesh
  99822. */
  99823. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  99824. // Position
  99825. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind)) {
  99826. return this;
  99827. }
  99828. var submeshes = this.subMeshes.splice(0);
  99829. this._resetPointsArrayCache();
  99830. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind);
  99831. var temp = new Array();
  99832. var index;
  99833. for (index = 0; index < data.length; index += 3) {
  99834. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  99835. }
  99836. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind).isUpdatable());
  99837. // Normals
  99838. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind)) {
  99839. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind);
  99840. temp = [];
  99841. for (index = 0; index < data.length; index += 3) {
  99842. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  99843. }
  99844. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind).isUpdatable());
  99845. }
  99846. // flip faces?
  99847. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  99848. this.flipFaces();
  99849. }
  99850. // Restore submeshes
  99851. this.releaseSubMeshes();
  99852. this.subMeshes = submeshes;
  99853. return this;
  99854. };
  99855. /**
  99856. * Modifies the mesh geometry according to its own current World Matrix.
  99857. * The mesh World Matrix is then reset.
  99858. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99859. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99860. * @see http://doc.babylonjs.com/resources/baking_transformations
  99861. * @returns the current mesh
  99862. */
  99863. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  99864. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  99865. this.scaling.copyFromFloats(1, 1, 1);
  99866. this.position.copyFromFloats(0, 0, 0);
  99867. this.rotation.copyFromFloats(0, 0, 0);
  99868. //only if quaternion is already set
  99869. if (this.rotationQuaternion) {
  99870. this.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  99871. }
  99872. this._worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  99873. return this;
  99874. };
  99875. Object.defineProperty(Mesh.prototype, "_positions", {
  99876. // Cache
  99877. /** @hidden */
  99878. get: function () {
  99879. if (this._geometry) {
  99880. return this._geometry._positions;
  99881. }
  99882. return null;
  99883. },
  99884. enumerable: true,
  99885. configurable: true
  99886. });
  99887. /** @hidden */
  99888. Mesh.prototype._resetPointsArrayCache = function () {
  99889. if (this._geometry) {
  99890. this._geometry._resetPointsArrayCache();
  99891. }
  99892. return this;
  99893. };
  99894. /** @hidden */
  99895. Mesh.prototype._generatePointsArray = function () {
  99896. if (this._geometry) {
  99897. return this._geometry._generatePointsArray();
  99898. }
  99899. return false;
  99900. };
  99901. /**
  99902. * Returns a new Mesh object generated from the current mesh properties.
  99903. * This method must not get confused with createInstance()
  99904. * @param name is a string, the name given to the new mesh
  99905. * @param newParent can be any Node object (default `null`)
  99906. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99907. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99908. * @returns a new mesh
  99909. */
  99910. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  99911. if (name === void 0) { name = ""; }
  99912. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  99913. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  99914. };
  99915. /**
  99916. * Releases resources associated with this mesh.
  99917. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99918. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99919. */
  99920. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  99921. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  99922. this.morphTargetManager = null;
  99923. if (this._geometry) {
  99924. this._geometry.releaseForMesh(this, true);
  99925. }
  99926. var internalDataInfo = this._internalMeshDataInfo;
  99927. if (internalDataInfo._onBeforeDrawObservable) {
  99928. internalDataInfo._onBeforeDrawObservable.clear();
  99929. }
  99930. if (internalDataInfo._onBeforeBindObservable) {
  99931. internalDataInfo._onBeforeBindObservable.clear();
  99932. }
  99933. if (internalDataInfo._onBeforeRenderObservable) {
  99934. internalDataInfo._onBeforeRenderObservable.clear();
  99935. }
  99936. if (internalDataInfo._onAfterRenderObservable) {
  99937. internalDataInfo._onAfterRenderObservable.clear();
  99938. }
  99939. // Sources
  99940. if (this._scene.useClonedMeshhMap) {
  99941. if (internalDataInfo.meshMap) {
  99942. for (var uniqueId in internalDataInfo.meshMap) {
  99943. var mesh = internalDataInfo.meshMap[uniqueId];
  99944. if (mesh) {
  99945. mesh._internalMeshDataInfo._source = null;
  99946. internalDataInfo.meshMap[uniqueId] = undefined;
  99947. }
  99948. }
  99949. }
  99950. if (internalDataInfo._source && internalDataInfo._source._internalMeshDataInfo.meshMap) {
  99951. internalDataInfo._source._internalMeshDataInfo.meshMap[this.uniqueId] = undefined;
  99952. }
  99953. }
  99954. else {
  99955. var meshes = this.getScene().meshes;
  99956. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  99957. var abstractMesh = meshes_1[_i];
  99958. var mesh = abstractMesh;
  99959. if (mesh._internalMeshDataInfo && mesh._internalMeshDataInfo._source && mesh._internalMeshDataInfo._source === this) {
  99960. mesh._internalMeshDataInfo._source = null;
  99961. }
  99962. }
  99963. }
  99964. internalDataInfo._source = null;
  99965. // Instances
  99966. if (this._instanceDataStorage.instancesBuffer) {
  99967. this._instanceDataStorage.instancesBuffer.dispose();
  99968. this._instanceDataStorage.instancesBuffer = null;
  99969. }
  99970. while (this.instances.length) {
  99971. this.instances[0].dispose();
  99972. }
  99973. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  99974. };
  99975. /**
  99976. * Modifies the mesh geometry according to a displacement map.
  99977. * 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.
  99978. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99979. * @param url is a string, the URL from the image file is to be downloaded.
  99980. * @param minHeight is the lower limit of the displacement.
  99981. * @param maxHeight is the upper limit of the displacement.
  99982. * @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.
  99983. * @param uvOffset is an optional vector2 used to offset UV.
  99984. * @param uvScale is an optional vector2 used to scale UV.
  99985. * @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.
  99986. * @returns the Mesh.
  99987. */
  99988. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  99989. var _this = this;
  99990. if (forceUpdate === void 0) { forceUpdate = false; }
  99991. var scene = this.getScene();
  99992. var onload = function (img) {
  99993. // Getting height map data
  99994. var canvas = document.createElement("canvas");
  99995. var context = canvas.getContext("2d");
  99996. var heightMapWidth = img.width;
  99997. var heightMapHeight = img.height;
  99998. canvas.width = heightMapWidth;
  99999. canvas.height = heightMapHeight;
  100000. context.drawImage(img, 0, 0);
  100001. // Create VertexData from map data
  100002. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  100003. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  100004. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  100005. //execute success callback, if set
  100006. if (onSuccess) {
  100007. onSuccess(_this);
  100008. }
  100009. };
  100010. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  100011. return this;
  100012. };
  100013. /**
  100014. * Modifies the mesh geometry according to a displacementMap buffer.
  100015. * 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.
  100016. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  100017. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  100018. * @param heightMapWidth is the width of the buffer image.
  100019. * @param heightMapHeight is the height of the buffer image.
  100020. * @param minHeight is the lower limit of the displacement.
  100021. * @param maxHeight is the upper limit of the displacement.
  100022. * @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.
  100023. * @param uvOffset is an optional vector2 used to offset UV.
  100024. * @param uvScale is an optional vector2 used to scale UV.
  100025. * @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.
  100026. * @returns the Mesh.
  100027. */
  100028. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  100029. if (forceUpdate === void 0) { forceUpdate = false; }
  100030. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind)
  100031. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind)
  100032. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UVKind)) {
  100033. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  100034. return this;
  100035. }
  100036. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, true, true);
  100037. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind);
  100038. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UVKind);
  100039. var position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  100040. var normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  100041. var uv = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  100042. uvOffset = uvOffset || _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  100043. uvScale = uvScale || new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  100044. for (var index = 0; index < positions.length; index += 3) {
  100045. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  100046. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  100047. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  100048. // Compute height
  100049. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  100050. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  100051. var pos = (u + v * heightMapWidth) * 4;
  100052. var r = buffer[pos] / 255.0;
  100053. var g = buffer[pos + 1] / 255.0;
  100054. var b = buffer[pos + 2] / 255.0;
  100055. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  100056. normal.normalize();
  100057. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  100058. position = position.add(normal);
  100059. position.toArray(positions, index);
  100060. }
  100061. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  100062. if (forceUpdate) {
  100063. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, positions);
  100064. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, normals);
  100065. }
  100066. else {
  100067. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, positions);
  100068. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, normals);
  100069. }
  100070. return this;
  100071. };
  100072. /**
  100073. * Modify the mesh to get a flat shading rendering.
  100074. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  100075. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  100076. * @returns current mesh
  100077. */
  100078. Mesh.prototype.convertToFlatShadedMesh = function () {
  100079. var kinds = this.getVerticesDataKinds();
  100080. var vbs = {};
  100081. var data = {};
  100082. var newdata = {};
  100083. var updatableNormals = false;
  100084. var kindIndex;
  100085. var kind;
  100086. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  100087. kind = kinds[kindIndex];
  100088. var vertexBuffer = this.getVertexBuffer(kind);
  100089. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind) {
  100090. updatableNormals = vertexBuffer.isUpdatable();
  100091. kinds.splice(kindIndex, 1);
  100092. kindIndex--;
  100093. continue;
  100094. }
  100095. vbs[kind] = vertexBuffer;
  100096. data[kind] = vbs[kind].getData();
  100097. newdata[kind] = [];
  100098. }
  100099. // Save previous submeshes
  100100. var previousSubmeshes = this.subMeshes.slice(0);
  100101. var indices = this.getIndices();
  100102. var totalIndices = this.getTotalIndices();
  100103. // Generating unique vertices per face
  100104. var index;
  100105. for (index = 0; index < totalIndices; index++) {
  100106. var vertexIndex = indices[index];
  100107. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  100108. kind = kinds[kindIndex];
  100109. var stride = vbs[kind].getStrideSize();
  100110. for (var offset = 0; offset < stride; offset++) {
  100111. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  100112. }
  100113. }
  100114. }
  100115. // Updating faces & normal
  100116. var normals = [];
  100117. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind];
  100118. for (index = 0; index < totalIndices; index += 3) {
  100119. indices[index] = index;
  100120. indices[index + 1] = index + 1;
  100121. indices[index + 2] = index + 2;
  100122. var p1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  100123. var p2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  100124. var p3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  100125. var p1p2 = p1.subtract(p2);
  100126. var p3p2 = p3.subtract(p2);
  100127. var normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  100128. // Store same normals for every vertex
  100129. for (var localIndex = 0; localIndex < 3; localIndex++) {
  100130. normals.push(normal.x);
  100131. normals.push(normal.y);
  100132. normals.push(normal.z);
  100133. }
  100134. }
  100135. this.setIndices(indices);
  100136. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, normals, updatableNormals);
  100137. // Updating vertex buffers
  100138. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  100139. kind = kinds[kindIndex];
  100140. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  100141. }
  100142. // Updating submeshes
  100143. this.releaseSubMeshes();
  100144. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  100145. var previousOne = previousSubmeshes[submeshIndex];
  100146. _subMesh__WEBPACK_IMPORTED_MODULE_12__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  100147. }
  100148. this.synchronizeInstances();
  100149. return this;
  100150. };
  100151. /**
  100152. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  100153. * In other words, more vertices, no more indices and a single bigger VBO.
  100154. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  100155. * @returns current mesh
  100156. */
  100157. Mesh.prototype.convertToUnIndexedMesh = function () {
  100158. var kinds = this.getVerticesDataKinds();
  100159. var vbs = {};
  100160. var data = {};
  100161. var newdata = {};
  100162. var kindIndex;
  100163. var kind;
  100164. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  100165. kind = kinds[kindIndex];
  100166. var vertexBuffer = this.getVertexBuffer(kind);
  100167. vbs[kind] = vertexBuffer;
  100168. data[kind] = vbs[kind].getData();
  100169. newdata[kind] = [];
  100170. }
  100171. // Save previous submeshes
  100172. var previousSubmeshes = this.subMeshes.slice(0);
  100173. var indices = this.getIndices();
  100174. var totalIndices = this.getTotalIndices();
  100175. // Generating unique vertices per face
  100176. var index;
  100177. for (index = 0; index < totalIndices; index++) {
  100178. var vertexIndex = indices[index];
  100179. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  100180. kind = kinds[kindIndex];
  100181. var stride = vbs[kind].getStrideSize();
  100182. for (var offset = 0; offset < stride; offset++) {
  100183. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  100184. }
  100185. }
  100186. }
  100187. // Updating indices
  100188. for (index = 0; index < totalIndices; index += 3) {
  100189. indices[index] = index;
  100190. indices[index + 1] = index + 1;
  100191. indices[index + 2] = index + 2;
  100192. }
  100193. this.setIndices(indices);
  100194. // Updating vertex buffers
  100195. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  100196. kind = kinds[kindIndex];
  100197. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  100198. }
  100199. // Updating submeshes
  100200. this.releaseSubMeshes();
  100201. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  100202. var previousOne = previousSubmeshes[submeshIndex];
  100203. _subMesh__WEBPACK_IMPORTED_MODULE_12__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  100204. }
  100205. this._unIndexed = true;
  100206. this.synchronizeInstances();
  100207. return this;
  100208. };
  100209. /**
  100210. * Inverses facet orientations.
  100211. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  100212. * @param flipNormals will also inverts the normals
  100213. * @returns current mesh
  100214. */
  100215. Mesh.prototype.flipFaces = function (flipNormals) {
  100216. if (flipNormals === void 0) { flipNormals = false; }
  100217. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ExtractFromMesh(this);
  100218. var i;
  100219. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  100220. for (i = 0; i < vertex_data.normals.length; i++) {
  100221. vertex_data.normals[i] *= -1;
  100222. }
  100223. }
  100224. if (vertex_data.indices) {
  100225. var temp;
  100226. for (i = 0; i < vertex_data.indices.length; i += 3) {
  100227. // reassign indices
  100228. temp = vertex_data.indices[i + 1];
  100229. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  100230. vertex_data.indices[i + 2] = temp;
  100231. }
  100232. }
  100233. vertex_data.applyToMesh(this, this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind));
  100234. return this;
  100235. };
  100236. /**
  100237. * Increase the number of facets and hence vertices in a mesh
  100238. * Vertex normals are interpolated from existing vertex normals
  100239. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  100240. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  100241. */
  100242. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  100243. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ExtractFromMesh(this);
  100244. var uvs = vertex_data.uvs;
  100245. var currentIndices = vertex_data.indices;
  100246. var positions = vertex_data.positions;
  100247. var normals = vertex_data.normals;
  100248. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  100249. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("VertexData contains null entries");
  100250. }
  100251. else {
  100252. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  100253. var tempIndices = new Array();
  100254. for (var i = 0; i < segments + 1; i++) {
  100255. tempIndices[i] = new Array();
  100256. }
  100257. var a; //vertex index of one end of a side
  100258. var b; //vertex index of other end of the side
  100259. var deltaPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  100260. var deltaNormal = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  100261. var deltaUV = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  100262. var indices = new Array();
  100263. var vertexIndex = new Array();
  100264. var side = new Array();
  100265. var len;
  100266. var positionPtr = positions.length;
  100267. var uvPtr = uvs.length;
  100268. for (var i = 0; i < currentIndices.length; i += 3) {
  100269. vertexIndex[0] = currentIndices[i];
  100270. vertexIndex[1] = currentIndices[i + 1];
  100271. vertexIndex[2] = currentIndices[i + 2];
  100272. for (var j = 0; j < 3; j++) {
  100273. a = vertexIndex[j];
  100274. b = vertexIndex[(j + 1) % 3];
  100275. if (side[a] === undefined && side[b] === undefined) {
  100276. side[a] = new Array();
  100277. side[b] = new Array();
  100278. }
  100279. else {
  100280. if (side[a] === undefined) {
  100281. side[a] = new Array();
  100282. }
  100283. if (side[b] === undefined) {
  100284. side[b] = new Array();
  100285. }
  100286. }
  100287. if (side[a][b] === undefined && side[b][a] === undefined) {
  100288. side[a][b] = [];
  100289. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  100290. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  100291. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  100292. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  100293. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  100294. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  100295. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  100296. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  100297. side[a][b].push(a);
  100298. for (var k = 1; k < segments; k++) {
  100299. side[a][b].push(positions.length / 3);
  100300. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  100301. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  100302. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  100303. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  100304. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  100305. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  100306. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  100307. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  100308. }
  100309. side[a][b].push(b);
  100310. side[b][a] = new Array();
  100311. len = side[a][b].length;
  100312. for (var idx = 0; idx < len; idx++) {
  100313. side[b][a][idx] = side[a][b][len - 1 - idx];
  100314. }
  100315. }
  100316. }
  100317. //Calculate positions, normals and uvs of new internal vertices
  100318. tempIndices[0][0] = currentIndices[i];
  100319. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  100320. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  100321. for (var k = 2; k < segments; k++) {
  100322. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  100323. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  100324. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  100325. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  100326. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  100327. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  100328. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  100329. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  100330. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  100331. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  100332. for (var j = 1; j < k; j++) {
  100333. tempIndices[k][j] = positions.length / 3;
  100334. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  100335. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  100336. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  100337. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  100338. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  100339. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  100340. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  100341. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  100342. }
  100343. }
  100344. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  100345. // reform indices
  100346. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  100347. for (var k = 1; k < segments; k++) {
  100348. for (var j = 0; j < k; j++) {
  100349. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  100350. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  100351. }
  100352. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  100353. }
  100354. }
  100355. vertex_data.indices = indices;
  100356. vertex_data.applyToMesh(this, this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind));
  100357. }
  100358. };
  100359. /**
  100360. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  100361. * This will undo any application of covertToFlatShadedMesh
  100362. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  100363. */
  100364. Mesh.prototype.forceSharedVertices = function () {
  100365. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ExtractFromMesh(this);
  100366. var currentUVs = vertex_data.uvs;
  100367. var currentIndices = vertex_data.indices;
  100368. var currentPositions = vertex_data.positions;
  100369. var currentColors = vertex_data.colors;
  100370. if (currentIndices === void 0 || currentPositions === void 0 || currentIndices === null || currentPositions === null) {
  100371. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("VertexData contains empty entries");
  100372. }
  100373. else {
  100374. var positions = new Array();
  100375. var indices = new Array();
  100376. var uvs = new Array();
  100377. var colors = new Array();
  100378. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  100379. var indexPtr = 0; // pointer to next available index value
  100380. var uniquePositions = new Array(); // unique vertex positions
  100381. var ptr; // pointer to element in uniquePositions
  100382. var facet;
  100383. for (var i = 0; i < currentIndices.length; i += 3) {
  100384. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  100385. pstring = new Array();
  100386. for (var j = 0; j < 3; j++) {
  100387. pstring[j] = "";
  100388. for (var k = 0; k < 3; k++) {
  100389. //small values make 0
  100390. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  100391. currentPositions[3 * facet[j] + k] = 0;
  100392. }
  100393. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  100394. }
  100395. pstring[j] = pstring[j].slice(0, -1);
  100396. }
  100397. //check facet vertices to see that none are repeated
  100398. // do not process any facet that has a repeated vertex, ie is a line
  100399. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  100400. //for each facet position check if already listed in uniquePositions
  100401. // if not listed add to uniquePositions and set index pointer
  100402. // if listed use its index in uniquePositions and new index pointer
  100403. for (var j = 0; j < 3; j++) {
  100404. ptr = uniquePositions.indexOf(pstring[j]);
  100405. if (ptr < 0) {
  100406. uniquePositions.push(pstring[j]);
  100407. ptr = indexPtr++;
  100408. //not listed so add individual x, y, z coordinates to positions
  100409. for (var k = 0; k < 3; k++) {
  100410. positions.push(currentPositions[3 * facet[j] + k]);
  100411. }
  100412. if (currentColors !== null && currentColors !== void 0) {
  100413. for (var k = 0; k < 4; k++) {
  100414. colors.push(currentColors[4 * facet[j] + k]);
  100415. }
  100416. }
  100417. if (currentUVs !== null && currentUVs !== void 0) {
  100418. for (var k = 0; k < 2; k++) {
  100419. uvs.push(currentUVs[2 * facet[j] + k]);
  100420. }
  100421. }
  100422. }
  100423. // add new index pointer to indices array
  100424. indices.push(ptr);
  100425. }
  100426. }
  100427. }
  100428. var normals = new Array();
  100429. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ComputeNormals(positions, indices, normals);
  100430. //create new vertex data object and update
  100431. vertex_data.positions = positions;
  100432. vertex_data.indices = indices;
  100433. vertex_data.normals = normals;
  100434. if (currentUVs !== null && currentUVs !== void 0) {
  100435. vertex_data.uvs = uvs;
  100436. }
  100437. if (currentColors !== null && currentColors !== void 0) {
  100438. vertex_data.colors = colors;
  100439. }
  100440. vertex_data.applyToMesh(this, this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind));
  100441. }
  100442. };
  100443. // Instances
  100444. /** @hidden */
  100445. Mesh._instancedMeshFactory = function (name, mesh) {
  100446. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("InstancedMesh");
  100447. };
  100448. /** @hidden */
  100449. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  100450. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("PhysicsImpostor");
  100451. };
  100452. /**
  100453. * Creates a new InstancedMesh object from the mesh model.
  100454. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100455. * @param name defines the name of the new instance
  100456. * @returns a new InstancedMesh
  100457. */
  100458. Mesh.prototype.createInstance = function (name) {
  100459. return Mesh._instancedMeshFactory(name, this);
  100460. };
  100461. /**
  100462. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  100463. * After this call, all the mesh instances have the same submeshes than the current mesh.
  100464. * @returns the current mesh
  100465. */
  100466. Mesh.prototype.synchronizeInstances = function () {
  100467. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  100468. var instance = this.instances[instanceIndex];
  100469. instance._syncSubMeshes();
  100470. }
  100471. return this;
  100472. };
  100473. /**
  100474. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  100475. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  100476. * This should be used together with the simplification to avoid disappearing triangles.
  100477. * @param successCallback an optional success callback to be called after the optimization finished.
  100478. * @returns the current mesh
  100479. */
  100480. Mesh.prototype.optimizeIndices = function (successCallback) {
  100481. var _this = this;
  100482. var indices = this.getIndices();
  100483. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind);
  100484. if (!positions || !indices) {
  100485. return this;
  100486. }
  100487. var vectorPositions = new Array();
  100488. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  100489. vectorPositions.push(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  100490. }
  100491. var dupes = new Array();
  100492. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  100493. var realPos = vectorPositions.length - 1 - iteration;
  100494. var testedPosition = vectorPositions[realPos];
  100495. for (var j = 0; j < realPos; ++j) {
  100496. var againstPosition = vectorPositions[j];
  100497. if (testedPosition.equals(againstPosition)) {
  100498. dupes[realPos] = j;
  100499. break;
  100500. }
  100501. }
  100502. }, function () {
  100503. for (var i = 0; i < indices.length; ++i) {
  100504. indices[i] = dupes[indices[i]] || indices[i];
  100505. }
  100506. //indices are now reordered
  100507. var originalSubMeshes = _this.subMeshes.slice(0);
  100508. _this.setIndices(indices);
  100509. _this.subMeshes = originalSubMeshes;
  100510. if (successCallback) {
  100511. successCallback(_this);
  100512. }
  100513. });
  100514. return this;
  100515. };
  100516. /**
  100517. * Serialize current mesh
  100518. * @param serializationObject defines the object which will receive the serialization data
  100519. */
  100520. Mesh.prototype.serialize = function (serializationObject) {
  100521. serializationObject.name = this.name;
  100522. serializationObject.id = this.id;
  100523. serializationObject.type = this.getClassName();
  100524. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  100525. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  100526. }
  100527. serializationObject.position = this.position.asArray();
  100528. if (this.rotationQuaternion) {
  100529. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  100530. }
  100531. else if (this.rotation) {
  100532. serializationObject.rotation = this.rotation.asArray();
  100533. }
  100534. serializationObject.scaling = this.scaling.asArray();
  100535. if (this._postMultiplyPivotMatrix) {
  100536. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  100537. }
  100538. else {
  100539. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  100540. }
  100541. serializationObject.isEnabled = this.isEnabled(false);
  100542. serializationObject.isVisible = this.isVisible;
  100543. serializationObject.infiniteDistance = this.infiniteDistance;
  100544. serializationObject.pickable = this.isPickable;
  100545. serializationObject.receiveShadows = this.receiveShadows;
  100546. serializationObject.billboardMode = this.billboardMode;
  100547. serializationObject.visibility = this.visibility;
  100548. serializationObject.checkCollisions = this.checkCollisions;
  100549. serializationObject.isBlocker = this.isBlocker;
  100550. // Parent
  100551. if (this.parent) {
  100552. serializationObject.parentId = this.parent.id;
  100553. }
  100554. // Geometry
  100555. serializationObject.isUnIndexed = this.isUnIndexed;
  100556. var geometry = this._geometry;
  100557. if (geometry) {
  100558. var geometryId = geometry.id;
  100559. serializationObject.geometryId = geometryId;
  100560. // SubMeshes
  100561. serializationObject.subMeshes = [];
  100562. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  100563. var subMesh = this.subMeshes[subIndex];
  100564. serializationObject.subMeshes.push({
  100565. materialIndex: subMesh.materialIndex,
  100566. verticesStart: subMesh.verticesStart,
  100567. verticesCount: subMesh.verticesCount,
  100568. indexStart: subMesh.indexStart,
  100569. indexCount: subMesh.indexCount
  100570. });
  100571. }
  100572. }
  100573. // Material
  100574. if (this.material) {
  100575. serializationObject.materialId = this.material.id;
  100576. }
  100577. else {
  100578. this.material = null;
  100579. }
  100580. // Morph targets
  100581. if (this.morphTargetManager) {
  100582. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  100583. }
  100584. // Skeleton
  100585. if (this.skeleton) {
  100586. serializationObject.skeletonId = this.skeleton.id;
  100587. }
  100588. // Physics
  100589. //TODO implement correct serialization for physics impostors.
  100590. if (this.getScene()._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_22__["SceneComponentConstants"].NAME_PHYSICSENGINE)) {
  100591. var impostor = this.getPhysicsImpostor();
  100592. if (impostor) {
  100593. serializationObject.physicsMass = impostor.getParam("mass");
  100594. serializationObject.physicsFriction = impostor.getParam("friction");
  100595. serializationObject.physicsRestitution = impostor.getParam("mass");
  100596. serializationObject.physicsImpostor = impostor.type;
  100597. }
  100598. }
  100599. // Metadata
  100600. if (this.metadata) {
  100601. serializationObject.metadata = this.metadata;
  100602. }
  100603. // Instances
  100604. serializationObject.instances = [];
  100605. for (var index = 0; index < this.instances.length; index++) {
  100606. var instance = this.instances[index];
  100607. if (instance.doNotSerialize) {
  100608. continue;
  100609. }
  100610. var serializationInstance = {
  100611. name: instance.name,
  100612. id: instance.id,
  100613. position: instance.position.asArray(),
  100614. scaling: instance.scaling.asArray()
  100615. };
  100616. if (instance.parent) {
  100617. serializationInstance.parentId = instance.parent.id;
  100618. }
  100619. if (instance.rotationQuaternion) {
  100620. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  100621. }
  100622. else if (instance.rotation) {
  100623. serializationInstance.rotation = instance.rotation.asArray();
  100624. }
  100625. serializationObject.instances.push(serializationInstance);
  100626. // Animations
  100627. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  100628. serializationInstance.ranges = instance.serializeAnimationRanges();
  100629. }
  100630. //
  100631. // Animations
  100632. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  100633. serializationObject.ranges = this.serializeAnimationRanges();
  100634. // Layer mask
  100635. serializationObject.layerMask = this.layerMask;
  100636. // Alpha
  100637. serializationObject.alphaIndex = this.alphaIndex;
  100638. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  100639. // Overlay
  100640. serializationObject.overlayAlpha = this.overlayAlpha;
  100641. serializationObject.overlayColor = this.overlayColor.asArray();
  100642. serializationObject.renderOverlay = this.renderOverlay;
  100643. // Fog
  100644. serializationObject.applyFog = this.applyFog;
  100645. // Action Manager
  100646. if (this.actionManager) {
  100647. serializationObject.actions = this.actionManager.serialize(this.name);
  100648. }
  100649. };
  100650. /** @hidden */
  100651. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  100652. if (!this.geometry) {
  100653. return;
  100654. }
  100655. this._markSubMeshesAsAttributesDirty();
  100656. var morphTargetManager = this._internalMeshDataInfo._morphTargetManager;
  100657. if (morphTargetManager && morphTargetManager.vertexCount) {
  100658. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  100659. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  100660. this.morphTargetManager = null;
  100661. return;
  100662. }
  100663. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  100664. var morphTarget = morphTargetManager.getActiveTarget(index);
  100665. var positions = morphTarget.getPositions();
  100666. if (!positions) {
  100667. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Invalid morph target. Target must have positions.");
  100668. return;
  100669. }
  100670. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind + index, positions, false, 3);
  100671. var normals = morphTarget.getNormals();
  100672. if (normals) {
  100673. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind + index, normals, false, 3);
  100674. }
  100675. var tangents = morphTarget.getTangents();
  100676. if (tangents) {
  100677. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  100678. }
  100679. var uvs = morphTarget.getUVs();
  100680. if (uvs) {
  100681. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UVKind + "_" + index, uvs, false, 2);
  100682. }
  100683. }
  100684. }
  100685. else {
  100686. var index = 0;
  100687. // Positions
  100688. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind + index)) {
  100689. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind + index);
  100690. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind + index)) {
  100691. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind + index);
  100692. }
  100693. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].TangentKind + index)) {
  100694. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].TangentKind + index);
  100695. }
  100696. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UVKind + index)) {
  100697. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UVKind + "_" + index);
  100698. }
  100699. index++;
  100700. }
  100701. }
  100702. };
  100703. /**
  100704. * Returns a new Mesh object parsed from the source provided.
  100705. * @param parsedMesh is the source
  100706. * @param scene defines the hosting scene
  100707. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  100708. * @returns a new Mesh
  100709. */
  100710. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  100711. var mesh;
  100712. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  100713. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  100714. }
  100715. else {
  100716. mesh = new Mesh(parsedMesh.name, scene);
  100717. }
  100718. mesh.id = parsedMesh.id;
  100719. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  100720. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  100721. }
  100722. mesh.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  100723. if (parsedMesh.metadata !== undefined) {
  100724. mesh.metadata = parsedMesh.metadata;
  100725. }
  100726. if (parsedMesh.rotationQuaternion) {
  100727. mesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  100728. }
  100729. else if (parsedMesh.rotation) {
  100730. mesh.rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  100731. }
  100732. mesh.scaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  100733. if (parsedMesh.localMatrix) {
  100734. mesh.setPreTransformMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  100735. }
  100736. else if (parsedMesh.pivotMatrix) {
  100737. mesh.setPivotMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  100738. }
  100739. mesh.setEnabled(parsedMesh.isEnabled);
  100740. mesh.isVisible = parsedMesh.isVisible;
  100741. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  100742. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  100743. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  100744. if (parsedMesh.applyFog !== undefined) {
  100745. mesh.applyFog = parsedMesh.applyFog;
  100746. }
  100747. if (parsedMesh.pickable !== undefined) {
  100748. mesh.isPickable = parsedMesh.pickable;
  100749. }
  100750. if (parsedMesh.alphaIndex !== undefined) {
  100751. mesh.alphaIndex = parsedMesh.alphaIndex;
  100752. }
  100753. mesh.receiveShadows = parsedMesh.receiveShadows;
  100754. mesh.billboardMode = parsedMesh.billboardMode;
  100755. if (parsedMesh.visibility !== undefined) {
  100756. mesh.visibility = parsedMesh.visibility;
  100757. }
  100758. mesh.checkCollisions = parsedMesh.checkCollisions;
  100759. if (parsedMesh.isBlocker !== undefined) {
  100760. mesh.isBlocker = parsedMesh.isBlocker;
  100761. }
  100762. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  100763. // freezeWorldMatrix
  100764. if (parsedMesh.freezeWorldMatrix) {
  100765. mesh._waitingData.freezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  100766. }
  100767. // Parent
  100768. if (parsedMesh.parentId) {
  100769. mesh._waitingParentId = parsedMesh.parentId;
  100770. }
  100771. // Actions
  100772. if (parsedMesh.actions !== undefined) {
  100773. mesh._waitingData.actions = parsedMesh.actions;
  100774. }
  100775. // Overlay
  100776. if (parsedMesh.overlayAlpha !== undefined) {
  100777. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  100778. }
  100779. if (parsedMesh.overlayColor !== undefined) {
  100780. mesh.overlayColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_6__["Color3"].FromArray(parsedMesh.overlayColor);
  100781. }
  100782. if (parsedMesh.renderOverlay !== undefined) {
  100783. mesh.renderOverlay = parsedMesh.renderOverlay;
  100784. }
  100785. // Geometry
  100786. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  100787. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  100788. if (parsedMesh.delayLoadingFile) {
  100789. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED;
  100790. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  100791. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_13__["BoundingInfo"](_Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.boundingBoxMinimum), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.boundingBoxMaximum));
  100792. if (parsedMesh._binaryInfo) {
  100793. mesh._binaryInfo = parsedMesh._binaryInfo;
  100794. }
  100795. mesh._delayInfo = [];
  100796. if (parsedMesh.hasUVs) {
  100797. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UVKind);
  100798. }
  100799. if (parsedMesh.hasUVs2) {
  100800. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UV2Kind);
  100801. }
  100802. if (parsedMesh.hasUVs3) {
  100803. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UV3Kind);
  100804. }
  100805. if (parsedMesh.hasUVs4) {
  100806. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UV4Kind);
  100807. }
  100808. if (parsedMesh.hasUVs5) {
  100809. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UV5Kind);
  100810. }
  100811. if (parsedMesh.hasUVs6) {
  100812. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].UV6Kind);
  100813. }
  100814. if (parsedMesh.hasColors) {
  100815. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].ColorKind);
  100816. }
  100817. if (parsedMesh.hasMatricesIndices) {
  100818. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesIndicesKind);
  100819. }
  100820. if (parsedMesh.hasMatricesWeights) {
  100821. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind);
  100822. }
  100823. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"]._ImportGeometry;
  100824. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_16__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  100825. mesh._checkDelayState();
  100826. }
  100827. }
  100828. else {
  100829. _geometry__WEBPACK_IMPORTED_MODULE_10__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  100830. }
  100831. // Material
  100832. if (parsedMesh.materialId) {
  100833. mesh.setMaterialByID(parsedMesh.materialId);
  100834. }
  100835. else {
  100836. mesh.material = null;
  100837. }
  100838. // Morph targets
  100839. if (parsedMesh.morphTargetManagerId > -1) {
  100840. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  100841. }
  100842. // Skeleton
  100843. if (parsedMesh.skeletonId > -1) {
  100844. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  100845. if (parsedMesh.numBoneInfluencers) {
  100846. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  100847. }
  100848. }
  100849. // Animations
  100850. if (parsedMesh.animations) {
  100851. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  100852. var parsedAnimation = parsedMesh.animations[animationIndex];
  100853. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_20__["_TypeStore"].GetClass("BABYLON.Animation");
  100854. if (internalClass) {
  100855. mesh.animations.push(internalClass.Parse(parsedAnimation));
  100856. }
  100857. }
  100858. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  100859. }
  100860. if (parsedMesh.autoAnimate) {
  100861. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  100862. }
  100863. // Layer Mask
  100864. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  100865. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  100866. }
  100867. else {
  100868. mesh.layerMask = 0x0FFFFFFF;
  100869. }
  100870. // Physics
  100871. if (parsedMesh.physicsImpostor) {
  100872. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  100873. }
  100874. // Levels
  100875. if (parsedMesh.lodMeshIds) {
  100876. mesh._waitingData.lods = {
  100877. ids: parsedMesh.lodMeshIds,
  100878. distances: (parsedMesh.lodDistances) ? parsedMesh.lodDistances : null,
  100879. coverages: (parsedMesh.lodCoverages) ? parsedMesh.lodCoverages : null
  100880. };
  100881. }
  100882. // Instances
  100883. if (parsedMesh.instances) {
  100884. for (var index = 0; index < parsedMesh.instances.length; index++) {
  100885. var parsedInstance = parsedMesh.instances[index];
  100886. var instance = mesh.createInstance(parsedInstance.name);
  100887. if (parsedInstance.id) {
  100888. instance.id = parsedInstance.id;
  100889. }
  100890. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  100891. if (parsedInstance.tags) {
  100892. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  100893. }
  100894. else {
  100895. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  100896. }
  100897. }
  100898. instance.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  100899. if (parsedInstance.metadata !== undefined) {
  100900. instance.metadata = parsedInstance.metadata;
  100901. }
  100902. if (parsedInstance.parentId) {
  100903. instance._waitingParentId = parsedInstance.parentId;
  100904. }
  100905. if (parsedInstance.rotationQuaternion) {
  100906. instance.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  100907. }
  100908. else if (parsedInstance.rotation) {
  100909. instance.rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  100910. }
  100911. instance.scaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  100912. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  100913. instance.checkCollisions = parsedInstance.checkCollisions;
  100914. }
  100915. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  100916. instance.isPickable = parsedInstance.pickable;
  100917. }
  100918. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  100919. instance.showBoundingBox = parsedInstance.showBoundingBox;
  100920. }
  100921. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  100922. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  100923. }
  100924. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  100925. instance.alphaIndex = parsedInstance.alphaIndex;
  100926. }
  100927. // Physics
  100928. if (parsedInstance.physicsImpostor) {
  100929. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  100930. }
  100931. // Animation
  100932. if (parsedInstance.animations) {
  100933. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  100934. parsedAnimation = parsedInstance.animations[animationIndex];
  100935. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_20__["_TypeStore"].GetClass("BABYLON.Animation");
  100936. if (internalClass) {
  100937. instance.animations.push(internalClass.Parse(parsedAnimation));
  100938. }
  100939. }
  100940. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  100941. if (parsedInstance.autoAnimate) {
  100942. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  100943. }
  100944. }
  100945. }
  100946. }
  100947. return mesh;
  100948. };
  100949. /**
  100950. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  100951. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  100952. * @param name defines the name of the mesh to create
  100953. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  100954. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  100955. * @param closePath creates a seam between the first and the last points of each path of the path array
  100956. * @param offset is taken in account only if the `pathArray` is containing a single path
  100957. * @param scene defines the hosting scene
  100958. * @param updatable defines if the mesh must be flagged as updatable
  100959. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100960. * @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)
  100961. * @returns a new Mesh
  100962. */
  100963. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  100964. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  100965. };
  100966. /**
  100967. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  100968. * @param name defines the name of the mesh to create
  100969. * @param radius sets the radius size (float) of the polygon (default 0.5)
  100970. * @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
  100971. * @param scene defines the hosting scene
  100972. * @param updatable defines if the mesh must be flagged as updatable
  100973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100974. * @returns a new Mesh
  100975. */
  100976. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  100977. if (scene === void 0) { scene = null; }
  100978. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  100979. };
  100980. /**
  100981. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  100982. * @param name defines the name of the mesh to create
  100983. * @param size sets the size (float) of each box side (default 1)
  100984. * @param scene defines the hosting scene
  100985. * @param updatable defines if the mesh must be flagged as updatable
  100986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100987. * @returns a new Mesh
  100988. */
  100989. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  100990. if (scene === void 0) { scene = null; }
  100991. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  100992. };
  100993. /**
  100994. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  100995. * @param name defines the name of the mesh to create
  100996. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  100997. * @param diameter sets the diameter size (float) of the sphere (default 1)
  100998. * @param scene defines the hosting scene
  100999. * @param updatable defines if the mesh must be flagged as updatable
  101000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101001. * @returns a new Mesh
  101002. */
  101003. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  101004. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101005. };
  101006. /**
  101007. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101008. * @param name defines the name of the mesh to create
  101009. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101010. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101011. * @param scene defines the hosting scene
  101012. * @returns a new Mesh
  101013. */
  101014. Mesh.CreateHemisphere = function (name, segments, diameter, scene) {
  101015. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101016. };
  101017. /**
  101018. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101019. * @param name defines the name of the mesh to create
  101020. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101021. * @param diameterTop set the top cap diameter (floats, default 1)
  101022. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101023. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101024. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101025. * @param scene defines the hosting scene
  101026. * @param updatable defines if the mesh must be flagged as updatable
  101027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101028. * @returns a new Mesh
  101029. */
  101030. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  101031. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101032. };
  101033. // Torus (Code from SharpDX.org)
  101034. /**
  101035. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101036. * @param name defines the name of the mesh to create
  101037. * @param diameter sets the diameter size (float) of the torus (default 1)
  101038. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101039. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101040. * @param scene defines the hosting scene
  101041. * @param updatable defines if the mesh must be flagged as updatable
  101042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101043. * @returns a new Mesh
  101044. */
  101045. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  101046. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101047. };
  101048. /**
  101049. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101050. * @param name defines the name of the mesh to create
  101051. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101052. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101053. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101054. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101055. * @param p the number of windings on X axis (positive integers, default 2)
  101056. * @param q the number of windings on Y axis (positive integers, default 3)
  101057. * @param scene defines the hosting scene
  101058. * @param updatable defines if the mesh must be flagged as updatable
  101059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101060. * @returns a new Mesh
  101061. */
  101062. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  101063. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101064. };
  101065. /**
  101066. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  101067. * @param name defines the name of the mesh to create
  101068. * @param points is an array successive Vector3
  101069. * @param scene defines the hosting scene
  101070. * @param updatable defines if the mesh must be flagged as updatable
  101071. * @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).
  101072. * @returns a new Mesh
  101073. */
  101074. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  101075. if (scene === void 0) { scene = null; }
  101076. if (updatable === void 0) { updatable = false; }
  101077. if (instance === void 0) { instance = null; }
  101078. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101079. };
  101080. /**
  101081. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  101082. * @param name defines the name of the mesh to create
  101083. * @param points is an array successive Vector3
  101084. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101085. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101086. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101087. * @param scene defines the hosting scene
  101088. * @param updatable defines if the mesh must be flagged as updatable
  101089. * @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)
  101090. * @returns a new Mesh
  101091. */
  101092. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  101093. if (scene === void 0) { scene = null; }
  101094. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101095. };
  101096. /**
  101097. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101098. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101099. * 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.
  101100. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101101. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101102. * Remember you can only change the shape positions, not their number when updating a polygon.
  101103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101104. * @param name defines the name of the mesh to create
  101105. * @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
  101106. * @param scene defines the hosting scene
  101107. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101108. * @param updatable defines if the mesh must be flagged as updatable
  101109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101110. * @param earcutInjection can be used to inject your own earcut reference
  101111. * @returns a new Mesh
  101112. */
  101113. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  101114. if (earcutInjection === void 0) { earcutInjection = earcut; }
  101115. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101116. };
  101117. /**
  101118. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101120. * @param name defines the name of the mesh to create
  101121. * @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
  101122. * @param depth defines the height of extrusion
  101123. * @param scene defines the hosting scene
  101124. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101125. * @param updatable defines if the mesh must be flagged as updatable
  101126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101127. * @param earcutInjection can be used to inject your own earcut reference
  101128. * @returns a new Mesh
  101129. */
  101130. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  101131. if (earcutInjection === void 0) { earcutInjection = earcut; }
  101132. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101133. };
  101134. /**
  101135. * Creates an extruded shape mesh.
  101136. * 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
  101137. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101139. * @param name defines the name of the mesh to create
  101140. * @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
  101141. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101142. * @param scale is the value to scale the shape
  101143. * @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
  101144. * @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
  101145. * @param scene defines the hosting scene
  101146. * @param updatable defines if the mesh must be flagged as updatable
  101147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101148. * @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)
  101149. * @returns a new Mesh
  101150. */
  101151. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  101152. if (scene === void 0) { scene = null; }
  101153. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101154. };
  101155. /**
  101156. * Creates an custom extruded shape mesh.
  101157. * The custom extrusion is a parametric shape.
  101158. * It has no predefined shape. Its final shape will depend on the input parameters.
  101159. * Please consider using the same method from the MeshBuilder class instead
  101160. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101161. * @param name defines the name of the mesh to create
  101162. * @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
  101163. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101164. * @param scaleFunction is a custom Javascript function called on each path point
  101165. * @param rotationFunction is a custom Javascript function called on each path point
  101166. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101167. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101168. * @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
  101169. * @param scene defines the hosting scene
  101170. * @param updatable defines if the mesh must be flagged as updatable
  101171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101172. * @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)
  101173. * @returns a new Mesh
  101174. */
  101175. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  101176. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101177. };
  101178. /**
  101179. * Creates lathe mesh.
  101180. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101181. * Please consider using the same method from the MeshBuilder class instead
  101182. * @param name defines the name of the mesh to create
  101183. * @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
  101184. * @param radius is the radius value of the lathe
  101185. * @param tessellation is the side number of the lathe.
  101186. * @param scene defines the hosting scene
  101187. * @param updatable defines if the mesh must be flagged as updatable
  101188. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101189. * @returns a new Mesh
  101190. */
  101191. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  101192. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101193. };
  101194. /**
  101195. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101196. * @param name defines the name of the mesh to create
  101197. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101198. * @param scene defines the hosting scene
  101199. * @param updatable defines if the mesh must be flagged as updatable
  101200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101201. * @returns a new Mesh
  101202. */
  101203. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  101204. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101205. };
  101206. /**
  101207. * Creates a ground mesh.
  101208. * Please consider using the same method from the MeshBuilder class instead
  101209. * @param name defines the name of the mesh to create
  101210. * @param width set the width of the ground
  101211. * @param height set the height of the ground
  101212. * @param subdivisions sets the number of subdivisions per side
  101213. * @param scene defines the hosting scene
  101214. * @param updatable defines if the mesh must be flagged as updatable
  101215. * @returns a new Mesh
  101216. */
  101217. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  101218. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101219. };
  101220. /**
  101221. * Creates a tiled ground mesh.
  101222. * Please consider using the same method from the MeshBuilder class instead
  101223. * @param name defines the name of the mesh to create
  101224. * @param xmin set the ground minimum X coordinate
  101225. * @param zmin set the ground minimum Y coordinate
  101226. * @param xmax set the ground maximum X coordinate
  101227. * @param zmax set the ground maximum Z coordinate
  101228. * @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
  101229. * @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
  101230. * @param scene defines the hosting scene
  101231. * @param updatable defines if the mesh must be flagged as updatable
  101232. * @returns a new Mesh
  101233. */
  101234. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  101235. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101236. };
  101237. /**
  101238. * Creates a ground mesh from a height map.
  101239. * Please consider using the same method from the MeshBuilder class instead
  101240. * @see http://doc.babylonjs.com/babylon101/height_map
  101241. * @param name defines the name of the mesh to create
  101242. * @param url sets the URL of the height map image resource
  101243. * @param width set the ground width size
  101244. * @param height set the ground height size
  101245. * @param subdivisions sets the number of subdivision per side
  101246. * @param minHeight is the minimum altitude on the ground
  101247. * @param maxHeight is the maximum altitude on the ground
  101248. * @param scene defines the hosting scene
  101249. * @param updatable defines if the mesh must be flagged as updatable
  101250. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101251. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101252. * @returns a new Mesh
  101253. */
  101254. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  101255. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101256. };
  101257. /**
  101258. * Creates a tube mesh.
  101259. * The tube is a parametric shape.
  101260. * It has no predefined shape. Its final shape will depend on the input parameters.
  101261. * Please consider using the same method from the MeshBuilder class instead
  101262. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101263. * @param name defines the name of the mesh to create
  101264. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101265. * @param radius sets the tube radius size
  101266. * @param tessellation is the number of sides on the tubular surface
  101267. * @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
  101268. * @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
  101269. * @param scene defines the hosting scene
  101270. * @param updatable defines if the mesh must be flagged as updatable
  101271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101272. * @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)
  101273. * @returns a new Mesh
  101274. */
  101275. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  101276. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101277. };
  101278. /**
  101279. * Creates a polyhedron mesh.
  101280. * Please consider using the same method from the MeshBuilder class instead.
  101281. * * 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
  101282. * * The parameter `size` (positive float, default 1) sets the polygon size
  101283. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101284. * * 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`
  101285. * * 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
  101286. * * 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)`)
  101287. * * 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
  101288. * * 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
  101289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101290. * * 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
  101291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101292. * @param name defines the name of the mesh to create
  101293. * @param options defines the options used to create the mesh
  101294. * @param scene defines the hosting scene
  101295. * @returns a new Mesh
  101296. */
  101297. Mesh.CreatePolyhedron = function (name, options, scene) {
  101298. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101299. };
  101300. /**
  101301. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101302. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101303. * * 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`)
  101304. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101305. * * 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
  101306. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101307. * * 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
  101308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101309. * @param name defines the name of the mesh
  101310. * @param options defines the options used to create the mesh
  101311. * @param scene defines the hosting scene
  101312. * @returns a new Mesh
  101313. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101314. */
  101315. Mesh.CreateIcoSphere = function (name, options, scene) {
  101316. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101317. };
  101318. /**
  101319. * Creates a decal mesh.
  101320. * Please consider using the same method from the MeshBuilder class instead.
  101321. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101322. * @param name defines the name of the mesh
  101323. * @param sourceMesh defines the mesh receiving the decal
  101324. * @param position sets the position of the decal in world coordinates
  101325. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101326. * @param size sets the decal scaling
  101327. * @param angle sets the angle to rotate the decal
  101328. * @returns a new Mesh
  101329. */
  101330. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  101331. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("MeshBuilder");
  101332. };
  101333. // Skeletons
  101334. /**
  101335. * Prepare internal position array for software CPU skinning
  101336. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101337. */
  101338. Mesh.prototype.setPositionsForCPUSkinning = function () {
  101339. var internalDataInfo = this._internalMeshDataInfo;
  101340. if (!internalDataInfo._sourcePositions) {
  101341. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind);
  101342. if (!source) {
  101343. return internalDataInfo._sourcePositions;
  101344. }
  101345. internalDataInfo._sourcePositions = new Float32Array(source);
  101346. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind)) {
  101347. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, source, true);
  101348. }
  101349. }
  101350. return internalDataInfo._sourcePositions;
  101351. };
  101352. /**
  101353. * Prepare internal normal array for software CPU skinning
  101354. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101355. */
  101356. Mesh.prototype.setNormalsForCPUSkinning = function () {
  101357. var internalDataInfo = this._internalMeshDataInfo;
  101358. if (!internalDataInfo._sourceNormals) {
  101359. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind);
  101360. if (!source) {
  101361. return internalDataInfo._sourceNormals;
  101362. }
  101363. internalDataInfo._sourceNormals = new Float32Array(source);
  101364. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind)) {
  101365. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, source, true);
  101366. }
  101367. }
  101368. return internalDataInfo._sourceNormals;
  101369. };
  101370. /**
  101371. * Updates the vertex buffer by applying transformation from the bones
  101372. * @param skeleton defines the skeleton to apply to current mesh
  101373. * @returns the current mesh
  101374. */
  101375. Mesh.prototype.applySkeleton = function (skeleton) {
  101376. if (!this.geometry) {
  101377. return this;
  101378. }
  101379. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  101380. return this;
  101381. }
  101382. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  101383. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind)) {
  101384. return this;
  101385. }
  101386. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind)) {
  101387. return this;
  101388. }
  101389. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesIndicesKind)) {
  101390. return this;
  101391. }
  101392. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind)) {
  101393. return this;
  101394. }
  101395. var internalDataInfo = this._internalMeshDataInfo;
  101396. if (!internalDataInfo._sourcePositions) {
  101397. var submeshes = this.subMeshes.slice();
  101398. this.setPositionsForCPUSkinning();
  101399. this.subMeshes = submeshes;
  101400. }
  101401. if (!internalDataInfo._sourceNormals) {
  101402. this.setNormalsForCPUSkinning();
  101403. }
  101404. // positionsData checks for not being Float32Array will only pass at most once
  101405. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind);
  101406. if (!positionsData) {
  101407. return this;
  101408. }
  101409. if (!(positionsData instanceof Float32Array)) {
  101410. positionsData = new Float32Array(positionsData);
  101411. }
  101412. // normalsData checks for not being Float32Array will only pass at most once
  101413. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind);
  101414. if (!normalsData) {
  101415. return this;
  101416. }
  101417. if (!(normalsData instanceof Float32Array)) {
  101418. normalsData = new Float32Array(normalsData);
  101419. }
  101420. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesIndicesKind);
  101421. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsKind);
  101422. if (!matricesWeightsData || !matricesIndicesData) {
  101423. return this;
  101424. }
  101425. var needExtras = this.numBoneInfluencers > 4;
  101426. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  101427. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  101428. var skeletonMatrices = skeleton.getTransformMatrices(this);
  101429. var tempVector3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  101430. var finalMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  101431. var tempMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  101432. var matWeightIdx = 0;
  101433. var inf;
  101434. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  101435. var weight;
  101436. for (inf = 0; inf < 4; inf++) {
  101437. weight = matricesWeightsData[matWeightIdx + inf];
  101438. if (weight > 0) {
  101439. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  101440. finalMatrix.addToSelf(tempMatrix);
  101441. }
  101442. }
  101443. if (needExtras) {
  101444. for (inf = 0; inf < 4; inf++) {
  101445. weight = matricesWeightsExtraData[matWeightIdx + inf];
  101446. if (weight > 0) {
  101447. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  101448. finalMatrix.addToSelf(tempMatrix);
  101449. }
  101450. }
  101451. }
  101452. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(internalDataInfo._sourcePositions[index], internalDataInfo._sourcePositions[index + 1], internalDataInfo._sourcePositions[index + 2], finalMatrix, tempVector3);
  101453. tempVector3.toArray(positionsData, index);
  101454. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(internalDataInfo._sourceNormals[index], internalDataInfo._sourceNormals[index + 1], internalDataInfo._sourceNormals[index + 2], finalMatrix, tempVector3);
  101455. tempVector3.toArray(normalsData, index);
  101456. finalMatrix.reset();
  101457. }
  101458. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].PositionKind, positionsData);
  101459. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_8__["VertexBuffer"].NormalKind, normalsData);
  101460. return this;
  101461. };
  101462. // Tools
  101463. /**
  101464. * 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
  101465. * @param meshes defines the list of meshes to scan
  101466. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101467. */
  101468. Mesh.MinMax = function (meshes) {
  101469. var minVector = null;
  101470. var maxVector = null;
  101471. meshes.forEach(function (mesh) {
  101472. var boundingInfo = mesh.getBoundingInfo();
  101473. var boundingBox = boundingInfo.boundingBox;
  101474. if (!minVector || !maxVector) {
  101475. minVector = boundingBox.minimumWorld;
  101476. maxVector = boundingBox.maximumWorld;
  101477. }
  101478. else {
  101479. minVector.minimizeInPlace(boundingBox.minimumWorld);
  101480. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  101481. }
  101482. });
  101483. if (!minVector || !maxVector) {
  101484. return {
  101485. min: _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  101486. max: _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  101487. };
  101488. }
  101489. return {
  101490. min: minVector,
  101491. max: maxVector
  101492. };
  101493. };
  101494. /**
  101495. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101496. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101497. * @returns a vector3
  101498. */
  101499. Mesh.Center = function (meshesOrMinMaxVector) {
  101500. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  101501. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  101502. };
  101503. /**
  101504. * Merge the array of meshes into a single mesh for performance reasons.
  101505. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101506. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101507. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101508. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101509. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101510. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101511. * @returns a new mesh
  101512. */
  101513. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  101514. if (disposeSource === void 0) { disposeSource = true; }
  101515. var index;
  101516. if (!allow32BitsIndices) {
  101517. var totalVertices = 0;
  101518. // Counting vertices
  101519. for (index = 0; index < meshes.length; index++) {
  101520. if (meshes[index]) {
  101521. totalVertices += meshes[index].getTotalVertices();
  101522. if (totalVertices > 65536) {
  101523. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  101524. return null;
  101525. }
  101526. }
  101527. }
  101528. }
  101529. if (multiMultiMaterials) {
  101530. var newMultiMaterial = null;
  101531. var subIndex;
  101532. var matIndex;
  101533. subdivideWithSubMeshes = false;
  101534. }
  101535. var materialArray = new Array();
  101536. var materialIndexArray = new Array();
  101537. // Merge
  101538. var vertexData = null;
  101539. var otherVertexData;
  101540. var indiceArray = new Array();
  101541. var source = null;
  101542. for (index = 0; index < meshes.length; index++) {
  101543. if (meshes[index]) {
  101544. var mesh = meshes[index];
  101545. if (mesh.isAnInstance) {
  101546. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot merge instance meshes.");
  101547. return null;
  101548. }
  101549. var wm = mesh.computeWorldMatrix(true);
  101550. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].ExtractFromMesh(mesh, true, true);
  101551. otherVertexData.transform(wm);
  101552. if (vertexData) {
  101553. vertexData.merge(otherVertexData, allow32BitsIndices);
  101554. }
  101555. else {
  101556. vertexData = otherVertexData;
  101557. source = mesh;
  101558. }
  101559. if (subdivideWithSubMeshes) {
  101560. indiceArray.push(mesh.getTotalIndices());
  101561. }
  101562. if (multiMultiMaterials) {
  101563. if (mesh.material) {
  101564. var material = mesh.material;
  101565. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_15__["MultiMaterial"]) {
  101566. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  101567. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  101568. materialArray.push(material.subMaterials[matIndex]);
  101569. }
  101570. }
  101571. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  101572. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  101573. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  101574. }
  101575. }
  101576. else {
  101577. if (materialArray.indexOf(material) < 0) {
  101578. materialArray.push(material);
  101579. }
  101580. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  101581. materialIndexArray.push(materialArray.indexOf(material));
  101582. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  101583. }
  101584. }
  101585. }
  101586. else {
  101587. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  101588. materialIndexArray.push(0);
  101589. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  101590. }
  101591. }
  101592. }
  101593. }
  101594. }
  101595. source = source;
  101596. if (!meshSubclass) {
  101597. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  101598. }
  101599. vertexData.applyToMesh(meshSubclass);
  101600. // Setting properties
  101601. meshSubclass.checkCollisions = source.checkCollisions;
  101602. // Cleaning
  101603. if (disposeSource) {
  101604. for (index = 0; index < meshes.length; index++) {
  101605. if (meshes[index]) {
  101606. meshes[index].dispose();
  101607. }
  101608. }
  101609. }
  101610. // Subdivide
  101611. if (subdivideWithSubMeshes || multiMultiMaterials) {
  101612. //-- removal of global submesh
  101613. meshSubclass.releaseSubMeshes();
  101614. index = 0;
  101615. var offset = 0;
  101616. //-- apply subdivision according to index table
  101617. while (index < indiceArray.length) {
  101618. _subMesh__WEBPACK_IMPORTED_MODULE_12__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  101619. offset += indiceArray[index];
  101620. index++;
  101621. }
  101622. }
  101623. if (multiMultiMaterials) {
  101624. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_15__["MultiMaterial"](source.name + "_merged", source.getScene());
  101625. newMultiMaterial.subMaterials = materialArray;
  101626. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  101627. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  101628. }
  101629. meshSubclass.material = newMultiMaterial;
  101630. }
  101631. else {
  101632. meshSubclass.material = source.material;
  101633. }
  101634. return meshSubclass;
  101635. };
  101636. /** @hidden */
  101637. Mesh.prototype.addInstance = function (instance) {
  101638. instance._indexInSourceMeshInstanceArray = this.instances.length;
  101639. this.instances.push(instance);
  101640. };
  101641. /** @hidden */
  101642. Mesh.prototype.removeInstance = function (instance) {
  101643. // Remove from mesh
  101644. var index = instance._indexInSourceMeshInstanceArray;
  101645. if (index != -1) {
  101646. if (index !== this.instances.length - 1) {
  101647. var last = this.instances[this.instances.length - 1];
  101648. this.instances[index] = last;
  101649. last._indexInSourceMeshInstanceArray = index;
  101650. }
  101651. instance._indexInSourceMeshInstanceArray = -1;
  101652. this.instances.pop();
  101653. }
  101654. };
  101655. // Consts
  101656. /**
  101657. * Mesh side orientation : usually the external or front surface
  101658. */
  101659. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].FRONTSIDE;
  101660. /**
  101661. * Mesh side orientation : usually the internal or back surface
  101662. */
  101663. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].BACKSIDE;
  101664. /**
  101665. * Mesh side orientation : both internal and external or front and back surfaces
  101666. */
  101667. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].DOUBLESIDE;
  101668. /**
  101669. * Mesh side orientation : by default, `FRONTSIDE`
  101670. */
  101671. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"].DEFAULTSIDE;
  101672. /**
  101673. * Mesh cap setting : no cap
  101674. */
  101675. Mesh.NO_CAP = 0;
  101676. /**
  101677. * Mesh cap setting : one cap at the beginning of the mesh
  101678. */
  101679. Mesh.CAP_START = 1;
  101680. /**
  101681. * Mesh cap setting : one cap at the end of the mesh
  101682. */
  101683. Mesh.CAP_END = 2;
  101684. /**
  101685. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  101686. */
  101687. Mesh.CAP_ALL = 3;
  101688. /**
  101689. * Mesh pattern setting : no flip or rotate
  101690. */
  101691. Mesh.NO_FLIP = 0;
  101692. /**
  101693. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  101694. */
  101695. Mesh.FLIP_TILE = 1;
  101696. /**
  101697. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  101698. */
  101699. Mesh.ROTATE_TILE = 2;
  101700. /**
  101701. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  101702. */
  101703. Mesh.FLIP_ROW = 3;
  101704. /**
  101705. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  101706. */
  101707. Mesh.ROTATE_ROW = 4;
  101708. /**
  101709. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  101710. */
  101711. Mesh.FLIP_N_ROTATE_TILE = 5;
  101712. /**
  101713. * Mesh pattern setting : rotate pattern and rotate
  101714. */
  101715. Mesh.FLIP_N_ROTATE_ROW = 6;
  101716. /**
  101717. * Mesh tile positioning : part tiles same on left/right or top/bottom
  101718. */
  101719. Mesh.CENTER = 0;
  101720. /**
  101721. * Mesh tile positioning : part tiles on left
  101722. */
  101723. Mesh.LEFT = 1;
  101724. /**
  101725. * Mesh tile positioning : part tiles on right
  101726. */
  101727. Mesh.RIGHT = 2;
  101728. /**
  101729. * Mesh tile positioning : part tiles on top
  101730. */
  101731. Mesh.TOP = 3;
  101732. /**
  101733. * Mesh tile positioning : part tiles on bottom
  101734. */
  101735. Mesh.BOTTOM = 4;
  101736. // Statics
  101737. /** @hidden */
  101738. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  101739. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_21__["_DevTools"].WarnImport("GroundMesh");
  101740. };
  101741. return Mesh;
  101742. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_11__["AbstractMesh"]));
  101743. /***/ }),
  101744. /***/ "./Meshes/mesh.vertexData.ts":
  101745. /*!***********************************!*\
  101746. !*** ./Meshes/mesh.vertexData.ts ***!
  101747. \***********************************/
  101748. /*! exports provided: VertexData */
  101749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101750. "use strict";
  101751. __webpack_require__.r(__webpack_exports__);
  101752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  101753. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  101754. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  101755. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  101756. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  101757. /**
  101758. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  101759. */
  101760. var VertexData = /** @class */ (function () {
  101761. function VertexData() {
  101762. }
  101763. /**
  101764. * Uses the passed data array to set the set the values for the specified kind of data
  101765. * @param data a linear array of floating numbers
  101766. * @param kind the type of data that is being set, eg positions, colors etc
  101767. */
  101768. VertexData.prototype.set = function (data, kind) {
  101769. switch (kind) {
  101770. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  101771. this.positions = data;
  101772. break;
  101773. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  101774. this.normals = data;
  101775. break;
  101776. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  101777. this.tangents = data;
  101778. break;
  101779. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  101780. this.uvs = data;
  101781. break;
  101782. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  101783. this.uvs2 = data;
  101784. break;
  101785. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  101786. this.uvs3 = data;
  101787. break;
  101788. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  101789. this.uvs4 = data;
  101790. break;
  101791. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  101792. this.uvs5 = data;
  101793. break;
  101794. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  101795. this.uvs6 = data;
  101796. break;
  101797. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  101798. this.colors = data;
  101799. break;
  101800. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  101801. this.matricesIndices = data;
  101802. break;
  101803. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  101804. this.matricesWeights = data;
  101805. break;
  101806. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  101807. this.matricesIndicesExtra = data;
  101808. break;
  101809. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  101810. this.matricesWeightsExtra = data;
  101811. break;
  101812. }
  101813. };
  101814. /**
  101815. * Associates the vertexData to the passed Mesh.
  101816. * Sets it as updatable or not (default `false`)
  101817. * @param mesh the mesh the vertexData is applied to
  101818. * @param updatable when used and having the value true allows new data to update the vertexData
  101819. * @returns the VertexData
  101820. */
  101821. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  101822. this._applyTo(mesh, updatable);
  101823. return this;
  101824. };
  101825. /**
  101826. * Associates the vertexData to the passed Geometry.
  101827. * Sets it as updatable or not (default `false`)
  101828. * @param geometry the geometry the vertexData is applied to
  101829. * @param updatable when used and having the value true allows new data to update the vertexData
  101830. * @returns VertexData
  101831. */
  101832. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  101833. this._applyTo(geometry, updatable);
  101834. return this;
  101835. };
  101836. /**
  101837. * Updates the associated mesh
  101838. * @param mesh the mesh to be updated
  101839. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  101840. * @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
  101841. * @returns VertexData
  101842. */
  101843. VertexData.prototype.updateMesh = function (mesh) {
  101844. this._update(mesh);
  101845. return this;
  101846. };
  101847. /**
  101848. * Updates the associated geometry
  101849. * @param geometry the geometry to be updated
  101850. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  101851. * @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
  101852. * @returns VertexData.
  101853. */
  101854. VertexData.prototype.updateGeometry = function (geometry) {
  101855. this._update(geometry);
  101856. return this;
  101857. };
  101858. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  101859. if (updatable === void 0) { updatable = false; }
  101860. if (this.positions) {
  101861. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  101862. }
  101863. if (this.normals) {
  101864. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  101865. }
  101866. if (this.tangents) {
  101867. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  101868. }
  101869. if (this.uvs) {
  101870. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  101871. }
  101872. if (this.uvs2) {
  101873. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  101874. }
  101875. if (this.uvs3) {
  101876. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  101877. }
  101878. if (this.uvs4) {
  101879. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  101880. }
  101881. if (this.uvs5) {
  101882. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  101883. }
  101884. if (this.uvs6) {
  101885. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  101886. }
  101887. if (this.colors) {
  101888. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  101889. }
  101890. if (this.matricesIndices) {
  101891. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  101892. }
  101893. if (this.matricesWeights) {
  101894. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  101895. }
  101896. if (this.matricesIndicesExtra) {
  101897. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  101898. }
  101899. if (this.matricesWeightsExtra) {
  101900. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  101901. }
  101902. if (this.indices) {
  101903. meshOrGeometry.setIndices(this.indices, null, updatable);
  101904. }
  101905. else {
  101906. meshOrGeometry.setIndices([], null);
  101907. }
  101908. return this;
  101909. };
  101910. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  101911. if (this.positions) {
  101912. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  101913. }
  101914. if (this.normals) {
  101915. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  101916. }
  101917. if (this.tangents) {
  101918. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  101919. }
  101920. if (this.uvs) {
  101921. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  101922. }
  101923. if (this.uvs2) {
  101924. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  101925. }
  101926. if (this.uvs3) {
  101927. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  101928. }
  101929. if (this.uvs4) {
  101930. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  101931. }
  101932. if (this.uvs5) {
  101933. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  101934. }
  101935. if (this.uvs6) {
  101936. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  101937. }
  101938. if (this.colors) {
  101939. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  101940. }
  101941. if (this.matricesIndices) {
  101942. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  101943. }
  101944. if (this.matricesWeights) {
  101945. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  101946. }
  101947. if (this.matricesIndicesExtra) {
  101948. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  101949. }
  101950. if (this.matricesWeightsExtra) {
  101951. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  101952. }
  101953. if (this.indices) {
  101954. meshOrGeometry.setIndices(this.indices, null);
  101955. }
  101956. return this;
  101957. };
  101958. /**
  101959. * Transforms each position and each normal of the vertexData according to the passed Matrix
  101960. * @param matrix the transforming matrix
  101961. * @returns the VertexData
  101962. */
  101963. VertexData.prototype.transform = function (matrix) {
  101964. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  101965. var transformed = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101966. var index;
  101967. if (this.positions) {
  101968. var position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101969. for (index = 0; index < this.positions.length; index += 3) {
  101970. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  101971. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  101972. this.positions[index] = transformed.x;
  101973. this.positions[index + 1] = transformed.y;
  101974. this.positions[index + 2] = transformed.z;
  101975. }
  101976. }
  101977. if (this.normals) {
  101978. var normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101979. for (index = 0; index < this.normals.length; index += 3) {
  101980. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  101981. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  101982. this.normals[index] = transformed.x;
  101983. this.normals[index + 1] = transformed.y;
  101984. this.normals[index + 2] = transformed.z;
  101985. }
  101986. }
  101987. if (this.tangents) {
  101988. var tangent = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  101989. var tangentTransformed = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  101990. for (index = 0; index < this.tangents.length; index += 4) {
  101991. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  101992. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  101993. this.tangents[index] = tangentTransformed.x;
  101994. this.tangents[index + 1] = tangentTransformed.y;
  101995. this.tangents[index + 2] = tangentTransformed.z;
  101996. this.tangents[index + 3] = tangentTransformed.w;
  101997. }
  101998. }
  101999. if (flip && this.indices) {
  102000. for (index = 0; index < this.indices.length; index += 3) {
  102001. var tmp = this.indices[index + 1];
  102002. this.indices[index + 1] = this.indices[index + 2];
  102003. this.indices[index + 2] = tmp;
  102004. }
  102005. }
  102006. return this;
  102007. };
  102008. /**
  102009. * Merges the passed VertexData into the current one
  102010. * @param other the VertexData to be merged into the current one
  102011. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102012. * @returns the modified VertexData
  102013. */
  102014. VertexData.prototype.merge = function (other, use32BitsIndices) {
  102015. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  102016. this._validate();
  102017. other._validate();
  102018. if (!this.normals !== !other.normals ||
  102019. !this.tangents !== !other.tangents ||
  102020. !this.uvs !== !other.uvs ||
  102021. !this.uvs2 !== !other.uvs2 ||
  102022. !this.uvs3 !== !other.uvs3 ||
  102023. !this.uvs4 !== !other.uvs4 ||
  102024. !this.uvs5 !== !other.uvs5 ||
  102025. !this.uvs6 !== !other.uvs6 ||
  102026. !this.colors !== !other.colors ||
  102027. !this.matricesIndices !== !other.matricesIndices ||
  102028. !this.matricesWeights !== !other.matricesWeights ||
  102029. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  102030. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  102031. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  102032. }
  102033. if (other.indices) {
  102034. if (!this.indices) {
  102035. this.indices = [];
  102036. }
  102037. var offset = this.positions ? this.positions.length / 3 : 0;
  102038. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  102039. if (isSrcTypedArray) {
  102040. var len = this.indices.length + other.indices.length;
  102041. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  102042. temp.set(this.indices);
  102043. var decal = this.indices.length;
  102044. for (var index = 0; index < other.indices.length; index++) {
  102045. temp[decal + index] = other.indices[index] + offset;
  102046. }
  102047. this.indices = temp;
  102048. }
  102049. else {
  102050. for (var index = 0; index < other.indices.length; index++) {
  102051. this.indices.push(other.indices[index] + offset);
  102052. }
  102053. }
  102054. }
  102055. this.positions = this._mergeElement(this.positions, other.positions);
  102056. this.normals = this._mergeElement(this.normals, other.normals);
  102057. this.tangents = this._mergeElement(this.tangents, other.tangents);
  102058. this.uvs = this._mergeElement(this.uvs, other.uvs);
  102059. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  102060. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  102061. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  102062. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  102063. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  102064. this.colors = this._mergeElement(this.colors, other.colors);
  102065. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  102066. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  102067. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  102068. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  102069. return this;
  102070. };
  102071. VertexData.prototype._mergeElement = function (source, other) {
  102072. if (!source) {
  102073. return other;
  102074. }
  102075. if (!other) {
  102076. return source;
  102077. }
  102078. var len = other.length + source.length;
  102079. var isSrcTypedArray = source instanceof Float32Array;
  102080. var isOthTypedArray = other instanceof Float32Array;
  102081. // use non-loop method when the source is Float32Array
  102082. if (isSrcTypedArray) {
  102083. var ret32 = new Float32Array(len);
  102084. ret32.set(source);
  102085. ret32.set(other, source.length);
  102086. return ret32;
  102087. // source is number[], when other is also use concat
  102088. }
  102089. else if (!isOthTypedArray) {
  102090. return source.concat(other);
  102091. // source is a number[], but other is a Float32Array, loop required
  102092. }
  102093. else {
  102094. var ret = source.slice(0); // copy source to a separate array
  102095. for (var i = 0, len = other.length; i < len; i++) {
  102096. ret.push(other[i]);
  102097. }
  102098. return ret;
  102099. }
  102100. };
  102101. VertexData.prototype._validate = function () {
  102102. if (!this.positions) {
  102103. throw new Error("Positions are required");
  102104. }
  102105. var getElementCount = function (kind, values) {
  102106. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  102107. if ((values.length % stride) !== 0) {
  102108. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  102109. }
  102110. return values.length / stride;
  102111. };
  102112. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  102113. var validateElementCount = function (kind, values) {
  102114. var elementCount = getElementCount(kind, values);
  102115. if (elementCount !== positionsElementCount) {
  102116. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  102117. }
  102118. };
  102119. if (this.normals) {
  102120. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  102121. }
  102122. if (this.tangents) {
  102123. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  102124. }
  102125. if (this.uvs) {
  102126. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  102127. }
  102128. if (this.uvs2) {
  102129. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  102130. }
  102131. if (this.uvs3) {
  102132. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  102133. }
  102134. if (this.uvs4) {
  102135. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  102136. }
  102137. if (this.uvs5) {
  102138. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  102139. }
  102140. if (this.uvs6) {
  102141. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  102142. }
  102143. if (this.colors) {
  102144. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  102145. }
  102146. if (this.matricesIndices) {
  102147. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  102148. }
  102149. if (this.matricesWeights) {
  102150. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  102151. }
  102152. if (this.matricesIndicesExtra) {
  102153. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  102154. }
  102155. if (this.matricesWeightsExtra) {
  102156. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  102157. }
  102158. };
  102159. /**
  102160. * Serializes the VertexData
  102161. * @returns a serialized object
  102162. */
  102163. VertexData.prototype.serialize = function () {
  102164. var serializationObject = this.serialize();
  102165. if (this.positions) {
  102166. serializationObject.positions = this.positions;
  102167. }
  102168. if (this.normals) {
  102169. serializationObject.normals = this.normals;
  102170. }
  102171. if (this.tangents) {
  102172. serializationObject.tangents = this.tangents;
  102173. }
  102174. if (this.uvs) {
  102175. serializationObject.uvs = this.uvs;
  102176. }
  102177. if (this.uvs2) {
  102178. serializationObject.uvs2 = this.uvs2;
  102179. }
  102180. if (this.uvs3) {
  102181. serializationObject.uvs3 = this.uvs3;
  102182. }
  102183. if (this.uvs4) {
  102184. serializationObject.uvs4 = this.uvs4;
  102185. }
  102186. if (this.uvs5) {
  102187. serializationObject.uvs5 = this.uvs5;
  102188. }
  102189. if (this.uvs6) {
  102190. serializationObject.uvs6 = this.uvs6;
  102191. }
  102192. if (this.colors) {
  102193. serializationObject.colors = this.colors;
  102194. }
  102195. if (this.matricesIndices) {
  102196. serializationObject.matricesIndices = this.matricesIndices;
  102197. serializationObject.matricesIndices._isExpanded = true;
  102198. }
  102199. if (this.matricesWeights) {
  102200. serializationObject.matricesWeights = this.matricesWeights;
  102201. }
  102202. if (this.matricesIndicesExtra) {
  102203. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  102204. serializationObject.matricesIndicesExtra._isExpanded = true;
  102205. }
  102206. if (this.matricesWeightsExtra) {
  102207. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  102208. }
  102209. serializationObject.indices = this.indices;
  102210. return serializationObject;
  102211. };
  102212. // Statics
  102213. /**
  102214. * Extracts the vertexData from a mesh
  102215. * @param mesh the mesh from which to extract the VertexData
  102216. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102217. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102218. * @returns the object VertexData associated to the passed mesh
  102219. */
  102220. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  102221. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  102222. };
  102223. /**
  102224. * Extracts the vertexData from the geometry
  102225. * @param geometry the geometry from which to extract the VertexData
  102226. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102227. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102228. * @returns the object VertexData associated to the passed mesh
  102229. */
  102230. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  102231. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  102232. };
  102233. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  102234. var result = new VertexData();
  102235. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  102236. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  102237. }
  102238. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  102239. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  102240. }
  102241. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  102242. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  102243. }
  102244. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  102245. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  102246. }
  102247. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  102248. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  102249. }
  102250. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  102251. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  102252. }
  102253. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  102254. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  102255. }
  102256. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  102257. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  102258. }
  102259. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  102260. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  102261. }
  102262. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  102263. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  102264. }
  102265. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  102266. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  102267. }
  102268. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  102269. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  102270. }
  102271. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  102272. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  102273. }
  102274. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  102275. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  102276. }
  102277. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  102278. return result;
  102279. };
  102280. /**
  102281. * Creates the VertexData for a Ribbon
  102282. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102283. * * pathArray array of paths, each of which an array of successive Vector3
  102284. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102285. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102286. * * 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
  102287. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102288. * * 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)
  102289. * * 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)
  102290. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102291. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102292. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102293. * @returns the VertexData of the ribbon
  102294. */
  102295. VertexData.CreateRibbon = function (options) {
  102296. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  102297. };
  102298. /**
  102299. * Creates the VertexData for a box
  102300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102301. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102302. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102303. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102304. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102305. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102306. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102308. * * 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)
  102309. * * 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)
  102310. * @returns the VertexData of the box
  102311. */
  102312. VertexData.CreateBox = function (options) {
  102313. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  102314. };
  102315. /**
  102316. * Creates the VertexData for a tiled box
  102317. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102318. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102319. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102320. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102322. * @returns the VertexData of the box
  102323. */
  102324. VertexData.CreateTiledBox = function (options) {
  102325. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("tiledBoxBuilder");
  102326. };
  102327. /**
  102328. * Creates the VertexData for a tiled plane
  102329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102330. * * pattern a limited pattern arrangement depending on the number
  102331. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102332. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102333. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102335. * * 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)
  102336. * * 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)
  102337. * @returns the VertexData of the tiled plane
  102338. */
  102339. VertexData.CreateTiledPlane = function (options) {
  102340. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("tiledPlaneBuilder");
  102341. };
  102342. /**
  102343. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102344. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102345. * * segments sets the number of horizontal strips optional, default 32
  102346. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102347. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102348. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102349. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102350. * * 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
  102351. * * 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
  102352. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102353. * * 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)
  102354. * * 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)
  102355. * @returns the VertexData of the ellipsoid
  102356. */
  102357. VertexData.CreateSphere = function (options) {
  102358. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  102359. };
  102360. /**
  102361. * Creates the VertexData for a cylinder, cone or prism
  102362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102363. * * height sets the height (y direction) of the cylinder, optional, default 2
  102364. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102365. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102366. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102367. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102368. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102369. * * 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
  102370. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102371. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102372. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102373. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102375. * * 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)
  102376. * * 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)
  102377. * @returns the VertexData of the cylinder, cone or prism
  102378. */
  102379. VertexData.CreateCylinder = function (options) {
  102380. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  102381. };
  102382. /**
  102383. * Creates the VertexData for a torus
  102384. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102385. * * diameter the diameter of the torus, optional default 1
  102386. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102387. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102389. * * 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)
  102390. * * 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)
  102391. * @returns the VertexData of the torus
  102392. */
  102393. VertexData.CreateTorus = function (options) {
  102394. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  102395. };
  102396. /**
  102397. * Creates the VertexData of the LineSystem
  102398. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102399. * - lines an array of lines, each line being an array of successive Vector3
  102400. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102401. * @returns the VertexData of the LineSystem
  102402. */
  102403. VertexData.CreateLineSystem = function (options) {
  102404. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  102405. };
  102406. /**
  102407. * Create the VertexData for a DashedLines
  102408. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102409. * - points an array successive Vector3
  102410. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102411. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102412. * - dashNb the intended total number of dashes, optional, default 200
  102413. * @returns the VertexData for the DashedLines
  102414. */
  102415. VertexData.CreateDashedLines = function (options) {
  102416. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  102417. };
  102418. /**
  102419. * Creates the VertexData for a Ground
  102420. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102421. * - width the width (x direction) of the ground, optional, default 1
  102422. * - height the height (z direction) of the ground, optional, default 1
  102423. * - subdivisions the number of subdivisions per side, optional, default 1
  102424. * @returns the VertexData of the Ground
  102425. */
  102426. VertexData.CreateGround = function (options) {
  102427. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  102428. };
  102429. /**
  102430. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102431. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102432. * * xmin the ground minimum X coordinate, optional, default -1
  102433. * * zmin the ground minimum Z coordinate, optional, default -1
  102434. * * xmax the ground maximum X coordinate, optional, default 1
  102435. * * zmax the ground maximum Z coordinate, optional, default 1
  102436. * * 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}
  102437. * * 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}
  102438. * @returns the VertexData of the TiledGround
  102439. */
  102440. VertexData.CreateTiledGround = function (options) {
  102441. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  102442. };
  102443. /**
  102444. * Creates the VertexData of the Ground designed from a heightmap
  102445. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102446. * * width the width (x direction) of the ground
  102447. * * height the height (z direction) of the ground
  102448. * * subdivisions the number of subdivisions per side
  102449. * * minHeight the minimum altitude on the ground, optional, default 0
  102450. * * maxHeight the maximum altitude on the ground, optional default 1
  102451. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102452. * * buffer the array holding the image color data
  102453. * * bufferWidth the width of image
  102454. * * bufferHeight the height of image
  102455. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102456. * @returns the VertexData of the Ground designed from a heightmap
  102457. */
  102458. VertexData.CreateGroundFromHeightMap = function (options) {
  102459. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  102460. };
  102461. /**
  102462. * Creates the VertexData for a Plane
  102463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102464. * * size sets the width and height of the plane to the value of size, optional default 1
  102465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102468. * * 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)
  102469. * * 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)
  102470. * @returns the VertexData of the box
  102471. */
  102472. VertexData.CreatePlane = function (options) {
  102473. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  102474. };
  102475. /**
  102476. * Creates the VertexData of the Disc or regular Polygon
  102477. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102478. * * radius the radius of the disc, optional default 0.5
  102479. * * tessellation the number of polygon sides, optional, default 64
  102480. * * 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
  102481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102482. * * 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)
  102483. * * 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)
  102484. * @returns the VertexData of the box
  102485. */
  102486. VertexData.CreateDisc = function (options) {
  102487. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  102488. };
  102489. /**
  102490. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102491. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102492. * @param polygon a mesh built from polygonTriangulation.build()
  102493. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102494. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102495. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102496. * @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)
  102497. * @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)
  102498. * @returns the VertexData of the Polygon
  102499. */
  102500. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  102501. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  102502. };
  102503. /**
  102504. * Creates the VertexData of the IcoSphere
  102505. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102506. * * radius the radius of the IcoSphere, optional default 1
  102507. * * radiusX allows stretching in the x direction, optional, default radius
  102508. * * radiusY allows stretching in the y direction, optional, default radius
  102509. * * radiusZ allows stretching in the z direction, optional, default radius
  102510. * * flat when true creates a flat shaded mesh, optional, default true
  102511. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102513. * * 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)
  102514. * * 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)
  102515. * @returns the VertexData of the IcoSphere
  102516. */
  102517. VertexData.CreateIcoSphere = function (options) {
  102518. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  102519. };
  102520. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  102521. /**
  102522. * Creates the VertexData for a Polyhedron
  102523. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102524. * * type provided types are:
  102525. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102526. * * 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)
  102527. * * size the size of the IcoSphere, optional default 1
  102528. * * sizeX allows stretching in the x direction, optional, default size
  102529. * * sizeY allows stretching in the y direction, optional, default size
  102530. * * sizeZ allows stretching in the z direction, optional, default size
  102531. * * 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
  102532. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102533. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102534. * * flat when true creates a flat shaded mesh, optional, default true
  102535. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102537. * * 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)
  102538. * * 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)
  102539. * @returns the VertexData of the Polyhedron
  102540. */
  102541. VertexData.CreatePolyhedron = function (options) {
  102542. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  102543. };
  102544. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  102545. /**
  102546. * Creates the VertexData for a TorusKnot
  102547. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102548. * * radius the radius of the torus knot, optional, default 2
  102549. * * tube the thickness of the tube, optional, default 0.5
  102550. * * radialSegments the number of sides on each tube segments, optional, default 32
  102551. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102552. * * p the number of windings around the z axis, optional, default 2
  102553. * * q the number of windings around the x axis, optional, default 3
  102554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102555. * * 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)
  102556. * * 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)
  102557. * @returns the VertexData of the Torus Knot
  102558. */
  102559. VertexData.CreateTorusKnot = function (options) {
  102560. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  102561. };
  102562. // Tools
  102563. /**
  102564. * Compute normals for given positions and indices
  102565. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102566. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102567. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102568. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102569. * * facetNormals : optional array of facet normals (vector3)
  102570. * * facetPositions : optional array of facet positions (vector3)
  102571. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102572. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102573. * * bInfo : optional bounding info, required for facetPartitioning computation
  102574. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102575. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102576. * * useRightHandedSystem: optional boolean to for right handed system computation
  102577. * * depthSort : optional boolean to enable the facet depth sort computation
  102578. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102579. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102580. */
  102581. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  102582. // temporary scalar variables
  102583. var index = 0; // facet index
  102584. var p1p2x = 0.0; // p1p2 vector x coordinate
  102585. var p1p2y = 0.0; // p1p2 vector y coordinate
  102586. var p1p2z = 0.0; // p1p2 vector z coordinate
  102587. var p3p2x = 0.0; // p3p2 vector x coordinate
  102588. var p3p2y = 0.0; // p3p2 vector y coordinate
  102589. var p3p2z = 0.0; // p3p2 vector z coordinate
  102590. var faceNormalx = 0.0; // facet normal x coordinate
  102591. var faceNormaly = 0.0; // facet normal y coordinate
  102592. var faceNormalz = 0.0; // facet normal z coordinate
  102593. var length = 0.0; // facet normal length before normalization
  102594. var v1x = 0; // vector1 x index in the positions array
  102595. var v1y = 0; // vector1 y index in the positions array
  102596. var v1z = 0; // vector1 z index in the positions array
  102597. var v2x = 0; // vector2 x index in the positions array
  102598. var v2y = 0; // vector2 y index in the positions array
  102599. var v2z = 0; // vector2 z index in the positions array
  102600. var v3x = 0; // vector3 x index in the positions array
  102601. var v3y = 0; // vector3 y index in the positions array
  102602. var v3z = 0; // vector3 z index in the positions array
  102603. var computeFacetNormals = false;
  102604. var computeFacetPositions = false;
  102605. var computeFacetPartitioning = false;
  102606. var computeDepthSort = false;
  102607. var faceNormalSign = 1;
  102608. var ratio = 0;
  102609. var distanceTo = null;
  102610. if (options) {
  102611. computeFacetNormals = (options.facetNormals) ? true : false;
  102612. computeFacetPositions = (options.facetPositions) ? true : false;
  102613. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  102614. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  102615. ratio = options.ratio || 0;
  102616. computeDepthSort = (options.depthSort) ? true : false;
  102617. distanceTo = (options.distanceTo);
  102618. if (computeDepthSort) {
  102619. if (distanceTo === undefined) {
  102620. distanceTo = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102621. }
  102622. var depthSortedFacets = options.depthSortedFacets;
  102623. }
  102624. }
  102625. // facetPartitioning reinit if needed
  102626. var xSubRatio = 0;
  102627. var ySubRatio = 0;
  102628. var zSubRatio = 0;
  102629. var subSq = 0;
  102630. if (computeFacetPartitioning && options && options.bbSize) {
  102631. var ox = 0; // X partitioning index for facet position
  102632. var oy = 0; // Y partinioning index for facet position
  102633. var oz = 0; // Z partinioning index for facet position
  102634. var b1x = 0; // X partitioning index for facet v1 vertex
  102635. var b1y = 0; // Y partitioning index for facet v1 vertex
  102636. var b1z = 0; // z partitioning index for facet v1 vertex
  102637. var b2x = 0; // X partitioning index for facet v2 vertex
  102638. var b2y = 0; // Y partitioning index for facet v2 vertex
  102639. var b2z = 0; // Z partitioning index for facet v2 vertex
  102640. var b3x = 0; // X partitioning index for facet v3 vertex
  102641. var b3y = 0; // Y partitioning index for facet v3 vertex
  102642. var b3z = 0; // Z partitioning index for facet v3 vertex
  102643. var block_idx_o = 0; // facet barycenter block index
  102644. var block_idx_v1 = 0; // v1 vertex block index
  102645. var block_idx_v2 = 0; // v2 vertex block index
  102646. var block_idx_v3 = 0; // v3 vertex block index
  102647. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  102648. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  102649. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  102650. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  102651. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  102652. subSq = options.subDiv.max * options.subDiv.max;
  102653. options.facetPartitioning.length = 0;
  102654. }
  102655. // reset the normals
  102656. for (index = 0; index < positions.length; index++) {
  102657. normals[index] = 0.0;
  102658. }
  102659. // Loop : 1 indice triplet = 1 facet
  102660. var nbFaces = (indices.length / 3) | 0;
  102661. for (index = 0; index < nbFaces; index++) {
  102662. // get the indexes of the coordinates of each vertex of the facet
  102663. v1x = indices[index * 3] * 3;
  102664. v1y = v1x + 1;
  102665. v1z = v1x + 2;
  102666. v2x = indices[index * 3 + 1] * 3;
  102667. v2y = v2x + 1;
  102668. v2z = v2x + 2;
  102669. v3x = indices[index * 3 + 2] * 3;
  102670. v3y = v3x + 1;
  102671. v3z = v3x + 2;
  102672. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  102673. p1p2y = positions[v1y] - positions[v2y];
  102674. p1p2z = positions[v1z] - positions[v2z];
  102675. p3p2x = positions[v3x] - positions[v2x];
  102676. p3p2y = positions[v3y] - positions[v2y];
  102677. p3p2z = positions[v3z] - positions[v2z];
  102678. // compute the face normal with the cross product
  102679. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  102680. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  102681. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  102682. // normalize this normal and store it in the array facetData
  102683. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  102684. length = (length === 0) ? 1.0 : length;
  102685. faceNormalx /= length;
  102686. faceNormaly /= length;
  102687. faceNormalz /= length;
  102688. if (computeFacetNormals && options) {
  102689. options.facetNormals[index].x = faceNormalx;
  102690. options.facetNormals[index].y = faceNormaly;
  102691. options.facetNormals[index].z = faceNormalz;
  102692. }
  102693. if (computeFacetPositions && options) {
  102694. // compute and the facet barycenter coordinates in the array facetPositions
  102695. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  102696. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  102697. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  102698. }
  102699. if (computeFacetPartitioning && options) {
  102700. // store the facet indexes in arrays in the main facetPartitioning array :
  102701. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  102702. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  102703. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  102704. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  102705. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  102706. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  102707. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  102708. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  102709. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  102710. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  102711. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  102712. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  102713. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  102714. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  102715. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  102716. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  102717. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  102718. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  102719. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  102720. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  102721. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  102722. // push each facet index in each block containing the vertex
  102723. options.facetPartitioning[block_idx_v1].push(index);
  102724. if (block_idx_v2 != block_idx_v1) {
  102725. options.facetPartitioning[block_idx_v2].push(index);
  102726. }
  102727. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  102728. options.facetPartitioning[block_idx_v3].push(index);
  102729. }
  102730. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  102731. options.facetPartitioning[block_idx_o].push(index);
  102732. }
  102733. }
  102734. if (computeDepthSort && options && options.facetPositions) {
  102735. var dsf = depthSortedFacets[index];
  102736. dsf.ind = index * 3;
  102737. dsf.sqDistance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  102738. }
  102739. // compute the normals anyway
  102740. normals[v1x] += faceNormalx; // accumulate all the normals per face
  102741. normals[v1y] += faceNormaly;
  102742. normals[v1z] += faceNormalz;
  102743. normals[v2x] += faceNormalx;
  102744. normals[v2y] += faceNormaly;
  102745. normals[v2z] += faceNormalz;
  102746. normals[v3x] += faceNormalx;
  102747. normals[v3y] += faceNormaly;
  102748. normals[v3z] += faceNormalz;
  102749. }
  102750. // last normalization of each normal
  102751. for (index = 0; index < normals.length / 3; index++) {
  102752. faceNormalx = normals[index * 3];
  102753. faceNormaly = normals[index * 3 + 1];
  102754. faceNormalz = normals[index * 3 + 2];
  102755. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  102756. length = (length === 0) ? 1.0 : length;
  102757. faceNormalx /= length;
  102758. faceNormaly /= length;
  102759. faceNormalz /= length;
  102760. normals[index * 3] = faceNormalx;
  102761. normals[index * 3 + 1] = faceNormaly;
  102762. normals[index * 3 + 2] = faceNormalz;
  102763. }
  102764. };
  102765. /** @hidden */
  102766. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  102767. var li = indices.length;
  102768. var ln = normals.length;
  102769. var i;
  102770. var n;
  102771. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  102772. switch (sideOrientation) {
  102773. case VertexData.FRONTSIDE:
  102774. // nothing changed
  102775. break;
  102776. case VertexData.BACKSIDE:
  102777. var tmp;
  102778. // indices
  102779. for (i = 0; i < li; i += 3) {
  102780. tmp = indices[i];
  102781. indices[i] = indices[i + 2];
  102782. indices[i + 2] = tmp;
  102783. }
  102784. // normals
  102785. for (n = 0; n < ln; n++) {
  102786. normals[n] = -normals[n];
  102787. }
  102788. break;
  102789. case VertexData.DOUBLESIDE:
  102790. // positions
  102791. var lp = positions.length;
  102792. var l = lp / 3;
  102793. for (var p = 0; p < lp; p++) {
  102794. positions[lp + p] = positions[p];
  102795. }
  102796. // indices
  102797. for (i = 0; i < li; i += 3) {
  102798. indices[i + li] = indices[i + 2] + l;
  102799. indices[i + 1 + li] = indices[i + 1] + l;
  102800. indices[i + 2 + li] = indices[i] + l;
  102801. }
  102802. // normals
  102803. for (n = 0; n < ln; n++) {
  102804. normals[ln + n] = -normals[n];
  102805. }
  102806. // uvs
  102807. var lu = uvs.length;
  102808. var u = 0;
  102809. for (u = 0; u < lu; u++) {
  102810. uvs[u + lu] = uvs[u];
  102811. }
  102812. frontUVs = frontUVs ? frontUVs : new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  102813. backUVs = backUVs ? backUVs : new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  102814. u = 0;
  102815. for (i = 0; i < lu / 2; i++) {
  102816. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  102817. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  102818. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  102819. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  102820. u += 2;
  102821. }
  102822. break;
  102823. }
  102824. };
  102825. /**
  102826. * Applies VertexData created from the imported parameters to the geometry
  102827. * @param parsedVertexData the parsed data from an imported file
  102828. * @param geometry the geometry to apply the VertexData to
  102829. */
  102830. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  102831. var vertexData = new VertexData();
  102832. // positions
  102833. var positions = parsedVertexData.positions;
  102834. if (positions) {
  102835. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  102836. }
  102837. // normals
  102838. var normals = parsedVertexData.normals;
  102839. if (normals) {
  102840. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  102841. }
  102842. // tangents
  102843. var tangents = parsedVertexData.tangents;
  102844. if (tangents) {
  102845. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  102846. }
  102847. // uvs
  102848. var uvs = parsedVertexData.uvs;
  102849. if (uvs) {
  102850. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  102851. }
  102852. // uv2s
  102853. var uv2s = parsedVertexData.uv2s;
  102854. if (uv2s) {
  102855. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  102856. }
  102857. // uv3s
  102858. var uv3s = parsedVertexData.uv3s;
  102859. if (uv3s) {
  102860. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  102861. }
  102862. // uv4s
  102863. var uv4s = parsedVertexData.uv4s;
  102864. if (uv4s) {
  102865. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  102866. }
  102867. // uv5s
  102868. var uv5s = parsedVertexData.uv5s;
  102869. if (uv5s) {
  102870. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  102871. }
  102872. // uv6s
  102873. var uv6s = parsedVertexData.uv6s;
  102874. if (uv6s) {
  102875. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  102876. }
  102877. // colors
  102878. var colors = parsedVertexData.colors;
  102879. if (colors) {
  102880. vertexData.set(_Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  102881. }
  102882. // matricesIndices
  102883. var matricesIndices = parsedVertexData.matricesIndices;
  102884. if (matricesIndices) {
  102885. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  102886. }
  102887. // matricesWeights
  102888. var matricesWeights = parsedVertexData.matricesWeights;
  102889. if (matricesWeights) {
  102890. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  102891. }
  102892. // indices
  102893. var indices = parsedVertexData.indices;
  102894. if (indices) {
  102895. vertexData.indices = indices;
  102896. }
  102897. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  102898. };
  102899. /**
  102900. * Mesh side orientation : usually the external or front surface
  102901. */
  102902. VertexData.FRONTSIDE = 0;
  102903. /**
  102904. * Mesh side orientation : usually the internal or back surface
  102905. */
  102906. VertexData.BACKSIDE = 1;
  102907. /**
  102908. * Mesh side orientation : both internal and external or front and back surfaces
  102909. */
  102910. VertexData.DOUBLESIDE = 2;
  102911. /**
  102912. * Mesh side orientation : by default, `FRONTSIDE`
  102913. */
  102914. VertexData.DEFAULTSIDE = 0;
  102915. return VertexData;
  102916. }());
  102917. /***/ }),
  102918. /***/ "./Meshes/meshBuilder.ts":
  102919. /*!*******************************!*\
  102920. !*** ./Meshes/meshBuilder.ts ***!
  102921. \*******************************/
  102922. /*! exports provided: MeshBuilder */
  102923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102924. "use strict";
  102925. __webpack_require__.r(__webpack_exports__);
  102926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  102927. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  102928. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  102929. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  102930. /* harmony import */ var _Builders_tiledBoxBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/tiledBoxBuilder */ "./Meshes/Builders/tiledBoxBuilder.ts");
  102931. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  102932. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  102933. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  102934. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  102935. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  102936. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  102937. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  102938. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  102939. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  102940. /* harmony import */ var _Builders_tiledPlaneBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tiledPlaneBuilder */ "./Meshes/Builders/tiledPlaneBuilder.ts");
  102941. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  102942. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  102943. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  102944. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  102945. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  102946. /**
  102947. * Class containing static functions to help procedurally build meshes
  102948. */
  102949. var MeshBuilder = /** @class */ (function () {
  102950. function MeshBuilder() {
  102951. }
  102952. /**
  102953. * Creates a box mesh
  102954. * * The parameter `size` sets the size (float) of each box side (default 1)
  102955. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  102956. * * 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)
  102957. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  102958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102959. * * 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
  102960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  102962. * @param name defines the name of the mesh
  102963. * @param options defines the options used to create the mesh
  102964. * @param scene defines the hosting scene
  102965. * @returns the box mesh
  102966. */
  102967. MeshBuilder.CreateBox = function (name, options, scene) {
  102968. if (scene === void 0) { scene = null; }
  102969. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  102970. };
  102971. /**
  102972. * Creates a tiled box mesh
  102973. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102975. * @param name defines the name of the mesh
  102976. * @param options defines the options used to create the mesh
  102977. * @param scene defines the hosting scene
  102978. * @returns the tiled box mesh
  102979. */
  102980. MeshBuilder.CreateTiledBox = function (name, options, scene) {
  102981. if (scene === void 0) { scene = null; }
  102982. return _Builders_tiledBoxBuilder__WEBPACK_IMPORTED_MODULE_3__["TiledBoxBuilder"].CreateTiledBox(name, options, scene);
  102983. };
  102984. /**
  102985. * Creates a sphere mesh
  102986. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  102987. * * 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`)
  102988. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  102989. * * 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
  102990. * * 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)
  102991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102992. * * 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
  102993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102994. * @param name defines the name of the mesh
  102995. * @param options defines the options used to create the mesh
  102996. * @param scene defines the hosting scene
  102997. * @returns the sphere mesh
  102998. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  102999. */
  103000. MeshBuilder.CreateSphere = function (name, options, scene) {
  103001. if (scene === void 0) { scene = null; }
  103002. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_4__["SphereBuilder"].CreateSphere(name, options, scene);
  103003. };
  103004. /**
  103005. * Creates a plane polygonal mesh. By default, this is a disc
  103006. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103007. * * 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
  103008. * * 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
  103009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103010. * * 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
  103011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103012. * @param name defines the name of the mesh
  103013. * @param options defines the options used to create the mesh
  103014. * @param scene defines the hosting scene
  103015. * @returns the plane polygonal mesh
  103016. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103017. */
  103018. MeshBuilder.CreateDisc = function (name, options, scene) {
  103019. if (scene === void 0) { scene = null; }
  103020. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  103021. };
  103022. /**
  103023. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103024. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103025. * * 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`)
  103026. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103027. * * 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
  103028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103029. * * 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
  103030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103031. * @param name defines the name of the mesh
  103032. * @param options defines the options used to create the mesh
  103033. * @param scene defines the hosting scene
  103034. * @returns the icosahedron mesh
  103035. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103036. */
  103037. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  103038. if (scene === void 0) { scene = null; }
  103039. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  103040. };
  103041. /**
  103042. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103043. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103044. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103045. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103046. * * 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
  103047. * * 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
  103048. * * 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
  103049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103050. * * 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
  103051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103052. * * 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
  103053. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103054. * * 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
  103055. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103057. * @param name defines the name of the mesh
  103058. * @param options defines the options used to create the mesh
  103059. * @param scene defines the hosting scene
  103060. * @returns the ribbon mesh
  103061. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103063. */
  103064. MeshBuilder.CreateRibbon = function (name, options, scene) {
  103065. if (scene === void 0) { scene = null; }
  103066. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  103067. };
  103068. /**
  103069. * Creates a cylinder or a cone mesh
  103070. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103071. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103072. * * 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.
  103073. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103074. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103075. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103076. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103077. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  103078. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103079. * * 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).
  103080. * * 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
  103081. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103082. * * 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
  103083. * * 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.
  103084. * * If `enclose` is false, a ring surface is one element.
  103085. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103086. * * 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
  103087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103088. * * 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
  103089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103090. * @param name defines the name of the mesh
  103091. * @param options defines the options used to create the mesh
  103092. * @param scene defines the hosting scene
  103093. * @returns the cylinder mesh
  103094. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103095. */
  103096. MeshBuilder.CreateCylinder = function (name, options, scene) {
  103097. if (scene === void 0) { scene = null; }
  103098. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"].CreateCylinder(name, options, scene);
  103099. };
  103100. /**
  103101. * Creates a torus mesh
  103102. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103103. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103104. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103106. * * 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
  103107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103108. * @param name defines the name of the mesh
  103109. * @param options defines the options used to create the mesh
  103110. * @param scene defines the hosting scene
  103111. * @returns the torus mesh
  103112. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103113. */
  103114. MeshBuilder.CreateTorus = function (name, options, scene) {
  103115. if (scene === void 0) { scene = null; }
  103116. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusBuilder"].CreateTorus(name, options, scene);
  103117. };
  103118. /**
  103119. * Creates a torus knot mesh
  103120. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103121. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103122. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103123. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103125. * * 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
  103126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103127. * @param name defines the name of the mesh
  103128. * @param options defines the options used to create the mesh
  103129. * @param scene defines the hosting scene
  103130. * @returns the torus knot mesh
  103131. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103132. */
  103133. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  103134. if (scene === void 0) { scene = null; }
  103135. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  103136. };
  103137. /**
  103138. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103139. * * 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
  103140. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103141. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103142. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103143. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103144. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103145. * * 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
  103146. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103149. * @param name defines the name of the new line system
  103150. * @param options defines the options used to create the line system
  103151. * @param scene defines the hosting scene
  103152. * @returns a new line system mesh
  103153. */
  103154. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  103155. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLineSystem(name, options, scene);
  103156. };
  103157. /**
  103158. * Creates a line mesh
  103159. * 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
  103160. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103161. * * The parameter `points` is an array successive Vector3
  103162. * * 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
  103163. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103164. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103165. * * When updating an instance, remember that only point positions can change, not the number of points
  103166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103168. * @param name defines the name of the new line system
  103169. * @param options defines the options used to create the line system
  103170. * @param scene defines the hosting scene
  103171. * @returns a new line mesh
  103172. */
  103173. MeshBuilder.CreateLines = function (name, options, scene) {
  103174. if (scene === void 0) { scene = null; }
  103175. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines(name, options, scene);
  103176. };
  103177. /**
  103178. * Creates a dashed line mesh
  103179. * * 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
  103180. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103181. * * The parameter `points` is an array successive Vector3
  103182. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103183. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103184. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103185. * * 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
  103186. * * When updating an instance, remember that only point positions can change, not the number of points
  103187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103188. * @param name defines the name of the mesh
  103189. * @param options defines the options used to create the mesh
  103190. * @param scene defines the hosting scene
  103191. * @returns the dashed line mesh
  103192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103193. */
  103194. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  103195. if (scene === void 0) { scene = null; }
  103196. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateDashedLines(name, options, scene);
  103197. };
  103198. /**
  103199. * 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.
  103200. * * 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.
  103201. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103202. * * 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.
  103203. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103204. * * 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
  103205. * * 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
  103206. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103208. * * 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
  103209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103211. * @param name defines the name of the mesh
  103212. * @param options defines the options used to create the mesh
  103213. * @param scene defines the hosting scene
  103214. * @returns the extruded shape mesh
  103215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103217. */
  103218. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  103219. if (scene === void 0) { scene = null; }
  103220. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  103221. };
  103222. /**
  103223. * Creates an custom extruded shape mesh.
  103224. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103225. * * 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.
  103226. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103227. * * 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
  103228. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103229. * * 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
  103230. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103231. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103232. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103233. * * 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
  103234. * * 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
  103235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103237. * * 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
  103238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103240. * @param name defines the name of the mesh
  103241. * @param options defines the options used to create the mesh
  103242. * @param scene defines the hosting scene
  103243. * @returns the custom extruded shape mesh
  103244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103247. */
  103248. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  103249. if (scene === void 0) { scene = null; }
  103250. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  103251. };
  103252. /**
  103253. * Creates lathe mesh.
  103254. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103255. * * 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
  103256. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103257. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103258. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103259. * * 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
  103260. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103261. * * 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
  103262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103263. * * 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
  103264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103266. * @param name defines the name of the mesh
  103267. * @param options defines the options used to create the mesh
  103268. * @param scene defines the hosting scene
  103269. * @returns the lathe mesh
  103270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103271. */
  103272. MeshBuilder.CreateLathe = function (name, options, scene) {
  103273. if (scene === void 0) { scene = null; }
  103274. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_11__["LatheBuilder"].CreateLathe(name, options, scene);
  103275. };
  103276. /**
  103277. * Creates a tiled plane mesh
  103278. * * You can set a limited pattern arrangement with the tiles
  103279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103280. * * 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
  103281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103282. * @param name defines the name of the mesh
  103283. * @param options defines the options used to create the mesh
  103284. * @param scene defines the hosting scene
  103285. * @returns the plane mesh
  103286. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103287. */
  103288. MeshBuilder.CreateTiledPlane = function (name, options, scene) {
  103289. if (scene === void 0) { scene = null; }
  103290. return _Builders_tiledPlaneBuilder__WEBPACK_IMPORTED_MODULE_13__["TiledPlaneBuilder"].CreateTiledPlane(name, options, scene);
  103291. };
  103292. /**
  103293. * Creates a plane mesh
  103294. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103295. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103296. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103298. * * 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
  103299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103300. * @param name defines the name of the mesh
  103301. * @param options defines the options used to create the mesh
  103302. * @param scene defines the hosting scene
  103303. * @returns the plane mesh
  103304. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103305. */
  103306. MeshBuilder.CreatePlane = function (name, options, scene) {
  103307. if (scene === void 0) { scene = null; }
  103308. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_12__["PlaneBuilder"].CreatePlane(name, options, scene);
  103309. };
  103310. /**
  103311. * Creates a ground mesh
  103312. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103313. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103315. * @param name defines the name of the mesh
  103316. * @param options defines the options used to create the mesh
  103317. * @param scene defines the hosting scene
  103318. * @returns the ground mesh
  103319. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  103320. */
  103321. MeshBuilder.CreateGround = function (name, options, scene) {
  103322. if (scene === void 0) { scene = null; }
  103323. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_14__["GroundBuilder"].CreateGround(name, options, scene);
  103324. };
  103325. /**
  103326. * Creates a tiled ground mesh
  103327. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  103328. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  103329. * * 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
  103330. * * 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
  103331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103332. * @param name defines the name of the mesh
  103333. * @param options defines the options used to create the mesh
  103334. * @param scene defines the hosting scene
  103335. * @returns the tiled ground mesh
  103336. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  103337. */
  103338. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  103339. if (scene === void 0) { scene = null; }
  103340. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_14__["GroundBuilder"].CreateTiledGround(name, options, scene);
  103341. };
  103342. /**
  103343. * Creates a ground mesh from a height map
  103344. * * The parameter `url` sets the URL of the height map image resource.
  103345. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103346. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103347. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103348. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  103349. * * 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.
  103350. * * 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).
  103351. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  103352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103353. * @param name defines the name of the mesh
  103354. * @param url defines the url to the height map
  103355. * @param options defines the options used to create the mesh
  103356. * @param scene defines the hosting scene
  103357. * @returns the ground mesh
  103358. * @see https://doc.babylonjs.com/babylon101/height_map
  103359. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  103360. */
  103361. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  103362. if (scene === void 0) { scene = null; }
  103363. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_14__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  103364. };
  103365. /**
  103366. * Creates a polygon mesh
  103367. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103368. * * 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
  103369. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103371. * * 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)
  103372. * * Remember you can only change the shape positions, not their number when updating a polygon
  103373. * @param name defines the name of the mesh
  103374. * @param options defines the options used to create the mesh
  103375. * @param scene defines the hosting scene
  103376. * @param earcutInjection can be used to inject your own earcut reference
  103377. * @returns the polygon mesh
  103378. */
  103379. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  103380. if (scene === void 0) { scene = null; }
  103381. if (earcutInjection === void 0) { earcutInjection = earcut; }
  103382. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  103383. };
  103384. /**
  103385. * Creates an extruded polygon mesh, with depth in the Y direction.
  103386. * * 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)
  103387. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103388. * @param name defines the name of the mesh
  103389. * @param options defines the options used to create the mesh
  103390. * @param scene defines the hosting scene
  103391. * @param earcutInjection can be used to inject your own earcut reference
  103392. * @returns the polygon mesh
  103393. */
  103394. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  103395. if (scene === void 0) { scene = null; }
  103396. if (earcutInjection === void 0) { earcutInjection = earcut; }
  103397. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  103398. };
  103399. /**
  103400. * Creates a tube mesh.
  103401. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103402. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103403. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103404. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103405. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103406. * * 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)
  103407. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103408. * * 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
  103409. * * 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
  103410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103411. * * 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
  103412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103414. * @param name defines the name of the mesh
  103415. * @param options defines the options used to create the mesh
  103416. * @param scene defines the hosting scene
  103417. * @returns the tube mesh
  103418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103419. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103420. */
  103421. MeshBuilder.CreateTube = function (name, options, scene) {
  103422. if (scene === void 0) { scene = null; }
  103423. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_15__["TubeBuilder"].CreateTube(name, options, scene);
  103424. };
  103425. /**
  103426. * Creates a polyhedron mesh
  103427. * * 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
  103428. * * The parameter `size` (positive float, default 1) sets the polygon size
  103429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  103430. * * 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`
  103431. * * 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
  103432. * * 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)`)
  103433. * * 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
  103434. * * 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
  103435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103436. * * 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
  103437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103438. * @param name defines the name of the mesh
  103439. * @param options defines the options used to create the mesh
  103440. * @param scene defines the hosting scene
  103441. * @returns the polyhedron mesh
  103442. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  103443. */
  103444. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  103445. if (scene === void 0) { scene = null; }
  103446. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_16__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  103447. };
  103448. /**
  103449. * Creates a decal mesh.
  103450. * 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
  103451. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103452. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103453. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103454. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103455. * @param name defines the name of the mesh
  103456. * @param sourceMesh defines the mesh where the decal must be applied
  103457. * @param options defines the options used to create the mesh
  103458. * @param scene defines the hosting scene
  103459. * @returns the decal mesh
  103460. * @see https://doc.babylonjs.com/how_to/decals
  103461. */
  103462. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  103463. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_18__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  103464. };
  103465. return MeshBuilder;
  103466. }());
  103467. /***/ }),
  103468. /***/ "./Meshes/meshLODLevel.ts":
  103469. /*!********************************!*\
  103470. !*** ./Meshes/meshLODLevel.ts ***!
  103471. \********************************/
  103472. /*! exports provided: MeshLODLevel */
  103473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103474. "use strict";
  103475. __webpack_require__.r(__webpack_exports__);
  103476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  103477. /**
  103478. * Class used to represent a specific level of detail of a mesh
  103479. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103480. */
  103481. var MeshLODLevel = /** @class */ (function () {
  103482. /**
  103483. * Creates a new LOD level
  103484. * @param distance defines the distance where this level should star being displayed
  103485. * @param mesh defines the mesh to use to render this level
  103486. */
  103487. function MeshLODLevel(
  103488. /** Defines the distance where this level should star being displayed */
  103489. distance,
  103490. /** Defines the mesh to use to render this level */
  103491. mesh) {
  103492. this.distance = distance;
  103493. this.mesh = mesh;
  103494. }
  103495. return MeshLODLevel;
  103496. }());
  103497. /***/ }),
  103498. /***/ "./Meshes/meshSimplification.ts":
  103499. /*!**************************************!*\
  103500. !*** ./Meshes/meshSimplification.ts ***!
  103501. \**************************************/
  103502. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  103503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103504. "use strict";
  103505. __webpack_require__.r(__webpack_exports__);
  103506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  103507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  103508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  103509. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  103510. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103511. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  103512. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  103513. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103514. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  103515. /**
  103516. * Class used to specify simplification options
  103517. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103518. */
  103519. var SimplificationSettings = /** @class */ (function () {
  103520. /**
  103521. * Creates a SimplificationSettings
  103522. * @param quality expected quality
  103523. * @param distance distance when this optimized version should be used
  103524. * @param optimizeMesh already optimized mesh
  103525. */
  103526. function SimplificationSettings(
  103527. /** expected quality */
  103528. quality,
  103529. /** distance when this optimized version should be used */
  103530. distance,
  103531. /** already optimized mesh */
  103532. optimizeMesh) {
  103533. this.quality = quality;
  103534. this.distance = distance;
  103535. this.optimizeMesh = optimizeMesh;
  103536. }
  103537. return SimplificationSettings;
  103538. }());
  103539. /**
  103540. * Queue used to order the simplification tasks
  103541. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103542. */
  103543. var SimplificationQueue = /** @class */ (function () {
  103544. /**
  103545. * Creates a new queue
  103546. */
  103547. function SimplificationQueue() {
  103548. this.running = false;
  103549. this._simplificationArray = [];
  103550. }
  103551. /**
  103552. * Adds a new simplification task
  103553. * @param task defines a task to add
  103554. */
  103555. SimplificationQueue.prototype.addTask = function (task) {
  103556. this._simplificationArray.push(task);
  103557. };
  103558. /**
  103559. * Execute next task
  103560. */
  103561. SimplificationQueue.prototype.executeNext = function () {
  103562. var task = this._simplificationArray.pop();
  103563. if (task) {
  103564. this.running = true;
  103565. this.runSimplification(task);
  103566. }
  103567. else {
  103568. this.running = false;
  103569. }
  103570. };
  103571. /**
  103572. * Execute a simplification task
  103573. * @param task defines the task to run
  103574. */
  103575. SimplificationQueue.prototype.runSimplification = function (task) {
  103576. var _this = this;
  103577. if (task.parallelProcessing) {
  103578. //parallel simplifier
  103579. task.settings.forEach(function (setting) {
  103580. var simplifier = _this.getSimplifier(task);
  103581. simplifier.simplify(setting, function (newMesh) {
  103582. task.mesh.addLODLevel(setting.distance, newMesh);
  103583. newMesh.isVisible = true;
  103584. //check if it is the last
  103585. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  103586. //all done, run the success callback.
  103587. task.successCallback();
  103588. }
  103589. _this.executeNext();
  103590. });
  103591. });
  103592. }
  103593. else {
  103594. //single simplifier.
  103595. var simplifier = this.getSimplifier(task);
  103596. var runDecimation = function (setting, callback) {
  103597. simplifier.simplify(setting, function (newMesh) {
  103598. task.mesh.addLODLevel(setting.distance, newMesh);
  103599. newMesh.isVisible = true;
  103600. //run the next quality level
  103601. callback();
  103602. });
  103603. };
  103604. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  103605. runDecimation(task.settings[loop.index], function () {
  103606. loop.executeNext();
  103607. });
  103608. }, function () {
  103609. //execution ended, run the success callback.
  103610. if (task.successCallback) {
  103611. task.successCallback();
  103612. }
  103613. _this.executeNext();
  103614. });
  103615. }
  103616. };
  103617. SimplificationQueue.prototype.getSimplifier = function (task) {
  103618. switch (task.simplificationType) {
  103619. case SimplificationType.QUADRATIC:
  103620. default:
  103621. return new QuadraticErrorSimplification(task.mesh);
  103622. }
  103623. };
  103624. return SimplificationQueue;
  103625. }());
  103626. /**
  103627. * The implemented types of simplification
  103628. * At the moment only Quadratic Error Decimation is implemented
  103629. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103630. */
  103631. var SimplificationType;
  103632. (function (SimplificationType) {
  103633. /** Quadratic error decimation */
  103634. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  103635. })(SimplificationType || (SimplificationType = {}));
  103636. var DecimationTriangle = /** @class */ (function () {
  103637. function DecimationTriangle(vertices) {
  103638. this.vertices = vertices;
  103639. this.error = new Array(4);
  103640. this.deleted = false;
  103641. this.isDirty = false;
  103642. this.deletePending = false;
  103643. this.borderFactor = 0;
  103644. }
  103645. return DecimationTriangle;
  103646. }());
  103647. var DecimationVertex = /** @class */ (function () {
  103648. function DecimationVertex(position, id) {
  103649. this.position = position;
  103650. this.id = id;
  103651. this.isBorder = true;
  103652. this.q = new QuadraticMatrix();
  103653. this.triangleCount = 0;
  103654. this.triangleStart = 0;
  103655. this.originalOffsets = [];
  103656. }
  103657. DecimationVertex.prototype.updatePosition = function (newPosition) {
  103658. this.position.copyFrom(newPosition);
  103659. };
  103660. return DecimationVertex;
  103661. }());
  103662. var QuadraticMatrix = /** @class */ (function () {
  103663. function QuadraticMatrix(data) {
  103664. this.data = new Array(10);
  103665. for (var i = 0; i < 10; ++i) {
  103666. if (data && data[i]) {
  103667. this.data[i] = data[i];
  103668. }
  103669. else {
  103670. this.data[i] = 0;
  103671. }
  103672. }
  103673. }
  103674. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  103675. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  103676. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  103677. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  103678. return det;
  103679. };
  103680. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  103681. for (var i = 0; i < 10; ++i) {
  103682. this.data[i] += matrix.data[i];
  103683. }
  103684. };
  103685. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  103686. for (var i = 0; i < 10; ++i) {
  103687. this.data[i] += data[i];
  103688. }
  103689. };
  103690. QuadraticMatrix.prototype.add = function (matrix) {
  103691. var m = new QuadraticMatrix();
  103692. for (var i = 0; i < 10; ++i) {
  103693. m.data[i] = this.data[i] + matrix.data[i];
  103694. }
  103695. return m;
  103696. };
  103697. QuadraticMatrix.FromData = function (a, b, c, d) {
  103698. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  103699. };
  103700. //returning an array to avoid garbage collection
  103701. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  103702. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  103703. };
  103704. return QuadraticMatrix;
  103705. }());
  103706. var Reference = /** @class */ (function () {
  103707. function Reference(vertexId, triangleId) {
  103708. this.vertexId = vertexId;
  103709. this.triangleId = triangleId;
  103710. }
  103711. return Reference;
  103712. }());
  103713. /**
  103714. * An implementation of the Quadratic Error simplification algorithm.
  103715. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  103716. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  103717. * @author RaananW
  103718. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103719. */
  103720. var QuadraticErrorSimplification = /** @class */ (function () {
  103721. function QuadraticErrorSimplification(_mesh) {
  103722. this._mesh = _mesh;
  103723. this.syncIterations = 5000;
  103724. this.aggressiveness = 7;
  103725. this.decimationIterations = 100;
  103726. this.boundingBoxEpsilon = _Maths_math_constants__WEBPACK_IMPORTED_MODULE_5__["Epsilon"];
  103727. }
  103728. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  103729. var _this = this;
  103730. this.initDecimatedMesh();
  103731. //iterating through the submeshes array, one after the other.
  103732. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  103733. _this.initWithMesh(loop.index, function () {
  103734. _this.runDecimation(settings, loop.index, function () {
  103735. loop.executeNext();
  103736. });
  103737. }, settings.optimizeMesh);
  103738. }, function () {
  103739. setTimeout(function () {
  103740. successCallback(_this._reconstructedMesh);
  103741. }, 0);
  103742. });
  103743. };
  103744. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  103745. var _this = this;
  103746. var targetCount = ~~(this.triangles.length * settings.quality);
  103747. var deletedTriangles = 0;
  103748. var triangleCount = this.triangles.length;
  103749. var iterationFunction = function (iteration, callback) {
  103750. setTimeout(function () {
  103751. if (iteration % 5 === 0) {
  103752. _this.updateMesh(iteration === 0);
  103753. }
  103754. for (var i = 0; i < _this.triangles.length; ++i) {
  103755. _this.triangles[i].isDirty = false;
  103756. }
  103757. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  103758. var trianglesIterator = function (i) {
  103759. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  103760. var t = _this.triangles[tIdx];
  103761. if (!t) {
  103762. return;
  103763. }
  103764. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  103765. return;
  103766. }
  103767. for (var j = 0; j < 3; ++j) {
  103768. if (t.error[j] < threshold) {
  103769. var deleted0 = [];
  103770. var deleted1 = [];
  103771. var v0 = t.vertices[j];
  103772. var v1 = t.vertices[(j + 1) % 3];
  103773. if (v0.isBorder || v1.isBorder) {
  103774. continue;
  103775. }
  103776. var p = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103777. // var n = Vector3.Zero();
  103778. // var uv = Vector2.Zero();
  103779. // var color = new Color4(0, 0, 0, 1);
  103780. _this.calculateError(v0, v1, p);
  103781. var delTr = new Array();
  103782. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  103783. continue;
  103784. }
  103785. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  103786. continue;
  103787. }
  103788. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  103789. continue;
  103790. }
  103791. var uniqueArray = new Array();
  103792. delTr.forEach(function (deletedT) {
  103793. if (uniqueArray.indexOf(deletedT) === -1) {
  103794. deletedT.deletePending = true;
  103795. uniqueArray.push(deletedT);
  103796. }
  103797. });
  103798. if (uniqueArray.length % 2 !== 0) {
  103799. continue;
  103800. }
  103801. v0.q = v1.q.add(v0.q);
  103802. v0.updatePosition(p);
  103803. var tStart = _this.references.length;
  103804. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  103805. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  103806. var tCount = _this.references.length - tStart;
  103807. if (tCount <= v0.triangleCount) {
  103808. if (tCount) {
  103809. for (var c = 0; c < tCount; c++) {
  103810. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  103811. }
  103812. }
  103813. }
  103814. else {
  103815. v0.triangleStart = tStart;
  103816. }
  103817. v0.triangleCount = tCount;
  103818. break;
  103819. }
  103820. }
  103821. };
  103822. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  103823. }, 0);
  103824. };
  103825. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  103826. if (triangleCount - deletedTriangles <= targetCount) {
  103827. loop.breakLoop();
  103828. }
  103829. else {
  103830. iterationFunction(loop.index, function () {
  103831. loop.executeNext();
  103832. });
  103833. }
  103834. }, function () {
  103835. setTimeout(function () {
  103836. //reconstruct this part of the mesh
  103837. _this.reconstructMesh(submeshIndex);
  103838. successCallback();
  103839. }, 0);
  103840. });
  103841. };
  103842. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  103843. var _this = this;
  103844. this.vertices = [];
  103845. this.triangles = [];
  103846. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  103847. var indices = this._mesh.getIndices();
  103848. var submesh = this._mesh.subMeshes[submeshIndex];
  103849. var findInVertices = function (positionToSearch) {
  103850. if (optimizeMesh) {
  103851. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  103852. if (_this.vertices[ii].position.equals(positionToSearch)) {
  103853. return _this.vertices[ii];
  103854. }
  103855. }
  103856. }
  103857. return null;
  103858. };
  103859. var vertexReferences = [];
  103860. var vertexInit = function (i) {
  103861. if (!positionData) {
  103862. return;
  103863. }
  103864. var offset = i + submesh.verticesStart;
  103865. var position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  103866. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  103867. vertex.originalOffsets.push(offset);
  103868. if (vertex.id === _this.vertices.length) {
  103869. _this.vertices.push(vertex);
  103870. }
  103871. vertexReferences.push(vertex.id);
  103872. };
  103873. //var totalVertices = mesh.getTotalVertices();
  103874. var totalVertices = submesh.verticesCount;
  103875. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  103876. var indicesInit = function (i) {
  103877. if (!indices) {
  103878. return;
  103879. }
  103880. var offset = (submesh.indexStart / 3) + i;
  103881. var pos = (offset * 3);
  103882. var i0 = indices[pos + 0];
  103883. var i1 = indices[pos + 1];
  103884. var i2 = indices[pos + 2];
  103885. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  103886. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  103887. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  103888. var triangle = new DecimationTriangle([v0, v1, v2]);
  103889. triangle.originalOffset = pos;
  103890. _this.triangles.push(triangle);
  103891. };
  103892. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  103893. _this.init(callback);
  103894. });
  103895. });
  103896. };
  103897. QuadraticErrorSimplification.prototype.init = function (callback) {
  103898. var _this = this;
  103899. var triangleInit1 = function (i) {
  103900. var t = _this.triangles[i];
  103901. t.normal = _Maths_math_vector__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();
  103902. for (var j = 0; j < 3; j++) {
  103903. t.vertices[j].q.addArrayInPlace(QuadraticMatrix.DataFromNumbers(t.normal.x, t.normal.y, t.normal.z, -(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(t.normal, t.vertices[0].position))));
  103904. }
  103905. };
  103906. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  103907. var triangleInit2 = function (i) {
  103908. var t = _this.triangles[i];
  103909. for (var j = 0; j < 3; ++j) {
  103910. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  103911. }
  103912. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  103913. };
  103914. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  103915. callback();
  103916. });
  103917. });
  103918. };
  103919. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  103920. var newTriangles = [];
  103921. var i;
  103922. for (i = 0; i < this.vertices.length; ++i) {
  103923. this.vertices[i].triangleCount = 0;
  103924. }
  103925. var t;
  103926. var j;
  103927. for (i = 0; i < this.triangles.length; ++i) {
  103928. if (!this.triangles[i].deleted) {
  103929. t = this.triangles[i];
  103930. for (j = 0; j < 3; ++j) {
  103931. t.vertices[j].triangleCount = 1;
  103932. }
  103933. newTriangles.push(t);
  103934. }
  103935. }
  103936. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  103937. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  103938. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  103939. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  103940. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  103941. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  103942. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  103943. var vertexCount = 0;
  103944. for (i = 0; i < this.vertices.length; ++i) {
  103945. var vertex = this.vertices[i];
  103946. vertex.id = vertexCount;
  103947. if (vertex.triangleCount) {
  103948. vertex.originalOffsets.forEach(function (originalOffset) {
  103949. if (!normalData) {
  103950. return;
  103951. }
  103952. newPositionData.push(vertex.position.x);
  103953. newPositionData.push(vertex.position.y);
  103954. newPositionData.push(vertex.position.z);
  103955. newNormalData.push(normalData[originalOffset * 3]);
  103956. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  103957. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  103958. if (uvs && uvs.length) {
  103959. newUVsData.push(uvs[(originalOffset * 2)]);
  103960. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  103961. }
  103962. if (colorsData && colorsData.length) {
  103963. newColorsData.push(colorsData[(originalOffset * 4)]);
  103964. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  103965. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  103966. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  103967. }
  103968. ++vertexCount;
  103969. });
  103970. }
  103971. }
  103972. var startingIndex = this._reconstructedMesh.getTotalIndices();
  103973. var startingVertex = this._reconstructedMesh.getTotalVertices();
  103974. var submeshesArray = this._reconstructedMesh.subMeshes;
  103975. this._reconstructedMesh.subMeshes = [];
  103976. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  103977. var originalIndices = this._mesh.getIndices();
  103978. for (i = 0; i < newTriangles.length; ++i) {
  103979. t = newTriangles[i]; //now get the new referencing point for each vertex
  103980. [0, 1, 2].forEach(function (idx) {
  103981. var id = originalIndices[t.originalOffset + idx];
  103982. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  103983. if (offset < 0) {
  103984. offset = 0;
  103985. }
  103986. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  103987. });
  103988. }
  103989. //overwriting the old vertex buffers and indices.
  103990. this._reconstructedMesh.setIndices(newIndicesArray);
  103991. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  103992. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  103993. if (newUVsData.length > 0) {
  103994. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  103995. }
  103996. if (newColorsData.length > 0) {
  103997. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  103998. }
  103999. //create submesh
  104000. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  104001. if (submeshIndex > 0) {
  104002. this._reconstructedMesh.subMeshes = [];
  104003. submeshesArray.forEach(function (submesh) {
  104004. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  104005. });
  104006. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  104007. }
  104008. };
  104009. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  104010. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  104011. this._reconstructedMesh.material = this._mesh.material;
  104012. this._reconstructedMesh.parent = this._mesh.parent;
  104013. this._reconstructedMesh.isVisible = false;
  104014. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  104015. };
  104016. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  104017. for (var i = 0; i < vertex1.triangleCount; ++i) {
  104018. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  104019. if (t.deleted) {
  104020. continue;
  104021. }
  104022. var s = this.references[vertex1.triangleStart + i].vertexId;
  104023. var v1 = t.vertices[(s + 1) % 3];
  104024. var v2 = t.vertices[(s + 2) % 3];
  104025. if ((v1 === vertex2 || v2 === vertex2)) {
  104026. deletedArray[i] = true;
  104027. delTr.push(t);
  104028. continue;
  104029. }
  104030. var d1 = v1.position.subtract(point);
  104031. d1 = d1.normalize();
  104032. var d2 = v2.position.subtract(point);
  104033. d2 = d2.normalize();
  104034. if (Math.abs(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  104035. return true;
  104036. }
  104037. var normal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  104038. deletedArray[i] = false;
  104039. if (_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  104040. return true;
  104041. }
  104042. }
  104043. return false;
  104044. };
  104045. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  104046. var newDeleted = deletedTriangles;
  104047. for (var i = 0; i < vertex.triangleCount; ++i) {
  104048. var ref = this.references[vertex.triangleStart + i];
  104049. var t = this.triangles[ref.triangleId];
  104050. if (t.deleted) {
  104051. continue;
  104052. }
  104053. if (deletedArray[i] && t.deletePending) {
  104054. t.deleted = true;
  104055. newDeleted++;
  104056. continue;
  104057. }
  104058. t.vertices[ref.vertexId] = origVertex;
  104059. t.isDirty = true;
  104060. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  104061. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  104062. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  104063. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  104064. this.references.push(ref);
  104065. }
  104066. return newDeleted;
  104067. };
  104068. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  104069. for (var i = 0; i < this.vertices.length; ++i) {
  104070. var vCount = [];
  104071. var vId = [];
  104072. var v = this.vertices[i];
  104073. var j;
  104074. for (j = 0; j < v.triangleCount; ++j) {
  104075. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  104076. for (var ii = 0; ii < 3; ii++) {
  104077. var ofs = 0;
  104078. var vv = triangle.vertices[ii];
  104079. while (ofs < vCount.length) {
  104080. if (vId[ofs] === vv.id) {
  104081. break;
  104082. }
  104083. ++ofs;
  104084. }
  104085. if (ofs === vCount.length) {
  104086. vCount.push(1);
  104087. vId.push(vv.id);
  104088. }
  104089. else {
  104090. vCount[ofs]++;
  104091. }
  104092. }
  104093. }
  104094. for (j = 0; j < vCount.length; ++j) {
  104095. if (vCount[j] === 1) {
  104096. this.vertices[vId[j]].isBorder = true;
  104097. }
  104098. else {
  104099. this.vertices[vId[j]].isBorder = false;
  104100. }
  104101. }
  104102. }
  104103. };
  104104. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  104105. if (identifyBorders === void 0) { identifyBorders = false; }
  104106. var i;
  104107. if (!identifyBorders) {
  104108. var newTrianglesVector = [];
  104109. for (i = 0; i < this.triangles.length; ++i) {
  104110. if (!this.triangles[i].deleted) {
  104111. newTrianglesVector.push(this.triangles[i]);
  104112. }
  104113. }
  104114. this.triangles = newTrianglesVector;
  104115. }
  104116. for (i = 0; i < this.vertices.length; ++i) {
  104117. this.vertices[i].triangleCount = 0;
  104118. this.vertices[i].triangleStart = 0;
  104119. }
  104120. var t;
  104121. var j;
  104122. var v;
  104123. for (i = 0; i < this.triangles.length; ++i) {
  104124. t = this.triangles[i];
  104125. for (j = 0; j < 3; ++j) {
  104126. v = t.vertices[j];
  104127. v.triangleCount++;
  104128. }
  104129. }
  104130. var tStart = 0;
  104131. for (i = 0; i < this.vertices.length; ++i) {
  104132. this.vertices[i].triangleStart = tStart;
  104133. tStart += this.vertices[i].triangleCount;
  104134. this.vertices[i].triangleCount = 0;
  104135. }
  104136. var newReferences = new Array(this.triangles.length * 3);
  104137. for (i = 0; i < this.triangles.length; ++i) {
  104138. t = this.triangles[i];
  104139. for (j = 0; j < 3; ++j) {
  104140. v = t.vertices[j];
  104141. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  104142. v.triangleCount++;
  104143. }
  104144. }
  104145. this.references = newReferences;
  104146. if (identifyBorders) {
  104147. this.identifyBorder();
  104148. }
  104149. };
  104150. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  104151. var x = point.x;
  104152. var y = point.y;
  104153. var z = point.z;
  104154. 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
  104155. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  104156. };
  104157. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  104158. var q = vertex1.q.add(vertex2.q);
  104159. var border = vertex1.isBorder && vertex2.isBorder;
  104160. var error = 0;
  104161. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  104162. if (qDet !== 0 && !border) {
  104163. if (!pointResult) {
  104164. pointResult = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104165. }
  104166. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  104167. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  104168. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  104169. error = this.vertexError(q, pointResult);
  104170. }
  104171. else {
  104172. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  104173. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  104174. var error1 = this.vertexError(q, vertex1.position);
  104175. var error2 = this.vertexError(q, vertex2.position);
  104176. var error3 = this.vertexError(q, p3);
  104177. error = Math.min(error1, error2, error3);
  104178. if (error === error1) {
  104179. if (pointResult) {
  104180. pointResult.copyFrom(vertex1.position);
  104181. }
  104182. }
  104183. else if (error === error2) {
  104184. if (pointResult) {
  104185. pointResult.copyFrom(vertex2.position);
  104186. }
  104187. }
  104188. else {
  104189. if (pointResult) {
  104190. pointResult.copyFrom(p3);
  104191. }
  104192. }
  104193. }
  104194. return error;
  104195. };
  104196. return QuadraticErrorSimplification;
  104197. }());
  104198. /***/ }),
  104199. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  104200. /*!****************************************************!*\
  104201. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  104202. \****************************************************/
  104203. /*! exports provided: SimplicationQueueSceneComponent */
  104204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104205. "use strict";
  104206. __webpack_require__.r(__webpack_exports__);
  104207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  104208. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  104209. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  104210. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  104211. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  104212. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  104213. get: function () {
  104214. if (!this._simplificationQueue) {
  104215. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  104216. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  104217. if (!component) {
  104218. component = new SimplicationQueueSceneComponent(this);
  104219. this._addComponent(component);
  104220. }
  104221. }
  104222. return this._simplificationQueue;
  104223. },
  104224. set: function (value) {
  104225. this._simplificationQueue = value;
  104226. },
  104227. enumerable: true,
  104228. configurable: true
  104229. });
  104230. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  104231. if (parallelProcessing === void 0) { parallelProcessing = true; }
  104232. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  104233. this.getScene().simplificationQueue.addTask({
  104234. settings: settings,
  104235. parallelProcessing: parallelProcessing,
  104236. mesh: this,
  104237. simplificationType: simplificationType,
  104238. successCallback: successCallback
  104239. });
  104240. return this;
  104241. };
  104242. /**
  104243. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104244. * created in a scene
  104245. */
  104246. var SimplicationQueueSceneComponent = /** @class */ (function () {
  104247. /**
  104248. * Creates a new instance of the component for the given scene
  104249. * @param scene Defines the scene to register the component in
  104250. */
  104251. function SimplicationQueueSceneComponent(scene) {
  104252. /**
  104253. * The component name helpfull to identify the component in the list of scene components.
  104254. */
  104255. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  104256. this.scene = scene;
  104257. }
  104258. /**
  104259. * Registers the component in a given scene
  104260. */
  104261. SimplicationQueueSceneComponent.prototype.register = function () {
  104262. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  104263. };
  104264. /**
  104265. * Rebuilds the elements related to this component in case of
  104266. * context lost for instance.
  104267. */
  104268. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  104269. // Nothing to do for this component
  104270. };
  104271. /**
  104272. * Disposes the component and the associated ressources
  104273. */
  104274. SimplicationQueueSceneComponent.prototype.dispose = function () {
  104275. // Nothing to do for this component
  104276. };
  104277. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  104278. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  104279. this.scene._simplificationQueue.executeNext();
  104280. }
  104281. };
  104282. return SimplicationQueueSceneComponent;
  104283. }());
  104284. /***/ }),
  104285. /***/ "./Meshes/polygonMesh.ts":
  104286. /*!*******************************!*\
  104287. !*** ./Meshes/polygonMesh.ts ***!
  104288. \*******************************/
  104289. /*! exports provided: Polygon, PolygonMeshBuilder */
  104290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104291. "use strict";
  104292. __webpack_require__.r(__webpack_exports__);
  104293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  104294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  104295. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104296. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104297. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  104298. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  104299. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  104300. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  104301. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  104302. /* harmony import */ var _Maths_math_path__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.path */ "./Maths/math.path.ts");
  104303. /**
  104304. * Vector2 wth index property
  104305. */
  104306. var IndexedVector2 = /** @class */ (function (_super) {
  104307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  104308. function IndexedVector2(original,
  104309. /** Index of the vector2 */
  104310. index) {
  104311. var _this = _super.call(this, original.x, original.y) || this;
  104312. _this.index = index;
  104313. return _this;
  104314. }
  104315. return IndexedVector2;
  104316. }(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  104317. /**
  104318. * Defines points to create a polygon
  104319. */
  104320. var PolygonPoints = /** @class */ (function () {
  104321. function PolygonPoints() {
  104322. this.elements = new Array();
  104323. }
  104324. PolygonPoints.prototype.add = function (originalPoints) {
  104325. var _this = this;
  104326. var result = new Array();
  104327. originalPoints.forEach(function (point) {
  104328. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  104329. var newPoint = new IndexedVector2(point, _this.elements.length);
  104330. result.push(newPoint);
  104331. _this.elements.push(newPoint);
  104332. }
  104333. });
  104334. return result;
  104335. };
  104336. PolygonPoints.prototype.computeBounds = function () {
  104337. var lmin = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  104338. var lmax = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  104339. this.elements.forEach(function (point) {
  104340. // x
  104341. if (point.x < lmin.x) {
  104342. lmin.x = point.x;
  104343. }
  104344. else if (point.x > lmax.x) {
  104345. lmax.x = point.x;
  104346. }
  104347. // y
  104348. if (point.y < lmin.y) {
  104349. lmin.y = point.y;
  104350. }
  104351. else if (point.y > lmax.y) {
  104352. lmax.y = point.y;
  104353. }
  104354. });
  104355. return {
  104356. min: lmin,
  104357. max: lmax,
  104358. width: lmax.x - lmin.x,
  104359. height: lmax.y - lmin.y
  104360. };
  104361. };
  104362. return PolygonPoints;
  104363. }());
  104364. /**
  104365. * Polygon
  104366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  104367. */
  104368. var Polygon = /** @class */ (function () {
  104369. function Polygon() {
  104370. }
  104371. /**
  104372. * Creates a rectangle
  104373. * @param xmin bottom X coord
  104374. * @param ymin bottom Y coord
  104375. * @param xmax top X coord
  104376. * @param ymax top Y coord
  104377. * @returns points that make the resulting rectation
  104378. */
  104379. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  104380. return [
  104381. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  104382. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  104383. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  104384. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  104385. ];
  104386. };
  104387. /**
  104388. * Creates a circle
  104389. * @param radius radius of circle
  104390. * @param cx scale in x
  104391. * @param cy scale in y
  104392. * @param numberOfSides number of sides that make up the circle
  104393. * @returns points that make the resulting circle
  104394. */
  104395. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  104396. if (cx === void 0) { cx = 0; }
  104397. if (cy === void 0) { cy = 0; }
  104398. if (numberOfSides === void 0) { numberOfSides = 32; }
  104399. var result = new Array();
  104400. var angle = 0;
  104401. var increment = (Math.PI * 2) / numberOfSides;
  104402. for (var i = 0; i < numberOfSides; i++) {
  104403. result.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  104404. angle -= increment;
  104405. }
  104406. return result;
  104407. };
  104408. /**
  104409. * Creates a polygon from input string
  104410. * @param input Input polygon data
  104411. * @returns the parsed points
  104412. */
  104413. Polygon.Parse = function (input) {
  104414. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  104415. var i, result = [];
  104416. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  104417. result.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  104418. }
  104419. return result;
  104420. };
  104421. /**
  104422. * Starts building a polygon from x and y coordinates
  104423. * @param x x coordinate
  104424. * @param y y coordinate
  104425. * @returns the started path2
  104426. */
  104427. Polygon.StartingAt = function (x, y) {
  104428. return _Maths_math_path__WEBPACK_IMPORTED_MODULE_7__["Path2"].StartingAt(x, y);
  104429. };
  104430. return Polygon;
  104431. }());
  104432. /**
  104433. * Builds a polygon
  104434. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  104435. */
  104436. var PolygonMeshBuilder = /** @class */ (function () {
  104437. /**
  104438. * Creates a PolygonMeshBuilder
  104439. * @param name name of the builder
  104440. * @param contours Path of the polygon
  104441. * @param scene scene to add to when creating the mesh
  104442. * @param earcutInjection can be used to inject your own earcut reference
  104443. */
  104444. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  104445. if (earcutInjection === void 0) { earcutInjection = earcut; }
  104446. this._points = new PolygonPoints();
  104447. this._outlinepoints = new PolygonPoints();
  104448. this._holes = new Array();
  104449. this._epoints = new Array();
  104450. this._eholes = new Array();
  104451. this.bjsEarcut = earcutInjection;
  104452. this._name = name;
  104453. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  104454. var points;
  104455. if (contours instanceof _Maths_math_path__WEBPACK_IMPORTED_MODULE_7__["Path2"]) {
  104456. points = contours.getPoints();
  104457. }
  104458. else {
  104459. points = contours;
  104460. }
  104461. this._addToepoint(points);
  104462. this._points.add(points);
  104463. this._outlinepoints.add(points);
  104464. if (typeof this.bjsEarcut === 'undefined') {
  104465. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  104466. }
  104467. }
  104468. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  104469. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  104470. var p = points_1[_i];
  104471. this._epoints.push(p.x, p.y);
  104472. }
  104473. };
  104474. /**
  104475. * Adds a whole within the polygon
  104476. * @param hole Array of points defining the hole
  104477. * @returns this
  104478. */
  104479. PolygonMeshBuilder.prototype.addHole = function (hole) {
  104480. this._points.add(hole);
  104481. var holepoints = new PolygonPoints();
  104482. holepoints.add(hole);
  104483. this._holes.push(holepoints);
  104484. this._eholes.push(this._epoints.length / 2);
  104485. this._addToepoint(hole);
  104486. return this;
  104487. };
  104488. /**
  104489. * Creates the polygon
  104490. * @param updatable If the mesh should be updatable
  104491. * @param depth The depth of the mesh created
  104492. * @returns the created mesh
  104493. */
  104494. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  104495. if (updatable === void 0) { updatable = false; }
  104496. if (depth === void 0) { depth = 0; }
  104497. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  104498. var vertexData = this.buildVertexData(depth);
  104499. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  104500. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  104501. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  104502. result.setIndices(vertexData.indices);
  104503. return result;
  104504. };
  104505. /**
  104506. * Creates the polygon
  104507. * @param depth The depth of the mesh created
  104508. * @returns the created VertexData
  104509. */
  104510. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  104511. var _this = this;
  104512. if (depth === void 0) { depth = 0; }
  104513. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  104514. var normals = new Array();
  104515. var positions = new Array();
  104516. var uvs = new Array();
  104517. var bounds = this._points.computeBounds();
  104518. this._points.elements.forEach(function (p) {
  104519. normals.push(0, 1.0, 0);
  104520. positions.push(p.x, 0, p.y);
  104521. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  104522. });
  104523. var indices = new Array();
  104524. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  104525. for (var i = 0; i < res.length; i++) {
  104526. indices.push(res[i]);
  104527. }
  104528. if (depth > 0) {
  104529. var positionscount = (positions.length / 3); //get the current pointcount
  104530. this._points.elements.forEach(function (p) {
  104531. normals.push(0, -1.0, 0);
  104532. positions.push(p.x, -depth, p.y);
  104533. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  104534. });
  104535. var totalCount = indices.length;
  104536. for (var i = 0; i < totalCount; i += 3) {
  104537. var i0 = indices[i + 0];
  104538. var i1 = indices[i + 1];
  104539. var i2 = indices[i + 2];
  104540. indices.push(i2 + positionscount);
  104541. indices.push(i1 + positionscount);
  104542. indices.push(i0 + positionscount);
  104543. }
  104544. //Add the sides
  104545. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  104546. this._holes.forEach(function (hole) {
  104547. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  104548. });
  104549. }
  104550. result.indices = indices;
  104551. result.positions = positions;
  104552. result.normals = normals;
  104553. result.uvs = uvs;
  104554. return result;
  104555. };
  104556. /**
  104557. * Adds a side to the polygon
  104558. * @param positions points that make the polygon
  104559. * @param normals normals of the polygon
  104560. * @param uvs uvs of the polygon
  104561. * @param indices indices of the polygon
  104562. * @param bounds bounds of the polygon
  104563. * @param points points of the polygon
  104564. * @param depth depth of the polygon
  104565. * @param flip flip of the polygon
  104566. */
  104567. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  104568. var StartIndex = positions.length / 3;
  104569. var ulength = 0;
  104570. for (var i = 0; i < points.elements.length; i++) {
  104571. var p = points.elements[i];
  104572. var p1;
  104573. if ((i + 1) > points.elements.length - 1) {
  104574. p1 = points.elements[0];
  104575. }
  104576. else {
  104577. p1 = points.elements[i + 1];
  104578. }
  104579. positions.push(p.x, 0, p.y);
  104580. positions.push(p.x, -depth, p.y);
  104581. positions.push(p1.x, 0, p1.y);
  104582. positions.push(p1.x, -depth, p1.y);
  104583. var v1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  104584. var v2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  104585. var v3 = v2.subtract(v1);
  104586. var v4 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  104587. var vn = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  104588. vn = vn.normalize();
  104589. uvs.push(ulength / bounds.width, 0);
  104590. uvs.push(ulength / bounds.width, 1);
  104591. ulength += v3.length();
  104592. uvs.push((ulength / bounds.width), 0);
  104593. uvs.push((ulength / bounds.width), 1);
  104594. if (!flip) {
  104595. normals.push(-vn.x, -vn.y, -vn.z);
  104596. normals.push(-vn.x, -vn.y, -vn.z);
  104597. normals.push(-vn.x, -vn.y, -vn.z);
  104598. normals.push(-vn.x, -vn.y, -vn.z);
  104599. indices.push(StartIndex);
  104600. indices.push(StartIndex + 1);
  104601. indices.push(StartIndex + 2);
  104602. indices.push(StartIndex + 1);
  104603. indices.push(StartIndex + 3);
  104604. indices.push(StartIndex + 2);
  104605. }
  104606. else {
  104607. normals.push(vn.x, vn.y, vn.z);
  104608. normals.push(vn.x, vn.y, vn.z);
  104609. normals.push(vn.x, vn.y, vn.z);
  104610. normals.push(vn.x, vn.y, vn.z);
  104611. indices.push(StartIndex);
  104612. indices.push(StartIndex + 2);
  104613. indices.push(StartIndex + 1);
  104614. indices.push(StartIndex + 1);
  104615. indices.push(StartIndex + 2);
  104616. indices.push(StartIndex + 3);
  104617. }
  104618. StartIndex += 4;
  104619. }
  104620. };
  104621. return PolygonMeshBuilder;
  104622. }());
  104623. /***/ }),
  104624. /***/ "./Meshes/subMesh.ts":
  104625. /*!***************************!*\
  104626. !*** ./Meshes/subMesh.ts ***!
  104627. \***************************/
  104628. /*! exports provided: BaseSubMesh, SubMesh */
  104629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104630. "use strict";
  104631. __webpack_require__.r(__webpack_exports__);
  104632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  104633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  104634. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104635. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  104636. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  104637. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  104638. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104639. /* harmony import */ var _Maths_math_functions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.functions */ "./Maths/math.functions.ts");
  104640. /**
  104641. * Base class for submeshes
  104642. */
  104643. var BaseSubMesh = /** @class */ (function () {
  104644. function BaseSubMesh() {
  104645. /** @hidden */
  104646. this._materialDefines = null;
  104647. /** @hidden */
  104648. this._materialEffect = null;
  104649. }
  104650. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  104651. /**
  104652. * Gets associated effect
  104653. */
  104654. get: function () {
  104655. return this._materialEffect;
  104656. },
  104657. enumerable: true,
  104658. configurable: true
  104659. });
  104660. /**
  104661. * Sets associated effect (effect used to render this submesh)
  104662. * @param effect defines the effect to associate with
  104663. * @param defines defines the set of defines used to compile this effect
  104664. */
  104665. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  104666. if (defines === void 0) { defines = null; }
  104667. if (this._materialEffect === effect) {
  104668. if (!effect) {
  104669. this._materialDefines = null;
  104670. }
  104671. return;
  104672. }
  104673. this._materialDefines = defines;
  104674. this._materialEffect = effect;
  104675. };
  104676. return BaseSubMesh;
  104677. }());
  104678. /**
  104679. * Defines a subdivision inside a mesh
  104680. */
  104681. var SubMesh = /** @class */ (function (_super) {
  104682. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  104683. /**
  104684. * Creates a new submesh
  104685. * @param materialIndex defines the material index to use
  104686. * @param verticesStart defines vertex index start
  104687. * @param verticesCount defines vertices count
  104688. * @param indexStart defines index start
  104689. * @param indexCount defines indices count
  104690. * @param mesh defines the parent mesh
  104691. * @param renderingMesh defines an optional rendering mesh
  104692. * @param createBoundingBox defines if bounding box should be created for this submesh
  104693. */
  104694. function SubMesh(
  104695. /** the material index to use */
  104696. materialIndex,
  104697. /** vertex index start */
  104698. verticesStart,
  104699. /** vertices count */
  104700. verticesCount,
  104701. /** index start */
  104702. indexStart,
  104703. /** indices count */
  104704. indexCount, mesh, renderingMesh, createBoundingBox) {
  104705. if (createBoundingBox === void 0) { createBoundingBox = true; }
  104706. var _this = _super.call(this) || this;
  104707. _this.materialIndex = materialIndex;
  104708. _this.verticesStart = verticesStart;
  104709. _this.verticesCount = verticesCount;
  104710. _this.indexStart = indexStart;
  104711. _this.indexCount = indexCount;
  104712. /** @hidden */
  104713. _this._linesIndexCount = 0;
  104714. _this._linesIndexBuffer = null;
  104715. /** @hidden */
  104716. _this._lastColliderWorldVertices = null;
  104717. /** @hidden */
  104718. _this._lastColliderTransformMatrix = null;
  104719. /** @hidden */
  104720. _this._renderId = 0;
  104721. /** @hidden */
  104722. _this._alphaIndex = 0;
  104723. /** @hidden */
  104724. _this._distanceToCamera = 0;
  104725. _this._currentMaterial = null;
  104726. _this._mesh = mesh;
  104727. _this._renderingMesh = renderingMesh || mesh;
  104728. mesh.subMeshes.push(_this);
  104729. _this._trianglePlanes = [];
  104730. _this._id = mesh.subMeshes.length - 1;
  104731. if (createBoundingBox) {
  104732. _this.refreshBoundingInfo();
  104733. mesh.computeWorldMatrix(true);
  104734. }
  104735. return _this;
  104736. }
  104737. /**
  104738. * Add a new submesh to a mesh
  104739. * @param materialIndex defines the material index to use
  104740. * @param verticesStart defines vertex index start
  104741. * @param verticesCount defines vertices count
  104742. * @param indexStart defines index start
  104743. * @param indexCount defines indices count
  104744. * @param mesh defines the parent mesh
  104745. * @param renderingMesh defines an optional rendering mesh
  104746. * @param createBoundingBox defines if bounding box should be created for this submesh
  104747. * @returns the new submesh
  104748. */
  104749. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  104750. if (createBoundingBox === void 0) { createBoundingBox = true; }
  104751. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  104752. };
  104753. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  104754. /**
  104755. * Returns true if this submesh covers the entire parent mesh
  104756. * @ignorenaming
  104757. */
  104758. get: function () {
  104759. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  104760. },
  104761. enumerable: true,
  104762. configurable: true
  104763. });
  104764. /**
  104765. * Returns the submesh BoudingInfo object
  104766. * @returns current bounding info (or mesh's one if the submesh is global)
  104767. */
  104768. SubMesh.prototype.getBoundingInfo = function () {
  104769. if (this.IsGlobal) {
  104770. return this._mesh.getBoundingInfo();
  104771. }
  104772. return this._boundingInfo;
  104773. };
  104774. /**
  104775. * Sets the submesh BoundingInfo
  104776. * @param boundingInfo defines the new bounding info to use
  104777. * @returns the SubMesh
  104778. */
  104779. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  104780. this._boundingInfo = boundingInfo;
  104781. return this;
  104782. };
  104783. /**
  104784. * Returns the mesh of the current submesh
  104785. * @return the parent mesh
  104786. */
  104787. SubMesh.prototype.getMesh = function () {
  104788. return this._mesh;
  104789. };
  104790. /**
  104791. * Returns the rendering mesh of the submesh
  104792. * @returns the rendering mesh (could be different from parent mesh)
  104793. */
  104794. SubMesh.prototype.getRenderingMesh = function () {
  104795. return this._renderingMesh;
  104796. };
  104797. /**
  104798. * Returns the submesh material
  104799. * @returns null or the current material
  104800. */
  104801. SubMesh.prototype.getMaterial = function () {
  104802. var rootMaterial = this._renderingMesh.material;
  104803. if (rootMaterial === null || rootMaterial === undefined) {
  104804. return this._mesh.getScene().defaultMaterial;
  104805. }
  104806. else if (rootMaterial.getSubMaterial) {
  104807. var multiMaterial = rootMaterial;
  104808. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  104809. if (this._currentMaterial !== effectiveMaterial) {
  104810. this._currentMaterial = effectiveMaterial;
  104811. this._materialDefines = null;
  104812. }
  104813. return effectiveMaterial;
  104814. }
  104815. return rootMaterial;
  104816. };
  104817. // Methods
  104818. /**
  104819. * Sets a new updated BoundingInfo object to the submesh
  104820. * @param data defines an optional position array to use to determine the bounding info
  104821. * @returns the SubMesh
  104822. */
  104823. SubMesh.prototype.refreshBoundingInfo = function (data) {
  104824. if (data === void 0) { data = null; }
  104825. this._lastColliderWorldVertices = null;
  104826. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  104827. return this;
  104828. }
  104829. if (!data) {
  104830. data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  104831. }
  104832. if (!data) {
  104833. this._boundingInfo = this._mesh.getBoundingInfo();
  104834. return this;
  104835. }
  104836. var indices = this._renderingMesh.getIndices();
  104837. var extend;
  104838. //is this the only submesh?
  104839. if (this.indexStart === 0 && this.indexCount === indices.length) {
  104840. var boundingInfo = this._renderingMesh.getBoundingInfo();
  104841. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  104842. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  104843. }
  104844. else {
  104845. extend = Object(_Maths_math_functions__WEBPACK_IMPORTED_MODULE_5__["extractMinAndMaxIndexed"])(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  104846. }
  104847. if (this._boundingInfo) {
  104848. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  104849. }
  104850. else {
  104851. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_3__["BoundingInfo"](extend.minimum, extend.maximum);
  104852. }
  104853. return this;
  104854. };
  104855. /** @hidden */
  104856. SubMesh.prototype._checkCollision = function (collider) {
  104857. var boundingInfo = this.getBoundingInfo();
  104858. return boundingInfo._checkCollision(collider);
  104859. };
  104860. /**
  104861. * Updates the submesh BoundingInfo
  104862. * @param world defines the world matrix to use to update the bounding info
  104863. * @returns the submesh
  104864. */
  104865. SubMesh.prototype.updateBoundingInfo = function (world) {
  104866. var boundingInfo = this.getBoundingInfo();
  104867. if (!boundingInfo) {
  104868. this.refreshBoundingInfo();
  104869. boundingInfo = this.getBoundingInfo();
  104870. }
  104871. boundingInfo.update(world);
  104872. return this;
  104873. };
  104874. /**
  104875. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104876. * @param frustumPlanes defines the frustum planes
  104877. * @returns true if the submesh is intersecting with the frustum
  104878. */
  104879. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  104880. var boundingInfo = this.getBoundingInfo();
  104881. if (!boundingInfo) {
  104882. return false;
  104883. }
  104884. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  104885. };
  104886. /**
  104887. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104888. * @param frustumPlanes defines the frustum planes
  104889. * @returns true if the submesh is inside the frustum
  104890. */
  104891. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  104892. var boundingInfo = this.getBoundingInfo();
  104893. if (!boundingInfo) {
  104894. return false;
  104895. }
  104896. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  104897. };
  104898. /**
  104899. * Renders the submesh
  104900. * @param enableAlphaMode defines if alpha needs to be used
  104901. * @returns the submesh
  104902. */
  104903. SubMesh.prototype.render = function (enableAlphaMode) {
  104904. this._renderingMesh.render(this, enableAlphaMode);
  104905. return this;
  104906. };
  104907. /**
  104908. * @hidden
  104909. */
  104910. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  104911. if (!this._linesIndexBuffer) {
  104912. var linesIndices = [];
  104913. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  104914. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  104915. }
  104916. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  104917. this._linesIndexCount = linesIndices.length;
  104918. }
  104919. return this._linesIndexBuffer;
  104920. };
  104921. /**
  104922. * Checks if the submesh intersects with a ray
  104923. * @param ray defines the ray to test
  104924. * @returns true is the passed ray intersects the submesh bounding box
  104925. */
  104926. SubMesh.prototype.canIntersects = function (ray) {
  104927. var boundingInfo = this.getBoundingInfo();
  104928. if (!boundingInfo) {
  104929. return false;
  104930. }
  104931. return ray.intersectsBox(boundingInfo.boundingBox);
  104932. };
  104933. /**
  104934. * Intersects current submesh with a ray
  104935. * @param ray defines the ray to test
  104936. * @param positions defines mesh's positions array
  104937. * @param indices defines mesh's indices array
  104938. * @param fastCheck defines if only bounding info should be used
  104939. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104940. * @returns intersection info or null if no intersection
  104941. */
  104942. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  104943. var material = this.getMaterial();
  104944. if (!material) {
  104945. return null;
  104946. }
  104947. switch (material.fillMode) {
  104948. case _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_PointListDrawMode:
  104949. case _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_LineListDrawMode:
  104950. case _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_LineLoopDrawMode:
  104951. case _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_LineStripDrawMode:
  104952. case _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_TriangleFanDrawMode:
  104953. case _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_TriangleStripDrawMode:
  104954. return null;
  104955. }
  104956. // LineMesh first as it's also a Mesh...
  104957. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  104958. // Check if mesh is unindexed
  104959. if (!indices.length) {
  104960. return this._intersectUnIndexedLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  104961. }
  104962. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  104963. }
  104964. else {
  104965. // Check if mesh is unindexed
  104966. if (!indices.length && this._mesh._unIndexed) {
  104967. return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  104968. }
  104969. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  104970. }
  104971. };
  104972. /** @hidden */
  104973. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  104974. var intersectInfo = null;
  104975. // Line test
  104976. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  104977. var p0 = positions[indices[index]];
  104978. var p1 = positions[indices[index + 1]];
  104979. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  104980. if (length < 0) {
  104981. continue;
  104982. }
  104983. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  104984. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__["IntersectionInfo"](null, null, length);
  104985. intersectInfo.faceId = index / 2;
  104986. if (fastCheck) {
  104987. break;
  104988. }
  104989. }
  104990. }
  104991. return intersectInfo;
  104992. };
  104993. /** @hidden */
  104994. SubMesh.prototype._intersectUnIndexedLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  104995. var intersectInfo = null;
  104996. // Line test
  104997. for (var index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {
  104998. var p0 = positions[index];
  104999. var p1 = positions[index + 1];
  105000. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  105001. if (length < 0) {
  105002. continue;
  105003. }
  105004. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  105005. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__["IntersectionInfo"](null, null, length);
  105006. intersectInfo.faceId = index / 2;
  105007. if (fastCheck) {
  105008. break;
  105009. }
  105010. }
  105011. }
  105012. return intersectInfo;
  105013. };
  105014. /** @hidden */
  105015. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  105016. var intersectInfo = null;
  105017. // Triangles test
  105018. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  105019. var p0 = positions[indices[index]];
  105020. var p1 = positions[indices[index + 1]];
  105021. var p2 = positions[indices[index + 2]];
  105022. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  105023. continue;
  105024. }
  105025. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  105026. if (currentIntersectInfo) {
  105027. if (currentIntersectInfo.distance < 0) {
  105028. continue;
  105029. }
  105030. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  105031. intersectInfo = currentIntersectInfo;
  105032. intersectInfo.faceId = index / 3;
  105033. if (fastCheck) {
  105034. break;
  105035. }
  105036. }
  105037. }
  105038. }
  105039. return intersectInfo;
  105040. };
  105041. /** @hidden */
  105042. SubMesh.prototype._intersectUnIndexedTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  105043. var intersectInfo = null;
  105044. // Triangles test
  105045. for (var index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {
  105046. var p0 = positions[index];
  105047. var p1 = positions[index + 1];
  105048. var p2 = positions[index + 2];
  105049. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  105050. continue;
  105051. }
  105052. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  105053. if (currentIntersectInfo) {
  105054. if (currentIntersectInfo.distance < 0) {
  105055. continue;
  105056. }
  105057. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  105058. intersectInfo = currentIntersectInfo;
  105059. intersectInfo.faceId = index / 3;
  105060. if (fastCheck) {
  105061. break;
  105062. }
  105063. }
  105064. }
  105065. }
  105066. return intersectInfo;
  105067. };
  105068. /** @hidden */
  105069. SubMesh.prototype._rebuild = function () {
  105070. if (this._linesIndexBuffer) {
  105071. this._linesIndexBuffer = null;
  105072. }
  105073. };
  105074. // Clone
  105075. /**
  105076. * Creates a new submesh from the passed mesh
  105077. * @param newMesh defines the new hosting mesh
  105078. * @param newRenderingMesh defines an optional rendering mesh
  105079. * @returns the new submesh
  105080. */
  105081. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  105082. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  105083. if (!this.IsGlobal) {
  105084. var boundingInfo = this.getBoundingInfo();
  105085. if (!boundingInfo) {
  105086. return result;
  105087. }
  105088. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_3__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  105089. }
  105090. return result;
  105091. };
  105092. // Dispose
  105093. /**
  105094. * Release associated resources
  105095. */
  105096. SubMesh.prototype.dispose = function () {
  105097. if (this._linesIndexBuffer) {
  105098. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  105099. this._linesIndexBuffer = null;
  105100. }
  105101. // Remove from mesh
  105102. var index = this._mesh.subMeshes.indexOf(this);
  105103. this._mesh.subMeshes.splice(index, 1);
  105104. };
  105105. /**
  105106. * Gets the class name
  105107. * @returns the string "SubMesh".
  105108. */
  105109. SubMesh.prototype.getClassName = function () {
  105110. return "SubMesh";
  105111. };
  105112. // Statics
  105113. /**
  105114. * Creates a new submesh from indices data
  105115. * @param materialIndex the index of the main mesh material
  105116. * @param startIndex the index where to start the copy in the mesh indices array
  105117. * @param indexCount the number of indices to copy then from the startIndex
  105118. * @param mesh the main mesh to create the submesh from
  105119. * @param renderingMesh the optional rendering mesh
  105120. * @returns a new submesh
  105121. */
  105122. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  105123. var minVertexIndex = Number.MAX_VALUE;
  105124. var maxVertexIndex = -Number.MAX_VALUE;
  105125. var whatWillRender = (renderingMesh || mesh);
  105126. var indices = whatWillRender.getIndices();
  105127. for (var index = startIndex; index < startIndex + indexCount; index++) {
  105128. var vertexIndex = indices[index];
  105129. if (vertexIndex < minVertexIndex) {
  105130. minVertexIndex = vertexIndex;
  105131. }
  105132. if (vertexIndex > maxVertexIndex) {
  105133. maxVertexIndex = vertexIndex;
  105134. }
  105135. }
  105136. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  105137. };
  105138. return SubMesh;
  105139. }(BaseSubMesh));
  105140. /***/ }),
  105141. /***/ "./Meshes/trailMesh.ts":
  105142. /*!*****************************!*\
  105143. !*** ./Meshes/trailMesh.ts ***!
  105144. \*****************************/
  105145. /*! exports provided: TrailMesh */
  105146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105147. "use strict";
  105148. __webpack_require__.r(__webpack_exports__);
  105149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  105150. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105151. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  105152. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  105153. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105154. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  105155. /**
  105156. * Class used to create a trail following a mesh
  105157. */
  105158. var TrailMesh = /** @class */ (function (_super) {
  105159. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  105160. /**
  105161. * @constructor
  105162. * @param name The value used by scene.getMeshByName() to do a lookup.
  105163. * @param generator The mesh to generate a trail.
  105164. * @param scene The scene to add this mesh to.
  105165. * @param diameter Diameter of trailing mesh. Default is 1.
  105166. * @param length Length of trailing mesh. Default is 60.
  105167. * @param autoStart Automatically start trailing mesh. Default true.
  105168. */
  105169. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  105170. if (diameter === void 0) { diameter = 1; }
  105171. if (length === void 0) { length = 60; }
  105172. if (autoStart === void 0) { autoStart = true; }
  105173. var _this = _super.call(this, name, scene) || this;
  105174. _this._sectionPolygonPointsCount = 4;
  105175. _this._running = false;
  105176. _this._autoStart = autoStart;
  105177. _this._generator = generator;
  105178. _this._diameter = diameter;
  105179. _this._length = length;
  105180. _this._sectionVectors = [];
  105181. _this._sectionNormalVectors = [];
  105182. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  105183. _this._sectionVectors[i] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  105184. _this._sectionNormalVectors[i] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  105185. }
  105186. _this._createMesh();
  105187. return _this;
  105188. }
  105189. /**
  105190. * "TrailMesh"
  105191. * @returns "TrailMesh"
  105192. */
  105193. TrailMesh.prototype.getClassName = function () {
  105194. return "TrailMesh";
  105195. };
  105196. TrailMesh.prototype._createMesh = function () {
  105197. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  105198. var positions = [];
  105199. var normals = [];
  105200. var indices = [];
  105201. var meshCenter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  105202. if (this._generator._boundingInfo) {
  105203. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  105204. }
  105205. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  105206. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  105207. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  105208. }
  105209. for (var i = 1; i <= this._length; i++) {
  105210. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  105211. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  105212. }
  105213. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  105214. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  105215. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  105216. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  105217. }
  105218. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  105219. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  105220. }
  105221. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  105222. data.positions = positions;
  105223. data.normals = normals;
  105224. data.indices = indices;
  105225. data.applyToMesh(this, true);
  105226. if (this._autoStart) {
  105227. this.start();
  105228. }
  105229. };
  105230. /**
  105231. * Start trailing mesh.
  105232. */
  105233. TrailMesh.prototype.start = function () {
  105234. var _this = this;
  105235. if (!this._running) {
  105236. this._running = true;
  105237. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  105238. _this.update();
  105239. });
  105240. }
  105241. };
  105242. /**
  105243. * Stop trailing mesh.
  105244. */
  105245. TrailMesh.prototype.stop = function () {
  105246. if (this._beforeRenderObserver && this._running) {
  105247. this._running = false;
  105248. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  105249. }
  105250. };
  105251. /**
  105252. * Update trailing mesh geometry.
  105253. */
  105254. TrailMesh.prototype.update = function () {
  105255. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  105256. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  105257. var wm = this._generator.getWorldMatrix();
  105258. if (positions && normals) {
  105259. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  105260. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  105261. }
  105262. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  105263. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  105264. }
  105265. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  105266. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  105267. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  105268. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  105269. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  105270. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  105271. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  105272. }
  105273. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  105274. positions[l + 3 * i] = this._sectionVectors[i].x;
  105275. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  105276. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  105277. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  105278. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  105279. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  105280. }
  105281. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  105282. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  105283. }
  105284. };
  105285. /**
  105286. * Returns a new TrailMesh object.
  105287. * @param name is a string, the name given to the new mesh
  105288. * @param newGenerator use new generator object for cloned trail mesh
  105289. * @returns a new mesh
  105290. */
  105291. TrailMesh.prototype.clone = function (name, newGenerator) {
  105292. if (name === void 0) { name = ""; }
  105293. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  105294. };
  105295. /**
  105296. * Serializes this trail mesh
  105297. * @param serializationObject object to write serialization to
  105298. */
  105299. TrailMesh.prototype.serialize = function (serializationObject) {
  105300. _super.prototype.serialize.call(this, serializationObject);
  105301. };
  105302. /**
  105303. * Parses a serialized trail mesh
  105304. * @param parsedMesh the serialized mesh
  105305. * @param scene the scene to create the trail mesh in
  105306. * @returns the created trail mesh
  105307. */
  105308. TrailMesh.Parse = function (parsedMesh, scene) {
  105309. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  105310. };
  105311. return TrailMesh;
  105312. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  105313. /***/ }),
  105314. /***/ "./Meshes/transformNode.ts":
  105315. /*!*********************************!*\
  105316. !*** ./Meshes/transformNode.ts ***!
  105317. \*********************************/
  105318. /*! exports provided: TransformNode */
  105319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105320. "use strict";
  105321. __webpack_require__.r(__webpack_exports__);
  105322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  105323. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105324. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105325. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105326. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  105327. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  105328. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  105329. /**
  105330. * 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.
  105331. * @see https://doc.babylonjs.com/how_to/transformnode
  105332. */
  105333. var TransformNode = /** @class */ (function (_super) {
  105334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  105335. function TransformNode(name, scene, isPure) {
  105336. if (scene === void 0) { scene = null; }
  105337. if (isPure === void 0) { isPure = true; }
  105338. var _this = _super.call(this, name, scene) || this;
  105339. _this._forward = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  105340. _this._forwardInverted = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  105341. _this._up = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  105342. _this._right = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  105343. _this._rightInverted = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  105344. // Properties
  105345. _this._position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105346. _this._rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105347. _this._rotationQuaternion = null;
  105348. _this._scaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  105349. _this._isDirty = false;
  105350. _this._transformToBoneReferal = null;
  105351. _this._isAbsoluteSynced = false;
  105352. _this._billboardMode = TransformNode.BILLBOARDMODE_NONE;
  105353. _this._preserveParentRotationForBillboard = false;
  105354. /**
  105355. * 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
  105356. */
  105357. _this.scalingDeterminant = 1;
  105358. _this._infiniteDistance = false;
  105359. /**
  105360. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  105361. * By default the system will update normals to compensate
  105362. */
  105363. _this.ignoreNonUniformScaling = false;
  105364. /**
  105365. * 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
  105366. */
  105367. _this.reIntegrateRotationIntoRotationQuaternion = false;
  105368. // Cache
  105369. /** @hidden */
  105370. _this._poseMatrix = null;
  105371. /** @hidden */
  105372. _this._localMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  105373. _this._usePivotMatrix = false;
  105374. _this._absolutePosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105375. _this._absoluteScaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105376. _this._absoluteRotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  105377. _this._pivotMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  105378. _this._postMultiplyPivotMatrix = false;
  105379. _this._isWorldMatrixFrozen = false;
  105380. /** @hidden */
  105381. _this._indexInSceneTransformNodesArray = -1;
  105382. /**
  105383. * An event triggered after the world matrix is updated
  105384. */
  105385. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105386. _this._nonUniformScaling = false;
  105387. if (isPure) {
  105388. _this.getScene().addTransformNode(_this);
  105389. }
  105390. return _this;
  105391. }
  105392. Object.defineProperty(TransformNode.prototype, "billboardMode", {
  105393. /**
  105394. * Gets or sets the billboard mode. Default is 0.
  105395. *
  105396. * | Value | Type | Description |
  105397. * | --- | --- | --- |
  105398. * | 0 | BILLBOARDMODE_NONE | |
  105399. * | 1 | BILLBOARDMODE_X | |
  105400. * | 2 | BILLBOARDMODE_Y | |
  105401. * | 4 | BILLBOARDMODE_Z | |
  105402. * | 7 | BILLBOARDMODE_ALL | |
  105403. *
  105404. */
  105405. get: function () {
  105406. return this._billboardMode;
  105407. },
  105408. set: function (value) {
  105409. if (this._billboardMode === value) {
  105410. return;
  105411. }
  105412. this._billboardMode = value;
  105413. },
  105414. enumerable: true,
  105415. configurable: true
  105416. });
  105417. Object.defineProperty(TransformNode.prototype, "preserveParentRotationForBillboard", {
  105418. /**
  105419. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  105420. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  105421. */
  105422. get: function () {
  105423. return this._preserveParentRotationForBillboard;
  105424. },
  105425. set: function (value) {
  105426. if (value === this._preserveParentRotationForBillboard) {
  105427. return;
  105428. }
  105429. this._preserveParentRotationForBillboard = value;
  105430. },
  105431. enumerable: true,
  105432. configurable: true
  105433. });
  105434. Object.defineProperty(TransformNode.prototype, "infiniteDistance", {
  105435. /**
  105436. * Gets or sets the distance of the object to max, often used by skybox
  105437. */
  105438. get: function () {
  105439. return this._infiniteDistance;
  105440. },
  105441. set: function (value) {
  105442. if (this._infiniteDistance === value) {
  105443. return;
  105444. }
  105445. this._infiniteDistance = value;
  105446. },
  105447. enumerable: true,
  105448. configurable: true
  105449. });
  105450. /**
  105451. * Gets a string identifying the name of the class
  105452. * @returns "TransformNode" string
  105453. */
  105454. TransformNode.prototype.getClassName = function () {
  105455. return "TransformNode";
  105456. };
  105457. Object.defineProperty(TransformNode.prototype, "position", {
  105458. /**
  105459. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  105460. */
  105461. get: function () {
  105462. return this._position;
  105463. },
  105464. set: function (newPosition) {
  105465. this._position = newPosition;
  105466. this._isDirty = true;
  105467. },
  105468. enumerable: true,
  105469. configurable: true
  105470. });
  105471. Object.defineProperty(TransformNode.prototype, "rotation", {
  105472. /**
  105473. * 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)).
  105474. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  105475. */
  105476. get: function () {
  105477. return this._rotation;
  105478. },
  105479. set: function (newRotation) {
  105480. this._rotation = newRotation;
  105481. this._rotationQuaternion = null;
  105482. this._isDirty = true;
  105483. },
  105484. enumerable: true,
  105485. configurable: true
  105486. });
  105487. Object.defineProperty(TransformNode.prototype, "scaling", {
  105488. /**
  105489. * 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)).
  105490. */
  105491. get: function () {
  105492. return this._scaling;
  105493. },
  105494. set: function (newScaling) {
  105495. this._scaling = newScaling;
  105496. this._isDirty = true;
  105497. },
  105498. enumerable: true,
  105499. configurable: true
  105500. });
  105501. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  105502. /**
  105503. * 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).
  105504. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  105505. */
  105506. get: function () {
  105507. return this._rotationQuaternion;
  105508. },
  105509. set: function (quaternion) {
  105510. this._rotationQuaternion = quaternion;
  105511. //reset the rotation vector.
  105512. if (quaternion) {
  105513. this._rotation.setAll(0.0);
  105514. }
  105515. this._isDirty = true;
  105516. },
  105517. enumerable: true,
  105518. configurable: true
  105519. });
  105520. Object.defineProperty(TransformNode.prototype, "forward", {
  105521. /**
  105522. * The forward direction of that transform in world space.
  105523. */
  105524. get: function () {
  105525. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  105526. },
  105527. enumerable: true,
  105528. configurable: true
  105529. });
  105530. Object.defineProperty(TransformNode.prototype, "up", {
  105531. /**
  105532. * The up direction of that transform in world space.
  105533. */
  105534. get: function () {
  105535. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  105536. },
  105537. enumerable: true,
  105538. configurable: true
  105539. });
  105540. Object.defineProperty(TransformNode.prototype, "right", {
  105541. /**
  105542. * The right direction of that transform in world space.
  105543. */
  105544. get: function () {
  105545. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  105546. },
  105547. enumerable: true,
  105548. configurable: true
  105549. });
  105550. /**
  105551. * Copies the parameter passed Matrix into the mesh Pose matrix.
  105552. * @param matrix the matrix to copy the pose from
  105553. * @returns this TransformNode.
  105554. */
  105555. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  105556. if (!this._poseMatrix) {
  105557. this._poseMatrix = matrix.clone();
  105558. return this;
  105559. }
  105560. this._poseMatrix.copyFrom(matrix);
  105561. return this;
  105562. };
  105563. /**
  105564. * Returns the mesh Pose matrix.
  105565. * @returns the pose matrix
  105566. */
  105567. TransformNode.prototype.getPoseMatrix = function () {
  105568. if (!this._poseMatrix) {
  105569. this._poseMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  105570. }
  105571. return this._poseMatrix;
  105572. };
  105573. /** @hidden */
  105574. TransformNode.prototype._isSynchronized = function () {
  105575. var cache = this._cache;
  105576. if (this.billboardMode !== cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  105577. return false;
  105578. }
  105579. if (cache.pivotMatrixUpdated) {
  105580. return false;
  105581. }
  105582. if (this.infiniteDistance) {
  105583. return false;
  105584. }
  105585. if (!cache.position.equals(this._position)) {
  105586. return false;
  105587. }
  105588. if (this._rotationQuaternion) {
  105589. if (!cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  105590. return false;
  105591. }
  105592. }
  105593. else if (!cache.rotation.equals(this._rotation)) {
  105594. return false;
  105595. }
  105596. if (!cache.scaling.equals(this._scaling)) {
  105597. return false;
  105598. }
  105599. return true;
  105600. };
  105601. /** @hidden */
  105602. TransformNode.prototype._initCache = function () {
  105603. _super.prototype._initCache.call(this);
  105604. var cache = this._cache;
  105605. cache.localMatrixUpdated = false;
  105606. cache.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105607. cache.scaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105608. cache.rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105609. cache.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  105610. cache.billboardMode = -1;
  105611. cache.infiniteDistance = false;
  105612. };
  105613. /**
  105614. * Flag the transform node as dirty (Forcing it to update everything)
  105615. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  105616. * @returns this transform node
  105617. */
  105618. TransformNode.prototype.markAsDirty = function (property) {
  105619. this._currentRenderId = Number.MAX_VALUE;
  105620. this._isDirty = true;
  105621. return this;
  105622. };
  105623. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  105624. /**
  105625. * Returns the current mesh absolute position.
  105626. * Returns a Vector3.
  105627. */
  105628. get: function () {
  105629. return this._absolutePosition;
  105630. },
  105631. enumerable: true,
  105632. configurable: true
  105633. });
  105634. Object.defineProperty(TransformNode.prototype, "absoluteScaling", {
  105635. /**
  105636. * Returns the current mesh absolute scaling.
  105637. * Returns a Vector3.
  105638. */
  105639. get: function () {
  105640. this._syncAbsoluteScalingAndRotation();
  105641. return this._absoluteScaling;
  105642. },
  105643. enumerable: true,
  105644. configurable: true
  105645. });
  105646. Object.defineProperty(TransformNode.prototype, "absoluteRotationQuaternion", {
  105647. /**
  105648. * Returns the current mesh absolute rotation.
  105649. * Returns a Quaternion.
  105650. */
  105651. get: function () {
  105652. this._syncAbsoluteScalingAndRotation();
  105653. return this._absoluteRotationQuaternion;
  105654. },
  105655. enumerable: true,
  105656. configurable: true
  105657. });
  105658. /**
  105659. * Sets a new matrix to apply before all other transformation
  105660. * @param matrix defines the transform matrix
  105661. * @returns the current TransformNode
  105662. */
  105663. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  105664. return this.setPivotMatrix(matrix, false);
  105665. };
  105666. /**
  105667. * Sets a new pivot matrix to the current node
  105668. * @param matrix defines the new pivot matrix to use
  105669. * @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
  105670. * @returns the current TransformNode
  105671. */
  105672. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  105673. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  105674. this._pivotMatrix.copyFrom(matrix);
  105675. this._usePivotMatrix = !this._pivotMatrix.isIdentity();
  105676. this._cache.pivotMatrixUpdated = true;
  105677. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  105678. if (this._postMultiplyPivotMatrix) {
  105679. if (!this._pivotMatrixInverse) {
  105680. this._pivotMatrixInverse = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  105681. }
  105682. else {
  105683. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  105684. }
  105685. }
  105686. return this;
  105687. };
  105688. /**
  105689. * Returns the mesh pivot matrix.
  105690. * Default : Identity.
  105691. * @returns the matrix
  105692. */
  105693. TransformNode.prototype.getPivotMatrix = function () {
  105694. return this._pivotMatrix;
  105695. };
  105696. /**
  105697. * Prevents the World matrix to be computed any longer.
  105698. * @returns the TransformNode.
  105699. */
  105700. TransformNode.prototype.freezeWorldMatrix = function () {
  105701. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  105702. this.computeWorldMatrix(true);
  105703. this._isWorldMatrixFrozen = true;
  105704. return this;
  105705. };
  105706. /**
  105707. * Allows back the World matrix computation.
  105708. * @returns the TransformNode.
  105709. */
  105710. TransformNode.prototype.unfreezeWorldMatrix = function () {
  105711. this._isWorldMatrixFrozen = false;
  105712. this.computeWorldMatrix(true);
  105713. return this;
  105714. };
  105715. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  105716. /**
  105717. * True if the World matrix has been frozen.
  105718. */
  105719. get: function () {
  105720. return this._isWorldMatrixFrozen;
  105721. },
  105722. enumerable: true,
  105723. configurable: true
  105724. });
  105725. /**
  105726. * Retuns the mesh absolute position in the World.
  105727. * @returns a Vector3.
  105728. */
  105729. TransformNode.prototype.getAbsolutePosition = function () {
  105730. this.computeWorldMatrix();
  105731. return this._absolutePosition;
  105732. };
  105733. /**
  105734. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  105735. * @param absolutePosition the absolute position to set
  105736. * @returns the TransformNode.
  105737. */
  105738. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  105739. if (!absolutePosition) {
  105740. return this;
  105741. }
  105742. var absolutePositionX;
  105743. var absolutePositionY;
  105744. var absolutePositionZ;
  105745. if (absolutePosition.x === undefined) {
  105746. if (arguments.length < 3) {
  105747. return this;
  105748. }
  105749. absolutePositionX = arguments[0];
  105750. absolutePositionY = arguments[1];
  105751. absolutePositionZ = arguments[2];
  105752. }
  105753. else {
  105754. absolutePositionX = absolutePosition.x;
  105755. absolutePositionY = absolutePosition.y;
  105756. absolutePositionZ = absolutePosition.z;
  105757. }
  105758. if (this.parent) {
  105759. var invertParentWorldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  105760. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  105761. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  105762. }
  105763. else {
  105764. this.position.x = absolutePositionX;
  105765. this.position.y = absolutePositionY;
  105766. this.position.z = absolutePositionZ;
  105767. }
  105768. return this;
  105769. };
  105770. /**
  105771. * Sets the mesh position in its local space.
  105772. * @param vector3 the position to set in localspace
  105773. * @returns the TransformNode.
  105774. */
  105775. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  105776. this.computeWorldMatrix();
  105777. this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  105778. return this;
  105779. };
  105780. /**
  105781. * Returns the mesh position in the local space from the current World matrix values.
  105782. * @returns a new Vector3.
  105783. */
  105784. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  105785. this.computeWorldMatrix();
  105786. var invLocalWorldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  105787. this._localMatrix.invertToRef(invLocalWorldMatrix);
  105788. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  105789. };
  105790. /**
  105791. * Translates the mesh along the passed Vector3 in its local space.
  105792. * @param vector3 the distance to translate in localspace
  105793. * @returns the TransformNode.
  105794. */
  105795. TransformNode.prototype.locallyTranslate = function (vector3) {
  105796. this.computeWorldMatrix(true);
  105797. this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  105798. return this;
  105799. };
  105800. /**
  105801. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  105802. * @param targetPoint the position (must be in same space as current mesh) to look at
  105803. * @param yawCor optional yaw (y-axis) correction in radians
  105804. * @param pitchCor optional pitch (x-axis) correction in radians
  105805. * @param rollCor optional roll (z-axis) correction in radians
  105806. * @param space the choosen space of the target
  105807. * @returns the TransformNode.
  105808. */
  105809. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  105810. if (yawCor === void 0) { yawCor = 0; }
  105811. if (pitchCor === void 0) { pitchCor = 0; }
  105812. if (rollCor === void 0) { rollCor = 0; }
  105813. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].LOCAL; }
  105814. var dv = TransformNode._lookAtVectorCache;
  105815. var pos = space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  105816. targetPoint.subtractToRef(pos, dv);
  105817. this.setDirection(dv, yawCor, pitchCor, rollCor);
  105818. // Correct for parent's rotation offset
  105819. if (space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].WORLD && this.parent) {
  105820. if (this.rotationQuaternion) {
  105821. // Get local rotation matrix of the looking object
  105822. var rotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  105823. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  105824. // Offset rotation by parent's inverted rotation matrix to correct in world space
  105825. var parentRotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1];
  105826. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  105827. parentRotationMatrix.invert();
  105828. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  105829. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  105830. }
  105831. else {
  105832. // Get local rotation matrix of the looking object
  105833. var quaternionRotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[0];
  105834. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  105835. var rotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  105836. quaternionRotation.toRotationMatrix(rotationMatrix);
  105837. // Offset rotation by parent's inverted rotation matrix to correct in world space
  105838. var parentRotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1];
  105839. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  105840. parentRotationMatrix.invert();
  105841. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  105842. quaternionRotation.fromRotationMatrix(rotationMatrix);
  105843. quaternionRotation.toEulerAnglesToRef(this.rotation);
  105844. }
  105845. }
  105846. return this;
  105847. };
  105848. /**
  105849. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  105850. * This Vector3 is expressed in the World space.
  105851. * @param localAxis axis to rotate
  105852. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  105853. */
  105854. TransformNode.prototype.getDirection = function (localAxis) {
  105855. var result = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105856. this.getDirectionToRef(localAxis, result);
  105857. return result;
  105858. };
  105859. /**
  105860. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  105861. * localAxis is expressed in the mesh local space.
  105862. * result is computed in the Wordl space from the mesh World matrix.
  105863. * @param localAxis axis to rotate
  105864. * @param result the resulting transformnode
  105865. * @returns this TransformNode.
  105866. */
  105867. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  105868. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  105869. return this;
  105870. };
  105871. /**
  105872. * Sets this transform node rotation to the given local axis.
  105873. * @param localAxis the axis in local space
  105874. * @param yawCor optional yaw (y-axis) correction in radians
  105875. * @param pitchCor optional pitch (x-axis) correction in radians
  105876. * @param rollCor optional roll (z-axis) correction in radians
  105877. * @returns this TransformNode
  105878. */
  105879. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  105880. if (yawCor === void 0) { yawCor = 0; }
  105881. if (pitchCor === void 0) { pitchCor = 0; }
  105882. if (rollCor === void 0) { rollCor = 0; }
  105883. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  105884. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  105885. var pitch = -Math.atan2(localAxis.y, len);
  105886. if (this.rotationQuaternion) {
  105887. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  105888. }
  105889. else {
  105890. this.rotation.x = pitch + pitchCor;
  105891. this.rotation.y = yaw + yawCor;
  105892. this.rotation.z = rollCor;
  105893. }
  105894. return this;
  105895. };
  105896. /**
  105897. * Sets a new pivot point to the current node
  105898. * @param point defines the new pivot point to use
  105899. * @param space defines if the point is in world or local space (local by default)
  105900. * @returns the current TransformNode
  105901. */
  105902. TransformNode.prototype.setPivotPoint = function (point, space) {
  105903. if (space === void 0) { space = _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].LOCAL; }
  105904. if (this.getScene().getRenderId() == 0) {
  105905. this.computeWorldMatrix(true);
  105906. }
  105907. var wm = this.getWorldMatrix();
  105908. if (space == _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].WORLD) {
  105909. var tmat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  105910. wm.invertToRef(tmat);
  105911. point = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  105912. }
  105913. return this.setPivotMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  105914. };
  105915. /**
  105916. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  105917. * @returns the pivot point
  105918. */
  105919. TransformNode.prototype.getPivotPoint = function () {
  105920. var point = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105921. this.getPivotPointToRef(point);
  105922. return point;
  105923. };
  105924. /**
  105925. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  105926. * @param result the vector3 to store the result
  105927. * @returns this TransformNode.
  105928. */
  105929. TransformNode.prototype.getPivotPointToRef = function (result) {
  105930. result.x = -this._pivotMatrix.m[12];
  105931. result.y = -this._pivotMatrix.m[13];
  105932. result.z = -this._pivotMatrix.m[14];
  105933. return this;
  105934. };
  105935. /**
  105936. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  105937. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  105938. */
  105939. TransformNode.prototype.getAbsolutePivotPoint = function () {
  105940. var point = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105941. this.getAbsolutePivotPointToRef(point);
  105942. return point;
  105943. };
  105944. /**
  105945. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  105946. * @param result vector3 to store the result
  105947. * @returns this TransformNode.
  105948. */
  105949. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  105950. result.x = this._pivotMatrix.m[12];
  105951. result.y = this._pivotMatrix.m[13];
  105952. result.z = this._pivotMatrix.m[14];
  105953. this.getPivotPointToRef(result);
  105954. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  105955. return this;
  105956. };
  105957. /**
  105958. * Defines the passed node as the parent of the current node.
  105959. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  105960. * @see https://doc.babylonjs.com/how_to/parenting
  105961. * @param node the node ot set as the parent
  105962. * @returns this TransformNode.
  105963. */
  105964. TransformNode.prototype.setParent = function (node) {
  105965. if (!node && !this.parent) {
  105966. return this;
  105967. }
  105968. var quatRotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[0];
  105969. var position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  105970. var scale = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
  105971. if (!node) {
  105972. this.computeWorldMatrix(true);
  105973. this.getWorldMatrix().decompose(scale, quatRotation, position);
  105974. }
  105975. else {
  105976. var diffMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  105977. var invParentMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1];
  105978. this.computeWorldMatrix(true);
  105979. node.computeWorldMatrix(true);
  105980. node.getWorldMatrix().invertToRef(invParentMatrix);
  105981. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  105982. diffMatrix.decompose(scale, quatRotation, position);
  105983. }
  105984. if (this.rotationQuaternion) {
  105985. this.rotationQuaternion.copyFrom(quatRotation);
  105986. }
  105987. else {
  105988. quatRotation.toEulerAnglesToRef(this.rotation);
  105989. }
  105990. this.scaling.copyFrom(scale);
  105991. this.position.copyFrom(position);
  105992. this.parent = node;
  105993. return this;
  105994. };
  105995. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  105996. /**
  105997. * True if the scaling property of this object is non uniform eg. (1,2,1)
  105998. */
  105999. get: function () {
  106000. return this._nonUniformScaling;
  106001. },
  106002. enumerable: true,
  106003. configurable: true
  106004. });
  106005. /** @hidden */
  106006. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  106007. if (this._nonUniformScaling === value) {
  106008. return false;
  106009. }
  106010. this._nonUniformScaling = value;
  106011. return true;
  106012. };
  106013. /**
  106014. * Attach the current TransformNode to another TransformNode associated with a bone
  106015. * @param bone Bone affecting the TransformNode
  106016. * @param affectedTransformNode TransformNode associated with the bone
  106017. * @returns this object
  106018. */
  106019. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  106020. this._transformToBoneReferal = affectedTransformNode;
  106021. this.parent = bone;
  106022. if (bone.getWorldMatrix().determinant() < 0) {
  106023. this.scalingDeterminant *= -1;
  106024. }
  106025. return this;
  106026. };
  106027. /**
  106028. * Detach the transform node if its associated with a bone
  106029. * @returns this object
  106030. */
  106031. TransformNode.prototype.detachFromBone = function () {
  106032. if (!this.parent) {
  106033. return this;
  106034. }
  106035. if (this.parent.getWorldMatrix().determinant() < 0) {
  106036. this.scalingDeterminant *= -1;
  106037. }
  106038. this._transformToBoneReferal = null;
  106039. this.parent = null;
  106040. return this;
  106041. };
  106042. /**
  106043. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  106044. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  106045. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  106046. * The passed axis is also normalized.
  106047. * @param axis the axis to rotate around
  106048. * @param amount the amount to rotate in radians
  106049. * @param space Space to rotate in (Default: local)
  106050. * @returns the TransformNode.
  106051. */
  106052. TransformNode.prototype.rotate = function (axis, amount, space) {
  106053. axis.normalize();
  106054. if (!this.rotationQuaternion) {
  106055. this.rotationQuaternion = this.rotation.toQuaternion();
  106056. this.rotation.setAll(0);
  106057. }
  106058. var rotationQuaternion;
  106059. if (!space || space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].LOCAL) {
  106060. rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  106061. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  106062. }
  106063. else {
  106064. if (this.parent) {
  106065. var invertParentWorldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  106066. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  106067. axis = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  106068. }
  106069. rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  106070. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  106071. }
  106072. return this;
  106073. };
  106074. /**
  106075. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  106076. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  106077. * The passed axis is also normalized. .
  106078. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  106079. * @param point the point to rotate around
  106080. * @param axis the axis to rotate around
  106081. * @param amount the amount to rotate in radians
  106082. * @returns the TransformNode
  106083. */
  106084. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  106085. axis.normalize();
  106086. if (!this.rotationQuaternion) {
  106087. this.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  106088. this.rotation.setAll(0);
  106089. }
  106090. var tmpVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  106091. var finalScale = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
  106092. var finalTranslation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[2];
  106093. var finalRotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[0];
  106094. var translationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0]; // T
  106095. var translationMatrixInv = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1]; // T'
  106096. var rotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[2]; // R
  106097. var finalMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[3]; // T' x R x T
  106098. point.subtractToRef(this.position, tmpVector);
  106099. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  106100. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  106101. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  106102. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  106103. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  106104. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  106105. this.position.addInPlace(finalTranslation);
  106106. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  106107. return this;
  106108. };
  106109. /**
  106110. * Translates the mesh along the axis vector for the passed distance in the given space.
  106111. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  106112. * @param axis the axis to translate in
  106113. * @param distance the distance to translate
  106114. * @param space Space to rotate in (Default: local)
  106115. * @returns the TransformNode.
  106116. */
  106117. TransformNode.prototype.translate = function (axis, distance, space) {
  106118. var displacementVector = axis.scale(distance);
  106119. if (!space || space === _Maths_math_axis__WEBPACK_IMPORTED_MODULE_5__["Space"].LOCAL) {
  106120. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  106121. this.setPositionWithLocalVector(tempV3);
  106122. }
  106123. else {
  106124. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  106125. }
  106126. return this;
  106127. };
  106128. /**
  106129. * Adds a rotation step to the mesh current rotation.
  106130. * x, y, z are Euler angles expressed in radians.
  106131. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  106132. * This means this rotation is made in the mesh local space only.
  106133. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  106134. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  106135. * ```javascript
  106136. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  106137. * ```
  106138. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  106139. * 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.
  106140. * @param x Rotation to add
  106141. * @param y Rotation to add
  106142. * @param z Rotation to add
  106143. * @returns the TransformNode.
  106144. */
  106145. TransformNode.prototype.addRotation = function (x, y, z) {
  106146. var rotationQuaternion;
  106147. if (this.rotationQuaternion) {
  106148. rotationQuaternion = this.rotationQuaternion;
  106149. }
  106150. else {
  106151. rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[1];
  106152. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  106153. }
  106154. var accumulation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[0];
  106155. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  106156. rotationQuaternion.multiplyInPlace(accumulation);
  106157. if (!this.rotationQuaternion) {
  106158. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  106159. }
  106160. return this;
  106161. };
  106162. /**
  106163. * @hidden
  106164. */
  106165. TransformNode.prototype._getEffectiveParent = function () {
  106166. return this.parent;
  106167. };
  106168. /**
  106169. * Computes the world matrix of the node
  106170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  106171. * @returns the world matrix
  106172. */
  106173. TransformNode.prototype.computeWorldMatrix = function (force) {
  106174. if (this._isWorldMatrixFrozen && !this._isDirty) {
  106175. return this._worldMatrix;
  106176. }
  106177. var currentRenderId = this.getScene().getRenderId();
  106178. if (!this._isDirty && !force && this.isSynchronized()) {
  106179. this._currentRenderId = currentRenderId;
  106180. return this._worldMatrix;
  106181. }
  106182. this._updateCache();
  106183. var cache = this._cache;
  106184. cache.pivotMatrixUpdated = false;
  106185. cache.billboardMode = this.billboardMode;
  106186. cache.infiniteDistance = this.infiniteDistance;
  106187. this._currentRenderId = currentRenderId;
  106188. this._childUpdateId++;
  106189. this._isDirty = false;
  106190. var parent = this._getEffectiveParent();
  106191. var useBillboardPath = this._billboardMode !== TransformNode.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
  106192. var camera = this.getScene().activeCamera;
  106193. // Scaling
  106194. var scaling = cache.scaling;
  106195. var translation = cache.position;
  106196. // Translation
  106197. if (this._infiniteDistance) {
  106198. if (!this.parent && camera) {
  106199. var cameraWorldMatrix = camera.getWorldMatrix();
  106200. var cameraGlobalPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  106201. translation.copyFromFloats(this._position.x + cameraGlobalPosition.x, this._position.y + cameraGlobalPosition.y, this._position.z + cameraGlobalPosition.z);
  106202. }
  106203. else {
  106204. translation.copyFrom(this._position);
  106205. }
  106206. }
  106207. else {
  106208. translation.copyFrom(this._position);
  106209. }
  106210. // Scaling
  106211. scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
  106212. // Rotation
  106213. var rotation = cache.rotationQuaternion;
  106214. if (this._rotationQuaternion) {
  106215. if (this.reIntegrateRotationIntoRotationQuaternion) {
  106216. var len = this.rotation.lengthSquared();
  106217. if (len) {
  106218. this._rotationQuaternion.multiplyInPlace(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
  106219. this._rotation.copyFromFloats(0, 0, 0);
  106220. }
  106221. }
  106222. rotation.copyFrom(this._rotationQuaternion);
  106223. }
  106224. else {
  106225. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
  106226. cache.rotation.copyFrom(this._rotation);
  106227. }
  106228. // Compose
  106229. if (this._usePivotMatrix) {
  106230. var scaleMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1];
  106231. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
  106232. // Rotation
  106233. var rotationMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0];
  106234. rotation.toRotationMatrix(rotationMatrix);
  106235. // Composing transformations
  106236. this._pivotMatrix.multiplyToRef(scaleMatrix, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[4]);
  106237. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[4].multiplyToRef(rotationMatrix, this._localMatrix);
  106238. // Post multiply inverse of pivotMatrix
  106239. if (this._postMultiplyPivotMatrix) {
  106240. this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix);
  106241. }
  106242. this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
  106243. }
  106244. else {
  106245. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ComposeToRef(scaling, rotation, translation, this._localMatrix);
  106246. }
  106247. // Parent
  106248. if (parent && parent.getWorldMatrix) {
  106249. if (force) {
  106250. parent.computeWorldMatrix();
  106251. }
  106252. if (useBillboardPath) {
  106253. if (this._transformToBoneReferal) {
  106254. parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[7]);
  106255. }
  106256. else {
  106257. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[7].copyFrom(parent.getWorldMatrix());
  106258. }
  106259. // Extract scaling and translation from parent
  106260. var translation_1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[5];
  106261. var scale = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[6];
  106262. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[7].decompose(scale, undefined, translation_1);
  106263. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[7]);
  106264. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[7].setTranslation(translation_1);
  106265. this._localMatrix.multiplyToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[7], this._worldMatrix);
  106266. }
  106267. else {
  106268. if (this._transformToBoneReferal) {
  106269. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[6]);
  106270. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  106271. }
  106272. else {
  106273. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), this._worldMatrix);
  106274. }
  106275. }
  106276. this._markSyncedWithParent();
  106277. }
  106278. else {
  106279. this._worldMatrix.copyFrom(this._localMatrix);
  106280. }
  106281. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  106282. if (useBillboardPath && camera) {
  106283. var storedTranslation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  106284. this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
  106285. // Cancel camera rotation
  106286. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1].copyFrom(camera.getViewMatrix());
  106287. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  106288. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[1].invertToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0]);
  106289. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  106290. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0].decompose(undefined, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[0], undefined);
  106291. var eulerAngles = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
  106292. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Quaternion[0].toEulerAnglesToRef(eulerAngles);
  106293. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
  106294. eulerAngles.x = 0;
  106295. }
  106296. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
  106297. eulerAngles.y = 0;
  106298. }
  106299. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
  106300. eulerAngles.z = 0;
  106301. }
  106302. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0]);
  106303. }
  106304. this._worldMatrix.setTranslationFromFloats(0, 0, 0);
  106305. this._worldMatrix.multiplyToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0], this._worldMatrix);
  106306. // Restore translation
  106307. this._worldMatrix.setTranslation(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0]);
  106308. }
  106309. // Normal matrix
  106310. if (!this.ignoreNonUniformScaling) {
  106311. if (this._scaling.isNonUniform) {
  106312. this._updateNonUniformScalingState(true);
  106313. }
  106314. else if (parent && parent._nonUniformScaling) {
  106315. this._updateNonUniformScalingState(parent._nonUniformScaling);
  106316. }
  106317. else {
  106318. this._updateNonUniformScalingState(false);
  106319. }
  106320. }
  106321. else {
  106322. this._updateNonUniformScalingState(false);
  106323. }
  106324. this._afterComputeWorldMatrix();
  106325. // Absolute position
  106326. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  106327. this._isAbsoluteSynced = false;
  106328. // Callbacks
  106329. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  106330. if (!this._poseMatrix) {
  106331. this._poseMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  106332. }
  106333. // Cache the determinant
  106334. this._worldMatrixDeterminantIsDirty = true;
  106335. return this._worldMatrix;
  106336. };
  106337. TransformNode.prototype._afterComputeWorldMatrix = function () {
  106338. };
  106339. /**
  106340. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  106341. * @param func callback function to add
  106342. *
  106343. * @returns the TransformNode.
  106344. */
  106345. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  106346. this.onAfterWorldMatrixUpdateObservable.add(func);
  106347. return this;
  106348. };
  106349. /**
  106350. * Removes a registered callback function.
  106351. * @param func callback function to remove
  106352. * @returns the TransformNode.
  106353. */
  106354. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  106355. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  106356. return this;
  106357. };
  106358. /**
  106359. * Gets the position of the current mesh in camera space
  106360. * @param camera defines the camera to use
  106361. * @returns a position
  106362. */
  106363. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  106364. if (camera === void 0) { camera = null; }
  106365. if (!camera) {
  106366. camera = this.getScene().activeCamera;
  106367. }
  106368. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  106369. };
  106370. /**
  106371. * Returns the distance from the mesh to the active camera
  106372. * @param camera defines the camera to use
  106373. * @returns the distance
  106374. */
  106375. TransformNode.prototype.getDistanceToCamera = function (camera) {
  106376. if (camera === void 0) { camera = null; }
  106377. if (!camera) {
  106378. camera = this.getScene().activeCamera;
  106379. }
  106380. return this.absolutePosition.subtract(camera.globalPosition).length();
  106381. };
  106382. /**
  106383. * Clone the current transform node
  106384. * @param name Name of the new clone
  106385. * @param newParent New parent for the clone
  106386. * @param doNotCloneChildren Do not clone children hierarchy
  106387. * @returns the new transform node
  106388. */
  106389. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  106390. var _this = this;
  106391. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  106392. result.name = name;
  106393. result.id = name;
  106394. if (newParent) {
  106395. result.parent = newParent;
  106396. }
  106397. if (!doNotCloneChildren) {
  106398. // Children
  106399. var directDescendants = this.getDescendants(true);
  106400. for (var index = 0; index < directDescendants.length; index++) {
  106401. var child = directDescendants[index];
  106402. if (child.clone) {
  106403. child.clone(name + "." + child.name, result);
  106404. }
  106405. }
  106406. }
  106407. return result;
  106408. };
  106409. /**
  106410. * Serializes the objects information.
  106411. * @param currentSerializationObject defines the object to serialize in
  106412. * @returns the serialized object
  106413. */
  106414. TransformNode.prototype.serialize = function (currentSerializationObject) {
  106415. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  106416. serializationObject.type = this.getClassName();
  106417. // Parent
  106418. if (this.parent) {
  106419. serializationObject.parentId = this.parent.id;
  106420. }
  106421. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  106422. serializationObject.isEnabled = this.isEnabled();
  106423. // Parent
  106424. if (this.parent) {
  106425. serializationObject.parentId = this.parent.id;
  106426. }
  106427. return serializationObject;
  106428. };
  106429. // Statics
  106430. /**
  106431. * Returns a new TransformNode object parsed from the source provided.
  106432. * @param parsedTransformNode is the source.
  106433. * @param scene the scne the object belongs to
  106434. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  106435. * @returns a new TransformNode object parsed from the source provided.
  106436. */
  106437. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  106438. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  106439. if (parsedTransformNode.localMatrix) {
  106440. transformNode.setPreTransformMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  106441. }
  106442. else if (parsedTransformNode.pivotMatrix) {
  106443. transformNode.setPivotMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  106444. }
  106445. transformNode.setEnabled(parsedTransformNode.isEnabled);
  106446. // Parent
  106447. if (parsedTransformNode.parentId) {
  106448. transformNode._waitingParentId = parsedTransformNode.parentId;
  106449. }
  106450. return transformNode;
  106451. };
  106452. /**
  106453. * Get all child-transformNodes of this node
  106454. * @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
  106455. * @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
  106456. * @returns an array of TransformNode
  106457. */
  106458. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  106459. var results = [];
  106460. this._getDescendants(results, directDescendantsOnly, function (node) {
  106461. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  106462. });
  106463. return results;
  106464. };
  106465. /**
  106466. * Releases resources associated with this transform node.
  106467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106469. */
  106470. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  106471. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  106472. // Animations
  106473. this.getScene().stopAnimation(this);
  106474. // Remove from scene
  106475. this.getScene().removeTransformNode(this);
  106476. this.onAfterWorldMatrixUpdateObservable.clear();
  106477. if (doNotRecurse) {
  106478. var transformNodes = this.getChildTransformNodes(true);
  106479. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  106480. var transformNode = transformNodes_1[_i];
  106481. transformNode.parent = null;
  106482. transformNode.computeWorldMatrix(true);
  106483. }
  106484. }
  106485. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  106486. };
  106487. /**
  106488. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  106489. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  106490. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  106491. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  106492. * @returns the current mesh
  106493. */
  106494. TransformNode.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation, predicate) {
  106495. if (includeDescendants === void 0) { includeDescendants = true; }
  106496. if (ignoreRotation === void 0) { ignoreRotation = false; }
  106497. var storedRotation = null;
  106498. var storedRotationQuaternion = null;
  106499. if (ignoreRotation) {
  106500. if (this.rotationQuaternion) {
  106501. storedRotationQuaternion = this.rotationQuaternion.clone();
  106502. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  106503. }
  106504. else if (this.rotation) {
  106505. storedRotation = this.rotation.clone();
  106506. this.rotation.copyFromFloats(0, 0, 0);
  106507. }
  106508. }
  106509. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants, predicate);
  106510. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  106511. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  106512. if (maxDimension === 0) {
  106513. return this;
  106514. }
  106515. var scale = 1 / maxDimension;
  106516. this.scaling.scaleInPlace(scale);
  106517. if (ignoreRotation) {
  106518. if (this.rotationQuaternion && storedRotationQuaternion) {
  106519. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  106520. }
  106521. else if (this.rotation && storedRotation) {
  106522. this.rotation.copyFrom(storedRotation);
  106523. }
  106524. }
  106525. return this;
  106526. };
  106527. TransformNode.prototype._syncAbsoluteScalingAndRotation = function () {
  106528. if (!this._isAbsoluteSynced) {
  106529. this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion);
  106530. this._isAbsoluteSynced = true;
  106531. }
  106532. };
  106533. // Statics
  106534. /**
  106535. * Object will not rotate to face the camera
  106536. */
  106537. TransformNode.BILLBOARDMODE_NONE = 0;
  106538. /**
  106539. * Object will rotate to face the camera but only on the x axis
  106540. */
  106541. TransformNode.BILLBOARDMODE_X = 1;
  106542. /**
  106543. * Object will rotate to face the camera but only on the y axis
  106544. */
  106545. TransformNode.BILLBOARDMODE_Y = 2;
  106546. /**
  106547. * Object will rotate to face the camera but only on the z axis
  106548. */
  106549. TransformNode.BILLBOARDMODE_Z = 4;
  106550. /**
  106551. * Object will rotate to face the camera
  106552. */
  106553. TransformNode.BILLBOARDMODE_ALL = 7;
  106554. TransformNode._lookAtVectorCache = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  106555. TransformNode._rotationAxisCache = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  106556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  106558. ], TransformNode.prototype, "_position", void 0);
  106559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  106561. ], TransformNode.prototype, "_rotation", void 0);
  106562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  106564. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  106565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  106567. ], TransformNode.prototype, "_scaling", void 0);
  106568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("billboardMode")
  106570. ], TransformNode.prototype, "_billboardMode", void 0);
  106571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  106573. ], TransformNode.prototype, "scalingDeterminant", void 0);
  106574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("infiniteDistance")
  106576. ], TransformNode.prototype, "_infiniteDistance", void 0);
  106577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  106579. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  106580. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  106581. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  106582. ], TransformNode.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0);
  106583. return TransformNode;
  106584. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  106585. /***/ }),
  106586. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  106587. /*!***************************************************************!*\
  106588. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  106589. \***************************************************************/
  106590. /*! exports provided: CubeMapToSphericalPolynomialTools */
  106591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106592. "use strict";
  106593. __webpack_require__.r(__webpack_exports__);
  106594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  106595. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  106596. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106597. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  106598. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  106599. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.constants */ "./Maths/math.constants.ts");
  106600. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math.color */ "./Maths/math.color.ts");
  106601. var FileFaceOrientation = /** @class */ (function () {
  106602. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  106603. this.name = name;
  106604. this.worldAxisForNormal = worldAxisForNormal;
  106605. this.worldAxisForFileX = worldAxisForFileX;
  106606. this.worldAxisForFileY = worldAxisForFileY;
  106607. }
  106608. return FileFaceOrientation;
  106609. }());
  106610. /**
  106611. * Helper class dealing with the extraction of spherical polynomial dataArray
  106612. * from a cube map.
  106613. */
  106614. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  106615. function CubeMapToSphericalPolynomialTools() {
  106616. }
  106617. /**
  106618. * Converts a texture to the according Spherical Polynomial data.
  106619. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106620. *
  106621. * @param texture The texture to extract the information from.
  106622. * @return The Spherical Polynomial data.
  106623. */
  106624. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  106625. if (!texture.isCube) {
  106626. // Only supports cube Textures currently.
  106627. return null;
  106628. }
  106629. var size = texture.getSize().width;
  106630. var right = texture.readPixels(0);
  106631. var left = texture.readPixels(1);
  106632. var up;
  106633. var down;
  106634. if (texture.isRenderTarget) {
  106635. up = texture.readPixels(3);
  106636. down = texture.readPixels(2);
  106637. }
  106638. else {
  106639. up = texture.readPixels(2);
  106640. down = texture.readPixels(3);
  106641. }
  106642. var front = texture.readPixels(4);
  106643. var back = texture.readPixels(5);
  106644. var gammaSpace = texture.gammaSpace;
  106645. // Always read as RGBA.
  106646. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  106647. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  106648. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  106649. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  106650. }
  106651. var cubeInfo = {
  106652. size: size,
  106653. right: right,
  106654. left: left,
  106655. up: up,
  106656. down: down,
  106657. front: front,
  106658. back: back,
  106659. format: format,
  106660. type: type,
  106661. gammaSpace: gammaSpace,
  106662. };
  106663. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  106664. };
  106665. /**
  106666. * Converts a cubemap to the according Spherical Polynomial data.
  106667. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106668. *
  106669. * @param cubeInfo The Cube map to extract the information from.
  106670. * @return The Spherical Polynomial data.
  106671. */
  106672. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  106673. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  106674. var totalSolidAngle = 0.0;
  106675. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  106676. var du = 2.0 / cubeInfo.size;
  106677. var dv = du;
  106678. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  106679. var minUV = du * 0.5 - 1.0;
  106680. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  106681. var fileFace = this.FileFaces[faceIndex];
  106682. var dataArray = cubeInfo[fileFace.name];
  106683. var v = minUV;
  106684. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  106685. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  106686. // Because SP is still linear, so summation is fine in that basis.
  106687. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  106688. for (var y = 0; y < cubeInfo.size; y++) {
  106689. var u = minUV;
  106690. for (var x = 0; x < cubeInfo.size; x++) {
  106691. // World direction (not normalised)
  106692. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  106693. worldDirection.normalize();
  106694. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  106695. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  106696. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  106697. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  106698. // Prevent NaN harmonics with extreme HDRI data.
  106699. if (isNaN(r)) {
  106700. r = 0;
  106701. }
  106702. if (isNaN(g)) {
  106703. g = 0;
  106704. }
  106705. if (isNaN(b)) {
  106706. b = 0;
  106707. }
  106708. // Handle Integer types.
  106709. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  106710. r /= 255;
  106711. g /= 255;
  106712. b /= 255;
  106713. }
  106714. // Handle Gamma space textures.
  106715. if (cubeInfo.gammaSpace) {
  106716. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["ToLinearSpace"]);
  106717. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["ToLinearSpace"]);
  106718. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math_constants__WEBPACK_IMPORTED_MODULE_4__["ToLinearSpace"]);
  106719. }
  106720. // Prevent to explode in case of really high dynamic ranges.
  106721. // sh 3 would not be enough to accurately represent it.
  106722. var max = 4096;
  106723. r = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r, 0, max);
  106724. g = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g, 0, max);
  106725. b = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b, 0, max);
  106726. var color = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_5__["Color3"](r, g, b);
  106727. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  106728. totalSolidAngle += deltaSolidAngle;
  106729. u += du;
  106730. }
  106731. v += dv;
  106732. }
  106733. }
  106734. // Solid angle for entire sphere is 4*pi
  106735. var sphereSolidAngle = 4.0 * Math.PI;
  106736. // Adjust the solid angle to allow for how many faces we processed.
  106737. var facesProcessed = 6.0;
  106738. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  106739. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  106740. // This is needed because the numerical integration over the cube uses a
  106741. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  106742. // and also to compensate for accumulative error due to float precision in the summation.
  106743. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  106744. sphericalHarmonics.scaleInPlace(correctionFactor);
  106745. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  106746. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  106747. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  106748. };
  106749. CubeMapToSphericalPolynomialTools.FileFaces = [
  106750. new FileFaceOrientation("right", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  106751. new FileFaceOrientation("left", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  106752. new FileFaceOrientation("up", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1)),
  106753. new FileFaceOrientation("down", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1)),
  106754. new FileFaceOrientation("front", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  106755. new FileFaceOrientation("back", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)) // -Z bottom
  106756. ];
  106757. return CubeMapToSphericalPolynomialTools;
  106758. }());
  106759. /***/ }),
  106760. /***/ "./Misc/HighDynamicRange/hdr.ts":
  106761. /*!**************************************!*\
  106762. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  106763. \**************************************/
  106764. /*! exports provided: HDRTools */
  106765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106766. "use strict";
  106767. __webpack_require__.r(__webpack_exports__);
  106768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  106769. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  106770. /**
  106771. * This groups tools to convert HDR texture to native colors array.
  106772. */
  106773. var HDRTools = /** @class */ (function () {
  106774. function HDRTools() {
  106775. }
  106776. HDRTools.Ldexp = function (mantissa, exponent) {
  106777. if (exponent > 1023) {
  106778. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  106779. }
  106780. if (exponent < -1074) {
  106781. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  106782. }
  106783. return mantissa * Math.pow(2, exponent);
  106784. };
  106785. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  106786. if (exponent > 0) { /*nonzero pixel*/
  106787. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  106788. float32array[index + 0] = red * exponent;
  106789. float32array[index + 1] = green * exponent;
  106790. float32array[index + 2] = blue * exponent;
  106791. }
  106792. else {
  106793. float32array[index + 0] = 0;
  106794. float32array[index + 1] = 0;
  106795. float32array[index + 2] = 0;
  106796. }
  106797. };
  106798. HDRTools.readStringLine = function (uint8array, startIndex) {
  106799. var line = "";
  106800. var character = "";
  106801. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  106802. character = String.fromCharCode(uint8array[i]);
  106803. if (character == "\n") {
  106804. break;
  106805. }
  106806. line += character;
  106807. }
  106808. return line;
  106809. };
  106810. /**
  106811. * Reads header information from an RGBE texture stored in a native array.
  106812. * More information on this format are available here:
  106813. * https://en.wikipedia.org/wiki/RGBE_image_format
  106814. *
  106815. * @param uint8array The binary file stored in native array.
  106816. * @return The header information.
  106817. */
  106818. HDRTools.RGBE_ReadHeader = function (uint8array) {
  106819. var height = 0;
  106820. var width = 0;
  106821. var line = this.readStringLine(uint8array, 0);
  106822. if (line[0] != '#' || line[1] != '?') {
  106823. throw "Bad HDR Format.";
  106824. }
  106825. var endOfHeader = false;
  106826. var findFormat = false;
  106827. var lineIndex = 0;
  106828. do {
  106829. lineIndex += (line.length + 1);
  106830. line = this.readStringLine(uint8array, lineIndex);
  106831. if (line == "FORMAT=32-bit_rle_rgbe") {
  106832. findFormat = true;
  106833. }
  106834. else if (line.length == 0) {
  106835. endOfHeader = true;
  106836. }
  106837. } while (!endOfHeader);
  106838. if (!findFormat) {
  106839. throw "HDR Bad header format, unsupported FORMAT";
  106840. }
  106841. lineIndex += (line.length + 1);
  106842. line = this.readStringLine(uint8array, lineIndex);
  106843. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  106844. var match = sizeRegexp.exec(line);
  106845. // TODO. Support +Y and -X if needed.
  106846. if (!match || match.length < 3) {
  106847. throw "HDR Bad header format, no size";
  106848. }
  106849. width = parseInt(match[2]);
  106850. height = parseInt(match[1]);
  106851. if (width < 8 || width > 0x7fff) {
  106852. throw "HDR Bad header format, unsupported size";
  106853. }
  106854. lineIndex += (line.length + 1);
  106855. return {
  106856. height: height,
  106857. width: width,
  106858. dataPosition: lineIndex
  106859. };
  106860. };
  106861. /**
  106862. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  106863. * This RGBE texture needs to store the information as a panorama.
  106864. *
  106865. * More information on this format are available here:
  106866. * https://en.wikipedia.org/wiki/RGBE_image_format
  106867. *
  106868. * @param buffer The binary file stored in an array buffer.
  106869. * @param size The expected size of the extracted cubemap.
  106870. * @return The Cube Map information.
  106871. */
  106872. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  106873. var uint8array = new Uint8Array(buffer);
  106874. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  106875. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  106876. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  106877. return cubeMapData;
  106878. };
  106879. /**
  106880. * Returns the pixels data extracted from an RGBE texture.
  106881. * This pixels will be stored left to right up to down in the R G B order in one array.
  106882. *
  106883. * More information on this format are available here:
  106884. * https://en.wikipedia.org/wiki/RGBE_image_format
  106885. *
  106886. * @param uint8array The binary file stored in an array buffer.
  106887. * @param hdrInfo The header information of the file.
  106888. * @return The pixels data in RGB right to left up to down order.
  106889. */
  106890. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  106891. // Keep for multi format supports.
  106892. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  106893. };
  106894. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  106895. var num_scanlines = hdrInfo.height;
  106896. var scanline_width = hdrInfo.width;
  106897. var a, b, c, d, count;
  106898. var dataIndex = hdrInfo.dataPosition;
  106899. var index = 0, endIndex = 0, i = 0;
  106900. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  106901. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  106902. // 3 channels of 4 bytes per pixel in float.
  106903. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  106904. var resultArray = new Float32Array(resultBuffer);
  106905. // read in each successive scanline
  106906. while (num_scanlines > 0) {
  106907. a = uint8array[dataIndex++];
  106908. b = uint8array[dataIndex++];
  106909. c = uint8array[dataIndex++];
  106910. d = uint8array[dataIndex++];
  106911. if (a != 2 || b != 2 || (c & 0x80)) {
  106912. // this file is not run length encoded
  106913. throw "HDR Bad header format, not RLE";
  106914. }
  106915. if (((c << 8) | d) != scanline_width) {
  106916. throw "HDR Bad header format, wrong scan line width";
  106917. }
  106918. index = 0;
  106919. // read each of the four channels for the scanline into the buffer
  106920. for (i = 0; i < 4; i++) {
  106921. endIndex = (i + 1) * scanline_width;
  106922. while (index < endIndex) {
  106923. a = uint8array[dataIndex++];
  106924. b = uint8array[dataIndex++];
  106925. if (a > 128) {
  106926. // a run of the same value
  106927. count = a - 128;
  106928. if ((count == 0) || (count > endIndex - index)) {
  106929. throw "HDR Bad Format, bad scanline data (run)";
  106930. }
  106931. while (count-- > 0) {
  106932. scanLineArray[index++] = b;
  106933. }
  106934. }
  106935. else {
  106936. // a non-run
  106937. count = a;
  106938. if ((count == 0) || (count > endIndex - index)) {
  106939. throw "HDR Bad Format, bad scanline data (non-run)";
  106940. }
  106941. scanLineArray[index++] = b;
  106942. if (--count > 0) {
  106943. for (var j = 0; j < count; j++) {
  106944. scanLineArray[index++] = uint8array[dataIndex++];
  106945. }
  106946. }
  106947. }
  106948. }
  106949. }
  106950. // now convert data from buffer into floats
  106951. for (i = 0; i < scanline_width; i++) {
  106952. a = scanLineArray[i];
  106953. b = scanLineArray[i + scanline_width];
  106954. c = scanLineArray[i + 2 * scanline_width];
  106955. d = scanLineArray[i + 3 * scanline_width];
  106956. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  106957. }
  106958. num_scanlines--;
  106959. }
  106960. return resultArray;
  106961. };
  106962. return HDRTools;
  106963. }());
  106964. /***/ }),
  106965. /***/ "./Misc/HighDynamicRange/index.ts":
  106966. /*!****************************************!*\
  106967. !*** ./Misc/HighDynamicRange/index.ts ***!
  106968. \****************************************/
  106969. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  106970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106971. "use strict";
  106972. __webpack_require__.r(__webpack_exports__);
  106973. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  106974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  106975. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  106976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  106977. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  106978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  106979. /***/ }),
  106980. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  106981. /*!****************************************************!*\
  106982. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  106983. \****************************************************/
  106984. /*! exports provided: PanoramaToCubeMapTools */
  106985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106986. "use strict";
  106987. __webpack_require__.r(__webpack_exports__);
  106988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  106989. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  106990. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  106991. /**
  106992. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106993. */
  106994. var PanoramaToCubeMapTools = /** @class */ (function () {
  106995. function PanoramaToCubeMapTools() {
  106996. }
  106997. /**
  106998. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106999. *
  107000. * @param float32Array The source data.
  107001. * @param inputWidth The width of the input panorama.
  107002. * @param inputHeight The height of the input panorama.
  107003. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  107004. * @return The cubemap data
  107005. */
  107006. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  107007. if (!float32Array) {
  107008. throw "ConvertPanoramaToCubemap: input cannot be null";
  107009. }
  107010. if (float32Array.length != inputWidth * inputHeight * 3) {
  107011. throw "ConvertPanoramaToCubemap: input size is wrong";
  107012. }
  107013. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  107014. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  107015. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  107016. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  107017. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  107018. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  107019. return {
  107020. front: textureFront,
  107021. back: textureBack,
  107022. left: textureLeft,
  107023. right: textureRight,
  107024. up: textureUp,
  107025. down: textureDown,
  107026. size: size,
  107027. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  107028. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  107029. gammaSpace: false,
  107030. };
  107031. };
  107032. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  107033. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  107034. var textureArray = new Float32Array(buffer);
  107035. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  107036. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  107037. var dy = 1 / texSize;
  107038. var fy = 0;
  107039. for (var y = 0; y < texSize; y++) {
  107040. var xv1 = faceData[0];
  107041. var xv2 = faceData[2];
  107042. for (var x = 0; x < texSize; x++) {
  107043. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  107044. v.normalize();
  107045. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  107046. // 3 channels per pixels
  107047. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  107048. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  107049. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  107050. xv1 = xv1.add(rotDX1);
  107051. xv2 = xv2.add(rotDX2);
  107052. }
  107053. fy += dy;
  107054. }
  107055. return textureArray;
  107056. };
  107057. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  107058. var theta = Math.atan2(vDir.z, vDir.x);
  107059. var phi = Math.acos(vDir.y);
  107060. while (theta < -Math.PI) {
  107061. theta += 2 * Math.PI;
  107062. }
  107063. while (theta > Math.PI) {
  107064. theta -= 2 * Math.PI;
  107065. }
  107066. var dx = theta / Math.PI;
  107067. var dy = phi / Math.PI;
  107068. // recenter.
  107069. dx = dx * 0.5 + 0.5;
  107070. var px = Math.round(dx * inputWidth);
  107071. if (px < 0) {
  107072. px = 0;
  107073. }
  107074. else if (px >= inputWidth) {
  107075. px = inputWidth - 1;
  107076. }
  107077. var py = Math.round(dy * inputHeight);
  107078. if (py < 0) {
  107079. py = 0;
  107080. }
  107081. else if (py >= inputHeight) {
  107082. py = inputHeight - 1;
  107083. }
  107084. var inputY = (inputHeight - py - 1);
  107085. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  107086. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  107087. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  107088. return {
  107089. r: r,
  107090. g: g,
  107091. b: b
  107092. };
  107093. };
  107094. PanoramaToCubeMapTools.FACE_FRONT = [
  107095. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  107096. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  107097. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  107098. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  107099. ];
  107100. PanoramaToCubeMapTools.FACE_BACK = [
  107101. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  107102. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  107103. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  107104. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  107105. ];
  107106. PanoramaToCubeMapTools.FACE_RIGHT = [
  107107. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  107108. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  107109. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  107110. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  107111. ];
  107112. PanoramaToCubeMapTools.FACE_LEFT = [
  107113. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  107114. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  107115. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  107116. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  107117. ];
  107118. PanoramaToCubeMapTools.FACE_DOWN = [
  107119. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  107120. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  107121. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  107122. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  107123. ];
  107124. PanoramaToCubeMapTools.FACE_UP = [
  107125. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  107126. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  107127. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  107128. new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  107129. ];
  107130. return PanoramaToCubeMapTools;
  107131. }());
  107132. /***/ }),
  107133. /***/ "./Misc/andOrNotEvaluator.ts":
  107134. /*!***********************************!*\
  107135. !*** ./Misc/andOrNotEvaluator.ts ***!
  107136. \***********************************/
  107137. /*! exports provided: AndOrNotEvaluator */
  107138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107139. "use strict";
  107140. __webpack_require__.r(__webpack_exports__);
  107141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  107142. /**
  107143. * Class used to evalaute queries containing `and` and `or` operators
  107144. */
  107145. var AndOrNotEvaluator = /** @class */ (function () {
  107146. function AndOrNotEvaluator() {
  107147. }
  107148. /**
  107149. * Evaluate a query
  107150. * @param query defines the query to evaluate
  107151. * @param evaluateCallback defines the callback used to filter result
  107152. * @returns true if the query matches
  107153. */
  107154. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  107155. if (!query.match(/\([^\(\)]*\)/g)) {
  107156. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  107157. }
  107158. else {
  107159. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  107160. // remove parenthesis
  107161. r = r.slice(1, r.length - 1);
  107162. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  107163. });
  107164. }
  107165. if (query === "true") {
  107166. return true;
  107167. }
  107168. if (query === "false") {
  107169. return false;
  107170. }
  107171. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  107172. };
  107173. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  107174. evaluateCallback = evaluateCallback || (function (r) {
  107175. return r === "true" ? true : false;
  107176. });
  107177. var result;
  107178. var or = parenthesisContent.split("||");
  107179. for (var i in or) {
  107180. if (or.hasOwnProperty(i)) {
  107181. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  107182. var and = ori.split("&&");
  107183. if (and.length > 1) {
  107184. for (var j = 0; j < and.length; ++j) {
  107185. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  107186. if (andj !== "true" && andj !== "false") {
  107187. if (andj[0] === "!") {
  107188. result = !evaluateCallback(andj.substring(1));
  107189. }
  107190. else {
  107191. result = evaluateCallback(andj);
  107192. }
  107193. }
  107194. else {
  107195. result = andj === "true" ? true : false;
  107196. }
  107197. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  107198. ori = "false";
  107199. break;
  107200. }
  107201. }
  107202. }
  107203. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  107204. result = true;
  107205. break;
  107206. }
  107207. // result equals false (or undefined)
  107208. if (ori !== "true" && ori !== "false") {
  107209. if (ori[0] === "!") {
  107210. result = !evaluateCallback(ori.substring(1));
  107211. }
  107212. else {
  107213. result = evaluateCallback(ori);
  107214. }
  107215. }
  107216. else {
  107217. result = ori === "true" ? true : false;
  107218. }
  107219. }
  107220. }
  107221. // the whole parenthesis scope is replaced by 'true' or 'false'
  107222. return result ? "true" : "false";
  107223. };
  107224. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  107225. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  107226. // remove whitespaces
  107227. r = r.replace(/[\s]/g, function () { return ""; });
  107228. return r.length % 2 ? "!" : "";
  107229. });
  107230. booleanString = booleanString.trim();
  107231. if (booleanString === "!true") {
  107232. booleanString = "false";
  107233. }
  107234. else if (booleanString === "!false") {
  107235. booleanString = "true";
  107236. }
  107237. return booleanString;
  107238. };
  107239. return AndOrNotEvaluator;
  107240. }());
  107241. /***/ }),
  107242. /***/ "./Misc/arrayTools.ts":
  107243. /*!****************************!*\
  107244. !*** ./Misc/arrayTools.ts ***!
  107245. \****************************/
  107246. /*! exports provided: ArrayTools */
  107247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107248. "use strict";
  107249. __webpack_require__.r(__webpack_exports__);
  107250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  107251. /**
  107252. * Class containing a set of static utilities functions for arrays.
  107253. */
  107254. var ArrayTools = /** @class */ (function () {
  107255. function ArrayTools() {
  107256. }
  107257. /**
  107258. * Returns an array of the given size filled with element built from the given constructor and the paramters
  107259. * @param size the number of element to construct and put in the array
  107260. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  107261. * @returns a new array filled with new objects
  107262. */
  107263. ArrayTools.BuildArray = function (size, itemBuilder) {
  107264. var a = [];
  107265. for (var i = 0; i < size; ++i) {
  107266. a.push(itemBuilder());
  107267. }
  107268. return a;
  107269. };
  107270. return ArrayTools;
  107271. }());
  107272. /***/ }),
  107273. /***/ "./Misc/assetsManager.ts":
  107274. /*!*******************************!*\
  107275. !*** ./Misc/assetsManager.ts ***!
  107276. \*******************************/
  107277. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager */
  107278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107279. "use strict";
  107280. __webpack_require__.r(__webpack_exports__);
  107281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  107282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  107283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  107284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  107285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  107286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  107287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  107288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  107289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  107290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  107291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return EquiRectangularCubeTextureAssetTask; });
  107292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  107293. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107294. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  107295. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  107296. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  107297. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  107298. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  107299. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  107300. /* harmony import */ var _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  107301. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  107302. /**
  107303. * Defines the list of states available for a task inside a AssetsManager
  107304. */
  107305. var AssetTaskState;
  107306. (function (AssetTaskState) {
  107307. /**
  107308. * Initialization
  107309. */
  107310. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  107311. /**
  107312. * Running
  107313. */
  107314. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  107315. /**
  107316. * Done
  107317. */
  107318. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  107319. /**
  107320. * Error
  107321. */
  107322. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  107323. })(AssetTaskState || (AssetTaskState = {}));
  107324. /**
  107325. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  107326. */
  107327. var AbstractAssetTask = /** @class */ (function () {
  107328. /**
  107329. * Creates a new AssetsManager
  107330. * @param name defines the name of the task
  107331. */
  107332. function AbstractAssetTask(
  107333. /**
  107334. * Task name
  107335. */ name) {
  107336. this.name = name;
  107337. this._isCompleted = false;
  107338. this._taskState = AssetTaskState.INIT;
  107339. }
  107340. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  107341. /**
  107342. * Get if the task is completed
  107343. */
  107344. get: function () {
  107345. return this._isCompleted;
  107346. },
  107347. enumerable: true,
  107348. configurable: true
  107349. });
  107350. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  107351. /**
  107352. * Gets the current state of the task
  107353. */
  107354. get: function () {
  107355. return this._taskState;
  107356. },
  107357. enumerable: true,
  107358. configurable: true
  107359. });
  107360. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  107361. /**
  107362. * Gets the current error object (if task is in error)
  107363. */
  107364. get: function () {
  107365. return this._errorObject;
  107366. },
  107367. enumerable: true,
  107368. configurable: true
  107369. });
  107370. /**
  107371. * Internal only
  107372. * @hidden
  107373. */
  107374. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  107375. if (this._errorObject) {
  107376. return;
  107377. }
  107378. this._errorObject = {
  107379. message: message,
  107380. exception: exception
  107381. };
  107382. };
  107383. /**
  107384. * Execute the current task
  107385. * @param scene defines the scene where you want your assets to be loaded
  107386. * @param onSuccess is a callback called when the task is successfully executed
  107387. * @param onError is a callback called if an error occurs
  107388. */
  107389. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  107390. var _this = this;
  107391. this._taskState = AssetTaskState.RUNNING;
  107392. this.runTask(scene, function () {
  107393. _this.onDoneCallback(onSuccess, onError);
  107394. }, function (msg, exception) {
  107395. _this.onErrorCallback(onError, msg, exception);
  107396. });
  107397. };
  107398. /**
  107399. * Execute the current task
  107400. * @param scene defines the scene where you want your assets to be loaded
  107401. * @param onSuccess is a callback called when the task is successfully executed
  107402. * @param onError is a callback called if an error occurs
  107403. */
  107404. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107405. throw new Error("runTask is not implemented");
  107406. };
  107407. /**
  107408. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  107409. * This can be used with failed tasks that have the reason for failure fixed.
  107410. */
  107411. AbstractAssetTask.prototype.reset = function () {
  107412. this._taskState = AssetTaskState.INIT;
  107413. };
  107414. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  107415. this._taskState = AssetTaskState.ERROR;
  107416. this._errorObject = {
  107417. message: message,
  107418. exception: exception
  107419. };
  107420. if (this.onError) {
  107421. this.onError(this, message, exception);
  107422. }
  107423. onError();
  107424. };
  107425. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  107426. try {
  107427. this._taskState = AssetTaskState.DONE;
  107428. this._isCompleted = true;
  107429. if (this.onSuccess) {
  107430. this.onSuccess(this);
  107431. }
  107432. onSuccess();
  107433. }
  107434. catch (e) {
  107435. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  107436. }
  107437. };
  107438. return AbstractAssetTask;
  107439. }());
  107440. /**
  107441. * Class used to share progress information about assets loading
  107442. */
  107443. var AssetsProgressEvent = /** @class */ (function () {
  107444. /**
  107445. * Creates a AssetsProgressEvent
  107446. * @param remainingCount defines the number of remaining tasks to process
  107447. * @param totalCount defines the total number of tasks
  107448. * @param task defines the task that was just processed
  107449. */
  107450. function AssetsProgressEvent(remainingCount, totalCount, task) {
  107451. this.remainingCount = remainingCount;
  107452. this.totalCount = totalCount;
  107453. this.task = task;
  107454. }
  107455. return AssetsProgressEvent;
  107456. }());
  107457. /**
  107458. * Define a task used by AssetsManager to load meshes
  107459. */
  107460. var MeshAssetTask = /** @class */ (function (_super) {
  107461. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  107462. /**
  107463. * Creates a new MeshAssetTask
  107464. * @param name defines the name of the task
  107465. * @param meshesNames defines the list of mesh's names you want to load
  107466. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  107467. * @param sceneFilename defines the filename of the scene to load from
  107468. */
  107469. function MeshAssetTask(
  107470. /**
  107471. * Defines the name of the task
  107472. */
  107473. name,
  107474. /**
  107475. * Defines the list of mesh's names you want to load
  107476. */
  107477. meshesNames,
  107478. /**
  107479. * Defines the root url to use as a base to load your meshes and associated resources
  107480. */
  107481. rootUrl,
  107482. /**
  107483. * Defines the filename of the scene to load from
  107484. */
  107485. sceneFilename) {
  107486. var _this = _super.call(this, name) || this;
  107487. _this.name = name;
  107488. _this.meshesNames = meshesNames;
  107489. _this.rootUrl = rootUrl;
  107490. _this.sceneFilename = sceneFilename;
  107491. return _this;
  107492. }
  107493. /**
  107494. * Execute the current task
  107495. * @param scene defines the scene where you want your assets to be loaded
  107496. * @param onSuccess is a callback called when the task is successfully executed
  107497. * @param onError is a callback called if an error occurs
  107498. */
  107499. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107500. var _this = this;
  107501. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  107502. _this.loadedMeshes = meshes;
  107503. _this.loadedParticleSystems = particleSystems;
  107504. _this.loadedSkeletons = skeletons;
  107505. _this.loadedAnimationGroups = animationGroups;
  107506. onSuccess();
  107507. }, null, function (scene, message, exception) {
  107508. onError(message, exception);
  107509. });
  107510. };
  107511. return MeshAssetTask;
  107512. }(AbstractAssetTask));
  107513. /**
  107514. * Define a task used by AssetsManager to load text content
  107515. */
  107516. var TextFileAssetTask = /** @class */ (function (_super) {
  107517. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  107518. /**
  107519. * Creates a new TextFileAssetTask object
  107520. * @param name defines the name of the task
  107521. * @param url defines the location of the file to load
  107522. */
  107523. function TextFileAssetTask(
  107524. /**
  107525. * Defines the name of the task
  107526. */
  107527. name,
  107528. /**
  107529. * Defines the location of the file to load
  107530. */
  107531. url) {
  107532. var _this = _super.call(this, name) || this;
  107533. _this.name = name;
  107534. _this.url = url;
  107535. return _this;
  107536. }
  107537. /**
  107538. * Execute the current task
  107539. * @param scene defines the scene where you want your assets to be loaded
  107540. * @param onSuccess is a callback called when the task is successfully executed
  107541. * @param onError is a callback called if an error occurs
  107542. */
  107543. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107544. var _this = this;
  107545. scene._loadFile(this.url, function (data) {
  107546. _this.text = data;
  107547. onSuccess();
  107548. }, undefined, false, false, function (request, exception) {
  107549. if (request) {
  107550. onError(request.status + " " + request.statusText, exception);
  107551. }
  107552. });
  107553. };
  107554. return TextFileAssetTask;
  107555. }(AbstractAssetTask));
  107556. /**
  107557. * Define a task used by AssetsManager to load binary data
  107558. */
  107559. var BinaryFileAssetTask = /** @class */ (function (_super) {
  107560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  107561. /**
  107562. * Creates a new BinaryFileAssetTask object
  107563. * @param name defines the name of the new task
  107564. * @param url defines the location of the file to load
  107565. */
  107566. function BinaryFileAssetTask(
  107567. /**
  107568. * Defines the name of the task
  107569. */
  107570. name,
  107571. /**
  107572. * Defines the location of the file to load
  107573. */
  107574. url) {
  107575. var _this = _super.call(this, name) || this;
  107576. _this.name = name;
  107577. _this.url = url;
  107578. return _this;
  107579. }
  107580. /**
  107581. * Execute the current task
  107582. * @param scene defines the scene where you want your assets to be loaded
  107583. * @param onSuccess is a callback called when the task is successfully executed
  107584. * @param onError is a callback called if an error occurs
  107585. */
  107586. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107587. var _this = this;
  107588. scene._loadFile(this.url, function (data) {
  107589. _this.data = data;
  107590. onSuccess();
  107591. }, undefined, true, true, function (request, exception) {
  107592. if (request) {
  107593. onError(request.status + " " + request.statusText, exception);
  107594. }
  107595. });
  107596. };
  107597. return BinaryFileAssetTask;
  107598. }(AbstractAssetTask));
  107599. /**
  107600. * Define a task used by AssetsManager to load images
  107601. */
  107602. var ImageAssetTask = /** @class */ (function (_super) {
  107603. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  107604. /**
  107605. * Creates a new ImageAssetTask
  107606. * @param name defines the name of the task
  107607. * @param url defines the location of the image to load
  107608. */
  107609. function ImageAssetTask(
  107610. /**
  107611. * Defines the name of the task
  107612. */
  107613. name,
  107614. /**
  107615. * Defines the location of the image to load
  107616. */
  107617. url) {
  107618. var _this = _super.call(this, name) || this;
  107619. _this.name = name;
  107620. _this.url = url;
  107621. return _this;
  107622. }
  107623. /**
  107624. * Execute the current task
  107625. * @param scene defines the scene where you want your assets to be loaded
  107626. * @param onSuccess is a callback called when the task is successfully executed
  107627. * @param onError is a callback called if an error occurs
  107628. */
  107629. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107630. var _this = this;
  107631. var img = new Image();
  107632. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  107633. img.onload = function () {
  107634. _this.image = img;
  107635. onSuccess();
  107636. };
  107637. img.onerror = function (err) {
  107638. onError("Error loading image", err);
  107639. };
  107640. img.src = this.url;
  107641. };
  107642. return ImageAssetTask;
  107643. }(AbstractAssetTask));
  107644. /**
  107645. * Define a task used by AssetsManager to load 2D textures
  107646. */
  107647. var TextureAssetTask = /** @class */ (function (_super) {
  107648. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  107649. /**
  107650. * Creates a new TextureAssetTask object
  107651. * @param name defines the name of the task
  107652. * @param url defines the location of the file to load
  107653. * @param noMipmap defines if mipmap should not be generated (default is false)
  107654. * @param invertY defines if texture must be inverted on Y axis (default is false)
  107655. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  107656. */
  107657. function TextureAssetTask(
  107658. /**
  107659. * Defines the name of the task
  107660. */
  107661. name,
  107662. /**
  107663. * Defines the location of the file to load
  107664. */
  107665. url,
  107666. /**
  107667. * Defines if mipmap should not be generated (default is false)
  107668. */
  107669. noMipmap,
  107670. /**
  107671. * Defines if texture must be inverted on Y axis (default is false)
  107672. */
  107673. invertY,
  107674. /**
  107675. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  107676. */
  107677. samplingMode) {
  107678. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  107679. var _this = _super.call(this, name) || this;
  107680. _this.name = name;
  107681. _this.url = url;
  107682. _this.noMipmap = noMipmap;
  107683. _this.invertY = invertY;
  107684. _this.samplingMode = samplingMode;
  107685. return _this;
  107686. }
  107687. /**
  107688. * Execute the current task
  107689. * @param scene defines the scene where you want your assets to be loaded
  107690. * @param onSuccess is a callback called when the task is successfully executed
  107691. * @param onError is a callback called if an error occurs
  107692. */
  107693. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107694. var onload = function () {
  107695. onSuccess();
  107696. };
  107697. var onerror = function (message, exception) {
  107698. onError(message, exception);
  107699. };
  107700. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  107701. };
  107702. return TextureAssetTask;
  107703. }(AbstractAssetTask));
  107704. /**
  107705. * Define a task used by AssetsManager to load cube textures
  107706. */
  107707. var CubeTextureAssetTask = /** @class */ (function (_super) {
  107708. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  107709. /**
  107710. * Creates a new CubeTextureAssetTask
  107711. * @param name defines the name of the task
  107712. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  107713. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  107714. * @param noMipmap defines if mipmaps should not be generated (default is false)
  107715. * @param files defines the explicit list of files (undefined by default)
  107716. */
  107717. function CubeTextureAssetTask(
  107718. /**
  107719. * Defines the name of the task
  107720. */
  107721. name,
  107722. /**
  107723. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  107724. */
  107725. url,
  107726. /**
  107727. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  107728. */
  107729. extensions,
  107730. /**
  107731. * Defines if mipmaps should not be generated (default is false)
  107732. */
  107733. noMipmap,
  107734. /**
  107735. * Defines the explicit list of files (undefined by default)
  107736. */
  107737. files) {
  107738. var _this = _super.call(this, name) || this;
  107739. _this.name = name;
  107740. _this.url = url;
  107741. _this.extensions = extensions;
  107742. _this.noMipmap = noMipmap;
  107743. _this.files = files;
  107744. return _this;
  107745. }
  107746. /**
  107747. * Execute the current task
  107748. * @param scene defines the scene where you want your assets to be loaded
  107749. * @param onSuccess is a callback called when the task is successfully executed
  107750. * @param onError is a callback called if an error occurs
  107751. */
  107752. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107753. var onload = function () {
  107754. onSuccess();
  107755. };
  107756. var onerror = function (message, exception) {
  107757. onError(message, exception);
  107758. };
  107759. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  107760. };
  107761. return CubeTextureAssetTask;
  107762. }(AbstractAssetTask));
  107763. /**
  107764. * Define a task used by AssetsManager to load HDR cube textures
  107765. */
  107766. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  107767. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  107768. /**
  107769. * Creates a new HDRCubeTextureAssetTask object
  107770. * @param name defines the name of the task
  107771. * @param url defines the location of the file to load
  107772. * @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.
  107773. * @param noMipmap defines if mipmaps should not be generated (default is false)
  107774. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  107775. * @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)
  107776. * @param reserved Internal use only
  107777. */
  107778. function HDRCubeTextureAssetTask(
  107779. /**
  107780. * Defines the name of the task
  107781. */
  107782. name,
  107783. /**
  107784. * Defines the location of the file to load
  107785. */
  107786. url,
  107787. /**
  107788. * Defines the desired size (the more it increases the longer the generation will be)
  107789. */
  107790. size,
  107791. /**
  107792. * Defines if mipmaps should not be generated (default is false)
  107793. */
  107794. noMipmap,
  107795. /**
  107796. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  107797. */
  107798. generateHarmonics,
  107799. /**
  107800. * 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)
  107801. */
  107802. gammaSpace,
  107803. /**
  107804. * Internal Use Only
  107805. */
  107806. reserved) {
  107807. if (noMipmap === void 0) { noMipmap = false; }
  107808. if (generateHarmonics === void 0) { generateHarmonics = true; }
  107809. if (gammaSpace === void 0) { gammaSpace = false; }
  107810. if (reserved === void 0) { reserved = false; }
  107811. var _this = _super.call(this, name) || this;
  107812. _this.name = name;
  107813. _this.url = url;
  107814. _this.size = size;
  107815. _this.noMipmap = noMipmap;
  107816. _this.generateHarmonics = generateHarmonics;
  107817. _this.gammaSpace = gammaSpace;
  107818. _this.reserved = reserved;
  107819. return _this;
  107820. }
  107821. /**
  107822. * Execute the current task
  107823. * @param scene defines the scene where you want your assets to be loaded
  107824. * @param onSuccess is a callback called when the task is successfully executed
  107825. * @param onError is a callback called if an error occurs
  107826. */
  107827. HDRCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107828. var onload = function () {
  107829. onSuccess();
  107830. };
  107831. var onerror = function (message, exception) {
  107832. onError(message, exception);
  107833. };
  107834. 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);
  107835. };
  107836. return HDRCubeTextureAssetTask;
  107837. }(AbstractAssetTask));
  107838. /**
  107839. * Define a task used by AssetsManager to load Equirectangular cube textures
  107840. */
  107841. var EquiRectangularCubeTextureAssetTask = /** @class */ (function (_super) {
  107842. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTextureAssetTask, _super);
  107843. /**
  107844. * Creates a new EquiRectangularCubeTextureAssetTask object
  107845. * @param name defines the name of the task
  107846. * @param url defines the location of the file to load
  107847. * @param size defines the desired size (the more it increases the longer the generation will be)
  107848. * If the size is omitted this implies you are using a preprocessed cubemap.
  107849. * @param noMipmap defines if mipmaps should not be generated (default is false)
  107850. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  107851. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  107852. * (default is true)
  107853. */
  107854. function EquiRectangularCubeTextureAssetTask(
  107855. /**
  107856. * Defines the name of the task
  107857. */
  107858. name,
  107859. /**
  107860. * Defines the location of the file to load
  107861. */
  107862. url,
  107863. /**
  107864. * Defines the desired size (the more it increases the longer the generation will be)
  107865. */
  107866. size,
  107867. /**
  107868. * Defines if mipmaps should not be generated (default is false)
  107869. */
  107870. noMipmap,
  107871. /**
  107872. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  107873. * but the standard material would require them in Gamma space) (default is true)
  107874. */
  107875. gammaSpace) {
  107876. if (noMipmap === void 0) { noMipmap = false; }
  107877. if (gammaSpace === void 0) { gammaSpace = true; }
  107878. var _this = _super.call(this, name) || this;
  107879. _this.name = name;
  107880. _this.url = url;
  107881. _this.size = size;
  107882. _this.noMipmap = noMipmap;
  107883. _this.gammaSpace = gammaSpace;
  107884. return _this;
  107885. }
  107886. /**
  107887. * Execute the current task
  107888. * @param scene defines the scene where you want your assets to be loaded
  107889. * @param onSuccess is a callback called when the task is successfully executed
  107890. * @param onError is a callback called if an error occurs
  107891. */
  107892. EquiRectangularCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  107893. var onload = function () {
  107894. onSuccess();
  107895. };
  107896. var onerror = function (message, exception) {
  107897. onError(message, exception);
  107898. };
  107899. this.texture = new _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__["EquiRectangularCubeTexture"](this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
  107900. };
  107901. return EquiRectangularCubeTextureAssetTask;
  107902. }(AbstractAssetTask));
  107903. /**
  107904. * This class can be used to easily import assets into a scene
  107905. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  107906. */
  107907. var AssetsManager = /** @class */ (function () {
  107908. /**
  107909. * Creates a new AssetsManager
  107910. * @param scene defines the scene to work on
  107911. */
  107912. function AssetsManager(scene) {
  107913. this._isLoading = false;
  107914. this._tasks = new Array();
  107915. this._waitingTasksCount = 0;
  107916. this._totalTasksCount = 0;
  107917. /**
  107918. * Observable called when all tasks are processed
  107919. */
  107920. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  107921. /**
  107922. * Observable called when a task had an error
  107923. */
  107924. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  107925. /**
  107926. * Observable called when all tasks were executed
  107927. */
  107928. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  107929. /**
  107930. * Observable called when a task is done (whatever the result is)
  107931. */
  107932. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  107933. /**
  107934. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  107935. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107936. */
  107937. this.useDefaultLoadingScreen = true;
  107938. /**
  107939. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  107940. * when all assets have been downloaded.
  107941. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  107942. */
  107943. this.autoHideLoadingUI = true;
  107944. this._scene = scene;
  107945. }
  107946. /**
  107947. * Add a MeshAssetTask to the list of active tasks
  107948. * @param taskName defines the name of the new task
  107949. * @param meshesNames defines the name of meshes to load
  107950. * @param rootUrl defines the root url to use to locate files
  107951. * @param sceneFilename defines the filename of the scene file
  107952. * @returns a new MeshAssetTask object
  107953. */
  107954. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  107955. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  107956. this._tasks.push(task);
  107957. return task;
  107958. };
  107959. /**
  107960. * Add a TextFileAssetTask to the list of active tasks
  107961. * @param taskName defines the name of the new task
  107962. * @param url defines the url of the file to load
  107963. * @returns a new TextFileAssetTask object
  107964. */
  107965. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  107966. var task = new TextFileAssetTask(taskName, url);
  107967. this._tasks.push(task);
  107968. return task;
  107969. };
  107970. /**
  107971. * Add a BinaryFileAssetTask to the list of active tasks
  107972. * @param taskName defines the name of the new task
  107973. * @param url defines the url of the file to load
  107974. * @returns a new BinaryFileAssetTask object
  107975. */
  107976. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  107977. var task = new BinaryFileAssetTask(taskName, url);
  107978. this._tasks.push(task);
  107979. return task;
  107980. };
  107981. /**
  107982. * Add a ImageAssetTask to the list of active tasks
  107983. * @param taskName defines the name of the new task
  107984. * @param url defines the url of the file to load
  107985. * @returns a new ImageAssetTask object
  107986. */
  107987. AssetsManager.prototype.addImageTask = function (taskName, url) {
  107988. var task = new ImageAssetTask(taskName, url);
  107989. this._tasks.push(task);
  107990. return task;
  107991. };
  107992. /**
  107993. * Add a TextureAssetTask to the list of active tasks
  107994. * @param taskName defines the name of the new task
  107995. * @param url defines the url of the file to load
  107996. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  107997. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  107998. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  107999. * @returns a new TextureAssetTask object
  108000. */
  108001. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  108002. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  108003. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  108004. this._tasks.push(task);
  108005. return task;
  108006. };
  108007. /**
  108008. * Add a CubeTextureAssetTask to the list of active tasks
  108009. * @param taskName defines the name of the new task
  108010. * @param url defines the url of the file to load
  108011. * @param extensions defines the extension to use to load the cube map (can be null)
  108012. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108013. * @param files defines the list of files to load (can be null)
  108014. * @returns a new CubeTextureAssetTask object
  108015. */
  108016. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  108017. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  108018. this._tasks.push(task);
  108019. return task;
  108020. };
  108021. /**
  108022. *
  108023. * Add a HDRCubeTextureAssetTask to the list of active tasks
  108024. * @param taskName defines the name of the new task
  108025. * @param url defines the url of the file to load
  108026. * @param size defines the size you want for the cubemap (can be null)
  108027. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108028. * @param generateHarmonics defines if you want to automatically generate (true by default)
  108029. * @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)
  108030. * @param reserved Internal use only
  108031. * @returns a new HDRCubeTextureAssetTask object
  108032. */
  108033. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  108034. if (noMipmap === void 0) { noMipmap = false; }
  108035. if (generateHarmonics === void 0) { generateHarmonics = true; }
  108036. if (gammaSpace === void 0) { gammaSpace = false; }
  108037. if (reserved === void 0) { reserved = false; }
  108038. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  108039. this._tasks.push(task);
  108040. return task;
  108041. };
  108042. /**
  108043. *
  108044. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  108045. * @param taskName defines the name of the new task
  108046. * @param url defines the url of the file to load
  108047. * @param size defines the size you want for the cubemap (can be null)
  108048. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108049. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108050. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108051. * @returns a new EquiRectangularCubeTextureAssetTask object
  108052. */
  108053. AssetsManager.prototype.addEquiRectangularCubeTextureAssetTask = function (taskName, url, size, noMipmap, gammaSpace) {
  108054. if (noMipmap === void 0) { noMipmap = false; }
  108055. if (gammaSpace === void 0) { gammaSpace = true; }
  108056. var task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
  108057. this._tasks.push(task);
  108058. return task;
  108059. };
  108060. /**
  108061. * Remove a task from the assets manager.
  108062. * @param task the task to remove
  108063. */
  108064. AssetsManager.prototype.removeTask = function (task) {
  108065. var index = this._tasks.indexOf(task);
  108066. if (index > -1) {
  108067. this._tasks.splice(index, 1);
  108068. }
  108069. };
  108070. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  108071. this._waitingTasksCount--;
  108072. try {
  108073. if (this.onProgress) {
  108074. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  108075. }
  108076. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  108077. }
  108078. catch (e) {
  108079. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running progress callbacks.");
  108080. console.log(e);
  108081. }
  108082. if (this._waitingTasksCount === 0) {
  108083. try {
  108084. if (this.onFinish) {
  108085. this.onFinish(this._tasks);
  108086. }
  108087. // Let's remove successfull tasks
  108088. var currentTasks = this._tasks.slice();
  108089. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  108090. var task = currentTasks_1[_i];
  108091. if (task.taskState === AssetTaskState.DONE) {
  108092. var index = this._tasks.indexOf(task);
  108093. if (index > -1) {
  108094. this._tasks.splice(index, 1);
  108095. }
  108096. }
  108097. }
  108098. this.onTasksDoneObservable.notifyObservers(this._tasks);
  108099. }
  108100. catch (e) {
  108101. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running tasks-done callbacks.");
  108102. console.log(e);
  108103. }
  108104. this._isLoading = false;
  108105. if (this.autoHideLoadingUI) {
  108106. this._scene.getEngine().hideLoadingUI();
  108107. }
  108108. }
  108109. };
  108110. AssetsManager.prototype._runTask = function (task) {
  108111. var _this = this;
  108112. var done = function () {
  108113. try {
  108114. if (_this.onTaskSuccess) {
  108115. _this.onTaskSuccess(task);
  108116. }
  108117. _this.onTaskSuccessObservable.notifyObservers(task);
  108118. _this._decreaseWaitingTasksCount(task);
  108119. }
  108120. catch (e) {
  108121. error("Error executing task success callbacks", e);
  108122. }
  108123. };
  108124. var error = function (message, exception) {
  108125. task._setErrorObject(message, exception);
  108126. if (_this.onTaskError) {
  108127. _this.onTaskError(task);
  108128. }
  108129. _this.onTaskErrorObservable.notifyObservers(task);
  108130. _this._decreaseWaitingTasksCount(task);
  108131. };
  108132. task.run(this._scene, done, error);
  108133. };
  108134. /**
  108135. * Reset the AssetsManager and remove all tasks
  108136. * @return the current instance of the AssetsManager
  108137. */
  108138. AssetsManager.prototype.reset = function () {
  108139. this._isLoading = false;
  108140. this._tasks = new Array();
  108141. return this;
  108142. };
  108143. /**
  108144. * Start the loading process
  108145. * @return the current instance of the AssetsManager
  108146. */
  108147. AssetsManager.prototype.load = function () {
  108148. if (this._isLoading) {
  108149. return this;
  108150. }
  108151. this._isLoading = true;
  108152. this._waitingTasksCount = this._tasks.length;
  108153. this._totalTasksCount = this._tasks.length;
  108154. if (this._waitingTasksCount === 0) {
  108155. this._isLoading = false;
  108156. if (this.onFinish) {
  108157. this.onFinish(this._tasks);
  108158. }
  108159. this.onTasksDoneObservable.notifyObservers(this._tasks);
  108160. return this;
  108161. }
  108162. if (this.useDefaultLoadingScreen) {
  108163. this._scene.getEngine().displayLoadingUI();
  108164. }
  108165. for (var index = 0; index < this._tasks.length; index++) {
  108166. var task = this._tasks[index];
  108167. if (task.taskState === AssetTaskState.INIT) {
  108168. this._runTask(task);
  108169. }
  108170. }
  108171. return this;
  108172. };
  108173. /**
  108174. * Start the loading process as an async operation
  108175. * @return a promise returning the list of failed tasks
  108176. */
  108177. AssetsManager.prototype.loadAsync = function () {
  108178. var _this = this;
  108179. return new Promise(function (resolve, reject) {
  108180. if (_this._isLoading) {
  108181. resolve();
  108182. return;
  108183. }
  108184. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  108185. if (remainingTasks && remainingTasks.length) {
  108186. reject(remainingTasks);
  108187. }
  108188. else {
  108189. resolve();
  108190. }
  108191. });
  108192. _this.load();
  108193. });
  108194. };
  108195. return AssetsManager;
  108196. }());
  108197. /***/ }),
  108198. /***/ "./Misc/basis.ts":
  108199. /*!***********************!*\
  108200. !*** ./Misc/basis.ts ***!
  108201. \***********************/
  108202. /*! exports provided: BasisTranscodeConfiguration, BasisTools */
  108203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108204. "use strict";
  108205. __webpack_require__.r(__webpack_exports__);
  108206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BasisTranscodeConfiguration", function() { return BasisTranscodeConfiguration; });
  108207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BasisTools", function() { return BasisTools; });
  108208. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  108209. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108210. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  108211. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  108212. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108213. /**
  108214. * Info about the .basis files
  108215. */
  108216. var BasisFileInfo = /** @class */ (function () {
  108217. function BasisFileInfo() {
  108218. }
  108219. return BasisFileInfo;
  108220. }());
  108221. /**
  108222. * Result of transcoding a basis file
  108223. */
  108224. var TranscodeResult = /** @class */ (function () {
  108225. function TranscodeResult() {
  108226. }
  108227. return TranscodeResult;
  108228. }());
  108229. /**
  108230. * Configuration options for the Basis transcoder
  108231. */
  108232. var BasisTranscodeConfiguration = /** @class */ (function () {
  108233. function BasisTranscodeConfiguration() {
  108234. }
  108235. return BasisTranscodeConfiguration;
  108236. }());
  108237. /**
  108238. * @hidden
  108239. * Enum of basis transcoder formats
  108240. */
  108241. var BASIS_FORMATS;
  108242. (function (BASIS_FORMATS) {
  108243. BASIS_FORMATS[BASIS_FORMATS["cTFETC1"] = 0] = "cTFETC1";
  108244. BASIS_FORMATS[BASIS_FORMATS["cTFBC1"] = 1] = "cTFBC1";
  108245. BASIS_FORMATS[BASIS_FORMATS["cTFBC4"] = 2] = "cTFBC4";
  108246. BASIS_FORMATS[BASIS_FORMATS["cTFPVRTC1_4_OPAQUE_ONLY"] = 3] = "cTFPVRTC1_4_OPAQUE_ONLY";
  108247. BASIS_FORMATS[BASIS_FORMATS["cTFBC7_M6_OPAQUE_ONLY"] = 4] = "cTFBC7_M6_OPAQUE_ONLY";
  108248. BASIS_FORMATS[BASIS_FORMATS["cTFETC2"] = 5] = "cTFETC2";
  108249. BASIS_FORMATS[BASIS_FORMATS["cTFBC3"] = 6] = "cTFBC3";
  108250. BASIS_FORMATS[BASIS_FORMATS["cTFBC5"] = 7] = "cTFBC5";
  108251. })(BASIS_FORMATS || (BASIS_FORMATS = {}));
  108252. /**
  108253. * Used to load .Basis files
  108254. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  108255. */
  108256. var BasisTools = /** @class */ (function () {
  108257. function BasisTools() {
  108258. }
  108259. /**
  108260. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  108261. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  108262. * @returns internal format corresponding to the Basis format
  108263. */
  108264. BasisTools.GetInternalFormatFromBasisFormat = function (basisFormat) {
  108265. // Corrisponding internal formats
  108266. var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
  108267. var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
  108268. var RGB_ETC1_Format = 36196;
  108269. if (basisFormat === BASIS_FORMATS.cTFETC1) {
  108270. return RGB_ETC1_Format;
  108271. }
  108272. else if (basisFormat === BASIS_FORMATS.cTFBC1) {
  108273. return COMPRESSED_RGB_S3TC_DXT1_EXT;
  108274. }
  108275. else if (basisFormat === BASIS_FORMATS.cTFBC3) {
  108276. return COMPRESSED_RGBA_S3TC_DXT5_EXT;
  108277. }
  108278. else {
  108279. throw "The chosen Basis transcoder format is not currently supported";
  108280. }
  108281. };
  108282. BasisTools._CreateWorkerAsync = function () {
  108283. var _this = this;
  108284. if (!this._WorkerPromise) {
  108285. this._WorkerPromise = new Promise(function (res) {
  108286. if (_this._Worker) {
  108287. res(_this._Worker);
  108288. }
  108289. else {
  108290. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFileAsync(BasisTools.WasmModuleURL).then(function (wasmBinary) {
  108291. var workerBlobUrl = URL.createObjectURL(new Blob(["(" + workerFunc + ")()"], { type: "application/javascript" }));
  108292. _this._Worker = new Worker(workerBlobUrl);
  108293. var initHandler = function (msg) {
  108294. if (msg.data.action === "init") {
  108295. _this._Worker.removeEventListener("message", initHandler);
  108296. res(_this._Worker);
  108297. }
  108298. };
  108299. _this._Worker.addEventListener("message", initHandler);
  108300. _this._Worker.postMessage({ action: "init", url: BasisTools.JSModuleURL, wasmBinary: wasmBinary });
  108301. });
  108302. }
  108303. });
  108304. }
  108305. return this._WorkerPromise;
  108306. };
  108307. /**
  108308. * Transcodes a loaded image file to compressed pixel data
  108309. * @param imageData image data to transcode
  108310. * @param config configuration options for the transcoding
  108311. * @returns a promise resulting in the transcoded image
  108312. */
  108313. BasisTools.TranscodeAsync = function (imageData, config) {
  108314. var _this = this;
  108315. return new Promise(function (res, rej) {
  108316. _this._CreateWorkerAsync().then(function () {
  108317. var actionId = _this._actionId++;
  108318. var messageHandler = function (msg) {
  108319. if (msg.data.action === "transcode" && msg.data.id === actionId) {
  108320. _this._Worker.removeEventListener("message", messageHandler);
  108321. if (!msg.data.success) {
  108322. rej("Transcode is not supported on this device");
  108323. }
  108324. else {
  108325. res(msg.data);
  108326. }
  108327. }
  108328. };
  108329. _this._Worker.addEventListener("message", messageHandler);
  108330. _this._Worker.postMessage({ action: "transcode", id: actionId, imageData: imageData, config: config, ignoreSupportedFormats: _this._IgnoreSupportedFormats }, [imageData]);
  108331. });
  108332. });
  108333. };
  108334. /**
  108335. * Loads a texture from the transcode result
  108336. * @param texture texture load to
  108337. * @param transcodeResult the result of transcoding the basis file to load from
  108338. */
  108339. BasisTools.LoadTextureFromTranscodeResult = function (texture, transcodeResult) {
  108340. var _loop_1 = function () {
  108341. rootImage = transcodeResult.fileInfo.images[i].levels[0];
  108342. texture._invertVScale = texture.invertY;
  108343. if (transcodeResult.format === -1) {
  108344. // No compatable compressed format found, fallback to RGB
  108345. texture.type = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  108346. texture.format = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTUREFORMAT_RGB;
  108347. if (texture.getEngine().webGLVersion < 2 && (_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Log2(rootImage.width) % 1 !== 0 || _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Log2(rootImage.height) % 1 !== 0)) {
  108348. // Create non power of two texture
  108349. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](texture.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_TEMP);
  108350. texture._invertVScale = texture.invertY;
  108351. source_1.type = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  108352. source_1.format = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTUREFORMAT_RGB;
  108353. // Fallback requires aligned width/height
  108354. source_1.width = (rootImage.width + 3) & ~3;
  108355. source_1.height = (rootImage.height + 3) & ~3;
  108356. texture.getEngine()._bindTextureDirectly(source_1.getEngine()._gl.TEXTURE_2D, source_1, true);
  108357. texture.getEngine()._uploadDataToTextureDirectly(source_1, rootImage.transcodedPixels, i, 0, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTUREFORMAT_RGB, true);
  108358. // Resize to power of two
  108359. source_1.getEngine()._rescaleTexture(source_1, texture, texture.getEngine().scenes[0], source_1.getEngine()._getInternalFormat(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTUREFORMAT_RGB), function () {
  108360. source_1.getEngine()._releaseTexture(source_1);
  108361. source_1.getEngine()._bindTextureDirectly(source_1.getEngine()._gl.TEXTURE_2D, texture, true);
  108362. });
  108363. }
  108364. else {
  108365. // Fallback is already inverted
  108366. texture._invertVScale = !texture.invertY;
  108367. // Upload directly
  108368. texture.width = (rootImage.width + 3) & ~3;
  108369. texture.height = (rootImage.height + 3) & ~3;
  108370. texture.getEngine()._uploadDataToTextureDirectly(texture, rootImage.transcodedPixels, i, 0, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTUREFORMAT_RGB, true);
  108371. }
  108372. }
  108373. else {
  108374. texture.width = rootImage.width;
  108375. texture.height = rootImage.height;
  108376. // Upload all mip levels in the file
  108377. transcodeResult.fileInfo.images[i].levels.forEach(function (level, index) {
  108378. texture.getEngine()._uploadCompressedDataToTextureDirectly(texture, BasisTools.GetInternalFormatFromBasisFormat(transcodeResult.format), level.width, level.height, level.transcodedPixels, i, index);
  108379. });
  108380. if (texture.getEngine().webGLVersion < 2 && (_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Log2(texture.width) % 1 !== 0 || _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Log2(texture.height) % 1 !== 0)) {
  108381. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1.");
  108382. texture._cachedWrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  108383. texture._cachedWrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  108384. }
  108385. }
  108386. };
  108387. var rootImage;
  108388. for (var i = 0; i < transcodeResult.fileInfo.images.length; i++) {
  108389. _loop_1();
  108390. }
  108391. };
  108392. BasisTools._IgnoreSupportedFormats = false;
  108393. /**
  108394. * URL to use when loading the basis transcoder
  108395. */
  108396. BasisTools.JSModuleURL = "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js";
  108397. /**
  108398. * URL to use when loading the wasm module for the transcoder
  108399. */
  108400. BasisTools.WasmModuleURL = "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm";
  108401. BasisTools._WorkerPromise = null;
  108402. BasisTools._Worker = null;
  108403. BasisTools._actionId = 0;
  108404. return BasisTools;
  108405. }());
  108406. function workerFunc() {
  108407. var _BASIS_FORMAT = {
  108408. cTFETC1: 0,
  108409. cTFBC1: 1,
  108410. cTFBC4: 2,
  108411. cTFPVRTC1_4_OPAQUE_ONLY: 3,
  108412. cTFBC7_M6_OPAQUE_ONLY: 4,
  108413. cTFETC2: 5,
  108414. cTFBC3: 6,
  108415. cTFBC5: 7,
  108416. };
  108417. var transcoderModulePromise = null;
  108418. onmessage = function (event) {
  108419. if (event.data.action === "init") {
  108420. // Load the transcoder if it hasn't been yet
  108421. if (!transcoderModulePromise) {
  108422. // Override wasm binary
  108423. Module = { wasmBinary: (event.data.wasmBinary) };
  108424. importScripts(event.data.url);
  108425. transcoderModulePromise = new Promise(function (res) {
  108426. Module.onRuntimeInitialized = function () {
  108427. Module.initializeBasis();
  108428. res();
  108429. };
  108430. });
  108431. }
  108432. transcoderModulePromise.then(function () {
  108433. postMessage({ action: "init" });
  108434. });
  108435. }
  108436. else if (event.data.action === "transcode") {
  108437. // Transcode the basis image and return the resulting pixels
  108438. var config = event.data.config;
  108439. var imgData = event.data.imageData;
  108440. var loadedFile = new Module.BasisFile(new Uint8Array(imgData));
  108441. var fileInfo = GetFileInfo(loadedFile);
  108442. var format = event.data.ignoreSupportedFormats ? null : GetSupportedTranscodeFormat(event.data.config, fileInfo);
  108443. var needsConversion = false;
  108444. if (format === null) {
  108445. needsConversion = true;
  108446. format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;
  108447. }
  108448. // Begin transcode
  108449. var success = true;
  108450. if (!loadedFile.startTranscoding()) {
  108451. success = false;
  108452. }
  108453. var buffers = [];
  108454. for (var imageIndex = 0; imageIndex < fileInfo.images.length; imageIndex++) {
  108455. if (!success) {
  108456. break;
  108457. }
  108458. var image = fileInfo.images[imageIndex];
  108459. if (config.loadSingleImage === undefined || config.loadSingleImage === imageIndex) {
  108460. var mipCount = image.levels.length;
  108461. if (config.loadMipmapLevels === false) {
  108462. mipCount = 1;
  108463. }
  108464. for (var levelIndex = 0; levelIndex < mipCount; levelIndex++) {
  108465. var levelInfo = image.levels[levelIndex];
  108466. var pixels = TranscodeLevel(loadedFile, imageIndex, levelIndex, format, needsConversion);
  108467. if (!pixels) {
  108468. success = false;
  108469. break;
  108470. }
  108471. levelInfo.transcodedPixels = pixels;
  108472. buffers.push(levelInfo.transcodedPixels.buffer);
  108473. }
  108474. }
  108475. }
  108476. // Close file
  108477. loadedFile.close();
  108478. loadedFile.delete();
  108479. if (needsConversion) {
  108480. format = -1;
  108481. }
  108482. if (!success) {
  108483. postMessage({ action: "transcode", success: success, id: event.data.id });
  108484. }
  108485. else {
  108486. postMessage({ action: "transcode", success: success, id: event.data.id, fileInfo: fileInfo, format: format }, buffers);
  108487. }
  108488. }
  108489. };
  108490. /**
  108491. * Detects the supported transcode format for the file
  108492. * @param config transcode config
  108493. * @param fileInfo info about the file
  108494. * @returns the chosed format or null if none are supported
  108495. */
  108496. function GetSupportedTranscodeFormat(config, fileInfo) {
  108497. var format = null;
  108498. if (config.supportedCompressionFormats) {
  108499. if (config.supportedCompressionFormats.etc1) {
  108500. format = _BASIS_FORMAT.cTFETC1;
  108501. }
  108502. else if (config.supportedCompressionFormats.s3tc) {
  108503. format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;
  108504. }
  108505. else if (config.supportedCompressionFormats.pvrtc) {
  108506. // TODO uncomment this after pvrtc bug is fixed is basis transcoder
  108507. // See discussion here: https://github.com/mrdoob/three.js/issues/16524#issuecomment-498929924
  108508. // format = _BASIS_FORMAT.cTFPVRTC1_4_OPAQUE_ONLY;
  108509. }
  108510. else if (config.supportedCompressionFormats.etc2) {
  108511. format = _BASIS_FORMAT.cTFETC2;
  108512. }
  108513. }
  108514. return format;
  108515. }
  108516. /**
  108517. * Retreives information about the basis file eg. dimensions
  108518. * @param basisFile the basis file to get the info from
  108519. * @returns information about the basis file
  108520. */
  108521. function GetFileInfo(basisFile) {
  108522. var hasAlpha = basisFile.getHasAlpha();
  108523. var imageCount = basisFile.getNumImages();
  108524. var images = [];
  108525. for (var i = 0; i < imageCount; i++) {
  108526. var imageInfo = {
  108527. levels: []
  108528. };
  108529. var levelCount = basisFile.getNumLevels(i);
  108530. for (var level = 0; level < levelCount; level++) {
  108531. var levelInfo = {
  108532. width: basisFile.getImageWidth(i, level),
  108533. height: basisFile.getImageHeight(i, level)
  108534. };
  108535. imageInfo.levels.push(levelInfo);
  108536. }
  108537. images.push(imageInfo);
  108538. }
  108539. var info = { hasAlpha: hasAlpha, images: images };
  108540. return info;
  108541. }
  108542. function TranscodeLevel(loadedFile, imageIndex, levelIndex, format, convertToRgb565) {
  108543. var dstSize = loadedFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, format);
  108544. var dst = new Uint8Array(dstSize);
  108545. if (!loadedFile.transcodeImage(dst, imageIndex, levelIndex, format, 1, 0)) {
  108546. return null;
  108547. }
  108548. // If no supported format is found, load as dxt and convert to rgb565
  108549. if (convertToRgb565) {
  108550. var alignedWidth = (loadedFile.getImageWidth(imageIndex, levelIndex) + 3) & ~3;
  108551. var alignedHeight = (loadedFile.getImageHeight(imageIndex, levelIndex) + 3) & ~3;
  108552. dst = ConvertDxtToRgb565(dst, 0, alignedWidth, alignedHeight);
  108553. }
  108554. return dst;
  108555. }
  108556. /**
  108557. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  108558. * An unoptimized version of dxtToRgb565. Also, the floating
  108559. * point math used to compute the colors actually results in
  108560. * slightly different colors compared to hardware DXT decoders.
  108561. * @param src dxt src pixels
  108562. * @param srcByteOffset offset for the start of src
  108563. * @param width aligned width of the image
  108564. * @param height aligned height of the image
  108565. * @return the converted pixels
  108566. */
  108567. function ConvertDxtToRgb565(src, srcByteOffset, width, height) {
  108568. var c = new Uint16Array(4);
  108569. var dst = new Uint16Array(width * height);
  108570. var blockWidth = width / 4;
  108571. var blockHeight = height / 4;
  108572. for (var blockY = 0; blockY < blockHeight; blockY++) {
  108573. for (var blockX = 0; blockX < blockWidth; blockX++) {
  108574. var i = srcByteOffset + 8 * (blockY * blockWidth + blockX);
  108575. c[0] = src[i] | (src[i + 1] << 8);
  108576. c[1] = src[i + 2] | (src[i + 3] << 8);
  108577. c[2] = (2 * (c[0] & 0x1f) + 1 * (c[1] & 0x1f)) / 3
  108578. | (((2 * (c[0] & 0x7e0) + 1 * (c[1] & 0x7e0)) / 3) & 0x7e0)
  108579. | (((2 * (c[0] & 0xf800) + 1 * (c[1] & 0xf800)) / 3) & 0xf800);
  108580. c[3] = (2 * (c[1] & 0x1f) + 1 * (c[0] & 0x1f)) / 3
  108581. | (((2 * (c[1] & 0x7e0) + 1 * (c[0] & 0x7e0)) / 3) & 0x7e0)
  108582. | (((2 * (c[1] & 0xf800) + 1 * (c[0] & 0xf800)) / 3) & 0xf800);
  108583. for (var row = 0; row < 4; row++) {
  108584. var m = src[i + 4 + row];
  108585. var dstI = (blockY * 4 + row) * width + blockX * 4;
  108586. dst[dstI++] = c[m & 0x3];
  108587. dst[dstI++] = c[(m >> 2) & 0x3];
  108588. dst[dstI++] = c[(m >> 4) & 0x3];
  108589. dst[dstI++] = c[(m >> 6) & 0x3];
  108590. }
  108591. }
  108592. }
  108593. return dst;
  108594. }
  108595. }
  108596. /***/ }),
  108597. /***/ "./Misc/brdfTextureTools.ts":
  108598. /*!**********************************!*\
  108599. !*** ./Misc/brdfTextureTools.ts ***!
  108600. \**********************************/
  108601. /*! exports provided: BRDFTextureTools */
  108602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108603. "use strict";
  108604. __webpack_require__.r(__webpack_exports__);
  108605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  108606. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108607. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108608. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  108609. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  108610. /**
  108611. * Class used to host texture specific utilities
  108612. */
  108613. var BRDFTextureTools = /** @class */ (function () {
  108614. function BRDFTextureTools() {
  108615. }
  108616. /**
  108617. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  108618. * @param texture the texture to expand.
  108619. */
  108620. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  108621. // Gets everything ready.
  108622. var engine = texture.getEngine();
  108623. var caps = engine.getCaps();
  108624. var expandTexture = false;
  108625. // If half float available we can uncompress the texture
  108626. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  108627. expandTexture = true;
  108628. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  108629. }
  108630. // If full float available we can uncompress the texture
  108631. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  108632. expandTexture = true;
  108633. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  108634. }
  108635. // Expand the texture if possible
  108636. if (expandTexture) {
  108637. // Do not use during decode.
  108638. texture.isReady = false;
  108639. // Simply run through the decode PP.
  108640. 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);
  108641. texture._isRGBD = false;
  108642. texture.invertY = false;
  108643. // Hold the output of the decoding.
  108644. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  108645. generateDepthBuffer: false,
  108646. generateMipMaps: false,
  108647. generateStencilBuffer: false,
  108648. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  108649. type: texture.type,
  108650. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  108651. });
  108652. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  108653. // PP Render Pass
  108654. rgbdPostProcess_1.onApply = function (effect) {
  108655. effect._bindTexture("textureSampler", texture);
  108656. effect.setFloat2("scale", 1, 1);
  108657. };
  108658. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  108659. // Cleanup
  108660. engine.restoreDefaultFramebuffer();
  108661. engine._releaseTexture(texture);
  108662. engine._releaseFramebufferObjects(expandedTexture_1);
  108663. if (rgbdPostProcess_1) {
  108664. rgbdPostProcess_1.dispose();
  108665. }
  108666. // Internal Swap
  108667. expandedTexture_1._swapAndDie(texture);
  108668. // Ready to get rolling again.
  108669. texture.isReady = true;
  108670. });
  108671. }
  108672. };
  108673. /**
  108674. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  108675. * @param scene defines the hosting scene
  108676. * @returns the environment BRDF texture
  108677. */
  108678. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  108679. var _this = this;
  108680. if (!scene.environmentBRDFTexture) {
  108681. // Forces Delayed Texture Loading to prevent undefined error whilst setting RGBD values.
  108682. var useDelayedTextureLoading = scene.useDelayedTextureLoading;
  108683. scene.useDelayedTextureLoading = false;
  108684. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  108685. texture._texture._isRGBD = true;
  108686. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  108687. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  108688. scene.environmentBRDFTexture = texture;
  108689. scene.useDelayedTextureLoading = useDelayedTextureLoading;
  108690. texture.onLoadObservable.addOnce(function () {
  108691. _this._ExpandDefaultBRDFTexture(texture._texture);
  108692. });
  108693. }
  108694. return scene.environmentBRDFTexture;
  108695. };
  108696. BRDFTextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==";
  108697. return BRDFTextureTools;
  108698. }());
  108699. /***/ }),
  108700. /***/ "./Misc/dds.ts":
  108701. /*!*********************!*\
  108702. !*** ./Misc/dds.ts ***!
  108703. \*********************/
  108704. /*! exports provided: DDSTools */
  108705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108706. "use strict";
  108707. __webpack_require__.r(__webpack_exports__);
  108708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  108709. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108710. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  108711. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108712. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  108713. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  108714. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  108715. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  108716. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  108717. /* harmony import */ var _Engines_Extensions_engine_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/Extensions/engine.cubeTexture */ "./Engines/Extensions/engine.cubeTexture.ts");
  108718. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  108719. // All values and structures referenced from:
  108720. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  108721. var DDS_MAGIC = 0x20534444;
  108722. var
  108723. //DDSD_CAPS = 0x1,
  108724. //DDSD_HEIGHT = 0x2,
  108725. //DDSD_WIDTH = 0x4,
  108726. //DDSD_PITCH = 0x8,
  108727. //DDSD_PIXELFORMAT = 0x1000,
  108728. DDSD_MIPMAPCOUNT = 0x20000;
  108729. //DDSD_LINEARSIZE = 0x80000,
  108730. //DDSD_DEPTH = 0x800000;
  108731. // var DDSCAPS_COMPLEX = 0x8,
  108732. // DDSCAPS_MIPMAP = 0x400000,
  108733. // DDSCAPS_TEXTURE = 0x1000;
  108734. var DDSCAPS2_CUBEMAP = 0x200;
  108735. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  108736. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  108737. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  108738. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  108739. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  108740. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  108741. // DDSCAPS2_VOLUME = 0x200000;
  108742. var
  108743. //DDPF_ALPHAPIXELS = 0x1,
  108744. //DDPF_ALPHA = 0x2,
  108745. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  108746. //DDPF_YUV = 0x200,
  108747. DDPF_LUMINANCE = 0x20000;
  108748. function FourCCToInt32(value) {
  108749. return value.charCodeAt(0) +
  108750. (value.charCodeAt(1) << 8) +
  108751. (value.charCodeAt(2) << 16) +
  108752. (value.charCodeAt(3) << 24);
  108753. }
  108754. function Int32ToFourCC(value) {
  108755. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  108756. }
  108757. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  108758. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  108759. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  108760. var FOURCC_DX10 = FourCCToInt32("DX10");
  108761. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  108762. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  108763. var DXGI_FORMAT_R32G32B32A32_FLOAT = 2;
  108764. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  108765. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  108766. var headerLengthInt = 31; // The header length in 32 bit ints
  108767. // Offsets into the header array
  108768. var off_magic = 0;
  108769. var off_size = 1;
  108770. var off_flags = 2;
  108771. var off_height = 3;
  108772. var off_width = 4;
  108773. var off_mipmapCount = 7;
  108774. var off_pfFlags = 20;
  108775. var off_pfFourCC = 21;
  108776. var off_RGBbpp = 22;
  108777. var off_RMask = 23;
  108778. var off_GMask = 24;
  108779. var off_BMask = 25;
  108780. var off_AMask = 26;
  108781. // var off_caps1 = 27;
  108782. var off_caps2 = 28;
  108783. // var off_caps3 = 29;
  108784. // var off_caps4 = 30;
  108785. var off_dxgiFormat = 32;
  108786. /**
  108787. * Class used to provide DDS decompression tools
  108788. */
  108789. var DDSTools = /** @class */ (function () {
  108790. function DDSTools() {
  108791. }
  108792. /**
  108793. * Gets DDS information from an array buffer
  108794. * @param arrayBuffer defines the array buffer to read data from
  108795. * @returns the DDS information
  108796. */
  108797. DDSTools.GetDDSInfo = function (arrayBuffer) {
  108798. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  108799. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  108800. var mipmapCount = 1;
  108801. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  108802. mipmapCount = Math.max(1, header[off_mipmapCount]);
  108803. }
  108804. var fourCC = header[off_pfFourCC];
  108805. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  108806. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  108807. switch (fourCC) {
  108808. case FOURCC_D3DFMT_R16G16B16A16F:
  108809. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  108810. break;
  108811. case FOURCC_D3DFMT_R32G32B32A32F:
  108812. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  108813. break;
  108814. case FOURCC_DX10:
  108815. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  108816. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  108817. break;
  108818. }
  108819. if (dxgiFormat === DXGI_FORMAT_R32G32B32A32_FLOAT) {
  108820. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  108821. break;
  108822. }
  108823. }
  108824. return {
  108825. width: header[off_width],
  108826. height: header[off_height],
  108827. mipmapCount: mipmapCount,
  108828. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  108829. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  108830. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  108831. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  108832. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  108833. dxgiFormat: dxgiFormat,
  108834. textureType: textureType
  108835. };
  108836. };
  108837. DDSTools._ToHalfFloat = function (value) {
  108838. if (!DDSTools._FloatView) {
  108839. DDSTools._FloatView = new Float32Array(1);
  108840. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  108841. }
  108842. DDSTools._FloatView[0] = value;
  108843. var x = DDSTools._Int32View[0];
  108844. var bits = (x >> 16) & 0x8000; /* Get the sign */
  108845. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  108846. var e = (x >> 23) & 0xff; /* Using int is faster here */
  108847. /* If zero, or denormal, or exponent underflows too much for a denormal
  108848. * half, return signed zero. */
  108849. if (e < 103) {
  108850. return bits;
  108851. }
  108852. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  108853. if (e > 142) {
  108854. bits |= 0x7c00;
  108855. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  108856. * not Inf, so make sure we set one mantissa bit too. */
  108857. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  108858. return bits;
  108859. }
  108860. /* If exponent underflows but not too much, return a denormal */
  108861. if (e < 113) {
  108862. m |= 0x0800;
  108863. /* Extra rounding may overflow and set mantissa to 0 and exponent
  108864. * to 1, which is OK. */
  108865. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  108866. return bits;
  108867. }
  108868. bits |= ((e - 112) << 10) | (m >> 1);
  108869. bits += m & 1;
  108870. return bits;
  108871. };
  108872. DDSTools._FromHalfFloat = function (value) {
  108873. var s = (value & 0x8000) >> 15;
  108874. var e = (value & 0x7C00) >> 10;
  108875. var f = value & 0x03FF;
  108876. if (e === 0) {
  108877. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  108878. }
  108879. else if (e == 0x1F) {
  108880. return f ? NaN : ((s ? -1 : 1) * Infinity);
  108881. }
  108882. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  108883. };
  108884. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  108885. var destArray = new Float32Array(dataLength);
  108886. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  108887. var index = 0;
  108888. for (var y = 0; y < height; y++) {
  108889. for (var x = 0; x < width; x++) {
  108890. var srcPos = (x + y * width) * 4;
  108891. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  108892. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  108893. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  108894. if (DDSTools.StoreLODInAlphaChannel) {
  108895. destArray[index + 3] = lod;
  108896. }
  108897. else {
  108898. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  108899. }
  108900. index += 4;
  108901. }
  108902. }
  108903. return destArray;
  108904. };
  108905. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  108906. if (DDSTools.StoreLODInAlphaChannel) {
  108907. var destArray = new Uint16Array(dataLength);
  108908. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  108909. var index = 0;
  108910. for (var y = 0; y < height; y++) {
  108911. for (var x = 0; x < width; x++) {
  108912. var srcPos = (x + y * width) * 4;
  108913. destArray[index] = srcData[srcPos];
  108914. destArray[index + 1] = srcData[srcPos + 1];
  108915. destArray[index + 2] = srcData[srcPos + 2];
  108916. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  108917. index += 4;
  108918. }
  108919. }
  108920. return destArray;
  108921. }
  108922. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  108923. };
  108924. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  108925. if (DDSTools.StoreLODInAlphaChannel) {
  108926. var destArray = new Float32Array(dataLength);
  108927. var srcData = new Float32Array(arrayBuffer, dataOffset);
  108928. var index = 0;
  108929. for (var y = 0; y < height; y++) {
  108930. for (var x = 0; x < width; x++) {
  108931. var srcPos = (x + y * width) * 4;
  108932. destArray[index] = srcData[srcPos];
  108933. destArray[index + 1] = srcData[srcPos + 1];
  108934. destArray[index + 2] = srcData[srcPos + 2];
  108935. destArray[index + 3] = lod;
  108936. index += 4;
  108937. }
  108938. }
  108939. return destArray;
  108940. }
  108941. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  108942. };
  108943. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  108944. var destArray = new Uint8Array(dataLength);
  108945. var srcData = new Float32Array(arrayBuffer, dataOffset);
  108946. var index = 0;
  108947. for (var y = 0; y < height; y++) {
  108948. for (var x = 0; x < width; x++) {
  108949. var srcPos = (x + y * width) * 4;
  108950. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  108951. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  108952. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  108953. if (DDSTools.StoreLODInAlphaChannel) {
  108954. destArray[index + 3] = lod;
  108955. }
  108956. else {
  108957. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  108958. }
  108959. index += 4;
  108960. }
  108961. }
  108962. return destArray;
  108963. };
  108964. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  108965. var destArray = new Uint8Array(dataLength);
  108966. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  108967. var index = 0;
  108968. for (var y = 0; y < height; y++) {
  108969. for (var x = 0; x < width; x++) {
  108970. var srcPos = (x + y * width) * 4;
  108971. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  108972. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  108973. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  108974. if (DDSTools.StoreLODInAlphaChannel) {
  108975. destArray[index + 3] = lod;
  108976. }
  108977. else {
  108978. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  108979. }
  108980. index += 4;
  108981. }
  108982. }
  108983. return destArray;
  108984. };
  108985. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  108986. var byteArray = new Uint8Array(dataLength);
  108987. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  108988. var index = 0;
  108989. for (var y = 0; y < height; y++) {
  108990. for (var x = 0; x < width; x++) {
  108991. var srcPos = (x + y * width) * 4;
  108992. byteArray[index] = srcData[srcPos + rOffset];
  108993. byteArray[index + 1] = srcData[srcPos + gOffset];
  108994. byteArray[index + 2] = srcData[srcPos + bOffset];
  108995. byteArray[index + 3] = srcData[srcPos + aOffset];
  108996. index += 4;
  108997. }
  108998. }
  108999. return byteArray;
  109000. };
  109001. DDSTools._ExtractLongWordOrder = function (value) {
  109002. if (value === 0 || value === 255 || value === -16777216) {
  109003. return 0;
  109004. }
  109005. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  109006. };
  109007. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  109008. var byteArray = new Uint8Array(dataLength);
  109009. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  109010. var index = 0;
  109011. for (var y = 0; y < height; y++) {
  109012. for (var x = 0; x < width; x++) {
  109013. var srcPos = (x + y * width) * 3;
  109014. byteArray[index] = srcData[srcPos + rOffset];
  109015. byteArray[index + 1] = srcData[srcPos + gOffset];
  109016. byteArray[index + 2] = srcData[srcPos + bOffset];
  109017. index += 3;
  109018. }
  109019. }
  109020. return byteArray;
  109021. };
  109022. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  109023. var byteArray = new Uint8Array(dataLength);
  109024. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  109025. var index = 0;
  109026. for (var y = 0; y < height; y++) {
  109027. for (var x = 0; x < width; x++) {
  109028. var srcPos = (x + y * width);
  109029. byteArray[index] = srcData[srcPos];
  109030. index++;
  109031. }
  109032. }
  109033. return byteArray;
  109034. };
  109035. /**
  109036. * Uploads DDS Levels to a Babylon Texture
  109037. * @hidden
  109038. */
  109039. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  109040. if (lodIndex === void 0) { lodIndex = -1; }
  109041. var sphericalPolynomialFaces = null;
  109042. if (info.sphericalPolynomial) {
  109043. sphericalPolynomialFaces = new Array();
  109044. }
  109045. var ext = engine.getCaps().s3tc;
  109046. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  109047. var fourCC, width, height, dataLength = 0, dataOffset;
  109048. var byteArray, mipmapCount, mip;
  109049. var internalCompressedFormat = 0;
  109050. var blockBytes = 1;
  109051. if (header[off_magic] !== DDS_MAGIC) {
  109052. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  109053. return;
  109054. }
  109055. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  109056. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  109057. return;
  109058. }
  109059. if (info.isCompressed && !ext) {
  109060. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  109061. return;
  109062. }
  109063. var bpp = header[off_RGBbpp];
  109064. dataOffset = header[off_size] + 4;
  109065. var computeFormats = false;
  109066. if (info.isFourCC) {
  109067. fourCC = header[off_pfFourCC];
  109068. switch (fourCC) {
  109069. case FOURCC_DXT1:
  109070. blockBytes = 8;
  109071. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  109072. break;
  109073. case FOURCC_DXT3:
  109074. blockBytes = 16;
  109075. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  109076. break;
  109077. case FOURCC_DXT5:
  109078. blockBytes = 16;
  109079. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  109080. break;
  109081. case FOURCC_D3DFMT_R16G16B16A16F:
  109082. computeFormats = true;
  109083. break;
  109084. case FOURCC_D3DFMT_R32G32B32A32F:
  109085. computeFormats = true;
  109086. break;
  109087. case FOURCC_DX10:
  109088. // There is an additionnal header so dataOffset need to be changed
  109089. dataOffset += 5 * 4; // 5 uints
  109090. var supported = false;
  109091. switch (info.dxgiFormat) {
  109092. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  109093. case DXGI_FORMAT_R32G32B32A32_FLOAT:
  109094. computeFormats = true;
  109095. supported = true;
  109096. break;
  109097. case DXGI_FORMAT_B8G8R8X8_UNORM:
  109098. info.isRGB = true;
  109099. info.isFourCC = false;
  109100. bpp = 32;
  109101. supported = true;
  109102. break;
  109103. }
  109104. if (supported) {
  109105. break;
  109106. }
  109107. default:
  109108. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  109109. return;
  109110. }
  109111. }
  109112. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  109113. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  109114. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  109115. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  109116. if (computeFormats) {
  109117. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  109118. }
  109119. mipmapCount = 1;
  109120. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  109121. mipmapCount = Math.max(1, header[off_mipmapCount]);
  109122. }
  109123. var startFace = currentFace || 0;
  109124. for (var face = startFace; face < faces; face++) {
  109125. width = header[off_width];
  109126. height = header[off_height];
  109127. for (mip = 0; mip < mipmapCount; ++mip) {
  109128. if (lodIndex === -1 || lodIndex === mip) {
  109129. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  109130. var i = (lodIndex === -1) ? mip : 0;
  109131. if (!info.isCompressed && info.isFourCC) {
  109132. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  109133. dataLength = width * height * 4;
  109134. var floatArray = null;
  109135. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  109136. if (bpp === 128) {
  109137. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  109138. if (sphericalPolynomialFaces && i == 0) {
  109139. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  109140. }
  109141. }
  109142. else if (bpp === 64) {
  109143. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  109144. if (sphericalPolynomialFaces && i == 0) {
  109145. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  109146. }
  109147. }
  109148. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  109149. }
  109150. else {
  109151. if (bpp === 128) {
  109152. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  109153. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  109154. if (sphericalPolynomialFaces && i == 0) {
  109155. sphericalPolynomialFaces.push(floatArray);
  109156. }
  109157. }
  109158. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  109159. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  109160. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  109161. if (sphericalPolynomialFaces && i == 0) {
  109162. sphericalPolynomialFaces.push(floatArray);
  109163. }
  109164. }
  109165. else { // 64
  109166. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  109167. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  109168. if (sphericalPolynomialFaces && i == 0) {
  109169. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  109170. }
  109171. }
  109172. }
  109173. if (floatArray) {
  109174. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  109175. }
  109176. }
  109177. else if (info.isRGB) {
  109178. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  109179. if (bpp === 24) {
  109180. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  109181. dataLength = width * height * 3;
  109182. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  109183. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  109184. }
  109185. else { // 32
  109186. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  109187. dataLength = width * height * 4;
  109188. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  109189. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  109190. }
  109191. }
  109192. else if (info.isLuminance) {
  109193. var unpackAlignment = engine._getUnpackAlignement();
  109194. var unpaddedRowSize = width;
  109195. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  109196. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  109197. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  109198. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  109199. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  109200. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  109201. }
  109202. else {
  109203. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  109204. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  109205. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  109206. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  109207. }
  109208. }
  109209. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  109210. width *= 0.5;
  109211. height *= 0.5;
  109212. width = Math.max(1.0, width);
  109213. height = Math.max(1.0, height);
  109214. }
  109215. if (currentFace !== undefined) {
  109216. // Loading a single face
  109217. break;
  109218. }
  109219. }
  109220. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  109221. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  109222. size: header[off_width],
  109223. right: sphericalPolynomialFaces[0],
  109224. left: sphericalPolynomialFaces[1],
  109225. up: sphericalPolynomialFaces[2],
  109226. down: sphericalPolynomialFaces[3],
  109227. front: sphericalPolynomialFaces[4],
  109228. back: sphericalPolynomialFaces[5],
  109229. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  109230. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  109231. gammaSpace: false,
  109232. });
  109233. }
  109234. else {
  109235. info.sphericalPolynomial = undefined;
  109236. }
  109237. };
  109238. /**
  109239. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109240. */
  109241. DDSTools.StoreLODInAlphaChannel = false;
  109242. return DDSTools;
  109243. }());
  109244. /**
  109245. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109246. * @param rootUrl defines the url where the file to load is located
  109247. * @param scene defines the current scene
  109248. * @param lodScale defines scale to apply to the mip map selection
  109249. * @param lodOffset defines offset to apply to the mip map selection
  109250. * @param onLoad defines an optional callback raised when the texture is loaded
  109251. * @param onError defines an optional callback raised if there is an issue to load the texture
  109252. * @param format defines the format of the data
  109253. * @param forcedExtension defines the extension to use to pick the right loader
  109254. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109255. * @returns the cube texture as an InternalTexture
  109256. */
  109257. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  109258. var _this = this;
  109259. if (onLoad === void 0) { onLoad = null; }
  109260. if (onError === void 0) { onError = null; }
  109261. if (forcedExtension === void 0) { forcedExtension = null; }
  109262. if (createPolynomials === void 0) { createPolynomials = true; }
  109263. var callback = function (loadData) {
  109264. if (!loadData) {
  109265. if (onLoad) {
  109266. onLoad(null);
  109267. }
  109268. return;
  109269. }
  109270. var texture = loadData.texture;
  109271. if (!createPolynomials) {
  109272. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  109273. }
  109274. else if (loadData.info.sphericalPolynomial) {
  109275. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  109276. }
  109277. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  109278. if (_this.getCaps().textureLOD) {
  109279. // Do not add extra process if texture lod is supported.
  109280. if (onLoad) {
  109281. onLoad(texture);
  109282. }
  109283. return;
  109284. }
  109285. var mipSlices = 3;
  109286. var gl = _this._gl;
  109287. var width = loadData.width;
  109288. if (!width) {
  109289. return;
  109290. }
  109291. var textures = [];
  109292. for (var i = 0; i < mipSlices; i++) {
  109293. //compute LOD from even spacing in smoothness (matching shader calculation)
  109294. var smoothness = i / (mipSlices - 1);
  109295. var roughness = 1 - smoothness;
  109296. var minLODIndex = lodOffset; // roughness = 0
  109297. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  109298. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  109299. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  109300. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  109301. glTextureFromLod.type = texture.type;
  109302. glTextureFromLod.format = texture.format;
  109303. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  109304. glTextureFromLod.height = glTextureFromLod.width;
  109305. glTextureFromLod.isCube = true;
  109306. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  109307. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  109308. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  109309. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  109310. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  109311. if (loadData.isDDS) {
  109312. var info = loadData.info;
  109313. var data = loadData.data;
  109314. _this._unpackFlipY(info.isCompressed);
  109315. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  109316. }
  109317. else {
  109318. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  109319. }
  109320. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  109321. // Wrap in a base texture for easy binding.
  109322. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  109323. lodTexture.isCube = true;
  109324. lodTexture._texture = glTextureFromLod;
  109325. glTextureFromLod.isReady = true;
  109326. textures.push(lodTexture);
  109327. }
  109328. texture._lodTextureHigh = textures[2];
  109329. texture._lodTextureMid = textures[1];
  109330. texture._lodTextureLow = textures[0];
  109331. if (onLoad) {
  109332. onLoad(texture);
  109333. }
  109334. };
  109335. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  109336. };
  109337. /***/ }),
  109338. /***/ "./Misc/decorators.ts":
  109339. /*!****************************!*\
  109340. !*** ./Misc/decorators.ts ***!
  109341. \****************************/
  109342. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  109343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109344. "use strict";
  109345. __webpack_require__.r(__webpack_exports__);
  109346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  109347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  109348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  109349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  109350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  109351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  109352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  109353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  109354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  109355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  109356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  109357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  109358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  109359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  109360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  109361. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  109362. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  109363. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  109364. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  109365. var __decoratorInitialStore = {};
  109366. var __mergedStore = {};
  109367. var _copySource = function (creationFunction, source, instanciate) {
  109368. var destination = creationFunction();
  109369. // Tags
  109370. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  109371. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  109372. }
  109373. var classStore = getMergedStore(destination);
  109374. // Properties
  109375. for (var property in classStore) {
  109376. var propertyDescriptor = classStore[property];
  109377. var sourceProperty = source[property];
  109378. var propertyType = propertyDescriptor.type;
  109379. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  109380. switch (propertyType) {
  109381. case 0: // Value
  109382. case 6: // Mesh reference
  109383. case 11: // Camera reference
  109384. destination[property] = sourceProperty;
  109385. break;
  109386. case 1: // Texture
  109387. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  109388. break;
  109389. case 2: // Color3
  109390. case 3: // FresnelParameters
  109391. case 4: // Vector2
  109392. case 5: // Vector3
  109393. case 7: // Color Curves
  109394. case 10: // Quaternion
  109395. case 12: // Matrix
  109396. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  109397. break;
  109398. }
  109399. }
  109400. }
  109401. return destination;
  109402. };
  109403. function getDirectStore(target) {
  109404. var classKey = target.getClassName();
  109405. if (!__decoratorInitialStore[classKey]) {
  109406. __decoratorInitialStore[classKey] = {};
  109407. }
  109408. return __decoratorInitialStore[classKey];
  109409. }
  109410. /**
  109411. * Return the list of properties flagged as serializable
  109412. * @param target: host object
  109413. */
  109414. function getMergedStore(target) {
  109415. var classKey = target.getClassName();
  109416. if (__mergedStore[classKey]) {
  109417. return __mergedStore[classKey];
  109418. }
  109419. __mergedStore[classKey] = {};
  109420. var store = __mergedStore[classKey];
  109421. var currentTarget = target;
  109422. var currentKey = classKey;
  109423. while (currentKey) {
  109424. var initialStore = __decoratorInitialStore[currentKey];
  109425. for (var property in initialStore) {
  109426. store[property] = initialStore[property];
  109427. }
  109428. var parent_1 = void 0;
  109429. var done = false;
  109430. do {
  109431. parent_1 = Object.getPrototypeOf(currentTarget);
  109432. if (!parent_1.getClassName) {
  109433. done = true;
  109434. break;
  109435. }
  109436. if (parent_1.getClassName() !== currentKey) {
  109437. break;
  109438. }
  109439. currentTarget = parent_1;
  109440. } while (parent_1);
  109441. if (done) {
  109442. break;
  109443. }
  109444. currentKey = parent_1.getClassName();
  109445. currentTarget = parent_1;
  109446. }
  109447. return store;
  109448. }
  109449. function generateSerializableMember(type, sourceName) {
  109450. return function (target, propertyKey) {
  109451. var classStore = getDirectStore(target);
  109452. if (!classStore[propertyKey]) {
  109453. classStore[propertyKey] = { type: type, sourceName: sourceName };
  109454. }
  109455. };
  109456. }
  109457. function generateExpandMember(setCallback, targetKey) {
  109458. if (targetKey === void 0) { targetKey = null; }
  109459. return function (target, propertyKey) {
  109460. var key = targetKey || ("_" + propertyKey);
  109461. Object.defineProperty(target, propertyKey, {
  109462. get: function () {
  109463. return this[key];
  109464. },
  109465. set: function (value) {
  109466. if (this[key] === value) {
  109467. return;
  109468. }
  109469. this[key] = value;
  109470. target[setCallback].apply(this);
  109471. },
  109472. enumerable: true,
  109473. configurable: true
  109474. });
  109475. };
  109476. }
  109477. function expandToProperty(callback, targetKey) {
  109478. if (targetKey === void 0) { targetKey = null; }
  109479. return generateExpandMember(callback, targetKey);
  109480. }
  109481. function serialize(sourceName) {
  109482. return generateSerializableMember(0, sourceName); // value member
  109483. }
  109484. function serializeAsTexture(sourceName) {
  109485. return generateSerializableMember(1, sourceName); // texture member
  109486. }
  109487. function serializeAsColor3(sourceName) {
  109488. return generateSerializableMember(2, sourceName); // color3 member
  109489. }
  109490. function serializeAsFresnelParameters(sourceName) {
  109491. return generateSerializableMember(3, sourceName); // fresnel parameters member
  109492. }
  109493. function serializeAsVector2(sourceName) {
  109494. return generateSerializableMember(4, sourceName); // vector2 member
  109495. }
  109496. function serializeAsVector3(sourceName) {
  109497. return generateSerializableMember(5, sourceName); // vector3 member
  109498. }
  109499. function serializeAsMeshReference(sourceName) {
  109500. return generateSerializableMember(6, sourceName); // mesh reference member
  109501. }
  109502. function serializeAsColorCurves(sourceName) {
  109503. return generateSerializableMember(7, sourceName); // color curves
  109504. }
  109505. function serializeAsColor4(sourceName) {
  109506. return generateSerializableMember(8, sourceName); // color 4
  109507. }
  109508. function serializeAsImageProcessingConfiguration(sourceName) {
  109509. return generateSerializableMember(9, sourceName); // image processing
  109510. }
  109511. function serializeAsQuaternion(sourceName) {
  109512. return generateSerializableMember(10, sourceName); // quaternion member
  109513. }
  109514. function serializeAsMatrix(sourceName) {
  109515. return generateSerializableMember(12, sourceName); // matrix member
  109516. }
  109517. /**
  109518. * Decorator used to define property that can be serialized as reference to a camera
  109519. * @param sourceName defines the name of the property to decorate
  109520. */
  109521. function serializeAsCameraReference(sourceName) {
  109522. return generateSerializableMember(11, sourceName); // camera reference member
  109523. }
  109524. /**
  109525. * Class used to help serialization objects
  109526. */
  109527. var SerializationHelper = /** @class */ (function () {
  109528. function SerializationHelper() {
  109529. }
  109530. /**
  109531. * Appends the serialized animations from the source animations
  109532. * @param source Source containing the animations
  109533. * @param destination Target to store the animations
  109534. */
  109535. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  109536. if (source.animations) {
  109537. destination.animations = [];
  109538. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  109539. var animation = source.animations[animationIndex];
  109540. destination.animations.push(animation.serialize());
  109541. }
  109542. }
  109543. };
  109544. /**
  109545. * Static function used to serialized a specific entity
  109546. * @param entity defines the entity to serialize
  109547. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109548. * @returns a JSON compatible object representing the serialization of the entity
  109549. */
  109550. SerializationHelper.Serialize = function (entity, serializationObject) {
  109551. if (!serializationObject) {
  109552. serializationObject = {};
  109553. }
  109554. // Tags
  109555. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  109556. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  109557. }
  109558. var serializedProperties = getMergedStore(entity);
  109559. // Properties
  109560. for (var property in serializedProperties) {
  109561. var propertyDescriptor = serializedProperties[property];
  109562. var targetPropertyName = propertyDescriptor.sourceName || property;
  109563. var propertyType = propertyDescriptor.type;
  109564. var sourceProperty = entity[property];
  109565. if (sourceProperty !== undefined && sourceProperty !== null) {
  109566. switch (propertyType) {
  109567. case 0: // Value
  109568. serializationObject[targetPropertyName] = sourceProperty;
  109569. break;
  109570. case 1: // Texture
  109571. serializationObject[targetPropertyName] = sourceProperty.serialize();
  109572. break;
  109573. case 2: // Color3
  109574. serializationObject[targetPropertyName] = sourceProperty.asArray();
  109575. break;
  109576. case 3: // FresnelParameters
  109577. serializationObject[targetPropertyName] = sourceProperty.serialize();
  109578. break;
  109579. case 4: // Vector2
  109580. serializationObject[targetPropertyName] = sourceProperty.asArray();
  109581. break;
  109582. case 5: // Vector3
  109583. serializationObject[targetPropertyName] = sourceProperty.asArray();
  109584. break;
  109585. case 6: // Mesh reference
  109586. serializationObject[targetPropertyName] = sourceProperty.id;
  109587. break;
  109588. case 7: // Color Curves
  109589. serializationObject[targetPropertyName] = sourceProperty.serialize();
  109590. break;
  109591. case 8: // Color 4
  109592. serializationObject[targetPropertyName] = sourceProperty.asArray();
  109593. break;
  109594. case 9: // Image Processing
  109595. serializationObject[targetPropertyName] = sourceProperty.serialize();
  109596. break;
  109597. case 10: // Quaternion
  109598. serializationObject[targetPropertyName] = sourceProperty.asArray();
  109599. break;
  109600. case 11: // Camera reference
  109601. serializationObject[targetPropertyName] = sourceProperty.id;
  109602. case 12: // Matrix
  109603. serializationObject[targetPropertyName] = sourceProperty.asArray();
  109604. break;
  109605. }
  109606. }
  109607. }
  109608. return serializationObject;
  109609. };
  109610. /**
  109611. * Creates a new entity from a serialization data object
  109612. * @param creationFunction defines a function used to instanciated the new entity
  109613. * @param source defines the source serialization data
  109614. * @param scene defines the hosting scene
  109615. * @param rootUrl defines the root url for resources
  109616. * @returns a new entity
  109617. */
  109618. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  109619. if (rootUrl === void 0) { rootUrl = null; }
  109620. var destination = creationFunction();
  109621. if (!rootUrl) {
  109622. rootUrl = "";
  109623. }
  109624. // Tags
  109625. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  109626. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  109627. }
  109628. var classStore = getMergedStore(destination);
  109629. // Properties
  109630. for (var property in classStore) {
  109631. var propertyDescriptor = classStore[property];
  109632. var sourceProperty = source[propertyDescriptor.sourceName || property];
  109633. var propertyType = propertyDescriptor.type;
  109634. if (sourceProperty !== undefined && sourceProperty !== null) {
  109635. var dest = destination;
  109636. switch (propertyType) {
  109637. case 0: // Value
  109638. dest[property] = sourceProperty;
  109639. break;
  109640. case 1: // Texture
  109641. if (scene) {
  109642. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  109643. }
  109644. break;
  109645. case 2: // Color3
  109646. dest[property] = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(sourceProperty);
  109647. break;
  109648. case 3: // FresnelParameters
  109649. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  109650. break;
  109651. case 4: // Vector2
  109652. dest[property] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  109653. break;
  109654. case 5: // Vector3
  109655. dest[property] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  109656. break;
  109657. case 6: // Mesh reference
  109658. if (scene) {
  109659. dest[property] = scene.getLastMeshByID(sourceProperty);
  109660. }
  109661. break;
  109662. case 7: // Color Curves
  109663. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  109664. break;
  109665. case 8: // Color 4
  109666. dest[property] = _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(sourceProperty);
  109667. break;
  109668. case 9: // Image Processing
  109669. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  109670. break;
  109671. case 10: // Quaternion
  109672. dest[property] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  109673. break;
  109674. case 11: // Camera reference
  109675. if (scene) {
  109676. dest[property] = scene.getCameraByID(sourceProperty);
  109677. }
  109678. case 12: // Matrix
  109679. dest[property] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  109680. break;
  109681. }
  109682. }
  109683. }
  109684. return destination;
  109685. };
  109686. /**
  109687. * Clones an object
  109688. * @param creationFunction defines the function used to instanciate the new object
  109689. * @param source defines the source object
  109690. * @returns the cloned object
  109691. */
  109692. SerializationHelper.Clone = function (creationFunction, source) {
  109693. return _copySource(creationFunction, source, false);
  109694. };
  109695. /**
  109696. * Instanciates a new object based on a source one (some data will be shared between both object)
  109697. * @param creationFunction defines the function used to instanciate the new object
  109698. * @param source defines the source object
  109699. * @returns the new object
  109700. */
  109701. SerializationHelper.Instanciate = function (creationFunction, source) {
  109702. return _copySource(creationFunction, source, true);
  109703. };
  109704. /** @hidden */
  109705. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  109706. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  109707. };
  109708. /** @hidden */
  109709. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  109710. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  109711. };
  109712. /** @hidden */
  109713. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  109714. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  109715. };
  109716. /** @hidden */
  109717. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  109718. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  109719. };
  109720. return SerializationHelper;
  109721. }());
  109722. /***/ }),
  109723. /***/ "./Misc/deepCopier.ts":
  109724. /*!****************************!*\
  109725. !*** ./Misc/deepCopier.ts ***!
  109726. \****************************/
  109727. /*! exports provided: DeepCopier */
  109728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109729. "use strict";
  109730. __webpack_require__.r(__webpack_exports__);
  109731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  109732. var cloneValue = function (source, destinationObject) {
  109733. if (!source) {
  109734. return null;
  109735. }
  109736. if (source.getClassName && source.getClassName() === "Mesh") {
  109737. return null;
  109738. }
  109739. if (source.getClassName && source.getClassName() === "SubMesh") {
  109740. return source.clone(destinationObject);
  109741. }
  109742. else if (source.clone) {
  109743. return source.clone();
  109744. }
  109745. return null;
  109746. };
  109747. /**
  109748. * Class containing a set of static utilities functions for deep copy.
  109749. */
  109750. var DeepCopier = /** @class */ (function () {
  109751. function DeepCopier() {
  109752. }
  109753. /**
  109754. * Tries to copy an object by duplicating every property
  109755. * @param source defines the source object
  109756. * @param destination defines the target object
  109757. * @param doNotCopyList defines a list of properties to avoid
  109758. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  109759. */
  109760. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  109761. for (var prop in source) {
  109762. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  109763. continue;
  109764. }
  109765. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  109766. continue;
  109767. }
  109768. var sourceValue = source[prop];
  109769. var typeOfSourceValue = typeof sourceValue;
  109770. if (typeOfSourceValue === "function") {
  109771. continue;
  109772. }
  109773. try {
  109774. if (typeOfSourceValue === "object") {
  109775. if (sourceValue instanceof Array) {
  109776. destination[prop] = [];
  109777. if (sourceValue.length > 0) {
  109778. if (typeof sourceValue[0] == "object") {
  109779. for (var index = 0; index < sourceValue.length; index++) {
  109780. var clonedValue = cloneValue(sourceValue[index], destination);
  109781. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  109782. destination[prop].push(clonedValue);
  109783. }
  109784. }
  109785. }
  109786. else {
  109787. destination[prop] = sourceValue.slice(0);
  109788. }
  109789. }
  109790. }
  109791. else {
  109792. destination[prop] = cloneValue(sourceValue, destination);
  109793. }
  109794. }
  109795. else {
  109796. destination[prop] = sourceValue;
  109797. }
  109798. }
  109799. catch (e) {
  109800. // Just ignore error (it could be because of a read-only property)
  109801. }
  109802. }
  109803. };
  109804. return DeepCopier;
  109805. }());
  109806. /***/ }),
  109807. /***/ "./Misc/deferred.ts":
  109808. /*!**************************!*\
  109809. !*** ./Misc/deferred.ts ***!
  109810. \**************************/
  109811. /*! exports provided: Deferred */
  109812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109813. "use strict";
  109814. __webpack_require__.r(__webpack_exports__);
  109815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  109816. /**
  109817. * Wrapper class for promise with external resolve and reject.
  109818. */
  109819. var Deferred = /** @class */ (function () {
  109820. /**
  109821. * Constructor for this deferred object.
  109822. */
  109823. function Deferred() {
  109824. var _this = this;
  109825. this.promise = new Promise(function (resolve, reject) {
  109826. _this._resolve = resolve;
  109827. _this._reject = reject;
  109828. });
  109829. }
  109830. Object.defineProperty(Deferred.prototype, "resolve", {
  109831. /**
  109832. * The resolve method of the promise associated with this deferred object.
  109833. */
  109834. get: function () {
  109835. return this._resolve;
  109836. },
  109837. enumerable: true,
  109838. configurable: true
  109839. });
  109840. Object.defineProperty(Deferred.prototype, "reject", {
  109841. /**
  109842. * The reject method of the promise associated with this deferred object.
  109843. */
  109844. get: function () {
  109845. return this._reject;
  109846. },
  109847. enumerable: true,
  109848. configurable: true
  109849. });
  109850. return Deferred;
  109851. }());
  109852. /***/ }),
  109853. /***/ "./Misc/devTools.ts":
  109854. /*!**************************!*\
  109855. !*** ./Misc/devTools.ts ***!
  109856. \**************************/
  109857. /*! exports provided: _DevTools */
  109858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109859. "use strict";
  109860. __webpack_require__.r(__webpack_exports__);
  109861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  109862. /** @hidden */
  109863. var _DevTools = /** @class */ (function () {
  109864. function _DevTools() {
  109865. }
  109866. _DevTools.WarnImport = function (name) {
  109867. return name + " needs to be imported before as it contains a side-effect required by your code.";
  109868. };
  109869. return _DevTools;
  109870. }());
  109871. /***/ }),
  109872. /***/ "./Misc/domManagement.ts":
  109873. /*!*******************************!*\
  109874. !*** ./Misc/domManagement.ts ***!
  109875. \*******************************/
  109876. /*! exports provided: DomManagement */
  109877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109878. "use strict";
  109879. __webpack_require__.r(__webpack_exports__);
  109880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  109881. /**
  109882. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  109883. * Babylon.js
  109884. */
  109885. var DomManagement = /** @class */ (function () {
  109886. function DomManagement() {
  109887. }
  109888. /**
  109889. * Checks if the window object exists
  109890. * @returns true if the window object exists
  109891. */
  109892. DomManagement.IsWindowObjectExist = function () {
  109893. return (typeof window) !== "undefined";
  109894. };
  109895. /**
  109896. * Extracts text content from a DOM element hierarchy
  109897. * @param element defines the root element
  109898. * @returns a string
  109899. */
  109900. DomManagement.GetDOMTextContent = function (element) {
  109901. var result = "";
  109902. var child = element.firstChild;
  109903. while (child) {
  109904. if (child.nodeType === 3) {
  109905. result += child.textContent;
  109906. }
  109907. child = (child.nextSibling);
  109908. }
  109909. return result;
  109910. };
  109911. return DomManagement;
  109912. }());
  109913. /***/ }),
  109914. /***/ "./Misc/environmentTextureTools.ts":
  109915. /*!*****************************************!*\
  109916. !*** ./Misc/environmentTextureTools.ts ***!
  109917. \*****************************************/
  109918. /*! exports provided: EnvironmentTextureTools */
  109919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109920. "use strict";
  109921. __webpack_require__.r(__webpack_exports__);
  109922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  109923. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  109924. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  109925. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109926. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  109927. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  109928. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  109929. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109930. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  109931. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  109932. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  109933. /* harmony import */ var _Engines_Extensions_engine_renderTarget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/Extensions/engine.renderTarget */ "./Engines/Extensions/engine.renderTarget.ts");
  109934. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  109935. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  109936. /**
  109937. * Sets of helpers addressing the serialization and deserialization of environment texture
  109938. * stored in a BabylonJS env file.
  109939. * Those files are usually stored as .env files.
  109940. */
  109941. var EnvironmentTextureTools = /** @class */ (function () {
  109942. function EnvironmentTextureTools() {
  109943. }
  109944. /**
  109945. * Gets the environment info from an env file.
  109946. * @param data The array buffer containing the .env bytes.
  109947. * @returns the environment file info (the json header) if successfully parsed.
  109948. */
  109949. EnvironmentTextureTools.GetEnvInfo = function (data) {
  109950. var dataView = new DataView(data);
  109951. var pos = 0;
  109952. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  109953. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  109954. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  109955. return null;
  109956. }
  109957. }
  109958. // Read json manifest - collect characters up to null terminator
  109959. var manifestString = '';
  109960. var charCode = 0x00;
  109961. while ((charCode = dataView.getUint8(pos++))) {
  109962. manifestString += String.fromCharCode(charCode);
  109963. }
  109964. var manifest = JSON.parse(manifestString);
  109965. if (manifest.specular) {
  109966. // Extend the header with the position of the payload.
  109967. manifest.specular.specularDataPosition = pos;
  109968. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  109969. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  109970. }
  109971. return manifest;
  109972. };
  109973. /**
  109974. * Creates an environment texture from a loaded cube texture.
  109975. * @param texture defines the cube texture to convert in env file
  109976. * @return a promise containing the environment data if succesfull.
  109977. */
  109978. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  109979. var _this = this;
  109980. var internalTexture = texture.getInternalTexture();
  109981. if (!internalTexture) {
  109982. return Promise.reject("The cube texture is invalid.");
  109983. }
  109984. if (!texture._prefiltered) {
  109985. return Promise.reject("The cube texture is invalid (not prefiltered).");
  109986. }
  109987. var engine = internalTexture.getEngine();
  109988. if (engine && engine.premultipliedAlpha) {
  109989. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  109990. }
  109991. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  109992. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  109993. }
  109994. var canvas = engine.getRenderingCanvas();
  109995. if (!canvas) {
  109996. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  109997. }
  109998. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  109999. if (!engine.getCaps().textureFloatRender) {
  110000. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  110001. if (!engine.getCaps().textureHalfFloatRender) {
  110002. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  110003. }
  110004. }
  110005. var cubeWidth = internalTexture.width;
  110006. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  110007. var specularTextures = {};
  110008. var promises = [];
  110009. // Read and collect all mipmaps data from the cube.
  110010. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  110011. mipmapsCount = Math.round(mipmapsCount);
  110012. var _loop_1 = function (i) {
  110013. var faceWidth = Math.pow(2, mipmapsCount - i);
  110014. var _loop_2 = function (face) {
  110015. var data = texture.readPixels(face, i);
  110016. // Creates a temp texture with the face data.
  110017. 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);
  110018. // And rgbdEncode them.
  110019. var promise = new Promise(function (resolve, reject) {
  110020. 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);
  110021. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  110022. rgbdPostProcess.onApply = function (effect) {
  110023. effect._bindTexture("textureSampler", tempTexture);
  110024. };
  110025. // As the process needs to happen on the main canvas, keep track of the current size
  110026. var currentW = engine.getRenderWidth();
  110027. var currentH = engine.getRenderHeight();
  110028. // Set the desired size for the texture
  110029. engine.setSize(faceWidth, faceWidth);
  110030. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  110031. // Reading datas from WebGL
  110032. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  110033. var fileReader = new FileReader();
  110034. fileReader.onload = function (event) {
  110035. var arrayBuffer = event.target.result;
  110036. specularTextures[i * 6 + face] = arrayBuffer;
  110037. resolve();
  110038. };
  110039. fileReader.readAsArrayBuffer(blob);
  110040. });
  110041. // Reapply the previous canvas size
  110042. engine.setSize(currentW, currentH);
  110043. });
  110044. });
  110045. promises.push(promise);
  110046. };
  110047. // All faces of the cube.
  110048. for (var face = 0; face < 6; face++) {
  110049. _loop_2(face);
  110050. }
  110051. };
  110052. for (var i = 0; i <= mipmapsCount; i++) {
  110053. _loop_1(i);
  110054. }
  110055. // Once all the textures haves been collected as RGBD stored in PNGs
  110056. return Promise.all(promises).then(function () {
  110057. // We can delete the hosting scene keeping track of all the creation objects
  110058. hostingScene.dispose();
  110059. // Creates the json header for the env texture
  110060. var info = {
  110061. version: 1,
  110062. width: cubeWidth,
  110063. irradiance: _this._CreateEnvTextureIrradiance(texture),
  110064. specular: {
  110065. mipmaps: [],
  110066. lodGenerationScale: texture.lodGenerationScale
  110067. }
  110068. };
  110069. // Sets the specular image data information
  110070. var position = 0;
  110071. for (var i = 0; i <= mipmapsCount; i++) {
  110072. for (var face = 0; face < 6; face++) {
  110073. var byteLength = specularTextures[i * 6 + face].byteLength;
  110074. info.specular.mipmaps.push({
  110075. length: byteLength,
  110076. position: position
  110077. });
  110078. position += byteLength;
  110079. }
  110080. }
  110081. // Encode the JSON as an array buffer
  110082. var infoString = JSON.stringify(info);
  110083. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  110084. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  110085. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  110086. infoView[i] = infoString.charCodeAt(i);
  110087. }
  110088. // Ends up with a null terminator for easier parsing
  110089. infoView[infoString.length] = 0x00;
  110090. // Computes the final required size and creates the storage
  110091. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  110092. var finalBuffer = new ArrayBuffer(totalSize);
  110093. var finalBufferView = new Uint8Array(finalBuffer);
  110094. var dataView = new DataView(finalBuffer);
  110095. // Copy the magic bytes identifying the file in
  110096. var pos = 0;
  110097. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  110098. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  110099. }
  110100. // Add the json info
  110101. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  110102. pos += infoBuffer.byteLength;
  110103. // Finally inserts the texture data
  110104. for (var i = 0; i <= mipmapsCount; i++) {
  110105. for (var face = 0; face < 6; face++) {
  110106. var dataBuffer = specularTextures[i * 6 + face];
  110107. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  110108. pos += dataBuffer.byteLength;
  110109. }
  110110. }
  110111. // Voila
  110112. return finalBuffer;
  110113. });
  110114. };
  110115. /**
  110116. * Creates a JSON representation of the spherical data.
  110117. * @param texture defines the texture containing the polynomials
  110118. * @return the JSON representation of the spherical info
  110119. */
  110120. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  110121. var polynmials = texture.sphericalPolynomial;
  110122. if (polynmials == null) {
  110123. return null;
  110124. }
  110125. return {
  110126. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  110127. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  110128. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  110129. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  110130. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  110131. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  110132. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  110133. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  110134. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  110135. };
  110136. };
  110137. /**
  110138. * Uploads the texture info contained in the env file to the GPU.
  110139. * @param texture defines the internal texture to upload to
  110140. * @param arrayBuffer defines the buffer cotaining the data to load
  110141. * @param info defines the texture info retrieved through the GetEnvInfo method
  110142. * @returns a promise
  110143. */
  110144. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  110145. if (info.version !== 1) {
  110146. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  110147. }
  110148. var specularInfo = info.specular;
  110149. if (!specularInfo) {
  110150. // Nothing else parsed so far
  110151. return Promise.resolve();
  110152. }
  110153. // Double checks the enclosed info
  110154. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  110155. mipmapsCount = Math.round(mipmapsCount) + 1;
  110156. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  110157. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  110158. }
  110159. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  110160. var imageData = new Array(mipmapsCount);
  110161. for (var i = 0; i < mipmapsCount; i++) {
  110162. imageData[i] = new Array(6);
  110163. for (var face = 0; face < 6; face++) {
  110164. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  110165. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  110166. }
  110167. }
  110168. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  110169. };
  110170. /**
  110171. * Uploads the levels of image data to the GPU.
  110172. * @param texture defines the internal texture to upload to
  110173. * @param imageData defines the array buffer views of image data [mipmap][face]
  110174. * @returns a promise
  110175. */
  110176. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  110177. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  110178. throw new Error("Texture size must be a power of two");
  110179. }
  110180. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  110181. // Gets everything ready.
  110182. var engine = texture.getEngine();
  110183. var expandTexture = false;
  110184. var generateNonLODTextures = false;
  110185. var rgbdPostProcess = null;
  110186. var cubeRtt = null;
  110187. var lodTextures = null;
  110188. var caps = engine.getCaps();
  110189. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  110190. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  110191. texture.generateMipMaps = true;
  110192. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  110193. // Add extra process if texture lod is not supported
  110194. if (!caps.textureLOD) {
  110195. expandTexture = false;
  110196. generateNonLODTextures = true;
  110197. lodTextures = {};
  110198. }
  110199. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  110200. else if (engine.webGLVersion < 2) {
  110201. expandTexture = false;
  110202. }
  110203. // If half float available we can uncompress the texture
  110204. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  110205. expandTexture = true;
  110206. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  110207. }
  110208. // If full float available we can uncompress the texture
  110209. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  110210. expandTexture = true;
  110211. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  110212. }
  110213. // Expand the texture if possible
  110214. if (expandTexture) {
  110215. // Simply run through the decode PP
  110216. 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);
  110217. texture._isRGBD = false;
  110218. texture.invertY = false;
  110219. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  110220. generateDepthBuffer: false,
  110221. generateMipMaps: true,
  110222. generateStencilBuffer: false,
  110223. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  110224. type: texture.type,
  110225. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  110226. });
  110227. }
  110228. else {
  110229. texture._isRGBD = true;
  110230. texture.invertY = true;
  110231. // In case of missing support, applies the same patch than DDS files.
  110232. if (generateNonLODTextures) {
  110233. var mipSlices = 3;
  110234. var scale = texture._lodGenerationScale;
  110235. var offset = texture._lodGenerationOffset;
  110236. for (var i = 0; i < mipSlices; i++) {
  110237. //compute LOD from even spacing in smoothness (matching shader calculation)
  110238. var smoothness = i / (mipSlices - 1);
  110239. var roughness = 1 - smoothness;
  110240. var minLODIndex = offset; // roughness = 0
  110241. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  110242. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  110243. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  110244. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  110245. glTextureFromLod.isCube = true;
  110246. glTextureFromLod.invertY = true;
  110247. glTextureFromLod.generateMipMaps = false;
  110248. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  110249. // Wrap in a base texture for easy binding.
  110250. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  110251. lodTexture.isCube = true;
  110252. lodTexture._texture = glTextureFromLod;
  110253. lodTextures[mipmapIndex] = lodTexture;
  110254. switch (i) {
  110255. case 0:
  110256. texture._lodTextureLow = lodTexture;
  110257. break;
  110258. case 1:
  110259. texture._lodTextureMid = lodTexture;
  110260. break;
  110261. case 2:
  110262. texture._lodTextureHigh = lodTexture;
  110263. break;
  110264. }
  110265. }
  110266. }
  110267. }
  110268. var promises = [];
  110269. var _loop_3 = function (i) {
  110270. var _loop_4 = function (face) {
  110271. // Constructs an image element from image data
  110272. var bytes = imageData[i][face];
  110273. var blob = new Blob([bytes], { type: 'image/png' });
  110274. var url = URL.createObjectURL(blob);
  110275. var image = new Image();
  110276. image.src = url;
  110277. // Enqueue promise to upload to the texture.
  110278. var promise = new Promise(function (resolve, reject) {
  110279. image.onload = function () {
  110280. if (expandTexture) {
  110281. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  110282. reject(message);
  110283. }, image);
  110284. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  110285. // Uncompress the data to a RTT
  110286. rgbdPostProcess.onApply = function (effect) {
  110287. effect._bindTexture("textureSampler", tempTexture_1);
  110288. effect.setFloat2("scale", 1, 1);
  110289. };
  110290. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  110291. // Cleanup
  110292. engine.restoreDefaultFramebuffer();
  110293. tempTexture_1.dispose();
  110294. window.URL.revokeObjectURL(url);
  110295. resolve();
  110296. });
  110297. }
  110298. else {
  110299. engine._uploadImageToTexture(texture, image, face, i);
  110300. // Upload the face to the non lod texture support
  110301. if (generateNonLODTextures) {
  110302. var lodTexture = lodTextures[i];
  110303. if (lodTexture) {
  110304. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  110305. }
  110306. }
  110307. resolve();
  110308. }
  110309. };
  110310. image.onerror = function (error) {
  110311. reject(error);
  110312. };
  110313. });
  110314. promises.push(promise);
  110315. };
  110316. // All faces
  110317. for (var face = 0; face < 6; face++) {
  110318. _loop_4(face);
  110319. }
  110320. };
  110321. // All mipmaps up to provided number of images
  110322. for (var i = 0; i < imageData.length; i++) {
  110323. _loop_3(i);
  110324. }
  110325. // Fill remaining mipmaps with black textures.
  110326. if (imageData.length < mipmapsCount) {
  110327. var data = void 0;
  110328. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  110329. var dataLength = size * size * 4;
  110330. switch (texture.type) {
  110331. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  110332. data = new Uint8Array(dataLength);
  110333. break;
  110334. }
  110335. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  110336. data = new Uint16Array(dataLength);
  110337. break;
  110338. }
  110339. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  110340. data = new Float32Array(dataLength);
  110341. break;
  110342. }
  110343. }
  110344. for (var i = imageData.length; i < mipmapsCount; i++) {
  110345. for (var face = 0; face < 6; face++) {
  110346. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  110347. }
  110348. }
  110349. }
  110350. // Once all done, finishes the cleanup and return
  110351. return Promise.all(promises).then(function () {
  110352. // Release temp RTT.
  110353. if (cubeRtt) {
  110354. engine._releaseFramebufferObjects(cubeRtt);
  110355. engine._releaseTexture(texture);
  110356. cubeRtt._swapAndDie(texture);
  110357. }
  110358. // Release temp Post Process.
  110359. if (rgbdPostProcess) {
  110360. rgbdPostProcess.dispose();
  110361. }
  110362. // Flag internal texture as ready in case they are in use.
  110363. if (generateNonLODTextures) {
  110364. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  110365. texture._lodTextureHigh._texture.isReady = true;
  110366. }
  110367. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  110368. texture._lodTextureMid._texture.isReady = true;
  110369. }
  110370. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  110371. texture._lodTextureLow._texture.isReady = true;
  110372. }
  110373. }
  110374. });
  110375. };
  110376. /**
  110377. * Uploads spherical polynomials information to the texture.
  110378. * @param texture defines the texture we are trying to upload the information to
  110379. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  110380. */
  110381. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  110382. if (info.version !== 1) {
  110383. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  110384. }
  110385. var irradianceInfo = info.irradiance;
  110386. if (!irradianceInfo) {
  110387. return;
  110388. }
  110389. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  110390. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  110391. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  110392. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  110393. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  110394. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  110395. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  110396. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  110397. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  110398. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  110399. texture._sphericalPolynomial = sp;
  110400. };
  110401. /** @hidden */
  110402. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  110403. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  110404. internalTexture._bufferViewArrayArray = data;
  110405. internalTexture._lodGenerationScale = lodScale;
  110406. internalTexture._lodGenerationOffset = lodOffset;
  110407. internalTexture._sphericalPolynomial = sphericalPolynomial;
  110408. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  110409. internalTexture.isReady = true;
  110410. });
  110411. };
  110412. /**
  110413. * Magic number identifying the env file.
  110414. */
  110415. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  110416. return EnvironmentTextureTools;
  110417. }());
  110418. // References the dependencies.
  110419. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  110420. /***/ }),
  110421. /***/ "./Misc/fileTools.ts":
  110422. /*!***************************!*\
  110423. !*** ./Misc/fileTools.ts ***!
  110424. \***************************/
  110425. /*! exports provided: FileTools */
  110426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110427. "use strict";
  110428. __webpack_require__.r(__webpack_exports__);
  110429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FileTools", function() { return FileTools; });
  110430. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  110431. /* harmony import */ var _loadFileError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./loadFileError */ "./Misc/loadFileError.ts");
  110432. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  110433. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  110434. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  110435. /* harmony import */ var _retryStrategy__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./retryStrategy */ "./Misc/retryStrategy.ts");
  110436. /**
  110437. * @hidden
  110438. */
  110439. var FileTools = /** @class */ (function () {
  110440. function FileTools() {
  110441. }
  110442. /**
  110443. * Removes unwanted characters from an url
  110444. * @param url defines the url to clean
  110445. * @returns the cleaned url
  110446. */
  110447. FileTools._CleanUrl = function (url) {
  110448. url = url.replace(/#/mg, "%23");
  110449. return url;
  110450. };
  110451. /**
  110452. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110453. * @param url define the url we are trying
  110454. * @param element define the dom element where to configure the cors policy
  110455. */
  110456. FileTools.SetCorsBehavior = function (url, element) {
  110457. if (url && url.indexOf("data:") === 0) {
  110458. return;
  110459. }
  110460. if (this.CorsBehavior) {
  110461. if (typeof (this.CorsBehavior) === 'string' || this.CorsBehavior instanceof String) {
  110462. element.crossOrigin = this.CorsBehavior;
  110463. }
  110464. else {
  110465. var result = this.CorsBehavior(url);
  110466. if (result) {
  110467. element.crossOrigin = result;
  110468. }
  110469. }
  110470. }
  110471. };
  110472. /**
  110473. * Loads an image as an HTMLImageElement.
  110474. * @param input url string, ArrayBuffer, or Blob to load
  110475. * @param onLoad callback called when the image successfully loads
  110476. * @param onError callback called when the image fails to load
  110477. * @param offlineProvider offline provider for caching
  110478. * @returns the HTMLImageElement of the loaded image
  110479. */
  110480. FileTools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  110481. var url;
  110482. var usingObjectURL = false;
  110483. if (input instanceof ArrayBuffer) {
  110484. url = URL.createObjectURL(new Blob([input]));
  110485. usingObjectURL = true;
  110486. }
  110487. else if (input instanceof Blob) {
  110488. url = URL.createObjectURL(input);
  110489. usingObjectURL = true;
  110490. }
  110491. else {
  110492. url = this._CleanUrl(input);
  110493. url = this.PreprocessUrl(input);
  110494. }
  110495. var img = new Image();
  110496. this.SetCorsBehavior(url, img);
  110497. var loadHandler = function () {
  110498. img.removeEventListener("load", loadHandler);
  110499. img.removeEventListener("error", errorHandler);
  110500. onLoad(img);
  110501. // Must revoke the URL after calling onLoad to avoid security exceptions in
  110502. // certain scenarios (e.g. when hosted in vscode).
  110503. if (usingObjectURL && img.src) {
  110504. URL.revokeObjectURL(img.src);
  110505. }
  110506. };
  110507. var errorHandler = function (err) {
  110508. img.removeEventListener("load", loadHandler);
  110509. img.removeEventListener("error", errorHandler);
  110510. if (onError) {
  110511. onError("Error while trying to load image: " + input, err);
  110512. }
  110513. if (usingObjectURL && img.src) {
  110514. URL.revokeObjectURL(img.src);
  110515. }
  110516. };
  110517. img.addEventListener("load", loadHandler);
  110518. img.addEventListener("error", errorHandler);
  110519. var noOfflineSupport = function () {
  110520. img.src = url;
  110521. };
  110522. var loadFromOfflineSupport = function () {
  110523. if (offlineProvider) {
  110524. offlineProvider.loadImage(url, img);
  110525. }
  110526. };
  110527. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  110528. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  110529. }
  110530. else {
  110531. if (url.indexOf("file:") !== -1) {
  110532. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  110533. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  110534. try {
  110535. var blobURL;
  110536. try {
  110537. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  110538. }
  110539. catch (ex) {
  110540. // Chrome doesn't support oneTimeOnly parameter
  110541. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  110542. }
  110543. img.src = blobURL;
  110544. usingObjectURL = true;
  110545. }
  110546. catch (e) {
  110547. img.src = "";
  110548. }
  110549. return img;
  110550. }
  110551. }
  110552. noOfflineSupport();
  110553. }
  110554. return img;
  110555. };
  110556. /**
  110557. * Loads a file
  110558. * @param fileToLoad defines the file to load
  110559. * @param callback defines the callback to call when data is loaded
  110560. * @param progressCallBack defines the callback to call during loading process
  110561. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110562. * @returns a file request object
  110563. */
  110564. FileTools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  110565. var reader = new FileReader();
  110566. var request = {
  110567. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  110568. abort: function () { return reader.abort(); },
  110569. };
  110570. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  110571. reader.onerror = function (e) {
  110572. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  110573. };
  110574. reader.onload = function (e) {
  110575. //target doesn't have result from ts 1.3
  110576. callback(e.target['result']);
  110577. };
  110578. if (progressCallBack) {
  110579. reader.onprogress = progressCallBack;
  110580. }
  110581. if (!useArrayBuffer) {
  110582. // Asynchronous read
  110583. reader.readAsText(fileToLoad);
  110584. }
  110585. else {
  110586. reader.readAsArrayBuffer(fileToLoad);
  110587. }
  110588. return request;
  110589. };
  110590. /**
  110591. * Loads a file
  110592. * @param url url string, ArrayBuffer, or Blob to load
  110593. * @param onSuccess callback called when the file successfully loads
  110594. * @param onProgress callback called while file is loading (if the server supports this mode)
  110595. * @param offlineProvider defines the offline provider for caching
  110596. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110597. * @param onError callback called when the file fails to load
  110598. * @returns a file request object
  110599. */
  110600. FileTools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  110601. var _this = this;
  110602. url = this._CleanUrl(url);
  110603. url = this.PreprocessUrl(url);
  110604. // If file and file input are set
  110605. if (url.indexOf("file:") !== -1) {
  110606. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  110607. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  110608. return this.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  110609. }
  110610. }
  110611. var loadUrl = this.BaseUrl + url;
  110612. var aborted = false;
  110613. var fileRequest = {
  110614. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  110615. abort: function () { return aborted = true; },
  110616. };
  110617. var requestFile = function () {
  110618. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]();
  110619. var retryHandle = null;
  110620. fileRequest.abort = function () {
  110621. aborted = true;
  110622. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  110623. request.abort();
  110624. }
  110625. if (retryHandle !== null) {
  110626. clearTimeout(retryHandle);
  110627. retryHandle = null;
  110628. }
  110629. };
  110630. var retryLoop = function (retryIndex) {
  110631. request.open('GET', loadUrl);
  110632. if (useArrayBuffer) {
  110633. request.responseType = "arraybuffer";
  110634. }
  110635. if (onProgress) {
  110636. request.addEventListener("progress", onProgress);
  110637. }
  110638. var onLoadEnd = function () {
  110639. request.removeEventListener("loadend", onLoadEnd);
  110640. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  110641. fileRequest.onCompleteObservable.clear();
  110642. };
  110643. request.addEventListener("loadend", onLoadEnd);
  110644. var onReadyStateChange = function () {
  110645. if (aborted) {
  110646. return;
  110647. }
  110648. // In case of undefined state in some browsers.
  110649. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  110650. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  110651. request.removeEventListener("readystatechange", onReadyStateChange);
  110652. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist() || _this.IsFileURL()))) {
  110653. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  110654. return;
  110655. }
  110656. var retryStrategy = _this.DefaultRetryStrategy;
  110657. if (retryStrategy) {
  110658. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  110659. if (waitTime !== -1) {
  110660. // Prevent the request from completing for retry.
  110661. request.removeEventListener("loadend", onLoadEnd);
  110662. request = new _webRequest__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]();
  110663. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  110664. return;
  110665. }
  110666. }
  110667. var e = new _loadFileError__WEBPACK_IMPORTED_MODULE_1__["LoadFileError"]("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  110668. if (onError) {
  110669. onError(request, e);
  110670. }
  110671. else {
  110672. throw e;
  110673. }
  110674. }
  110675. };
  110676. request.addEventListener("readystatechange", onReadyStateChange);
  110677. request.send();
  110678. };
  110679. retryLoop(0);
  110680. };
  110681. // Caching all files
  110682. if (offlineProvider && offlineProvider.enableSceneOffline) {
  110683. var noOfflineSupport_1 = function (request) {
  110684. if (request && request.status > 400) {
  110685. if (onError) {
  110686. onError(request);
  110687. }
  110688. }
  110689. else {
  110690. if (!aborted) {
  110691. requestFile();
  110692. }
  110693. }
  110694. };
  110695. var loadFromOfflineSupport = function () {
  110696. // TODO: database needs to support aborting and should return a IFileRequest
  110697. if (aborted) {
  110698. return;
  110699. }
  110700. if (offlineProvider) {
  110701. offlineProvider.loadFile(url, function (data) {
  110702. if (!aborted) {
  110703. onSuccess(data);
  110704. }
  110705. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  110706. }, onProgress ? function (event) {
  110707. if (!aborted) {
  110708. onProgress(event);
  110709. }
  110710. } : undefined, noOfflineSupport_1, useArrayBuffer);
  110711. }
  110712. };
  110713. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  110714. }
  110715. else {
  110716. requestFile();
  110717. }
  110718. return fileRequest;
  110719. };
  110720. /**
  110721. * Checks if the loaded document was accessed via `file:`-Protocol.
  110722. * @returns boolean
  110723. */
  110724. FileTools.IsFileURL = function () {
  110725. return location.protocol === "file:";
  110726. };
  110727. /**
  110728. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110729. */
  110730. FileTools.DefaultRetryStrategy = _retryStrategy__WEBPACK_IMPORTED_MODULE_5__["RetryStrategy"].ExponentialBackoff();
  110731. /**
  110732. * Gets or sets the base URL to use to load assets
  110733. */
  110734. FileTools.BaseUrl = "";
  110735. /**
  110736. * Default behaviour for cors in the application.
  110737. * It can be a string if the expected behavior is identical in the entire app.
  110738. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110739. */
  110740. FileTools.CorsBehavior = "anonymous";
  110741. /**
  110742. * Gets or sets a function used to pre-process url before using them to load assets
  110743. */
  110744. FileTools.PreprocessUrl = function (url) {
  110745. return url;
  110746. };
  110747. return FileTools;
  110748. }());
  110749. /***/ }),
  110750. /***/ "./Misc/filesInput.ts":
  110751. /*!****************************!*\
  110752. !*** ./Misc/filesInput.ts ***!
  110753. \****************************/
  110754. /*! exports provided: FilesInput */
  110755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110756. "use strict";
  110757. __webpack_require__.r(__webpack_exports__);
  110758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  110759. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  110760. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110761. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  110762. /**
  110763. * Class used to help managing file picking and drag'n'drop
  110764. */
  110765. var FilesInput = /** @class */ (function () {
  110766. /**
  110767. * Creates a new FilesInput
  110768. * @param engine defines the rendering engine
  110769. * @param scene defines the hosting scene
  110770. * @param sceneLoadedCallback callback called when scene is loaded
  110771. * @param progressCallback callback called to track progress
  110772. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110773. * @param textureLoadingCallback callback called when a texture is loading
  110774. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110775. * @param onReloadCallback callback called when a reload is requested
  110776. * @param errorCallback callback call if an error occurs
  110777. */
  110778. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  110779. /**
  110780. * Callback called when a file is processed
  110781. */
  110782. this.onProcessFileCallback = function () { return true; };
  110783. this._engine = engine;
  110784. this._currentScene = scene;
  110785. this._sceneLoadedCallback = sceneLoadedCallback;
  110786. this._progressCallback = progressCallback;
  110787. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  110788. this._textureLoadingCallback = textureLoadingCallback;
  110789. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  110790. this._onReloadCallback = onReloadCallback;
  110791. this._errorCallback = errorCallback;
  110792. }
  110793. Object.defineProperty(FilesInput, "FilesToLoad", {
  110794. /**
  110795. * List of files ready to be loaded
  110796. */
  110797. get: function () {
  110798. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  110799. },
  110800. enumerable: true,
  110801. configurable: true
  110802. });
  110803. /**
  110804. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110805. * @param elementToMonitor defines the DOM element to track
  110806. */
  110807. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  110808. var _this = this;
  110809. if (elementToMonitor) {
  110810. this._elementToMonitor = elementToMonitor;
  110811. this._dragEnterHandler = function (e) { _this.drag(e); };
  110812. this._dragOverHandler = function (e) { _this.drag(e); };
  110813. this._dropHandler = function (e) { _this.drop(e); };
  110814. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  110815. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  110816. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  110817. }
  110818. };
  110819. /**
  110820. * Release all associated resources
  110821. */
  110822. FilesInput.prototype.dispose = function () {
  110823. if (!this._elementToMonitor) {
  110824. return;
  110825. }
  110826. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  110827. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  110828. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  110829. };
  110830. FilesInput.prototype.renderFunction = function () {
  110831. if (this._additionalRenderLoopLogicCallback) {
  110832. this._additionalRenderLoopLogicCallback();
  110833. }
  110834. if (this._currentScene) {
  110835. if (this._textureLoadingCallback) {
  110836. var remaining = this._currentScene.getWaitingItemsCount();
  110837. if (remaining > 0) {
  110838. this._textureLoadingCallback(remaining);
  110839. }
  110840. }
  110841. this._currentScene.render();
  110842. }
  110843. };
  110844. FilesInput.prototype.drag = function (e) {
  110845. e.stopPropagation();
  110846. e.preventDefault();
  110847. };
  110848. FilesInput.prototype.drop = function (eventDrop) {
  110849. eventDrop.stopPropagation();
  110850. eventDrop.preventDefault();
  110851. this.loadFiles(eventDrop);
  110852. };
  110853. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  110854. var _this = this;
  110855. var reader = folder.createReader();
  110856. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  110857. reader.readEntries(function (entries) {
  110858. remaining.count += entries.length;
  110859. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  110860. var entry = entries_1[_i];
  110861. if (entry.isFile) {
  110862. entry.file(function (file) {
  110863. file.correctName = relativePath + file.name;
  110864. files.push(file);
  110865. if (--remaining.count === 0) {
  110866. callback();
  110867. }
  110868. });
  110869. }
  110870. else if (entry.isDirectory) {
  110871. _this._traverseFolder(entry, files, remaining, callback);
  110872. }
  110873. }
  110874. if (--remaining.count) {
  110875. callback();
  110876. }
  110877. });
  110878. };
  110879. FilesInput.prototype._processFiles = function (files) {
  110880. for (var i = 0; i < files.length; i++) {
  110881. var name = files[i].correctName.toLowerCase();
  110882. var extension = name.split('.').pop();
  110883. if (!this.onProcessFileCallback(files[i], name, extension)) {
  110884. continue;
  110885. }
  110886. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  110887. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  110888. this._sceneFileToLoad = files[i];
  110889. }
  110890. FilesInput.FilesToLoad[name] = files[i];
  110891. }
  110892. };
  110893. /**
  110894. * Load files from a drop event
  110895. * @param event defines the drop event to use as source
  110896. */
  110897. FilesInput.prototype.loadFiles = function (event) {
  110898. var _this = this;
  110899. // Handling data transfer via drag'n'drop
  110900. if (event && event.dataTransfer && event.dataTransfer.files) {
  110901. this._filesToLoad = event.dataTransfer.files;
  110902. }
  110903. // Handling files from input files
  110904. if (event && event.target && event.target.files) {
  110905. this._filesToLoad = event.target.files;
  110906. }
  110907. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  110908. return;
  110909. }
  110910. if (this._startingProcessingFilesCallback) {
  110911. this._startingProcessingFilesCallback(this._filesToLoad);
  110912. }
  110913. if (this._filesToLoad && this._filesToLoad.length > 0) {
  110914. var files_1 = new Array();
  110915. var folders = [];
  110916. var items = event.dataTransfer ? event.dataTransfer.items : null;
  110917. for (var i = 0; i < this._filesToLoad.length; i++) {
  110918. var fileToLoad = this._filesToLoad[i];
  110919. var name_1 = fileToLoad.name.toLowerCase();
  110920. var entry = void 0;
  110921. fileToLoad.correctName = name_1;
  110922. if (items) {
  110923. var item = items[i];
  110924. if (item.getAsEntry) {
  110925. entry = item.getAsEntry();
  110926. }
  110927. else if (item.webkitGetAsEntry) {
  110928. entry = item.webkitGetAsEntry();
  110929. }
  110930. }
  110931. if (!entry) {
  110932. files_1.push(fileToLoad);
  110933. }
  110934. else {
  110935. if (entry.isDirectory) {
  110936. folders.push(entry);
  110937. }
  110938. else {
  110939. files_1.push(fileToLoad);
  110940. }
  110941. }
  110942. }
  110943. if (folders.length === 0) {
  110944. this._processFiles(files_1);
  110945. this._processReload();
  110946. }
  110947. else {
  110948. var remaining = { count: folders.length };
  110949. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  110950. var folder = folders_1[_i];
  110951. this._traverseFolder(folder, files_1, remaining, function () {
  110952. _this._processFiles(files_1);
  110953. if (remaining.count === 0) {
  110954. _this._processReload();
  110955. }
  110956. });
  110957. }
  110958. }
  110959. }
  110960. };
  110961. FilesInput.prototype._processReload = function () {
  110962. if (this._onReloadCallback) {
  110963. this._onReloadCallback(this._sceneFileToLoad);
  110964. }
  110965. else {
  110966. this.reload();
  110967. }
  110968. };
  110969. /**
  110970. * Reload the current scene from the loaded files
  110971. */
  110972. FilesInput.prototype.reload = function () {
  110973. var _this = this;
  110974. // If a scene file has been provided
  110975. if (this._sceneFileToLoad) {
  110976. if (this._currentScene) {
  110977. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  110978. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  110979. }
  110980. this._engine.stopRenderLoop();
  110981. }
  110982. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  110983. if (_this._progressCallback) {
  110984. _this._progressCallback(progress);
  110985. }
  110986. }).then(function (scene) {
  110987. if (_this._currentScene) {
  110988. _this._currentScene.dispose();
  110989. }
  110990. _this._currentScene = scene;
  110991. if (_this._sceneLoadedCallback) {
  110992. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  110993. }
  110994. // Wait for textures and shaders to be ready
  110995. _this._currentScene.executeWhenReady(function () {
  110996. _this._engine.runRenderLoop(function () {
  110997. _this.renderFunction();
  110998. });
  110999. });
  111000. }).catch(function (error) {
  111001. if (_this._errorCallback) {
  111002. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  111003. }
  111004. });
  111005. }
  111006. else {
  111007. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  111008. }
  111009. };
  111010. return FilesInput;
  111011. }());
  111012. /***/ }),
  111013. /***/ "./Misc/filesInputStore.ts":
  111014. /*!*********************************!*\
  111015. !*** ./Misc/filesInputStore.ts ***!
  111016. \*********************************/
  111017. /*! exports provided: FilesInputStore */
  111018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111019. "use strict";
  111020. __webpack_require__.r(__webpack_exports__);
  111021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  111022. /**
  111023. * Class used to help managing file picking and drag'n'drop
  111024. * File Storage
  111025. */
  111026. var FilesInputStore = /** @class */ (function () {
  111027. function FilesInputStore() {
  111028. }
  111029. /**
  111030. * List of files ready to be loaded
  111031. */
  111032. FilesInputStore.FilesToLoad = {};
  111033. return FilesInputStore;
  111034. }());
  111035. /***/ }),
  111036. /***/ "./Misc/gradients.ts":
  111037. /*!***************************!*\
  111038. !*** ./Misc/gradients.ts ***!
  111039. \***************************/
  111040. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, GradientHelper */
  111041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111042. "use strict";
  111043. __webpack_require__.r(__webpack_exports__);
  111044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  111045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  111046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  111047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GradientHelper", function() { return GradientHelper; });
  111048. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  111049. /** Class used to store color4 gradient */
  111050. var ColorGradient = /** @class */ (function () {
  111051. function ColorGradient() {
  111052. }
  111053. /**
  111054. * Will get a color picked randomly between color1 and color2.
  111055. * If color2 is undefined then color1 will be used
  111056. * @param result defines the target Color4 to store the result in
  111057. */
  111058. ColorGradient.prototype.getColorToRef = function (result) {
  111059. if (!this.color2) {
  111060. result.copyFrom(this.color1);
  111061. return;
  111062. }
  111063. _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  111064. };
  111065. return ColorGradient;
  111066. }());
  111067. /** Class used to store color 3 gradient */
  111068. var Color3Gradient = /** @class */ (function () {
  111069. function Color3Gradient() {
  111070. }
  111071. return Color3Gradient;
  111072. }());
  111073. /** Class used to store factor gradient */
  111074. var FactorGradient = /** @class */ (function () {
  111075. function FactorGradient() {
  111076. }
  111077. /**
  111078. * Will get a number picked randomly between factor1 and factor2.
  111079. * If factor2 is undefined then factor1 will be used
  111080. * @returns the picked number
  111081. */
  111082. FactorGradient.prototype.getFactor = function () {
  111083. if (this.factor2 === undefined) {
  111084. return this.factor1;
  111085. }
  111086. return this.factor1 + ((this.factor2 - this.factor1) * Math.random());
  111087. };
  111088. return FactorGradient;
  111089. }());
  111090. /**
  111091. * Helper used to simplify some generic gradient tasks
  111092. */
  111093. var GradientHelper = /** @class */ (function () {
  111094. function GradientHelper() {
  111095. }
  111096. /**
  111097. * Gets the current gradient from an array of IValueGradient
  111098. * @param ratio defines the current ratio to get
  111099. * @param gradients defines the array of IValueGradient
  111100. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  111101. */
  111102. GradientHelper.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  111103. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  111104. var currentGradient = gradients[gradientIndex];
  111105. var nextGradient = gradients[gradientIndex + 1];
  111106. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  111107. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  111108. updateFunc(currentGradient, nextGradient, scale);
  111109. return;
  111110. }
  111111. }
  111112. // Use last index if over
  111113. var lastIndex = gradients.length - 1;
  111114. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  111115. };
  111116. return GradientHelper;
  111117. }());
  111118. /***/ }),
  111119. /***/ "./Misc/guid.ts":
  111120. /*!**********************!*\
  111121. !*** ./Misc/guid.ts ***!
  111122. \**********************/
  111123. /*! exports provided: GUID */
  111124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111125. "use strict";
  111126. __webpack_require__.r(__webpack_exports__);
  111127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUID", function() { return GUID; });
  111128. /**
  111129. * Class used to manipulate GUIDs
  111130. */
  111131. var GUID = /** @class */ (function () {
  111132. function GUID() {
  111133. }
  111134. /**
  111135. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111136. * Be aware Math.random() could cause collisions, but:
  111137. * "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"
  111138. * @returns a pseudo random id
  111139. */
  111140. GUID.RandomId = function () {
  111141. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  111142. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  111143. return v.toString(16);
  111144. });
  111145. };
  111146. return GUID;
  111147. }());
  111148. /***/ }),
  111149. /***/ "./Misc/iInspectable.ts":
  111150. /*!******************************!*\
  111151. !*** ./Misc/iInspectable.ts ***!
  111152. \******************************/
  111153. /*! exports provided: InspectableType */
  111154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111155. "use strict";
  111156. __webpack_require__.r(__webpack_exports__);
  111157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  111158. /**
  111159. * Enum that determines the text-wrapping mode to use.
  111160. */
  111161. var InspectableType;
  111162. (function (InspectableType) {
  111163. /**
  111164. * Checkbox for booleans
  111165. */
  111166. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  111167. /**
  111168. * Sliders for numbers
  111169. */
  111170. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  111171. /**
  111172. * Vector3
  111173. */
  111174. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  111175. /**
  111176. * Quaternions
  111177. */
  111178. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  111179. /**
  111180. * Color3
  111181. */
  111182. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  111183. /**
  111184. * String
  111185. */
  111186. InspectableType[InspectableType["String"] = 5] = "String";
  111187. })(InspectableType || (InspectableType = {}));
  111188. /***/ }),
  111189. /***/ "./Misc/index.ts":
  111190. /*!***********************!*\
  111191. !*** ./Misc/index.ts ***!
  111192. \***********************/
  111193. /*! 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, CubeMapToSphericalPolynomialTools, 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, Tools, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, BRDFTextureTools, ColorGradient, Color3Gradient, FactorGradient, GradientHelper, PerfCounter, RetryStrategy, LoadFileError, HDRTools, PanoramaToCubeMapTools */
  111194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111195. "use strict";
  111196. __webpack_require__.r(__webpack_exports__);
  111197. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  111198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  111199. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  111200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  111201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  111202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  111203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  111204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  111205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  111206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  111207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  111208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  111209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  111210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["EquiRectangularCubeTextureAssetTask"]; });
  111211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  111212. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  111213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  111214. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  111215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  111216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  111217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  111218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  111219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  111220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  111221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  111222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  111223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  111224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  111225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  111226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  111227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  111228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  111229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  111230. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  111231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  111232. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  111233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  111234. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  111235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  111236. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  111237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  111238. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  111239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  111240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  111241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  111242. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  111243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  111244. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  111245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  111246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  111247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  111248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  111249. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  111250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  111251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  111252. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  111253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  111254. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  111255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  111256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  111257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  111258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  111259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  111260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  111261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  111262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  111263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  111264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  111265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  111266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  111267. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  111268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  111269. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  111270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  111271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  111272. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  111273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  111274. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  111275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  111276. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  111277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  111278. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  111279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  111280. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  111281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  111282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  111283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  111284. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  111285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  111286. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  111287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  111288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  111289. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  111290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  111291. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  111292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  111293. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  111294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  111295. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  111296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  111297. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  111298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  111299. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  111300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  111301. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  111302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  111303. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  111304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  111305. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  111306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  111307. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  111308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  111309. /* harmony import */ var _brdfTextureTools__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  111310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return _brdfTextureTools__WEBPACK_IMPORTED_MODULE_33__["BRDFTextureTools"]; });
  111311. /* harmony import */ var _gradients__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./gradients */ "./Misc/gradients.ts");
  111312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _gradients__WEBPACK_IMPORTED_MODULE_34__["ColorGradient"]; });
  111313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _gradients__WEBPACK_IMPORTED_MODULE_34__["Color3Gradient"]; });
  111314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _gradients__WEBPACK_IMPORTED_MODULE_34__["FactorGradient"]; });
  111315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GradientHelper", function() { return _gradients__WEBPACK_IMPORTED_MODULE_34__["GradientHelper"]; });
  111316. /* harmony import */ var _perfCounter__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./perfCounter */ "./Misc/perfCounter.ts");
  111317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _perfCounter__WEBPACK_IMPORTED_MODULE_35__["PerfCounter"]; });
  111318. /* harmony import */ var _retryStrategy__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./retryStrategy */ "./Misc/retryStrategy.ts");
  111319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _retryStrategy__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  111320. /* harmony import */ var _loadFileError__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./loadFileError */ "./Misc/loadFileError.ts");
  111321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _loadFileError__WEBPACK_IMPORTED_MODULE_37__["LoadFileError"]; });
  111322. /***/ }),
  111323. /***/ "./Misc/instantiationTools.ts":
  111324. /*!************************************!*\
  111325. !*** ./Misc/instantiationTools.ts ***!
  111326. \************************************/
  111327. /*! exports provided: InstantiationTools */
  111328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111329. "use strict";
  111330. __webpack_require__.r(__webpack_exports__);
  111331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstantiationTools", function() { return InstantiationTools; });
  111332. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  111333. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  111334. /**
  111335. * Class used to enable instatition of objects by class name
  111336. */
  111337. var InstantiationTools = /** @class */ (function () {
  111338. function InstantiationTools() {
  111339. }
  111340. /**
  111341. * Tries to instantiate a new object from a given class name
  111342. * @param className defines the class name to instantiate
  111343. * @returns the new object or null if the system was not able to do the instantiation
  111344. */
  111345. InstantiationTools.Instantiate = function (className) {
  111346. if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[className]) {
  111347. return this.RegisteredExternalClasses[className];
  111348. }
  111349. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].GetClass(className);
  111350. if (internalClass) {
  111351. return internalClass;
  111352. }
  111353. _logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn(className + " not found, you may have missed an import.");
  111354. var arr = className.split(".");
  111355. var fn = (window || this);
  111356. for (var i = 0, len = arr.length; i < len; i++) {
  111357. fn = fn[arr[i]];
  111358. }
  111359. if (typeof fn !== "function") {
  111360. return null;
  111361. }
  111362. return fn;
  111363. };
  111364. /**
  111365. * Use this object to register external classes like custom textures or material
  111366. * to allow the laoders to instantiate them
  111367. */
  111368. InstantiationTools.RegisteredExternalClasses = {};
  111369. return InstantiationTools;
  111370. }());
  111371. /***/ }),
  111372. /***/ "./Misc/khronosTextureContainer.ts":
  111373. /*!*****************************************!*\
  111374. !*** ./Misc/khronosTextureContainer.ts ***!
  111375. \*****************************************/
  111376. /*! exports provided: KhronosTextureContainer */
  111377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111378. "use strict";
  111379. __webpack_require__.r(__webpack_exports__);
  111380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  111381. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111382. /**
  111383. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111384. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111385. */
  111386. var KhronosTextureContainer = /** @class */ (function () {
  111387. /**
  111388. * Creates a new KhronosTextureContainer
  111389. * @param arrayBuffer contents of the KTX container file
  111390. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111391. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111392. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111393. */
  111394. function KhronosTextureContainer(
  111395. /** contents of the KTX container file */
  111396. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  111397. this.arrayBuffer = arrayBuffer;
  111398. /**
  111399. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111400. */
  111401. this.isInvalid = false;
  111402. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  111403. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  111404. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  111405. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  111406. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  111407. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  111408. this.isInvalid = true;
  111409. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  111410. return;
  111411. }
  111412. // load the reset of the header in native 32 bit uint
  111413. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  111414. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  111415. var endianness = headerDataView.getUint32(0, true);
  111416. var littleEndian = endianness === 0x04030201;
  111417. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  111418. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  111419. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  111420. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  111421. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  111422. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  111423. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  111424. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  111425. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  111426. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  111427. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  111428. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  111429. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  111430. if (this.glType !== 0) {
  111431. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  111432. return;
  111433. }
  111434. else {
  111435. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  111436. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  111437. }
  111438. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  111439. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  111440. return;
  111441. }
  111442. if (this.numberOfArrayElements !== 0) {
  111443. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  111444. return;
  111445. }
  111446. if (this.numberOfFaces !== facesExpected) {
  111447. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  111448. return;
  111449. }
  111450. // we now have a completely validated file, so could use existence of loadType as success
  111451. // would need to make this more elaborate & adjust checks above to support more than one load type
  111452. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  111453. }
  111454. /**
  111455. * Uploads KTX content to a Babylon Texture.
  111456. * It is assumed that the texture has already been created & is currently bound
  111457. * @hidden
  111458. */
  111459. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  111460. switch (this.loadType) {
  111461. case KhronosTextureContainer.COMPRESSED_2D:
  111462. this._upload2DCompressedLevels(texture, loadMipmaps);
  111463. break;
  111464. case KhronosTextureContainer.TEX_2D:
  111465. case KhronosTextureContainer.COMPRESSED_3D:
  111466. case KhronosTextureContainer.TEX_3D:
  111467. }
  111468. };
  111469. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  111470. // initialize width & height for level 1
  111471. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  111472. var width = this.pixelWidth;
  111473. var height = this.pixelHeight;
  111474. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  111475. for (var level = 0; level < mipmapCount; level++) {
  111476. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  111477. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  111478. for (var face = 0; face < this.numberOfFaces; face++) {
  111479. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  111480. var engine = texture.getEngine();
  111481. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  111482. dataOffset += imageSize; // add size of the image for the next face/mipmap
  111483. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  111484. }
  111485. width = Math.max(1.0, width * 0.5);
  111486. height = Math.max(1.0, height * 0.5);
  111487. }
  111488. };
  111489. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  111490. // load types
  111491. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  111492. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  111493. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  111494. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  111495. return KhronosTextureContainer;
  111496. }());
  111497. /***/ }),
  111498. /***/ "./Misc/loadFileError.ts":
  111499. /*!*******************************!*\
  111500. !*** ./Misc/loadFileError.ts ***!
  111501. \*******************************/
  111502. /*! exports provided: LoadFileError */
  111503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111504. "use strict";
  111505. __webpack_require__.r(__webpack_exports__);
  111506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  111507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  111508. /**
  111509. * @ignore
  111510. * Application error to support additional information when loading a file
  111511. */
  111512. var LoadFileError = /** @class */ (function (_super) {
  111513. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  111514. /**
  111515. * Creates a new LoadFileError
  111516. * @param message defines the message of the error
  111517. * @param request defines the optional web request
  111518. */
  111519. function LoadFileError(message,
  111520. /** defines the optional web request */
  111521. request) {
  111522. var _this = _super.call(this, message) || this;
  111523. _this.request = request;
  111524. _this.name = "LoadFileError";
  111525. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  111526. return _this;
  111527. }
  111528. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  111529. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  111530. // Polyfill for Object.setPrototypeOf if necessary.
  111531. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  111532. return LoadFileError;
  111533. }(Error));
  111534. /***/ }),
  111535. /***/ "./Misc/logger.ts":
  111536. /*!************************!*\
  111537. !*** ./Misc/logger.ts ***!
  111538. \************************/
  111539. /*! exports provided: Logger */
  111540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111541. "use strict";
  111542. __webpack_require__.r(__webpack_exports__);
  111543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  111544. /**
  111545. * Logger used througouht the application to allow configuration of
  111546. * the log level required for the messages.
  111547. */
  111548. var Logger = /** @class */ (function () {
  111549. function Logger() {
  111550. }
  111551. Logger._AddLogEntry = function (entry) {
  111552. Logger._LogCache = entry + Logger._LogCache;
  111553. if (Logger.OnNewCacheEntry) {
  111554. Logger.OnNewCacheEntry(entry);
  111555. }
  111556. };
  111557. Logger._FormatMessage = function (message) {
  111558. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  111559. var date = new Date();
  111560. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  111561. };
  111562. Logger._LogDisabled = function (message) {
  111563. // nothing to do
  111564. };
  111565. Logger._LogEnabled = function (message) {
  111566. var formattedMessage = Logger._FormatMessage(message);
  111567. console.log("BJS - " + formattedMessage);
  111568. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  111569. Logger._AddLogEntry(entry);
  111570. };
  111571. Logger._WarnDisabled = function (message) {
  111572. // nothing to do
  111573. };
  111574. Logger._WarnEnabled = function (message) {
  111575. var formattedMessage = Logger._FormatMessage(message);
  111576. console.warn("BJS - " + formattedMessage);
  111577. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  111578. Logger._AddLogEntry(entry);
  111579. };
  111580. Logger._ErrorDisabled = function (message) {
  111581. // nothing to do
  111582. };
  111583. Logger._ErrorEnabled = function (message) {
  111584. Logger.errorsCount++;
  111585. var formattedMessage = Logger._FormatMessage(message);
  111586. console.error("BJS - " + formattedMessage);
  111587. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  111588. Logger._AddLogEntry(entry);
  111589. };
  111590. Object.defineProperty(Logger, "LogCache", {
  111591. /**
  111592. * Gets current log cache (list of logs)
  111593. */
  111594. get: function () {
  111595. return Logger._LogCache;
  111596. },
  111597. enumerable: true,
  111598. configurable: true
  111599. });
  111600. /**
  111601. * Clears the log cache
  111602. */
  111603. Logger.ClearLogCache = function () {
  111604. Logger._LogCache = "";
  111605. Logger.errorsCount = 0;
  111606. };
  111607. Object.defineProperty(Logger, "LogLevels", {
  111608. /**
  111609. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  111610. */
  111611. set: function (level) {
  111612. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  111613. Logger.Log = Logger._LogEnabled;
  111614. }
  111615. else {
  111616. Logger.Log = Logger._LogDisabled;
  111617. }
  111618. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  111619. Logger.Warn = Logger._WarnEnabled;
  111620. }
  111621. else {
  111622. Logger.Warn = Logger._WarnDisabled;
  111623. }
  111624. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  111625. Logger.Error = Logger._ErrorEnabled;
  111626. }
  111627. else {
  111628. Logger.Error = Logger._ErrorDisabled;
  111629. }
  111630. },
  111631. enumerable: true,
  111632. configurable: true
  111633. });
  111634. /**
  111635. * No log
  111636. */
  111637. Logger.NoneLogLevel = 0;
  111638. /**
  111639. * Only message logs
  111640. */
  111641. Logger.MessageLogLevel = 1;
  111642. /**
  111643. * Only warning logs
  111644. */
  111645. Logger.WarningLogLevel = 2;
  111646. /**
  111647. * Only error logs
  111648. */
  111649. Logger.ErrorLogLevel = 4;
  111650. /**
  111651. * All logs
  111652. */
  111653. Logger.AllLogLevel = 7;
  111654. Logger._LogCache = "";
  111655. /**
  111656. * Gets a value indicating the number of loading errors
  111657. * @ignorenaming
  111658. */
  111659. Logger.errorsCount = 0;
  111660. /**
  111661. * Log a message to the console
  111662. */
  111663. Logger.Log = Logger._LogEnabled;
  111664. /**
  111665. * Write a warning message to the console
  111666. */
  111667. Logger.Warn = Logger._WarnEnabled;
  111668. /**
  111669. * Write an error message to the console
  111670. */
  111671. Logger.Error = Logger._ErrorEnabled;
  111672. return Logger;
  111673. }());
  111674. /***/ }),
  111675. /***/ "./Misc/meshExploder.ts":
  111676. /*!******************************!*\
  111677. !*** ./Misc/meshExploder.ts ***!
  111678. \******************************/
  111679. /*! exports provided: MeshExploder */
  111680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111681. "use strict";
  111682. __webpack_require__.r(__webpack_exports__);
  111683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  111684. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  111685. /**
  111686. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  111687. */
  111688. var MeshExploder = /** @class */ (function () {
  111689. /**
  111690. * Explodes meshes from a center mesh.
  111691. * @param meshes The meshes to explode.
  111692. * @param centerMesh The mesh to be center of explosion.
  111693. */
  111694. function MeshExploder(meshes, centerMesh) {
  111695. this._meshesOrigins = [];
  111696. this._toCenterVectors = [];
  111697. this._scaledDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111698. this._newPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111699. this._centerPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111700. this._meshes = meshes.slice();
  111701. if (centerMesh) {
  111702. this._centerMesh = centerMesh;
  111703. }
  111704. else {
  111705. this._setCenterMesh();
  111706. }
  111707. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  111708. if (centerMeshIndex >= 0) {
  111709. this._meshes.splice(centerMeshIndex, 1);
  111710. }
  111711. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  111712. for (var index = 0; index < this._meshes.length; index++) {
  111713. if (this._meshes[index]) {
  111714. var mesh = this._meshes[index];
  111715. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  111716. this._toCenterVectors[index] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111717. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  111718. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  111719. }
  111720. }
  111721. }
  111722. }
  111723. MeshExploder.prototype._setCenterMesh = function () {
  111724. var averageCenter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111725. var totalCenters = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111726. var shortestToCenter = Number.MAX_VALUE;
  111727. for (var index = 0; index < this._meshes.length; index++) {
  111728. if (this._meshes[index]) {
  111729. var mesh = this._meshes[index];
  111730. var boundingInfo = mesh.getBoundingInfo();
  111731. if (boundingInfo) {
  111732. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  111733. }
  111734. }
  111735. }
  111736. averageCenter = totalCenters.scale(1 / this._meshes.length);
  111737. for (var index = 0; index < this._meshes.length; index++) {
  111738. if (this._meshes[index]) {
  111739. var mesh = this._meshes[index];
  111740. var boundingInfo = mesh.getBoundingInfo();
  111741. if (boundingInfo) {
  111742. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  111743. if (distanceToCenter < shortestToCenter) {
  111744. this._centerMesh = mesh;
  111745. shortestToCenter = distanceToCenter;
  111746. }
  111747. }
  111748. }
  111749. }
  111750. };
  111751. /**
  111752. * Get class name
  111753. * @returns "MeshExploder"
  111754. */
  111755. MeshExploder.prototype.getClassName = function () {
  111756. return "MeshExploder";
  111757. };
  111758. /**
  111759. * "Exploded meshes"
  111760. * @returns Array of meshes with the centerMesh at index 0.
  111761. */
  111762. MeshExploder.prototype.getMeshes = function () {
  111763. var meshArray = this._meshes.slice();
  111764. meshArray.unshift(this._centerMesh);
  111765. return meshArray;
  111766. };
  111767. /**
  111768. * Explodes meshes giving a specific direction
  111769. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  111770. */
  111771. MeshExploder.prototype.explode = function (direction) {
  111772. if (direction === void 0) { direction = 1.0; }
  111773. for (var index = 0; index < this._meshes.length; index++) {
  111774. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  111775. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  111776. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  111777. this._meshes[index].setAbsolutePosition(this._newPosition);
  111778. }
  111779. }
  111780. this._centerMesh.setAbsolutePosition(this._centerPosition);
  111781. };
  111782. return MeshExploder;
  111783. }());
  111784. /***/ }),
  111785. /***/ "./Misc/observable.ts":
  111786. /*!****************************!*\
  111787. !*** ./Misc/observable.ts ***!
  111788. \****************************/
  111789. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  111790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111791. "use strict";
  111792. __webpack_require__.r(__webpack_exports__);
  111793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  111794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  111795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  111796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  111797. /**
  111798. * A class serves as a medium between the observable and its observers
  111799. */
  111800. var EventState = /** @class */ (function () {
  111801. /**
  111802. * Create a new EventState
  111803. * @param mask defines the mask associated with this state
  111804. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  111805. * @param target defines the original target of the state
  111806. * @param currentTarget defines the current target of the state
  111807. */
  111808. function EventState(mask, skipNextObservers, target, currentTarget) {
  111809. if (skipNextObservers === void 0) { skipNextObservers = false; }
  111810. this.initalize(mask, skipNextObservers, target, currentTarget);
  111811. }
  111812. /**
  111813. * Initialize the current event state
  111814. * @param mask defines the mask associated with this state
  111815. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  111816. * @param target defines the original target of the state
  111817. * @param currentTarget defines the current target of the state
  111818. * @returns the current event state
  111819. */
  111820. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  111821. if (skipNextObservers === void 0) { skipNextObservers = false; }
  111822. this.mask = mask;
  111823. this.skipNextObservers = skipNextObservers;
  111824. this.target = target;
  111825. this.currentTarget = currentTarget;
  111826. return this;
  111827. };
  111828. return EventState;
  111829. }());
  111830. /**
  111831. * Represent an Observer registered to a given Observable object.
  111832. */
  111833. var Observer = /** @class */ (function () {
  111834. /**
  111835. * Creates a new observer
  111836. * @param callback defines the callback to call when the observer is notified
  111837. * @param mask defines the mask of the observer (used to filter notifications)
  111838. * @param scope defines the current scope used to restore the JS context
  111839. */
  111840. function Observer(
  111841. /**
  111842. * Defines the callback to call when the observer is notified
  111843. */
  111844. callback,
  111845. /**
  111846. * Defines the mask of the observer (used to filter notifications)
  111847. */
  111848. mask,
  111849. /**
  111850. * Defines the current scope used to restore the JS context
  111851. */
  111852. scope) {
  111853. if (scope === void 0) { scope = null; }
  111854. this.callback = callback;
  111855. this.mask = mask;
  111856. this.scope = scope;
  111857. /** @hidden */
  111858. this._willBeUnregistered = false;
  111859. /**
  111860. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  111861. */
  111862. this.unregisterOnNextCall = false;
  111863. }
  111864. return Observer;
  111865. }());
  111866. /**
  111867. * Represent a list of observers registered to multiple Observables object.
  111868. */
  111869. var MultiObserver = /** @class */ (function () {
  111870. function MultiObserver() {
  111871. }
  111872. /**
  111873. * Release associated resources
  111874. */
  111875. MultiObserver.prototype.dispose = function () {
  111876. if (this._observers && this._observables) {
  111877. for (var index = 0; index < this._observers.length; index++) {
  111878. this._observables[index].remove(this._observers[index]);
  111879. }
  111880. }
  111881. this._observers = null;
  111882. this._observables = null;
  111883. };
  111884. /**
  111885. * Raise a callback when one of the observable will notify
  111886. * @param observables defines a list of observables to watch
  111887. * @param callback defines the callback to call on notification
  111888. * @param mask defines the mask used to filter notifications
  111889. * @param scope defines the current scope used to restore the JS context
  111890. * @returns the new MultiObserver
  111891. */
  111892. MultiObserver.Watch = function (observables, callback, mask, scope) {
  111893. if (mask === void 0) { mask = -1; }
  111894. if (scope === void 0) { scope = null; }
  111895. var result = new MultiObserver();
  111896. result._observers = new Array();
  111897. result._observables = observables;
  111898. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  111899. var observable = observables_1[_i];
  111900. var observer = observable.add(callback, mask, false, scope);
  111901. if (observer) {
  111902. result._observers.push(observer);
  111903. }
  111904. }
  111905. return result;
  111906. };
  111907. return MultiObserver;
  111908. }());
  111909. /**
  111910. * The Observable class is a simple implementation of the Observable pattern.
  111911. *
  111912. * 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.
  111913. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  111914. * 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).
  111915. * 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.
  111916. */
  111917. var Observable = /** @class */ (function () {
  111918. /**
  111919. * Creates a new observable
  111920. * @param onObserverAdded defines a callback to call when a new observer is added
  111921. */
  111922. function Observable(onObserverAdded) {
  111923. this._observers = new Array();
  111924. this._eventState = new EventState(0);
  111925. if (onObserverAdded) {
  111926. this._onObserverAdded = onObserverAdded;
  111927. }
  111928. }
  111929. Object.defineProperty(Observable.prototype, "observers", {
  111930. /**
  111931. * Gets the list of observers
  111932. */
  111933. get: function () {
  111934. return this._observers;
  111935. },
  111936. enumerable: true,
  111937. configurable: true
  111938. });
  111939. /**
  111940. * Create a new Observer with the specified callback
  111941. * @param callback the callback that will be executed for that Observer
  111942. * @param mask the mask used to filter observers
  111943. * @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.
  111944. * @param scope optional scope for the callback to be called from
  111945. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  111946. * @returns the new observer created for the callback
  111947. */
  111948. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  111949. if (mask === void 0) { mask = -1; }
  111950. if (insertFirst === void 0) { insertFirst = false; }
  111951. if (scope === void 0) { scope = null; }
  111952. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  111953. if (!callback) {
  111954. return null;
  111955. }
  111956. var observer = new Observer(callback, mask, scope);
  111957. observer.unregisterOnNextCall = unregisterOnFirstCall;
  111958. if (insertFirst) {
  111959. this._observers.unshift(observer);
  111960. }
  111961. else {
  111962. this._observers.push(observer);
  111963. }
  111964. if (this._onObserverAdded) {
  111965. this._onObserverAdded(observer);
  111966. }
  111967. return observer;
  111968. };
  111969. /**
  111970. * Create a new Observer with the specified callback and unregisters after the next notification
  111971. * @param callback the callback that will be executed for that Observer
  111972. * @returns the new observer created for the callback
  111973. */
  111974. Observable.prototype.addOnce = function (callback) {
  111975. return this.add(callback, undefined, undefined, undefined, true);
  111976. };
  111977. /**
  111978. * Remove an Observer from the Observable object
  111979. * @param observer the instance of the Observer to remove
  111980. * @returns false if it doesn't belong to this Observable
  111981. */
  111982. Observable.prototype.remove = function (observer) {
  111983. if (!observer) {
  111984. return false;
  111985. }
  111986. var index = this._observers.indexOf(observer);
  111987. if (index !== -1) {
  111988. this._deferUnregister(observer);
  111989. return true;
  111990. }
  111991. return false;
  111992. };
  111993. /**
  111994. * Remove a callback from the Observable object
  111995. * @param callback the callback to remove
  111996. * @param scope optional scope. If used only the callbacks with this scope will be removed
  111997. * @returns false if it doesn't belong to this Observable
  111998. */
  111999. Observable.prototype.removeCallback = function (callback, scope) {
  112000. for (var index = 0; index < this._observers.length; index++) {
  112001. var observer = this._observers[index];
  112002. if (observer._willBeUnregistered) {
  112003. continue;
  112004. }
  112005. if (observer.callback === callback && (!scope || scope === observer.scope)) {
  112006. this._deferUnregister(observer);
  112007. return true;
  112008. }
  112009. }
  112010. return false;
  112011. };
  112012. Observable.prototype._deferUnregister = function (observer) {
  112013. var _this = this;
  112014. observer.unregisterOnNextCall = false;
  112015. observer._willBeUnregistered = true;
  112016. setTimeout(function () {
  112017. _this._remove(observer);
  112018. }, 0);
  112019. };
  112020. // This should only be called when not iterating over _observers to avoid callback skipping.
  112021. // Removes an observer from the _observer Array.
  112022. Observable.prototype._remove = function (observer) {
  112023. if (!observer) {
  112024. return false;
  112025. }
  112026. var index = this._observers.indexOf(observer);
  112027. if (index !== -1) {
  112028. this._observers.splice(index, 1);
  112029. return true;
  112030. }
  112031. return false;
  112032. };
  112033. /**
  112034. * Moves the observable to the top of the observer list making it get called first when notified
  112035. * @param observer the observer to move
  112036. */
  112037. Observable.prototype.makeObserverTopPriority = function (observer) {
  112038. this._remove(observer);
  112039. this._observers.unshift(observer);
  112040. };
  112041. /**
  112042. * Moves the observable to the bottom of the observer list making it get called last when notified
  112043. * @param observer the observer to move
  112044. */
  112045. Observable.prototype.makeObserverBottomPriority = function (observer) {
  112046. this._remove(observer);
  112047. this._observers.push(observer);
  112048. };
  112049. /**
  112050. * Notify all Observers by calling their respective callback with the given data
  112051. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  112052. * @param eventData defines the data to send to all observers
  112053. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  112054. * @param target defines the original target of the state
  112055. * @param currentTarget defines the current target of the state
  112056. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  112057. */
  112058. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  112059. if (mask === void 0) { mask = -1; }
  112060. if (!this._observers.length) {
  112061. return true;
  112062. }
  112063. var state = this._eventState;
  112064. state.mask = mask;
  112065. state.target = target;
  112066. state.currentTarget = currentTarget;
  112067. state.skipNextObservers = false;
  112068. state.lastReturnValue = eventData;
  112069. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  112070. var obs = _a[_i];
  112071. if (obs._willBeUnregistered) {
  112072. continue;
  112073. }
  112074. if (obs.mask & mask) {
  112075. if (obs.scope) {
  112076. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  112077. }
  112078. else {
  112079. state.lastReturnValue = obs.callback(eventData, state);
  112080. }
  112081. if (obs.unregisterOnNextCall) {
  112082. this._deferUnregister(obs);
  112083. }
  112084. }
  112085. if (state.skipNextObservers) {
  112086. return false;
  112087. }
  112088. }
  112089. return true;
  112090. };
  112091. /**
  112092. * Calling this will execute each callback, expecting it to be a promise or return a value.
  112093. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  112094. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  112095. * and it is crucial that all callbacks will be executed.
  112096. * The order of the callbacks is kept, callbacks are not executed parallel.
  112097. *
  112098. * @param eventData The data to be sent to each callback
  112099. * @param mask is used to filter observers defaults to -1
  112100. * @param target defines the callback target (see EventState)
  112101. * @param currentTarget defines he current object in the bubbling phase
  112102. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  112103. */
  112104. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  112105. var _this = this;
  112106. if (mask === void 0) { mask = -1; }
  112107. // create an empty promise
  112108. var p = Promise.resolve(eventData);
  112109. // no observers? return this promise.
  112110. if (!this._observers.length) {
  112111. return p;
  112112. }
  112113. var state = this._eventState;
  112114. state.mask = mask;
  112115. state.target = target;
  112116. state.currentTarget = currentTarget;
  112117. state.skipNextObservers = false;
  112118. // execute one callback after another (not using Promise.all, the order is important)
  112119. this._observers.forEach(function (obs) {
  112120. if (state.skipNextObservers) {
  112121. return;
  112122. }
  112123. if (obs._willBeUnregistered) {
  112124. return;
  112125. }
  112126. if (obs.mask & mask) {
  112127. if (obs.scope) {
  112128. p = p.then(function (lastReturnedValue) {
  112129. state.lastReturnValue = lastReturnedValue;
  112130. return obs.callback.apply(obs.scope, [eventData, state]);
  112131. });
  112132. }
  112133. else {
  112134. p = p.then(function (lastReturnedValue) {
  112135. state.lastReturnValue = lastReturnedValue;
  112136. return obs.callback(eventData, state);
  112137. });
  112138. }
  112139. if (obs.unregisterOnNextCall) {
  112140. _this._deferUnregister(obs);
  112141. }
  112142. }
  112143. });
  112144. // return the eventData
  112145. return p.then(function () { return eventData; });
  112146. };
  112147. /**
  112148. * Notify a specific observer
  112149. * @param observer defines the observer to notify
  112150. * @param eventData defines the data to be sent to each callback
  112151. * @param mask is used to filter observers defaults to -1
  112152. */
  112153. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  112154. if (mask === void 0) { mask = -1; }
  112155. var state = this._eventState;
  112156. state.mask = mask;
  112157. state.skipNextObservers = false;
  112158. observer.callback(eventData, state);
  112159. };
  112160. /**
  112161. * Gets a boolean indicating if the observable has at least one observer
  112162. * @returns true is the Observable has at least one Observer registered
  112163. */
  112164. Observable.prototype.hasObservers = function () {
  112165. return this._observers.length > 0;
  112166. };
  112167. /**
  112168. * Clear the list of observers
  112169. */
  112170. Observable.prototype.clear = function () {
  112171. this._observers = new Array();
  112172. this._onObserverAdded = null;
  112173. };
  112174. /**
  112175. * Clone the current observable
  112176. * @returns a new observable
  112177. */
  112178. Observable.prototype.clone = function () {
  112179. var result = new Observable();
  112180. result._observers = this._observers.slice(0);
  112181. return result;
  112182. };
  112183. /**
  112184. * Does this observable handles observer registered with a given mask
  112185. * @param mask defines the mask to be tested
  112186. * @return whether or not one observer registered with the given mask is handeled
  112187. **/
  112188. Observable.prototype.hasSpecificMask = function (mask) {
  112189. if (mask === void 0) { mask = -1; }
  112190. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  112191. var obs = _a[_i];
  112192. if (obs.mask & mask || obs.mask === mask) {
  112193. return true;
  112194. }
  112195. }
  112196. return false;
  112197. };
  112198. return Observable;
  112199. }());
  112200. /***/ }),
  112201. /***/ "./Misc/perfCounter.ts":
  112202. /*!*****************************!*\
  112203. !*** ./Misc/perfCounter.ts ***!
  112204. \*****************************/
  112205. /*! exports provided: PerfCounter */
  112206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112207. "use strict";
  112208. __webpack_require__.r(__webpack_exports__);
  112209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  112210. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  112211. /**
  112212. * This class is used to track a performance counter which is number based.
  112213. * The user has access to many properties which give statistics of different nature.
  112214. *
  112215. * The implementer can track two kinds of Performance Counter: time and count.
  112216. * 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.
  112217. * 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.
  112218. */
  112219. var PerfCounter = /** @class */ (function () {
  112220. /**
  112221. * Creates a new counter
  112222. */
  112223. function PerfCounter() {
  112224. this._startMonitoringTime = 0;
  112225. this._min = 0;
  112226. this._max = 0;
  112227. this._average = 0;
  112228. this._lastSecAverage = 0;
  112229. this._current = 0;
  112230. this._totalValueCount = 0;
  112231. this._totalAccumulated = 0;
  112232. this._lastSecAccumulated = 0;
  112233. this._lastSecTime = 0;
  112234. this._lastSecValueCount = 0;
  112235. }
  112236. Object.defineProperty(PerfCounter.prototype, "min", {
  112237. /**
  112238. * Returns the smallest value ever
  112239. */
  112240. get: function () {
  112241. return this._min;
  112242. },
  112243. enumerable: true,
  112244. configurable: true
  112245. });
  112246. Object.defineProperty(PerfCounter.prototype, "max", {
  112247. /**
  112248. * Returns the biggest value ever
  112249. */
  112250. get: function () {
  112251. return this._max;
  112252. },
  112253. enumerable: true,
  112254. configurable: true
  112255. });
  112256. Object.defineProperty(PerfCounter.prototype, "average", {
  112257. /**
  112258. * Returns the average value since the performance counter is running
  112259. */
  112260. get: function () {
  112261. return this._average;
  112262. },
  112263. enumerable: true,
  112264. configurable: true
  112265. });
  112266. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  112267. /**
  112268. * Returns the average value of the last second the counter was monitored
  112269. */
  112270. get: function () {
  112271. return this._lastSecAverage;
  112272. },
  112273. enumerable: true,
  112274. configurable: true
  112275. });
  112276. Object.defineProperty(PerfCounter.prototype, "current", {
  112277. /**
  112278. * Returns the current value
  112279. */
  112280. get: function () {
  112281. return this._current;
  112282. },
  112283. enumerable: true,
  112284. configurable: true
  112285. });
  112286. Object.defineProperty(PerfCounter.prototype, "total", {
  112287. /**
  112288. * Gets the accumulated total
  112289. */
  112290. get: function () {
  112291. return this._totalAccumulated;
  112292. },
  112293. enumerable: true,
  112294. configurable: true
  112295. });
  112296. Object.defineProperty(PerfCounter.prototype, "count", {
  112297. /**
  112298. * Gets the total value count
  112299. */
  112300. get: function () {
  112301. return this._totalValueCount;
  112302. },
  112303. enumerable: true,
  112304. configurable: true
  112305. });
  112306. /**
  112307. * Call this method to start monitoring a new frame.
  112308. * 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.
  112309. */
  112310. PerfCounter.prototype.fetchNewFrame = function () {
  112311. this._totalValueCount++;
  112312. this._current = 0;
  112313. this._lastSecValueCount++;
  112314. };
  112315. /**
  112316. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  112317. * @param newCount the count value to add to the monitored count
  112318. * @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.
  112319. */
  112320. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  112321. if (!PerfCounter.Enabled) {
  112322. return;
  112323. }
  112324. this._current += newCount;
  112325. if (fetchResult) {
  112326. this._fetchResult();
  112327. }
  112328. };
  112329. /**
  112330. * Start monitoring this performance counter
  112331. */
  112332. PerfCounter.prototype.beginMonitoring = function () {
  112333. if (!PerfCounter.Enabled) {
  112334. return;
  112335. }
  112336. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now;
  112337. };
  112338. /**
  112339. * Compute the time lapsed since the previous beginMonitoring() call.
  112340. * @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
  112341. */
  112342. PerfCounter.prototype.endMonitoring = function (newFrame) {
  112343. if (newFrame === void 0) { newFrame = true; }
  112344. if (!PerfCounter.Enabled) {
  112345. return;
  112346. }
  112347. if (newFrame) {
  112348. this.fetchNewFrame();
  112349. }
  112350. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now;
  112351. this._current = currentTime - this._startMonitoringTime;
  112352. if (newFrame) {
  112353. this._fetchResult();
  112354. }
  112355. };
  112356. PerfCounter.prototype._fetchResult = function () {
  112357. this._totalAccumulated += this._current;
  112358. this._lastSecAccumulated += this._current;
  112359. // Min/Max update
  112360. this._min = Math.min(this._min, this._current);
  112361. this._max = Math.max(this._max, this._current);
  112362. this._average = this._totalAccumulated / this._totalValueCount;
  112363. // Reset last sec?
  112364. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now;
  112365. if ((now - this._lastSecTime) > 1000) {
  112366. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  112367. this._lastSecTime = now;
  112368. this._lastSecAccumulated = 0;
  112369. this._lastSecValueCount = 0;
  112370. }
  112371. };
  112372. /**
  112373. * Gets or sets a global boolean to turn on and off all the counters
  112374. */
  112375. PerfCounter.Enabled = true;
  112376. return PerfCounter;
  112377. }());
  112378. /***/ }),
  112379. /***/ "./Misc/performanceMonitor.ts":
  112380. /*!************************************!*\
  112381. !*** ./Misc/performanceMonitor.ts ***!
  112382. \************************************/
  112383. /*! exports provided: PerformanceMonitor, RollingAverage */
  112384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112385. "use strict";
  112386. __webpack_require__.r(__webpack_exports__);
  112387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  112388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  112389. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  112390. /**
  112391. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  112392. */
  112393. var PerformanceMonitor = /** @class */ (function () {
  112394. /**
  112395. * constructor
  112396. * @param frameSampleSize The number of samples required to saturate the sliding window
  112397. */
  112398. function PerformanceMonitor(frameSampleSize) {
  112399. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  112400. this._enabled = true;
  112401. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  112402. }
  112403. /**
  112404. * Samples current frame
  112405. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  112406. */
  112407. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  112408. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  112409. if (!this._enabled) {
  112410. return;
  112411. }
  112412. if (this._lastFrameTimeMs != null) {
  112413. var dt = timeMs - this._lastFrameTimeMs;
  112414. this._rollingFrameTime.add(dt);
  112415. }
  112416. this._lastFrameTimeMs = timeMs;
  112417. };
  112418. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  112419. /**
  112420. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  112421. */
  112422. get: function () {
  112423. return this._rollingFrameTime.average;
  112424. },
  112425. enumerable: true,
  112426. configurable: true
  112427. });
  112428. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  112429. /**
  112430. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  112431. */
  112432. get: function () {
  112433. return this._rollingFrameTime.variance;
  112434. },
  112435. enumerable: true,
  112436. configurable: true
  112437. });
  112438. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  112439. /**
  112440. * Returns the frame time of the most recent frame
  112441. */
  112442. get: function () {
  112443. return this._rollingFrameTime.history(0);
  112444. },
  112445. enumerable: true,
  112446. configurable: true
  112447. });
  112448. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  112449. /**
  112450. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  112451. */
  112452. get: function () {
  112453. return 1000.0 / this._rollingFrameTime.average;
  112454. },
  112455. enumerable: true,
  112456. configurable: true
  112457. });
  112458. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  112459. /**
  112460. * Returns the average framerate in frames per second using the most recent frame time
  112461. */
  112462. get: function () {
  112463. var history = this._rollingFrameTime.history(0);
  112464. if (history === 0) {
  112465. return 0;
  112466. }
  112467. return 1000.0 / history;
  112468. },
  112469. enumerable: true,
  112470. configurable: true
  112471. });
  112472. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  112473. /**
  112474. * Returns true if enough samples have been taken to completely fill the sliding window
  112475. */
  112476. get: function () {
  112477. return this._rollingFrameTime.isSaturated();
  112478. },
  112479. enumerable: true,
  112480. configurable: true
  112481. });
  112482. /**
  112483. * Enables contributions to the sliding window sample set
  112484. */
  112485. PerformanceMonitor.prototype.enable = function () {
  112486. this._enabled = true;
  112487. };
  112488. /**
  112489. * Disables contributions to the sliding window sample set
  112490. * Samples will not be interpolated over the disabled period
  112491. */
  112492. PerformanceMonitor.prototype.disable = function () {
  112493. this._enabled = false;
  112494. //clear last sample to avoid interpolating over the disabled period when next enabled
  112495. this._lastFrameTimeMs = null;
  112496. };
  112497. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  112498. /**
  112499. * Returns true if sampling is enabled
  112500. */
  112501. get: function () {
  112502. return this._enabled;
  112503. },
  112504. enumerable: true,
  112505. configurable: true
  112506. });
  112507. /**
  112508. * Resets performance monitor
  112509. */
  112510. PerformanceMonitor.prototype.reset = function () {
  112511. //clear last sample to avoid interpolating over the disabled period when next enabled
  112512. this._lastFrameTimeMs = null;
  112513. //wipe record
  112514. this._rollingFrameTime.reset();
  112515. };
  112516. return PerformanceMonitor;
  112517. }());
  112518. /**
  112519. * RollingAverage
  112520. *
  112521. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  112522. */
  112523. var RollingAverage = /** @class */ (function () {
  112524. /**
  112525. * constructor
  112526. * @param length The number of samples required to saturate the sliding window
  112527. */
  112528. function RollingAverage(length) {
  112529. this._samples = new Array(length);
  112530. this.reset();
  112531. }
  112532. /**
  112533. * Adds a sample to the sample set
  112534. * @param v The sample value
  112535. */
  112536. RollingAverage.prototype.add = function (v) {
  112537. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  112538. var delta;
  112539. //we need to check if we've already wrapped round
  112540. if (this.isSaturated()) {
  112541. //remove bottom of stack from mean
  112542. var bottomValue = this._samples[this._pos];
  112543. delta = bottomValue - this.average;
  112544. this.average -= delta / (this._sampleCount - 1);
  112545. this._m2 -= delta * (bottomValue - this.average);
  112546. }
  112547. else {
  112548. this._sampleCount++;
  112549. }
  112550. //add new value to mean
  112551. delta = v - this.average;
  112552. this.average += delta / (this._sampleCount);
  112553. this._m2 += delta * (v - this.average);
  112554. //set the new variance
  112555. this.variance = this._m2 / (this._sampleCount - 1);
  112556. this._samples[this._pos] = v;
  112557. this._pos++;
  112558. this._pos %= this._samples.length; //positive wrap around
  112559. };
  112560. /**
  112561. * Returns previously added values or null if outside of history or outside the sliding window domain
  112562. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  112563. * @return Value previously recorded with add() or null if outside of range
  112564. */
  112565. RollingAverage.prototype.history = function (i) {
  112566. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  112567. return 0;
  112568. }
  112569. var i0 = this._wrapPosition(this._pos - 1.0);
  112570. return this._samples[this._wrapPosition(i0 - i)];
  112571. };
  112572. /**
  112573. * Returns true if enough samples have been taken to completely fill the sliding window
  112574. * @return true if sample-set saturated
  112575. */
  112576. RollingAverage.prototype.isSaturated = function () {
  112577. return this._sampleCount >= this._samples.length;
  112578. };
  112579. /**
  112580. * Resets the rolling average (equivalent to 0 samples taken so far)
  112581. */
  112582. RollingAverage.prototype.reset = function () {
  112583. this.average = 0;
  112584. this.variance = 0;
  112585. this._sampleCount = 0;
  112586. this._pos = 0;
  112587. this._m2 = 0;
  112588. };
  112589. /**
  112590. * Wraps a value around the sample range boundaries
  112591. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  112592. * @return Wrapped position in sample range
  112593. */
  112594. RollingAverage.prototype._wrapPosition = function (i) {
  112595. var max = this._samples.length;
  112596. return ((i % max) + max) % max;
  112597. };
  112598. return RollingAverage;
  112599. }());
  112600. /***/ }),
  112601. /***/ "./Misc/pivotTools.ts":
  112602. /*!****************************!*\
  112603. !*** ./Misc/pivotTools.ts ***!
  112604. \****************************/
  112605. /*! exports provided: PivotTools */
  112606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112607. "use strict";
  112608. __webpack_require__.r(__webpack_exports__);
  112609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  112610. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  112611. /**
  112612. * Class containing a set of static utilities functions for managing Pivots
  112613. * @hidden
  112614. */
  112615. var PivotTools = /** @class */ (function () {
  112616. function PivotTools() {
  112617. }
  112618. /** @hidden */
  112619. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  112620. if (mesh && PivotTools._PivotCached === 0) {
  112621. // Save old pivot and set pivot to 0,0,0
  112622. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  112623. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  112624. mesh.setPivotMatrix(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  112625. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  112626. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  112627. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  112628. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  112629. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  112630. }
  112631. }
  112632. PivotTools._PivotCached++;
  112633. };
  112634. /** @hidden */
  112635. PivotTools._RestorePivotPoint = function (mesh) {
  112636. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  112637. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  112638. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  112639. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  112640. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  112641. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  112642. }
  112643. this._PivotCached--;
  112644. };
  112645. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  112646. // store/remove pivot point should only be applied during their outermost calls
  112647. PivotTools._PivotCached = 0;
  112648. PivotTools._OldPivotPoint = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112649. PivotTools._PivotTranslation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112650. PivotTools._PivotTmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112651. return PivotTools;
  112652. }());
  112653. /***/ }),
  112654. /***/ "./Misc/precisionDate.ts":
  112655. /*!*******************************!*\
  112656. !*** ./Misc/precisionDate.ts ***!
  112657. \*******************************/
  112658. /*! exports provided: PrecisionDate */
  112659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112660. "use strict";
  112661. __webpack_require__.r(__webpack_exports__);
  112662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  112663. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  112664. /**
  112665. * Class containing a set of static utilities functions for precision date
  112666. */
  112667. var PrecisionDate = /** @class */ (function () {
  112668. function PrecisionDate() {
  112669. }
  112670. Object.defineProperty(PrecisionDate, "Now", {
  112671. /**
  112672. * Gets either window.performance.now() if supported or Date.now() else
  112673. */
  112674. get: function () {
  112675. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  112676. return window.performance.now();
  112677. }
  112678. return Date.now();
  112679. },
  112680. enumerable: true,
  112681. configurable: true
  112682. });
  112683. return PrecisionDate;
  112684. }());
  112685. /***/ }),
  112686. /***/ "./Misc/promise.ts":
  112687. /*!*************************!*\
  112688. !*** ./Misc/promise.ts ***!
  112689. \*************************/
  112690. /*! exports provided: PromisePolyfill */
  112691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112692. "use strict";
  112693. __webpack_require__.r(__webpack_exports__);
  112694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  112695. var PromiseStates;
  112696. (function (PromiseStates) {
  112697. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  112698. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  112699. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  112700. })(PromiseStates || (PromiseStates = {}));
  112701. var FulFillmentAgregator = /** @class */ (function () {
  112702. function FulFillmentAgregator() {
  112703. this.count = 0;
  112704. this.target = 0;
  112705. this.results = [];
  112706. }
  112707. return FulFillmentAgregator;
  112708. }());
  112709. var InternalPromise = /** @class */ (function () {
  112710. function InternalPromise(resolver) {
  112711. var _this = this;
  112712. this._state = PromiseStates.Pending;
  112713. this._children = new Array();
  112714. this._rejectWasConsumed = false;
  112715. if (!resolver) {
  112716. return;
  112717. }
  112718. try {
  112719. resolver(function (value) {
  112720. _this._resolve(value);
  112721. }, function (reason) {
  112722. _this._reject(reason);
  112723. });
  112724. }
  112725. catch (e) {
  112726. this._reject(e);
  112727. }
  112728. }
  112729. Object.defineProperty(InternalPromise.prototype, "_result", {
  112730. get: function () {
  112731. return this._resultValue;
  112732. },
  112733. set: function (value) {
  112734. this._resultValue = value;
  112735. if (this._parent && this._parent._result === undefined) {
  112736. this._parent._result = value;
  112737. }
  112738. },
  112739. enumerable: true,
  112740. configurable: true
  112741. });
  112742. InternalPromise.prototype.catch = function (onRejected) {
  112743. return this.then(undefined, onRejected);
  112744. };
  112745. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  112746. var _this = this;
  112747. var newPromise = new InternalPromise();
  112748. newPromise._onFulfilled = onFulfilled;
  112749. newPromise._onRejected = onRejected;
  112750. // Composition
  112751. this._children.push(newPromise);
  112752. newPromise._parent = this;
  112753. if (this._state !== PromiseStates.Pending) {
  112754. setTimeout(function () {
  112755. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  112756. var returnedValue = newPromise._resolve(_this._result);
  112757. if (returnedValue !== undefined && returnedValue !== null) {
  112758. if (returnedValue._state !== undefined) {
  112759. var returnedPromise = returnedValue;
  112760. newPromise._children.push(returnedPromise);
  112761. returnedPromise._parent = newPromise;
  112762. newPromise = returnedPromise;
  112763. }
  112764. else {
  112765. newPromise._result = returnedValue;
  112766. }
  112767. }
  112768. }
  112769. else {
  112770. newPromise._reject(_this._reason);
  112771. }
  112772. });
  112773. }
  112774. return newPromise;
  112775. };
  112776. InternalPromise.prototype._moveChildren = function (children) {
  112777. var _a;
  112778. var _this = this;
  112779. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  112780. this._children.forEach(function (child) {
  112781. child._parent = _this;
  112782. });
  112783. if (this._state === PromiseStates.Fulfilled) {
  112784. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  112785. var child = _b[_i];
  112786. child._resolve(this._result);
  112787. }
  112788. }
  112789. else if (this._state === PromiseStates.Rejected) {
  112790. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  112791. var child = _d[_c];
  112792. child._reject(this._reason);
  112793. }
  112794. }
  112795. };
  112796. InternalPromise.prototype._resolve = function (value) {
  112797. try {
  112798. this._state = PromiseStates.Fulfilled;
  112799. var returnedValue = null;
  112800. if (this._onFulfilled) {
  112801. returnedValue = this._onFulfilled(value);
  112802. }
  112803. if (returnedValue !== undefined && returnedValue !== null) {
  112804. if (returnedValue._state !== undefined) {
  112805. // Transmit children
  112806. var returnedPromise = returnedValue;
  112807. returnedPromise._parent = this;
  112808. returnedPromise._moveChildren(this._children);
  112809. value = returnedPromise._result;
  112810. }
  112811. else {
  112812. value = returnedValue;
  112813. }
  112814. }
  112815. this._result = value;
  112816. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  112817. var child = _a[_i];
  112818. child._resolve(value);
  112819. }
  112820. this._children.length = 0;
  112821. delete this._onFulfilled;
  112822. delete this._onRejected;
  112823. }
  112824. catch (e) {
  112825. this._reject(e, true);
  112826. }
  112827. };
  112828. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  112829. if (onLocalThrow === void 0) { onLocalThrow = false; }
  112830. this._state = PromiseStates.Rejected;
  112831. this._reason = reason;
  112832. if (this._onRejected && !onLocalThrow) {
  112833. try {
  112834. this._onRejected(reason);
  112835. this._rejectWasConsumed = true;
  112836. }
  112837. catch (e) {
  112838. reason = e;
  112839. }
  112840. }
  112841. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  112842. var child = _a[_i];
  112843. if (this._rejectWasConsumed) {
  112844. child._resolve(null);
  112845. }
  112846. else {
  112847. child._reject(reason);
  112848. }
  112849. }
  112850. this._children.length = 0;
  112851. delete this._onFulfilled;
  112852. delete this._onRejected;
  112853. };
  112854. InternalPromise.resolve = function (value) {
  112855. var newPromise = new InternalPromise();
  112856. newPromise._resolve(value);
  112857. return newPromise;
  112858. };
  112859. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  112860. promise.then(function (value) {
  112861. agregator.results[index] = value;
  112862. agregator.count++;
  112863. if (agregator.count === agregator.target) {
  112864. agregator.rootPromise._resolve(agregator.results);
  112865. }
  112866. return null;
  112867. }, function (reason) {
  112868. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  112869. agregator.rootPromise._reject(reason);
  112870. }
  112871. });
  112872. };
  112873. InternalPromise.all = function (promises) {
  112874. var newPromise = new InternalPromise();
  112875. var agregator = new FulFillmentAgregator();
  112876. agregator.target = promises.length;
  112877. agregator.rootPromise = newPromise;
  112878. if (promises.length) {
  112879. for (var index = 0; index < promises.length; index++) {
  112880. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  112881. }
  112882. }
  112883. else {
  112884. newPromise._resolve([]);
  112885. }
  112886. return newPromise;
  112887. };
  112888. InternalPromise.race = function (promises) {
  112889. var newPromise = new InternalPromise();
  112890. if (promises.length) {
  112891. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  112892. var promise = promises_1[_i];
  112893. promise.then(function (value) {
  112894. if (newPromise) {
  112895. newPromise._resolve(value);
  112896. newPromise = null;
  112897. }
  112898. return null;
  112899. }, function (reason) {
  112900. if (newPromise) {
  112901. newPromise._reject(reason);
  112902. newPromise = null;
  112903. }
  112904. });
  112905. }
  112906. }
  112907. return newPromise;
  112908. };
  112909. return InternalPromise;
  112910. }());
  112911. /**
  112912. * Helper class that provides a small promise polyfill
  112913. */
  112914. var PromisePolyfill = /** @class */ (function () {
  112915. function PromisePolyfill() {
  112916. }
  112917. /**
  112918. * Static function used to check if the polyfill is required
  112919. * If this is the case then the function will inject the polyfill to window.Promise
  112920. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  112921. */
  112922. PromisePolyfill.Apply = function (force) {
  112923. if (force === void 0) { force = false; }
  112924. if (force || typeof Promise === 'undefined') {
  112925. var root = window;
  112926. root.Promise = InternalPromise;
  112927. }
  112928. };
  112929. return PromisePolyfill;
  112930. }());
  112931. /***/ }),
  112932. /***/ "./Misc/retryStrategy.ts":
  112933. /*!*******************************!*\
  112934. !*** ./Misc/retryStrategy.ts ***!
  112935. \*******************************/
  112936. /*! exports provided: RetryStrategy */
  112937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112938. "use strict";
  112939. __webpack_require__.r(__webpack_exports__);
  112940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  112941. /**
  112942. * Class used to define a retry strategy when error happens while loading assets
  112943. */
  112944. var RetryStrategy = /** @class */ (function () {
  112945. function RetryStrategy() {
  112946. }
  112947. /**
  112948. * Function used to defines an exponential back off strategy
  112949. * @param maxRetries defines the maximum number of retries (3 by default)
  112950. * @param baseInterval defines the interval between retries
  112951. * @returns the strategy function to use
  112952. */
  112953. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  112954. if (maxRetries === void 0) { maxRetries = 3; }
  112955. if (baseInterval === void 0) { baseInterval = 500; }
  112956. return function (url, request, retryIndex) {
  112957. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  112958. return -1;
  112959. }
  112960. return Math.pow(2, retryIndex) * baseInterval;
  112961. };
  112962. };
  112963. return RetryStrategy;
  112964. }());
  112965. /***/ }),
  112966. /***/ "./Misc/sceneOptimizer.ts":
  112967. /*!********************************!*\
  112968. !*** ./Misc/sceneOptimizer.ts ***!
  112969. \********************************/
  112970. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  112971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112972. "use strict";
  112973. __webpack_require__.r(__webpack_exports__);
  112974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  112975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  112976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  112977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  112978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  112979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  112980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  112981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  112982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  112983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  112984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  112985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  112986. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112987. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112988. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112989. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  112990. /**
  112991. * Defines the root class used to create scene optimization to use with SceneOptimizer
  112992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112993. */
  112994. var SceneOptimization = /** @class */ (function () {
  112995. /**
  112996. * Creates the SceneOptimization object
  112997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112998. * @param desc defines the description associated with the optimization
  112999. */
  113000. function SceneOptimization(
  113001. /**
  113002. * Defines the priority of this optimization (0 by default which means first in the list)
  113003. */
  113004. priority) {
  113005. if (priority === void 0) { priority = 0; }
  113006. this.priority = priority;
  113007. }
  113008. /**
  113009. * Gets a string describing the action executed by the current optimization
  113010. * @returns description string
  113011. */
  113012. SceneOptimization.prototype.getDescription = function () {
  113013. return "";
  113014. };
  113015. /**
  113016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113017. * @param scene defines the current scene where to apply this optimization
  113018. * @param optimizer defines the current optimizer
  113019. * @returns true if everything that can be done was applied
  113020. */
  113021. SceneOptimization.prototype.apply = function (scene, optimizer) {
  113022. return true;
  113023. };
  113024. return SceneOptimization;
  113025. }());
  113026. /**
  113027. * Defines an optimization used to reduce the size of render target textures
  113028. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113029. */
  113030. var TextureOptimization = /** @class */ (function (_super) {
  113031. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  113032. /**
  113033. * Creates the TextureOptimization object
  113034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113035. * @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
  113036. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113037. */
  113038. function TextureOptimization(
  113039. /**
  113040. * Defines the priority of this optimization (0 by default which means first in the list)
  113041. */
  113042. priority,
  113043. /**
  113044. * 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
  113045. */
  113046. maximumSize,
  113047. /**
  113048. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113049. */
  113050. step) {
  113051. if (priority === void 0) { priority = 0; }
  113052. if (maximumSize === void 0) { maximumSize = 1024; }
  113053. if (step === void 0) { step = 0.5; }
  113054. var _this = _super.call(this, priority) || this;
  113055. _this.priority = priority;
  113056. _this.maximumSize = maximumSize;
  113057. _this.step = step;
  113058. return _this;
  113059. }
  113060. /**
  113061. * Gets a string describing the action executed by the current optimization
  113062. * @returns description string
  113063. */
  113064. TextureOptimization.prototype.getDescription = function () {
  113065. return "Reducing render target texture size to " + this.maximumSize;
  113066. };
  113067. /**
  113068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113069. * @param scene defines the current scene where to apply this optimization
  113070. * @param optimizer defines the current optimizer
  113071. * @returns true if everything that can be done was applied
  113072. */
  113073. TextureOptimization.prototype.apply = function (scene, optimizer) {
  113074. var allDone = true;
  113075. for (var index = 0; index < scene.textures.length; index++) {
  113076. var texture = scene.textures[index];
  113077. if (!texture.canRescale || texture.getContext) {
  113078. continue;
  113079. }
  113080. var currentSize = texture.getSize();
  113081. var maxDimension = Math.max(currentSize.width, currentSize.height);
  113082. if (maxDimension > this.maximumSize) {
  113083. texture.scale(this.step);
  113084. allDone = false;
  113085. }
  113086. }
  113087. return allDone;
  113088. };
  113089. return TextureOptimization;
  113090. }(SceneOptimization));
  113091. /**
  113092. * Defines an optimization used to increase or decrease the rendering resolution
  113093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113094. */
  113095. var HardwareScalingOptimization = /** @class */ (function (_super) {
  113096. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  113097. /**
  113098. * Creates the HardwareScalingOptimization object
  113099. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113100. * @param maximumScale defines the maximum scale to use (2 by default)
  113101. * @param step defines the step to use between two passes (0.5 by default)
  113102. */
  113103. function HardwareScalingOptimization(
  113104. /**
  113105. * Defines the priority of this optimization (0 by default which means first in the list)
  113106. */
  113107. priority,
  113108. /**
  113109. * Defines the maximum scale to use (2 by default)
  113110. */
  113111. maximumScale,
  113112. /**
  113113. * Defines the step to use between two passes (0.5 by default)
  113114. */
  113115. step) {
  113116. if (priority === void 0) { priority = 0; }
  113117. if (maximumScale === void 0) { maximumScale = 2; }
  113118. if (step === void 0) { step = 0.25; }
  113119. var _this = _super.call(this, priority) || this;
  113120. _this.priority = priority;
  113121. _this.maximumScale = maximumScale;
  113122. _this.step = step;
  113123. _this._currentScale = -1;
  113124. _this._directionOffset = 1;
  113125. return _this;
  113126. }
  113127. /**
  113128. * Gets a string describing the action executed by the current optimization
  113129. * @return description string
  113130. */
  113131. HardwareScalingOptimization.prototype.getDescription = function () {
  113132. return "Setting hardware scaling level to " + this._currentScale;
  113133. };
  113134. /**
  113135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113136. * @param scene defines the current scene where to apply this optimization
  113137. * @param optimizer defines the current optimizer
  113138. * @returns true if everything that can be done was applied
  113139. */
  113140. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  113141. if (this._currentScale === -1) {
  113142. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  113143. if (this._currentScale > this.maximumScale) {
  113144. this._directionOffset = -1;
  113145. }
  113146. }
  113147. this._currentScale += this._directionOffset * this.step;
  113148. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  113149. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  113150. };
  113151. return HardwareScalingOptimization;
  113152. }(SceneOptimization));
  113153. /**
  113154. * Defines an optimization used to remove shadows
  113155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113156. */
  113157. var ShadowsOptimization = /** @class */ (function (_super) {
  113158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  113159. function ShadowsOptimization() {
  113160. return _super !== null && _super.apply(this, arguments) || this;
  113161. }
  113162. /**
  113163. * Gets a string describing the action executed by the current optimization
  113164. * @return description string
  113165. */
  113166. ShadowsOptimization.prototype.getDescription = function () {
  113167. return "Turning shadows on/off";
  113168. };
  113169. /**
  113170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113171. * @param scene defines the current scene where to apply this optimization
  113172. * @param optimizer defines the current optimizer
  113173. * @returns true if everything that can be done was applied
  113174. */
  113175. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  113176. scene.shadowsEnabled = optimizer.isInImprovementMode;
  113177. return true;
  113178. };
  113179. return ShadowsOptimization;
  113180. }(SceneOptimization));
  113181. /**
  113182. * Defines an optimization used to turn post-processes off
  113183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113184. */
  113185. var PostProcessesOptimization = /** @class */ (function (_super) {
  113186. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  113187. function PostProcessesOptimization() {
  113188. return _super !== null && _super.apply(this, arguments) || this;
  113189. }
  113190. /**
  113191. * Gets a string describing the action executed by the current optimization
  113192. * @return description string
  113193. */
  113194. PostProcessesOptimization.prototype.getDescription = function () {
  113195. return "Turning post-processes on/off";
  113196. };
  113197. /**
  113198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113199. * @param scene defines the current scene where to apply this optimization
  113200. * @param optimizer defines the current optimizer
  113201. * @returns true if everything that can be done was applied
  113202. */
  113203. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  113204. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  113205. return true;
  113206. };
  113207. return PostProcessesOptimization;
  113208. }(SceneOptimization));
  113209. /**
  113210. * Defines an optimization used to turn lens flares off
  113211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113212. */
  113213. var LensFlaresOptimization = /** @class */ (function (_super) {
  113214. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  113215. function LensFlaresOptimization() {
  113216. return _super !== null && _super.apply(this, arguments) || this;
  113217. }
  113218. /**
  113219. * Gets a string describing the action executed by the current optimization
  113220. * @return description string
  113221. */
  113222. LensFlaresOptimization.prototype.getDescription = function () {
  113223. return "Turning lens flares on/off";
  113224. };
  113225. /**
  113226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113227. * @param scene defines the current scene where to apply this optimization
  113228. * @param optimizer defines the current optimizer
  113229. * @returns true if everything that can be done was applied
  113230. */
  113231. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  113232. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  113233. return true;
  113234. };
  113235. return LensFlaresOptimization;
  113236. }(SceneOptimization));
  113237. /**
  113238. * Defines an optimization based on user defined callback.
  113239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113240. */
  113241. var CustomOptimization = /** @class */ (function (_super) {
  113242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  113243. function CustomOptimization() {
  113244. return _super !== null && _super.apply(this, arguments) || this;
  113245. }
  113246. /**
  113247. * Gets a string describing the action executed by the current optimization
  113248. * @returns description string
  113249. */
  113250. CustomOptimization.prototype.getDescription = function () {
  113251. if (this.onGetDescription) {
  113252. return this.onGetDescription();
  113253. }
  113254. return "Running user defined callback";
  113255. };
  113256. /**
  113257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113258. * @param scene defines the current scene where to apply this optimization
  113259. * @param optimizer defines the current optimizer
  113260. * @returns true if everything that can be done was applied
  113261. */
  113262. CustomOptimization.prototype.apply = function (scene, optimizer) {
  113263. if (this.onApply) {
  113264. return this.onApply(scene, optimizer);
  113265. }
  113266. return true;
  113267. };
  113268. return CustomOptimization;
  113269. }(SceneOptimization));
  113270. /**
  113271. * Defines an optimization used to turn particles off
  113272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113273. */
  113274. var ParticlesOptimization = /** @class */ (function (_super) {
  113275. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  113276. function ParticlesOptimization() {
  113277. return _super !== null && _super.apply(this, arguments) || this;
  113278. }
  113279. /**
  113280. * Gets a string describing the action executed by the current optimization
  113281. * @return description string
  113282. */
  113283. ParticlesOptimization.prototype.getDescription = function () {
  113284. return "Turning particles on/off";
  113285. };
  113286. /**
  113287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113288. * @param scene defines the current scene where to apply this optimization
  113289. * @param optimizer defines the current optimizer
  113290. * @returns true if everything that can be done was applied
  113291. */
  113292. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  113293. scene.particlesEnabled = optimizer.isInImprovementMode;
  113294. return true;
  113295. };
  113296. return ParticlesOptimization;
  113297. }(SceneOptimization));
  113298. /**
  113299. * Defines an optimization used to turn render targets off
  113300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113301. */
  113302. var RenderTargetsOptimization = /** @class */ (function (_super) {
  113303. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  113304. function RenderTargetsOptimization() {
  113305. return _super !== null && _super.apply(this, arguments) || this;
  113306. }
  113307. /**
  113308. * Gets a string describing the action executed by the current optimization
  113309. * @return description string
  113310. */
  113311. RenderTargetsOptimization.prototype.getDescription = function () {
  113312. return "Turning render targets off";
  113313. };
  113314. /**
  113315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113316. * @param scene defines the current scene where to apply this optimization
  113317. * @param optimizer defines the current optimizer
  113318. * @returns true if everything that can be done was applied
  113319. */
  113320. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  113321. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  113322. return true;
  113323. };
  113324. return RenderTargetsOptimization;
  113325. }(SceneOptimization));
  113326. /**
  113327. * Defines an optimization used to merge meshes with compatible materials
  113328. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113329. */
  113330. var MergeMeshesOptimization = /** @class */ (function (_super) {
  113331. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  113332. function MergeMeshesOptimization() {
  113333. var _this = _super !== null && _super.apply(this, arguments) || this;
  113334. _this._canBeMerged = function (abstractMesh) {
  113335. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  113336. return false;
  113337. }
  113338. var mesh = abstractMesh;
  113339. if (mesh.isDisposed()) {
  113340. return false;
  113341. }
  113342. if (!mesh.isVisible || !mesh.isEnabled()) {
  113343. return false;
  113344. }
  113345. if (mesh.instances.length > 0) {
  113346. return false;
  113347. }
  113348. if (mesh.skeleton || mesh.hasLODLevels) {
  113349. return false;
  113350. }
  113351. return true;
  113352. };
  113353. return _this;
  113354. }
  113355. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  113356. /**
  113357. * Gets or sets a boolean which defines if optimization octree has to be updated
  113358. */
  113359. get: function () {
  113360. return MergeMeshesOptimization._UpdateSelectionTree;
  113361. },
  113362. /**
  113363. * Gets or sets a boolean which defines if optimization octree has to be updated
  113364. */
  113365. set: function (value) {
  113366. MergeMeshesOptimization._UpdateSelectionTree = value;
  113367. },
  113368. enumerable: true,
  113369. configurable: true
  113370. });
  113371. /**
  113372. * Gets a string describing the action executed by the current optimization
  113373. * @return description string
  113374. */
  113375. MergeMeshesOptimization.prototype.getDescription = function () {
  113376. return "Merging similar meshes together";
  113377. };
  113378. /**
  113379. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113380. * @param scene defines the current scene where to apply this optimization
  113381. * @param optimizer defines the current optimizer
  113382. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113383. * @returns true if everything that can be done was applied
  113384. */
  113385. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  113386. var globalPool = scene.meshes.slice(0);
  113387. var globalLength = globalPool.length;
  113388. for (var index = 0; index < globalLength; index++) {
  113389. var currentPool = new Array();
  113390. var current = globalPool[index];
  113391. // Checks
  113392. if (!this._canBeMerged(current)) {
  113393. continue;
  113394. }
  113395. currentPool.push(current);
  113396. // Find compatible meshes
  113397. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  113398. var otherMesh = globalPool[subIndex];
  113399. if (!this._canBeMerged(otherMesh)) {
  113400. continue;
  113401. }
  113402. if (otherMesh.material !== current.material) {
  113403. continue;
  113404. }
  113405. if (otherMesh.checkCollisions !== current.checkCollisions) {
  113406. continue;
  113407. }
  113408. currentPool.push(otherMesh);
  113409. globalLength--;
  113410. globalPool.splice(subIndex, 1);
  113411. subIndex--;
  113412. }
  113413. if (currentPool.length < 2) {
  113414. continue;
  113415. }
  113416. // Merge meshes
  113417. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  113418. }
  113419. // Call the octree system optimization if it is defined.
  113420. var sceneAsAny = scene;
  113421. if (sceneAsAny.createOrUpdateSelectionOctree) {
  113422. if (updateSelectionTree != undefined) {
  113423. if (updateSelectionTree) {
  113424. sceneAsAny.createOrUpdateSelectionOctree();
  113425. }
  113426. }
  113427. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  113428. sceneAsAny.createOrUpdateSelectionOctree();
  113429. }
  113430. }
  113431. return true;
  113432. };
  113433. MergeMeshesOptimization._UpdateSelectionTree = false;
  113434. return MergeMeshesOptimization;
  113435. }(SceneOptimization));
  113436. /**
  113437. * Defines a list of options used by SceneOptimizer
  113438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113439. */
  113440. var SceneOptimizerOptions = /** @class */ (function () {
  113441. /**
  113442. * Creates a new list of options used by SceneOptimizer
  113443. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113444. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113445. */
  113446. function SceneOptimizerOptions(
  113447. /**
  113448. * Defines the target frame rate to reach (60 by default)
  113449. */
  113450. targetFrameRate,
  113451. /**
  113452. * Defines the interval between two checkes (2000ms by default)
  113453. */
  113454. trackerDuration) {
  113455. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  113456. if (trackerDuration === void 0) { trackerDuration = 2000; }
  113457. this.targetFrameRate = targetFrameRate;
  113458. this.trackerDuration = trackerDuration;
  113459. /**
  113460. * Gets the list of optimizations to apply
  113461. */
  113462. this.optimizations = new Array();
  113463. }
  113464. /**
  113465. * Add a new optimization
  113466. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113467. * @returns the current SceneOptimizerOptions
  113468. */
  113469. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  113470. this.optimizations.push(optimization);
  113471. return this;
  113472. };
  113473. /**
  113474. * Add a new custom optimization
  113475. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113476. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113477. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113478. * @returns the current SceneOptimizerOptions
  113479. */
  113480. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  113481. if (priority === void 0) { priority = 0; }
  113482. var optimization = new CustomOptimization(priority);
  113483. optimization.onApply = onApply;
  113484. optimization.onGetDescription = onGetDescription;
  113485. this.optimizations.push(optimization);
  113486. return this;
  113487. };
  113488. /**
  113489. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113490. * @param targetFrameRate defines the target frame rate (60 by default)
  113491. * @returns a SceneOptimizerOptions object
  113492. */
  113493. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  113494. var result = new SceneOptimizerOptions(targetFrameRate);
  113495. var priority = 0;
  113496. result.addOptimization(new MergeMeshesOptimization(priority));
  113497. result.addOptimization(new ShadowsOptimization(priority));
  113498. result.addOptimization(new LensFlaresOptimization(priority));
  113499. // Next priority
  113500. priority++;
  113501. result.addOptimization(new PostProcessesOptimization(priority));
  113502. result.addOptimization(new ParticlesOptimization(priority));
  113503. // Next priority
  113504. priority++;
  113505. result.addOptimization(new TextureOptimization(priority, 1024));
  113506. return result;
  113507. };
  113508. /**
  113509. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113510. * @param targetFrameRate defines the target frame rate (60 by default)
  113511. * @returns a SceneOptimizerOptions object
  113512. */
  113513. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  113514. var result = new SceneOptimizerOptions(targetFrameRate);
  113515. var priority = 0;
  113516. result.addOptimization(new MergeMeshesOptimization(priority));
  113517. result.addOptimization(new ShadowsOptimization(priority));
  113518. result.addOptimization(new LensFlaresOptimization(priority));
  113519. // Next priority
  113520. priority++;
  113521. result.addOptimization(new PostProcessesOptimization(priority));
  113522. result.addOptimization(new ParticlesOptimization(priority));
  113523. // Next priority
  113524. priority++;
  113525. result.addOptimization(new TextureOptimization(priority, 512));
  113526. // Next priority
  113527. priority++;
  113528. result.addOptimization(new RenderTargetsOptimization(priority));
  113529. // Next priority
  113530. priority++;
  113531. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  113532. return result;
  113533. };
  113534. /**
  113535. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113536. * @param targetFrameRate defines the target frame rate (60 by default)
  113537. * @returns a SceneOptimizerOptions object
  113538. */
  113539. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  113540. var result = new SceneOptimizerOptions(targetFrameRate);
  113541. var priority = 0;
  113542. result.addOptimization(new MergeMeshesOptimization(priority));
  113543. result.addOptimization(new ShadowsOptimization(priority));
  113544. result.addOptimization(new LensFlaresOptimization(priority));
  113545. // Next priority
  113546. priority++;
  113547. result.addOptimization(new PostProcessesOptimization(priority));
  113548. result.addOptimization(new ParticlesOptimization(priority));
  113549. // Next priority
  113550. priority++;
  113551. result.addOptimization(new TextureOptimization(priority, 256));
  113552. // Next priority
  113553. priority++;
  113554. result.addOptimization(new RenderTargetsOptimization(priority));
  113555. // Next priority
  113556. priority++;
  113557. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  113558. return result;
  113559. };
  113560. return SceneOptimizerOptions;
  113561. }());
  113562. /**
  113563. * Class used to run optimizations in order to reach a target frame rate
  113564. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113565. */
  113566. var SceneOptimizer = /** @class */ (function () {
  113567. /**
  113568. * Creates a new SceneOptimizer
  113569. * @param scene defines the scene to work on
  113570. * @param options defines the options to use with the SceneOptimizer
  113571. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113572. * @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)
  113573. */
  113574. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  113575. var _this = this;
  113576. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  113577. if (improvementMode === void 0) { improvementMode = false; }
  113578. this._isRunning = false;
  113579. this._currentPriorityLevel = 0;
  113580. this._targetFrameRate = 60;
  113581. this._trackerDuration = 2000;
  113582. this._currentFrameRate = 0;
  113583. this._improvementMode = false;
  113584. /**
  113585. * Defines an observable called when the optimizer reaches the target frame rate
  113586. */
  113587. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  113588. /**
  113589. * Defines an observable called when the optimizer enables an optimization
  113590. */
  113591. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  113592. /**
  113593. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113594. */
  113595. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  113596. if (!options) {
  113597. this._options = new SceneOptimizerOptions();
  113598. }
  113599. else {
  113600. this._options = options;
  113601. }
  113602. if (this._options.targetFrameRate) {
  113603. this._targetFrameRate = this._options.targetFrameRate;
  113604. }
  113605. if (this._options.trackerDuration) {
  113606. this._trackerDuration = this._options.trackerDuration;
  113607. }
  113608. if (autoGeneratePriorities) {
  113609. var priority = 0;
  113610. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  113611. var optim = _a[_i];
  113612. optim.priority = priority++;
  113613. }
  113614. }
  113615. this._improvementMode = improvementMode;
  113616. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  113617. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  113618. _this._sceneDisposeObserver = null;
  113619. _this.dispose();
  113620. });
  113621. }
  113622. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  113623. /**
  113624. * Gets a boolean indicating if the optimizer is in improvement mode
  113625. */
  113626. get: function () {
  113627. return this._improvementMode;
  113628. },
  113629. enumerable: true,
  113630. configurable: true
  113631. });
  113632. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  113633. /**
  113634. * Gets the current priority level (0 at start)
  113635. */
  113636. get: function () {
  113637. return this._currentPriorityLevel;
  113638. },
  113639. enumerable: true,
  113640. configurable: true
  113641. });
  113642. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  113643. /**
  113644. * Gets the current frame rate checked by the SceneOptimizer
  113645. */
  113646. get: function () {
  113647. return this._currentFrameRate;
  113648. },
  113649. enumerable: true,
  113650. configurable: true
  113651. });
  113652. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  113653. /**
  113654. * Gets or sets the current target frame rate (60 by default)
  113655. */
  113656. get: function () {
  113657. return this._targetFrameRate;
  113658. },
  113659. /**
  113660. * Gets or sets the current target frame rate (60 by default)
  113661. */
  113662. set: function (value) {
  113663. this._targetFrameRate = value;
  113664. },
  113665. enumerable: true,
  113666. configurable: true
  113667. });
  113668. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  113669. /**
  113670. * Gets or sets the current interval between two checks (every 2000ms by default)
  113671. */
  113672. get: function () {
  113673. return this._trackerDuration;
  113674. },
  113675. /**
  113676. * Gets or sets the current interval between two checks (every 2000ms by default)
  113677. */
  113678. set: function (value) {
  113679. this._trackerDuration = value;
  113680. },
  113681. enumerable: true,
  113682. configurable: true
  113683. });
  113684. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  113685. /**
  113686. * Gets the list of active optimizations
  113687. */
  113688. get: function () {
  113689. return this._options.optimizations;
  113690. },
  113691. enumerable: true,
  113692. configurable: true
  113693. });
  113694. /**
  113695. * Stops the current optimizer
  113696. */
  113697. SceneOptimizer.prototype.stop = function () {
  113698. this._isRunning = false;
  113699. };
  113700. /**
  113701. * Reset the optimizer to initial step (current priority level = 0)
  113702. */
  113703. SceneOptimizer.prototype.reset = function () {
  113704. this._currentPriorityLevel = 0;
  113705. };
  113706. /**
  113707. * Start the optimizer. By default it will try to reach a specific framerate
  113708. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113709. */
  113710. SceneOptimizer.prototype.start = function () {
  113711. var _this = this;
  113712. if (this._isRunning) {
  113713. return;
  113714. }
  113715. this._isRunning = true;
  113716. // Let's wait for the scene to be ready before running our check
  113717. this._scene.executeWhenReady(function () {
  113718. setTimeout(function () {
  113719. _this._checkCurrentState();
  113720. }, _this._trackerDuration);
  113721. });
  113722. };
  113723. SceneOptimizer.prototype._checkCurrentState = function () {
  113724. var _this = this;
  113725. if (!this._isRunning) {
  113726. return;
  113727. }
  113728. var scene = this._scene;
  113729. var options = this._options;
  113730. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  113731. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  113732. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  113733. this._isRunning = false;
  113734. this.onSuccessObservable.notifyObservers(this);
  113735. return;
  113736. }
  113737. // Apply current level of optimizations
  113738. var allDone = true;
  113739. var noOptimizationApplied = true;
  113740. for (var index = 0; index < options.optimizations.length; index++) {
  113741. var optimization = options.optimizations[index];
  113742. if (optimization.priority === this._currentPriorityLevel) {
  113743. noOptimizationApplied = false;
  113744. allDone = allDone && optimization.apply(scene, this);
  113745. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  113746. }
  113747. }
  113748. // If no optimization was applied, this is a failure :(
  113749. if (noOptimizationApplied) {
  113750. this._isRunning = false;
  113751. this.onFailureObservable.notifyObservers(this);
  113752. return;
  113753. }
  113754. // If all optimizations were done, move to next level
  113755. if (allDone) {
  113756. this._currentPriorityLevel++;
  113757. }
  113758. // Let's the system running for a specific amount of time before checking FPS
  113759. scene.executeWhenReady(function () {
  113760. setTimeout(function () {
  113761. _this._checkCurrentState();
  113762. }, _this._trackerDuration);
  113763. });
  113764. };
  113765. /**
  113766. * Release all resources
  113767. */
  113768. SceneOptimizer.prototype.dispose = function () {
  113769. this.stop();
  113770. this.onSuccessObservable.clear();
  113771. this.onFailureObservable.clear();
  113772. this.onNewOptimizationAppliedObservable.clear();
  113773. if (this._sceneDisposeObserver) {
  113774. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  113775. }
  113776. };
  113777. /**
  113778. * Helper function to create a SceneOptimizer with one single line of code
  113779. * @param scene defines the scene to work on
  113780. * @param options defines the options to use with the SceneOptimizer
  113781. * @param onSuccess defines a callback to call on success
  113782. * @param onFailure defines a callback to call on failure
  113783. * @returns the new SceneOptimizer object
  113784. */
  113785. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  113786. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  113787. if (onSuccess) {
  113788. optimizer.onSuccessObservable.add(function () {
  113789. onSuccess();
  113790. });
  113791. }
  113792. if (onFailure) {
  113793. optimizer.onFailureObservable.add(function () {
  113794. onFailure();
  113795. });
  113796. }
  113797. optimizer.start();
  113798. return optimizer;
  113799. };
  113800. return SceneOptimizer;
  113801. }());
  113802. /***/ }),
  113803. /***/ "./Misc/sceneSerializer.ts":
  113804. /*!*********************************!*\
  113805. !*** ./Misc/sceneSerializer.ts ***!
  113806. \*********************************/
  113807. /*! exports provided: SceneSerializer */
  113808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113809. "use strict";
  113810. __webpack_require__.r(__webpack_exports__);
  113811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  113812. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  113813. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  113814. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  113815. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  113816. var serializedGeometries = [];
  113817. var serializeGeometry = function (geometry, serializationGeometries) {
  113818. if (serializedGeometries[geometry.id]) {
  113819. return;
  113820. }
  113821. if (geometry.doNotSerialize) {
  113822. return;
  113823. }
  113824. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  113825. serializedGeometries[geometry.id] = true;
  113826. };
  113827. var serializeMesh = function (mesh, serializationScene) {
  113828. var serializationObject = {};
  113829. // Geometry
  113830. var geometry = mesh._geometry;
  113831. if (geometry) {
  113832. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  113833. // 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
  113834. serializeGeometry(geometry, serializationScene.geometries);
  113835. }
  113836. }
  113837. // Custom
  113838. if (mesh.serialize) {
  113839. mesh.serialize(serializationObject);
  113840. }
  113841. return serializationObject;
  113842. };
  113843. var finalizeSingleMesh = function (mesh, serializationObject) {
  113844. //only works if the mesh is already loaded
  113845. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  113846. //serialize material
  113847. if (mesh.material && !mesh.doNotSerialize) {
  113848. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  113849. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  113850. serializationObject.materials = serializationObject.materials || [];
  113851. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  113852. serializationObject.multiMaterials.push(mesh.material.serialize());
  113853. var _loop_1 = function (submaterial) {
  113854. if (submaterial) {
  113855. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  113856. serializationObject.materials.push(submaterial.serialize());
  113857. }
  113858. }
  113859. };
  113860. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  113861. var submaterial = _a[_i];
  113862. _loop_1(submaterial);
  113863. }
  113864. }
  113865. }
  113866. else {
  113867. serializationObject.materials = serializationObject.materials || [];
  113868. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  113869. serializationObject.materials.push(mesh.material.serialize());
  113870. }
  113871. }
  113872. }
  113873. //serialize geometry
  113874. var geometry = mesh._geometry;
  113875. if (geometry) {
  113876. if (!serializationObject.geometries) {
  113877. serializationObject.geometries = {};
  113878. serializationObject.geometries.boxes = [];
  113879. serializationObject.geometries.spheres = [];
  113880. serializationObject.geometries.cylinders = [];
  113881. serializationObject.geometries.toruses = [];
  113882. serializationObject.geometries.grounds = [];
  113883. serializationObject.geometries.planes = [];
  113884. serializationObject.geometries.torusKnots = [];
  113885. serializationObject.geometries.vertexData = [];
  113886. }
  113887. serializeGeometry(geometry, serializationObject.geometries);
  113888. }
  113889. // Skeletons
  113890. if (mesh.skeleton && !mesh.skeleton.doNotSerialize) {
  113891. serializationObject.skeletons = serializationObject.skeletons || [];
  113892. serializationObject.skeletons.push(mesh.skeleton.serialize());
  113893. }
  113894. //serialize the actual mesh
  113895. serializationObject.meshes = serializationObject.meshes || [];
  113896. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  113897. }
  113898. };
  113899. /**
  113900. * Class used to serialize a scene into a string
  113901. */
  113902. var SceneSerializer = /** @class */ (function () {
  113903. function SceneSerializer() {
  113904. }
  113905. /**
  113906. * Clear cache used by a previous serialization
  113907. */
  113908. SceneSerializer.ClearCache = function () {
  113909. serializedGeometries = [];
  113910. };
  113911. /**
  113912. * Serialize a scene into a JSON compatible object
  113913. * @param scene defines the scene to serialize
  113914. * @returns a JSON compatible object
  113915. */
  113916. SceneSerializer.Serialize = function (scene) {
  113917. var serializationObject = {};
  113918. SceneSerializer.ClearCache();
  113919. // Scene
  113920. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  113921. serializationObject.autoClear = scene.autoClear;
  113922. serializationObject.clearColor = scene.clearColor.asArray();
  113923. serializationObject.ambientColor = scene.ambientColor.asArray();
  113924. serializationObject.gravity = scene.gravity.asArray();
  113925. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  113926. // Fog
  113927. if (scene.fogMode && scene.fogMode !== 0) {
  113928. serializationObject.fogMode = scene.fogMode;
  113929. serializationObject.fogColor = scene.fogColor.asArray();
  113930. serializationObject.fogStart = scene.fogStart;
  113931. serializationObject.fogEnd = scene.fogEnd;
  113932. serializationObject.fogDensity = scene.fogDensity;
  113933. }
  113934. //Physics
  113935. if (scene.isPhysicsEnabled()) {
  113936. var physicEngine = scene.getPhysicsEngine();
  113937. if (physicEngine) {
  113938. serializationObject.physicsEnabled = true;
  113939. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  113940. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  113941. }
  113942. }
  113943. // Metadata
  113944. if (scene.metadata) {
  113945. serializationObject.metadata = scene.metadata;
  113946. }
  113947. // Morph targets
  113948. serializationObject.morphTargetManagers = [];
  113949. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  113950. var abstractMesh = _a[_i];
  113951. var manager = abstractMesh.morphTargetManager;
  113952. if (manager) {
  113953. serializationObject.morphTargetManagers.push(manager.serialize());
  113954. }
  113955. }
  113956. // Lights
  113957. serializationObject.lights = [];
  113958. var index;
  113959. var light;
  113960. for (index = 0; index < scene.lights.length; index++) {
  113961. light = scene.lights[index];
  113962. if (!light.doNotSerialize) {
  113963. serializationObject.lights.push(light.serialize());
  113964. }
  113965. }
  113966. // Cameras
  113967. serializationObject.cameras = [];
  113968. for (index = 0; index < scene.cameras.length; index++) {
  113969. var camera = scene.cameras[index];
  113970. if (!camera.doNotSerialize) {
  113971. serializationObject.cameras.push(camera.serialize());
  113972. }
  113973. }
  113974. if (scene.activeCamera) {
  113975. serializationObject.activeCameraID = scene.activeCamera.id;
  113976. }
  113977. // Animations
  113978. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  113979. // Animation Groups
  113980. if (scene.animationGroups && scene.animationGroups.length > 0) {
  113981. serializationObject.animationGroups = [];
  113982. for (var animationGroupIndex = 0; animationGroupIndex < scene.animationGroups.length; animationGroupIndex++) {
  113983. var animationGroup = scene.animationGroups[animationGroupIndex];
  113984. serializationObject.animationGroups.push(animationGroup.serialize());
  113985. }
  113986. }
  113987. // Reflection probes
  113988. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  113989. serializationObject.reflectionProbes = [];
  113990. for (index = 0; index < scene.reflectionProbes.length; index++) {
  113991. var reflectionProbe = scene.reflectionProbes[index];
  113992. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  113993. }
  113994. }
  113995. // Materials
  113996. serializationObject.materials = [];
  113997. serializationObject.multiMaterials = [];
  113998. var material;
  113999. for (index = 0; index < scene.materials.length; index++) {
  114000. material = scene.materials[index];
  114001. if (!material.doNotSerialize) {
  114002. serializationObject.materials.push(material.serialize());
  114003. }
  114004. }
  114005. // MultiMaterials
  114006. serializationObject.multiMaterials = [];
  114007. for (index = 0; index < scene.multiMaterials.length; index++) {
  114008. var multiMaterial = scene.multiMaterials[index];
  114009. serializationObject.multiMaterials.push(multiMaterial.serialize());
  114010. }
  114011. // Environment texture
  114012. if (scene.environmentTexture) {
  114013. serializationObject.environmentTexture = scene.environmentTexture.name;
  114014. }
  114015. // Skeletons
  114016. serializationObject.skeletons = [];
  114017. for (index = 0; index < scene.skeletons.length; index++) {
  114018. var skeleton = scene.skeletons[index];
  114019. if (!skeleton.doNotSerialize) {
  114020. serializationObject.skeletons.push(skeleton.serialize());
  114021. }
  114022. }
  114023. // Transform nodes
  114024. serializationObject.transformNodes = [];
  114025. for (index = 0; index < scene.transformNodes.length; index++) {
  114026. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  114027. }
  114028. // Geometries
  114029. serializationObject.geometries = {};
  114030. serializationObject.geometries.boxes = [];
  114031. serializationObject.geometries.spheres = [];
  114032. serializationObject.geometries.cylinders = [];
  114033. serializationObject.geometries.toruses = [];
  114034. serializationObject.geometries.grounds = [];
  114035. serializationObject.geometries.planes = [];
  114036. serializationObject.geometries.torusKnots = [];
  114037. serializationObject.geometries.vertexData = [];
  114038. serializedGeometries = [];
  114039. var geometries = scene.getGeometries();
  114040. for (index = 0; index < geometries.length; index++) {
  114041. var geometry = geometries[index];
  114042. if (geometry.isReady()) {
  114043. serializeGeometry(geometry, serializationObject.geometries);
  114044. }
  114045. }
  114046. // Meshes
  114047. serializationObject.meshes = [];
  114048. for (index = 0; index < scene.meshes.length; index++) {
  114049. var abstractMesh = scene.meshes[index];
  114050. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  114051. var mesh = abstractMesh;
  114052. if (!mesh.doNotSerialize) {
  114053. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  114054. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  114055. }
  114056. }
  114057. }
  114058. }
  114059. // Particles Systems
  114060. serializationObject.particleSystems = [];
  114061. for (index = 0; index < scene.particleSystems.length; index++) {
  114062. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  114063. }
  114064. // Action Manager
  114065. if (scene.actionManager) {
  114066. serializationObject.actions = scene.actionManager.serialize("scene");
  114067. }
  114068. // Components
  114069. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  114070. var component = _c[_b];
  114071. component.serialize(serializationObject);
  114072. }
  114073. return serializationObject;
  114074. };
  114075. /**
  114076. * Serialize a mesh into a JSON compatible object
  114077. * @param toSerialize defines the mesh to serialize
  114078. * @param withParents defines if parents must be serialized as well
  114079. * @param withChildren defines if children must be serialized as well
  114080. * @returns a JSON compatible object
  114081. */
  114082. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  114083. if (withParents === void 0) { withParents = false; }
  114084. if (withChildren === void 0) { withChildren = false; }
  114085. var serializationObject = {};
  114086. SceneSerializer.ClearCache();
  114087. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  114088. if (withParents || withChildren) {
  114089. //deliberate for loop! not for each, appended should be processed as well.
  114090. for (var i = 0; i < toSerialize.length; ++i) {
  114091. if (withChildren) {
  114092. toSerialize[i].getDescendants().forEach(function (node) {
  114093. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0) && !node.doNotSerialize) {
  114094. toSerialize.push(node);
  114095. }
  114096. });
  114097. }
  114098. //make sure the array doesn't contain the object already
  114099. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0) && !toSerialize[i].parent.doNotSerialize) {
  114100. toSerialize.push(toSerialize[i].parent);
  114101. }
  114102. }
  114103. }
  114104. toSerialize.forEach(function (mesh) {
  114105. finalizeSingleMesh(mesh, serializationObject);
  114106. });
  114107. return serializationObject;
  114108. };
  114109. return SceneSerializer;
  114110. }());
  114111. /***/ }),
  114112. /***/ "./Misc/screenshotTools.ts":
  114113. /*!*********************************!*\
  114114. !*** ./Misc/screenshotTools.ts ***!
  114115. \*********************************/
  114116. /*! exports provided: ScreenshotTools */
  114117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114118. "use strict";
  114119. __webpack_require__.r(__webpack_exports__);
  114120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  114121. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114122. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  114123. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114124. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  114125. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  114126. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  114127. /**
  114128. * Class containing a set of static utilities functions for screenshots
  114129. */
  114130. var ScreenshotTools = /** @class */ (function () {
  114131. function ScreenshotTools() {
  114132. }
  114133. /**
  114134. * Captures a screenshot of the current rendering
  114135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114136. * @param engine defines the rendering engine
  114137. * @param camera defines the source camera
  114138. * @param size This parameter can be set to a single number or to an object with the
  114139. * following (optional) properties: precision, width, height. If a single number is passed,
  114140. * it will be used for both width and height. If an object is passed, the screenshot size
  114141. * will be derived from the parameters. The precision property is a multiplier allowing
  114142. * rendering at a higher or lower resolution
  114143. * @param successCallback defines the callback receives a single parameter which contains the
  114144. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114145. * src parameter of an <img> to display it
  114146. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114147. * Check your browser for supported MIME types
  114148. */
  114149. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  114150. if (mimeType === void 0) { mimeType = "image/png"; }
  114151. var width;
  114152. var height;
  114153. // If a precision value is specified
  114154. if (size.precision) {
  114155. width = Math.round(engine.getRenderWidth() * size.precision);
  114156. height = Math.round(width / engine.getAspectRatio(camera));
  114157. }
  114158. else if (size.width && size.height) {
  114159. width = size.width;
  114160. height = size.height;
  114161. }
  114162. //If passing only width, computing height to keep display canvas ratio.
  114163. else if (size.width && !size.height) {
  114164. width = size.width;
  114165. height = Math.round(width / engine.getAspectRatio(camera));
  114166. }
  114167. //If passing only height, computing width to keep display canvas ratio.
  114168. else if (size.height && !size.width) {
  114169. height = size.height;
  114170. width = Math.round(height * engine.getAspectRatio(camera));
  114171. }
  114172. //Assuming here that "size" parameter is a number
  114173. else if (!isNaN(size)) {
  114174. height = size;
  114175. width = size;
  114176. }
  114177. else {
  114178. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  114179. return;
  114180. }
  114181. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  114182. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  114183. }
  114184. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  114185. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  114186. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  114187. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  114188. var newWidth = width;
  114189. var newHeight = newWidth / ratio;
  114190. if (newHeight > height) {
  114191. newHeight = height;
  114192. newWidth = newHeight * ratio;
  114193. }
  114194. var offsetX = Math.max(0, width - newWidth) / 2;
  114195. var offsetY = Math.max(0, height - newHeight) / 2;
  114196. var renderingCanvas = engine.getRenderingCanvas();
  114197. if (renderContext && renderingCanvas) {
  114198. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  114199. }
  114200. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  114201. };
  114202. /**
  114203. * Captures a screenshot of the current rendering
  114204. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114205. * @param engine defines the rendering engine
  114206. * @param camera defines the source camera
  114207. * @param size This parameter can be set to a single number or to an object with the
  114208. * following (optional) properties: precision, width, height. If a single number is passed,
  114209. * it will be used for both width and height. If an object is passed, the screenshot size
  114210. * will be derived from the parameters. The precision property is a multiplier allowing
  114211. * rendering at a higher or lower resolution
  114212. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114213. * Check your browser for supported MIME types
  114214. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114215. * to the src parameter of an <img> to display it
  114216. */
  114217. ScreenshotTools.CreateScreenshotAsync = function (engine, camera, size, mimeType) {
  114218. if (mimeType === void 0) { mimeType = "image/png"; }
  114219. return new Promise(function (resolve, reject) {
  114220. ScreenshotTools.CreateScreenshot(engine, camera, size, function (data) {
  114221. if (typeof (data) !== "undefined") {
  114222. resolve(data);
  114223. }
  114224. else {
  114225. reject(new Error("Data is undefined"));
  114226. }
  114227. }, mimeType);
  114228. });
  114229. };
  114230. /**
  114231. * Generates an image screenshot from the specified camera.
  114232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114233. * @param engine The engine to use for rendering
  114234. * @param camera The camera to use for rendering
  114235. * @param size This parameter can be set to a single number or to an object with the
  114236. * following (optional) properties: precision, width, height. If a single number is passed,
  114237. * it will be used for both width and height. If an object is passed, the screenshot size
  114238. * will be derived from the parameters. The precision property is a multiplier allowing
  114239. * rendering at a higher or lower resolution
  114240. * @param successCallback The callback receives a single parameter which contains the
  114241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114242. * src parameter of an <img> to display it
  114243. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114244. * Check your browser for supported MIME types
  114245. * @param samples Texture samples (default: 1)
  114246. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114247. * @param fileName A name for for the downloaded file.
  114248. */
  114249. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  114250. if (mimeType === void 0) { mimeType = "image/png"; }
  114251. if (samples === void 0) { samples = 1; }
  114252. if (antialiasing === void 0) { antialiasing = false; }
  114253. var width;
  114254. var height;
  114255. //If a precision value is specified
  114256. if (size.precision) {
  114257. width = Math.round(engine.getRenderWidth() * size.precision);
  114258. height = Math.round(width / engine.getAspectRatio(camera));
  114259. size = { width: width, height: height };
  114260. }
  114261. else if (size.width && size.height) {
  114262. width = size.width;
  114263. height = size.height;
  114264. }
  114265. //If passing only width, computing height to keep display canvas ratio.
  114266. else if (size.width && !size.height) {
  114267. width = size.width;
  114268. height = Math.round(width / engine.getAspectRatio(camera));
  114269. size = { width: width, height: height };
  114270. }
  114271. //If passing only height, computing width to keep display canvas ratio.
  114272. else if (size.height && !size.width) {
  114273. height = size.height;
  114274. width = Math.round(height * engine.getAspectRatio(camera));
  114275. size = { width: width, height: height };
  114276. }
  114277. //Assuming here that "size" parameter is a number
  114278. else if (!isNaN(size)) {
  114279. height = size;
  114280. width = size;
  114281. }
  114282. else {
  114283. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  114284. return;
  114285. }
  114286. var scene = camera.getScene();
  114287. var previousCamera = null;
  114288. if (scene.activeCamera !== camera) {
  114289. previousCamera = scene.activeCamera;
  114290. scene.activeCamera = camera;
  114291. }
  114292. var renderCanvas = engine.getRenderingCanvas();
  114293. if (!renderCanvas) {
  114294. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  114295. return;
  114296. }
  114297. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  114298. engine.setSize(width, height);
  114299. scene.render();
  114300. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  114301. 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);
  114302. texture.renderList = null;
  114303. texture.samples = samples;
  114304. if (antialiasing) {
  114305. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  114306. }
  114307. texture.onAfterRenderObservable.add(function () {
  114308. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  114309. });
  114310. scene.incrementRenderId();
  114311. scene.resetCachedMaterial();
  114312. texture.render(true);
  114313. texture.dispose();
  114314. if (previousCamera) {
  114315. scene.activeCamera = previousCamera;
  114316. }
  114317. engine.setSize(originalSize.width, originalSize.height);
  114318. camera.getProjectionMatrix(true); // Force cache refresh;
  114319. };
  114320. /**
  114321. * Generates an image screenshot from the specified camera.
  114322. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114323. * @param engine The engine to use for rendering
  114324. * @param camera The camera to use for rendering
  114325. * @param size This parameter can be set to a single number or to an object with the
  114326. * following (optional) properties: precision, width, height. If a single number is passed,
  114327. * it will be used for both width and height. If an object is passed, the screenshot size
  114328. * will be derived from the parameters. The precision property is a multiplier allowing
  114329. * rendering at a higher or lower resolution
  114330. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114331. * Check your browser for supported MIME types
  114332. * @param samples Texture samples (default: 1)
  114333. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114334. * @param fileName A name for for the downloaded file.
  114335. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114336. * to the src parameter of an <img> to display it
  114337. */
  114338. ScreenshotTools.CreateScreenshotUsingRenderTargetAsync = function (engine, camera, size, mimeType, samples, antialiasing, fileName) {
  114339. if (mimeType === void 0) { mimeType = "image/png"; }
  114340. if (samples === void 0) { samples = 1; }
  114341. if (antialiasing === void 0) { antialiasing = false; }
  114342. return new Promise(function (resolve, reject) {
  114343. ScreenshotTools.CreateScreenshotUsingRenderTarget(engine, camera, size, function (data) {
  114344. if (typeof (data) !== "undefined") {
  114345. resolve(data);
  114346. }
  114347. else {
  114348. reject(new Error("Data is undefined"));
  114349. }
  114350. }, mimeType, samples, antialiasing, fileName);
  114351. });
  114352. };
  114353. return ScreenshotTools;
  114354. }());
  114355. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  114356. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotAsync = ScreenshotTools.CreateScreenshotAsync;
  114357. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  114358. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTargetAsync = ScreenshotTools.CreateScreenshotUsingRenderTargetAsync;
  114359. /***/ }),
  114360. /***/ "./Misc/smartArray.ts":
  114361. /*!****************************!*\
  114362. !*** ./Misc/smartArray.ts ***!
  114363. \****************************/
  114364. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  114365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114366. "use strict";
  114367. __webpack_require__.r(__webpack_exports__);
  114368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  114369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  114370. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114371. /**
  114372. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  114373. */
  114374. var SmartArray = /** @class */ (function () {
  114375. /**
  114376. * Instantiates a Smart Array.
  114377. * @param capacity defines the default capacity of the array.
  114378. */
  114379. function SmartArray(capacity) {
  114380. /**
  114381. * The active length of the array.
  114382. */
  114383. this.length = 0;
  114384. this.data = new Array(capacity);
  114385. this._id = SmartArray._GlobalId++;
  114386. }
  114387. /**
  114388. * Pushes a value at the end of the active data.
  114389. * @param value defines the object to push in the array.
  114390. */
  114391. SmartArray.prototype.push = function (value) {
  114392. this.data[this.length++] = value;
  114393. if (this.length > this.data.length) {
  114394. this.data.length *= 2;
  114395. }
  114396. };
  114397. /**
  114398. * Iterates over the active data and apply the lambda to them.
  114399. * @param func defines the action to apply on each value.
  114400. */
  114401. SmartArray.prototype.forEach = function (func) {
  114402. for (var index = 0; index < this.length; index++) {
  114403. func(this.data[index]);
  114404. }
  114405. };
  114406. /**
  114407. * Sorts the full sets of data.
  114408. * @param compareFn defines the comparison function to apply.
  114409. */
  114410. SmartArray.prototype.sort = function (compareFn) {
  114411. this.data.sort(compareFn);
  114412. };
  114413. /**
  114414. * Resets the active data to an empty array.
  114415. */
  114416. SmartArray.prototype.reset = function () {
  114417. this.length = 0;
  114418. };
  114419. /**
  114420. * Releases all the data from the array as well as the array.
  114421. */
  114422. SmartArray.prototype.dispose = function () {
  114423. this.reset();
  114424. if (this.data) {
  114425. this.data.length = 0;
  114426. this.data = [];
  114427. }
  114428. };
  114429. /**
  114430. * Concats the active data with a given array.
  114431. * @param array defines the data to concatenate with.
  114432. */
  114433. SmartArray.prototype.concat = function (array) {
  114434. if (array.length === 0) {
  114435. return;
  114436. }
  114437. if (this.length + array.length > this.data.length) {
  114438. this.data.length = (this.length + array.length) * 2;
  114439. }
  114440. for (var index = 0; index < array.length; index++) {
  114441. this.data[this.length++] = (array.data || array)[index];
  114442. }
  114443. };
  114444. /**
  114445. * Returns the position of a value in the active data.
  114446. * @param value defines the value to find the index for
  114447. * @returns the index if found in the active data otherwise -1
  114448. */
  114449. SmartArray.prototype.indexOf = function (value) {
  114450. var position = this.data.indexOf(value);
  114451. if (position >= this.length) {
  114452. return -1;
  114453. }
  114454. return position;
  114455. };
  114456. /**
  114457. * Returns whether an element is part of the active data.
  114458. * @param value defines the value to look for
  114459. * @returns true if found in the active data otherwise false
  114460. */
  114461. SmartArray.prototype.contains = function (value) {
  114462. return this.indexOf(value) !== -1;
  114463. };
  114464. // Statics
  114465. SmartArray._GlobalId = 0;
  114466. return SmartArray;
  114467. }());
  114468. /**
  114469. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  114470. * The data in this array can only be present once
  114471. */
  114472. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  114473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  114474. function SmartArrayNoDuplicate() {
  114475. var _this = _super !== null && _super.apply(this, arguments) || this;
  114476. _this._duplicateId = 0;
  114477. return _this;
  114478. }
  114479. /**
  114480. * Pushes a value at the end of the active data.
  114481. * THIS DOES NOT PREVENT DUPPLICATE DATA
  114482. * @param value defines the object to push in the array.
  114483. */
  114484. SmartArrayNoDuplicate.prototype.push = function (value) {
  114485. _super.prototype.push.call(this, value);
  114486. if (!value.__smartArrayFlags) {
  114487. value.__smartArrayFlags = {};
  114488. }
  114489. value.__smartArrayFlags[this._id] = this._duplicateId;
  114490. };
  114491. /**
  114492. * Pushes a value at the end of the active data.
  114493. * If the data is already present, it won t be added again
  114494. * @param value defines the object to push in the array.
  114495. * @returns true if added false if it was already present
  114496. */
  114497. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  114498. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  114499. return false;
  114500. }
  114501. this.push(value);
  114502. return true;
  114503. };
  114504. /**
  114505. * Resets the active data to an empty array.
  114506. */
  114507. SmartArrayNoDuplicate.prototype.reset = function () {
  114508. _super.prototype.reset.call(this);
  114509. this._duplicateId++;
  114510. };
  114511. /**
  114512. * Concats the active data with a given array.
  114513. * This ensures no dupplicate will be present in the result.
  114514. * @param array defines the data to concatenate with.
  114515. */
  114516. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  114517. if (array.length === 0) {
  114518. return;
  114519. }
  114520. if (this.length + array.length > this.data.length) {
  114521. this.data.length = (this.length + array.length) * 2;
  114522. }
  114523. for (var index = 0; index < array.length; index++) {
  114524. var item = (array.data || array)[index];
  114525. this.pushNoDuplicate(item);
  114526. }
  114527. };
  114528. return SmartArrayNoDuplicate;
  114529. }(SmartArray));
  114530. /***/ }),
  114531. /***/ "./Misc/stringDictionary.ts":
  114532. /*!**********************************!*\
  114533. !*** ./Misc/stringDictionary.ts ***!
  114534. \**********************************/
  114535. /*! exports provided: StringDictionary */
  114536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114537. "use strict";
  114538. __webpack_require__.r(__webpack_exports__);
  114539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  114540. /**
  114541. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114542. * The underlying implementation relies on an associative array to ensure the best performances.
  114543. * The value can be anything including 'null' but except 'undefined'
  114544. */
  114545. var StringDictionary = /** @class */ (function () {
  114546. function StringDictionary() {
  114547. this._count = 0;
  114548. this._data = {};
  114549. }
  114550. /**
  114551. * This will clear this dictionary and copy the content from the 'source' one.
  114552. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114553. * @param source the dictionary to take the content from and copy to this dictionary
  114554. */
  114555. StringDictionary.prototype.copyFrom = function (source) {
  114556. var _this = this;
  114557. this.clear();
  114558. source.forEach(function (t, v) { return _this.add(t, v); });
  114559. };
  114560. /**
  114561. * Get a value based from its key
  114562. * @param key the given key to get the matching value from
  114563. * @return the value if found, otherwise undefined is returned
  114564. */
  114565. StringDictionary.prototype.get = function (key) {
  114566. var val = this._data[key];
  114567. if (val !== undefined) {
  114568. return val;
  114569. }
  114570. return undefined;
  114571. };
  114572. /**
  114573. * Get a value from its key or add it if it doesn't exist.
  114574. * This method will ensure you that a given key/data will be present in the dictionary.
  114575. * @param key the given key to get the matching value from
  114576. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114577. * The factory will only be invoked if there's no data for the given key.
  114578. * @return the value corresponding to the key.
  114579. */
  114580. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  114581. var val = this.get(key);
  114582. if (val !== undefined) {
  114583. return val;
  114584. }
  114585. val = factory(key);
  114586. if (val) {
  114587. this.add(key, val);
  114588. }
  114589. return val;
  114590. };
  114591. /**
  114592. * Get a value from its key if present in the dictionary otherwise add it
  114593. * @param key the key to get the value from
  114594. * @param val if there's no such key/value pair in the dictionary add it with this value
  114595. * @return the value corresponding to the key
  114596. */
  114597. StringDictionary.prototype.getOrAdd = function (key, val) {
  114598. var curVal = this.get(key);
  114599. if (curVal !== undefined) {
  114600. return curVal;
  114601. }
  114602. this.add(key, val);
  114603. return val;
  114604. };
  114605. /**
  114606. * Check if there's a given key in the dictionary
  114607. * @param key the key to check for
  114608. * @return true if the key is present, false otherwise
  114609. */
  114610. StringDictionary.prototype.contains = function (key) {
  114611. return this._data[key] !== undefined;
  114612. };
  114613. /**
  114614. * Add a new key and its corresponding value
  114615. * @param key the key to add
  114616. * @param value the value corresponding to the key
  114617. * @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
  114618. */
  114619. StringDictionary.prototype.add = function (key, value) {
  114620. if (this._data[key] !== undefined) {
  114621. return false;
  114622. }
  114623. this._data[key] = value;
  114624. ++this._count;
  114625. return true;
  114626. };
  114627. /**
  114628. * Update a specific value associated to a key
  114629. * @param key defines the key to use
  114630. * @param value defines the value to store
  114631. * @returns true if the value was updated (or false if the key was not found)
  114632. */
  114633. StringDictionary.prototype.set = function (key, value) {
  114634. if (this._data[key] === undefined) {
  114635. return false;
  114636. }
  114637. this._data[key] = value;
  114638. return true;
  114639. };
  114640. /**
  114641. * Get the element of the given key and remove it from the dictionary
  114642. * @param key defines the key to search
  114643. * @returns the value associated with the key or null if not found
  114644. */
  114645. StringDictionary.prototype.getAndRemove = function (key) {
  114646. var val = this.get(key);
  114647. if (val !== undefined) {
  114648. delete this._data[key];
  114649. --this._count;
  114650. return val;
  114651. }
  114652. return null;
  114653. };
  114654. /**
  114655. * Remove a key/value from the dictionary.
  114656. * @param key the key to remove
  114657. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114658. */
  114659. StringDictionary.prototype.remove = function (key) {
  114660. if (this.contains(key)) {
  114661. delete this._data[key];
  114662. --this._count;
  114663. return true;
  114664. }
  114665. return false;
  114666. };
  114667. /**
  114668. * Clear the whole content of the dictionary
  114669. */
  114670. StringDictionary.prototype.clear = function () {
  114671. this._data = {};
  114672. this._count = 0;
  114673. };
  114674. Object.defineProperty(StringDictionary.prototype, "count", {
  114675. /**
  114676. * Gets the current count
  114677. */
  114678. get: function () {
  114679. return this._count;
  114680. },
  114681. enumerable: true,
  114682. configurable: true
  114683. });
  114684. /**
  114685. * Execute a callback on each key/val of the dictionary.
  114686. * Note that you can remove any element in this dictionary in the callback implementation
  114687. * @param callback the callback to execute on a given key/value pair
  114688. */
  114689. StringDictionary.prototype.forEach = function (callback) {
  114690. for (var cur in this._data) {
  114691. var val = this._data[cur];
  114692. callback(cur, val);
  114693. }
  114694. };
  114695. /**
  114696. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  114697. * If the callback returns null or undefined the method will iterate to the next key/value pair
  114698. * Note that you can remove any element in this dictionary in the callback implementation
  114699. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  114700. * @returns the first item
  114701. */
  114702. StringDictionary.prototype.first = function (callback) {
  114703. for (var cur in this._data) {
  114704. var val = this._data[cur];
  114705. var res = callback(cur, val);
  114706. if (res) {
  114707. return res;
  114708. }
  114709. }
  114710. return null;
  114711. };
  114712. return StringDictionary;
  114713. }());
  114714. /***/ }),
  114715. /***/ "./Misc/stringTools.ts":
  114716. /*!*****************************!*\
  114717. !*** ./Misc/stringTools.ts ***!
  114718. \*****************************/
  114719. /*! exports provided: StringTools */
  114720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114721. "use strict";
  114722. __webpack_require__.r(__webpack_exports__);
  114723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringTools", function() { return StringTools; });
  114724. /**
  114725. * Helper to manipulate strings
  114726. */
  114727. var StringTools = /** @class */ (function () {
  114728. function StringTools() {
  114729. }
  114730. /**
  114731. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  114732. * @param str Source string
  114733. * @param suffix Suffix to search for in the source string
  114734. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  114735. */
  114736. StringTools.EndsWith = function (str, suffix) {
  114737. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  114738. };
  114739. /**
  114740. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  114741. * @param str Source string
  114742. * @param suffix Suffix to search for in the source string
  114743. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  114744. */
  114745. StringTools.StartsWith = function (str, suffix) {
  114746. return str.indexOf(suffix) === 0;
  114747. };
  114748. return StringTools;
  114749. }());
  114750. /***/ }),
  114751. /***/ "./Misc/tags.ts":
  114752. /*!**********************!*\
  114753. !*** ./Misc/tags.ts ***!
  114754. \**********************/
  114755. /*! exports provided: Tags */
  114756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114757. "use strict";
  114758. __webpack_require__.r(__webpack_exports__);
  114759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  114760. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  114761. /**
  114762. * Class used to store custom tags
  114763. */
  114764. var Tags = /** @class */ (function () {
  114765. function Tags() {
  114766. }
  114767. /**
  114768. * Adds support for tags on the given object
  114769. * @param obj defines the object to use
  114770. */
  114771. Tags.EnableFor = function (obj) {
  114772. obj._tags = obj._tags || {};
  114773. obj.hasTags = function () {
  114774. return Tags.HasTags(obj);
  114775. };
  114776. obj.addTags = function (tagsString) {
  114777. return Tags.AddTagsTo(obj, tagsString);
  114778. };
  114779. obj.removeTags = function (tagsString) {
  114780. return Tags.RemoveTagsFrom(obj, tagsString);
  114781. };
  114782. obj.matchesTagsQuery = function (tagsQuery) {
  114783. return Tags.MatchesQuery(obj, tagsQuery);
  114784. };
  114785. };
  114786. /**
  114787. * Removes tags support
  114788. * @param obj defines the object to use
  114789. */
  114790. Tags.DisableFor = function (obj) {
  114791. delete obj._tags;
  114792. delete obj.hasTags;
  114793. delete obj.addTags;
  114794. delete obj.removeTags;
  114795. delete obj.matchesTagsQuery;
  114796. };
  114797. /**
  114798. * Gets a boolean indicating if the given object has tags
  114799. * @param obj defines the object to use
  114800. * @returns a boolean
  114801. */
  114802. Tags.HasTags = function (obj) {
  114803. if (!obj._tags) {
  114804. return false;
  114805. }
  114806. var tags = obj._tags;
  114807. for (var i in tags) {
  114808. if (tags.hasOwnProperty(i)) {
  114809. return true;
  114810. }
  114811. }
  114812. return false;
  114813. };
  114814. /**
  114815. * Gets the tags available on a given object
  114816. * @param obj defines the object to use
  114817. * @param asString defines if the tags must be returned as a string instead of an array of strings
  114818. * @returns the tags
  114819. */
  114820. Tags.GetTags = function (obj, asString) {
  114821. if (asString === void 0) { asString = true; }
  114822. if (!obj._tags) {
  114823. return null;
  114824. }
  114825. if (asString) {
  114826. var tagsArray = [];
  114827. for (var tag in obj._tags) {
  114828. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  114829. tagsArray.push(tag);
  114830. }
  114831. }
  114832. return tagsArray.join(" ");
  114833. }
  114834. else {
  114835. return obj._tags;
  114836. }
  114837. };
  114838. /**
  114839. * Adds tags to an object
  114840. * @param obj defines the object to use
  114841. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  114842. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  114843. */
  114844. Tags.AddTagsTo = function (obj, tagsString) {
  114845. if (!tagsString) {
  114846. return;
  114847. }
  114848. if (typeof tagsString !== "string") {
  114849. return;
  114850. }
  114851. var tags = tagsString.split(" ");
  114852. tags.forEach(function (tag, index, array) {
  114853. Tags._AddTagTo(obj, tag);
  114854. });
  114855. };
  114856. /**
  114857. * @hidden
  114858. */
  114859. Tags._AddTagTo = function (obj, tag) {
  114860. tag = tag.trim();
  114861. if (tag === "" || tag === "true" || tag === "false") {
  114862. return;
  114863. }
  114864. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  114865. return;
  114866. }
  114867. Tags.EnableFor(obj);
  114868. obj._tags[tag] = true;
  114869. };
  114870. /**
  114871. * Removes specific tags from a specific object
  114872. * @param obj defines the object to use
  114873. * @param tagsString defines the tags to remove
  114874. */
  114875. Tags.RemoveTagsFrom = function (obj, tagsString) {
  114876. if (!Tags.HasTags(obj)) {
  114877. return;
  114878. }
  114879. var tags = tagsString.split(" ");
  114880. for (var t in tags) {
  114881. Tags._RemoveTagFrom(obj, tags[t]);
  114882. }
  114883. };
  114884. /**
  114885. * @hidden
  114886. */
  114887. Tags._RemoveTagFrom = function (obj, tag) {
  114888. delete obj._tags[tag];
  114889. };
  114890. /**
  114891. * Defines if tags hosted on an object match a given query
  114892. * @param obj defines the object to use
  114893. * @param tagsQuery defines the tag query
  114894. * @returns a boolean
  114895. */
  114896. Tags.MatchesQuery = function (obj, tagsQuery) {
  114897. if (tagsQuery === undefined) {
  114898. return true;
  114899. }
  114900. if (tagsQuery === "") {
  114901. return Tags.HasTags(obj);
  114902. }
  114903. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  114904. };
  114905. return Tags;
  114906. }());
  114907. /***/ }),
  114908. /***/ "./Misc/textureTools.ts":
  114909. /*!******************************!*\
  114910. !*** ./Misc/textureTools.ts ***!
  114911. \******************************/
  114912. /*! exports provided: TextureTools */
  114913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114914. "use strict";
  114915. __webpack_require__.r(__webpack_exports__);
  114916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  114917. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114918. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  114919. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114920. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  114921. /**
  114922. * Class used to host texture specific utilities
  114923. */
  114924. var TextureTools = /** @class */ (function () {
  114925. function TextureTools() {
  114926. }
  114927. /**
  114928. * Uses the GPU to create a copy texture rescaled at a given size
  114929. * @param texture Texture to copy from
  114930. * @param width defines the desired width
  114931. * @param height defines the desired height
  114932. * @param useBilinearMode defines if bilinear mode has to be used
  114933. * @return the generated texture
  114934. */
  114935. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  114936. if (useBilinearMode === void 0) { useBilinearMode = true; }
  114937. var scene = texture.getScene();
  114938. var engine = scene.getEngine();
  114939. 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);
  114940. rtt.wrapU = texture.wrapU;
  114941. rtt.wrapV = texture.wrapV;
  114942. rtt.uOffset = texture.uOffset;
  114943. rtt.vOffset = texture.vOffset;
  114944. rtt.uScale = texture.uScale;
  114945. rtt.vScale = texture.vScale;
  114946. rtt.uAng = texture.uAng;
  114947. rtt.vAng = texture.vAng;
  114948. rtt.wAng = texture.wAng;
  114949. rtt.coordinatesIndex = texture.coordinatesIndex;
  114950. rtt.level = texture.level;
  114951. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  114952. rtt._texture.isReady = false;
  114953. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  114954. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  114955. 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);
  114956. passPostProcess.getEffect().executeWhenCompiled(function () {
  114957. passPostProcess.onApply = function (effect) {
  114958. effect.setTexture("textureSampler", texture);
  114959. };
  114960. var internalTexture = rtt.getInternalTexture();
  114961. if (internalTexture) {
  114962. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  114963. engine.unBindFramebuffer(internalTexture);
  114964. rtt.disposeFramebufferObjects();
  114965. passPostProcess.dispose();
  114966. internalTexture.isReady = true;
  114967. }
  114968. });
  114969. return rtt;
  114970. };
  114971. return TextureTools;
  114972. }());
  114973. /***/ }),
  114974. /***/ "./Misc/tga.ts":
  114975. /*!*********************!*\
  114976. !*** ./Misc/tga.ts ***!
  114977. \*********************/
  114978. /*! exports provided: TGATools */
  114979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114980. "use strict";
  114981. __webpack_require__.r(__webpack_exports__);
  114982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  114983. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  114984. /**
  114985. * Based on jsTGALoader - Javascript loader for TGA file
  114986. * By Vincent Thibault
  114987. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114988. */
  114989. var TGATools = /** @class */ (function () {
  114990. function TGATools() {
  114991. }
  114992. /**
  114993. * Gets the header of a TGA file
  114994. * @param data defines the TGA data
  114995. * @returns the header
  114996. */
  114997. TGATools.GetTGAHeader = function (data) {
  114998. var offset = 0;
  114999. var header = {
  115000. id_length: data[offset++],
  115001. colormap_type: data[offset++],
  115002. image_type: data[offset++],
  115003. colormap_index: data[offset++] | data[offset++] << 8,
  115004. colormap_length: data[offset++] | data[offset++] << 8,
  115005. colormap_size: data[offset++],
  115006. origin: [
  115007. data[offset++] | data[offset++] << 8,
  115008. data[offset++] | data[offset++] << 8
  115009. ],
  115010. width: data[offset++] | data[offset++] << 8,
  115011. height: data[offset++] | data[offset++] << 8,
  115012. pixel_size: data[offset++],
  115013. flags: data[offset++]
  115014. };
  115015. return header;
  115016. };
  115017. /**
  115018. * Uploads TGA content to a Babylon Texture
  115019. * @hidden
  115020. */
  115021. TGATools.UploadContent = function (texture, data) {
  115022. // Not enough data to contain header ?
  115023. if (data.length < 19) {
  115024. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  115025. return;
  115026. }
  115027. // Read Header
  115028. var offset = 18;
  115029. var header = TGATools.GetTGAHeader(data);
  115030. // Assume it's a valid Targa file.
  115031. if (header.id_length + offset > data.length) {
  115032. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  115033. return;
  115034. }
  115035. // Skip not needed data
  115036. offset += header.id_length;
  115037. var use_rle = false;
  115038. var use_pal = false;
  115039. var use_grey = false;
  115040. // Get some informations.
  115041. switch (header.image_type) {
  115042. case TGATools._TYPE_RLE_INDEXED:
  115043. use_rle = true;
  115044. case TGATools._TYPE_INDEXED:
  115045. use_pal = true;
  115046. break;
  115047. case TGATools._TYPE_RLE_RGB:
  115048. use_rle = true;
  115049. case TGATools._TYPE_RGB:
  115050. // use_rgb = true;
  115051. break;
  115052. case TGATools._TYPE_RLE_GREY:
  115053. use_rle = true;
  115054. case TGATools._TYPE_GREY:
  115055. use_grey = true;
  115056. break;
  115057. }
  115058. var pixel_data;
  115059. // var numAlphaBits = header.flags & 0xf;
  115060. var pixel_size = header.pixel_size >> 3;
  115061. var pixel_total = header.width * header.height * pixel_size;
  115062. // Read palettes
  115063. var palettes;
  115064. if (use_pal) {
  115065. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  115066. }
  115067. // Read LRE
  115068. if (use_rle) {
  115069. pixel_data = new Uint8Array(pixel_total);
  115070. var c, count, i;
  115071. var localOffset = 0;
  115072. var pixels = new Uint8Array(pixel_size);
  115073. while (offset < pixel_total && localOffset < pixel_total) {
  115074. c = data[offset++];
  115075. count = (c & 0x7f) + 1;
  115076. // RLE pixels
  115077. if (c & 0x80) {
  115078. // Bind pixel tmp array
  115079. for (i = 0; i < pixel_size; ++i) {
  115080. pixels[i] = data[offset++];
  115081. }
  115082. // Copy pixel array
  115083. for (i = 0; i < count; ++i) {
  115084. pixel_data.set(pixels, localOffset + i * pixel_size);
  115085. }
  115086. localOffset += pixel_size * count;
  115087. }
  115088. // Raw pixels
  115089. else {
  115090. count *= pixel_size;
  115091. for (i = 0; i < count; ++i) {
  115092. pixel_data[localOffset + i] = data[offset++];
  115093. }
  115094. localOffset += count;
  115095. }
  115096. }
  115097. }
  115098. // RAW Pixels
  115099. else {
  115100. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  115101. }
  115102. // Load to texture
  115103. var x_start, y_start, x_step, y_step, y_end, x_end;
  115104. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  115105. default:
  115106. case TGATools._ORIGIN_UL:
  115107. x_start = 0;
  115108. x_step = 1;
  115109. x_end = header.width;
  115110. y_start = 0;
  115111. y_step = 1;
  115112. y_end = header.height;
  115113. break;
  115114. case TGATools._ORIGIN_BL:
  115115. x_start = 0;
  115116. x_step = 1;
  115117. x_end = header.width;
  115118. y_start = header.height - 1;
  115119. y_step = -1;
  115120. y_end = -1;
  115121. break;
  115122. case TGATools._ORIGIN_UR:
  115123. x_start = header.width - 1;
  115124. x_step = -1;
  115125. x_end = -1;
  115126. y_start = 0;
  115127. y_step = 1;
  115128. y_end = header.height;
  115129. break;
  115130. case TGATools._ORIGIN_BR:
  115131. x_start = header.width - 1;
  115132. x_step = -1;
  115133. x_end = -1;
  115134. y_start = header.height - 1;
  115135. y_step = -1;
  115136. y_end = -1;
  115137. break;
  115138. }
  115139. // Load the specify method
  115140. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  115141. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  115142. var engine = texture.getEngine();
  115143. engine._uploadDataToTextureDirectly(texture, imageData);
  115144. };
  115145. /** @hidden */
  115146. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  115147. var image = pixel_data, colormap = palettes;
  115148. var width = header.width, height = header.height;
  115149. var color, i = 0, x, y;
  115150. var imageData = new Uint8Array(width * height * 4);
  115151. for (y = y_start; y !== y_end; y += y_step) {
  115152. for (x = x_start; x !== x_end; x += x_step, i++) {
  115153. color = image[i];
  115154. imageData[(x + width * y) * 4 + 3] = 255;
  115155. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  115156. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  115157. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  115158. }
  115159. }
  115160. return imageData;
  115161. };
  115162. /** @hidden */
  115163. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  115164. var image = pixel_data;
  115165. var width = header.width, height = header.height;
  115166. var color, i = 0, x, y;
  115167. var imageData = new Uint8Array(width * height * 4);
  115168. for (y = y_start; y !== y_end; y += y_step) {
  115169. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  115170. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  115171. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  115172. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  115173. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  115174. imageData[(x + width * y) * 4 + 0] = r;
  115175. imageData[(x + width * y) * 4 + 1] = g;
  115176. imageData[(x + width * y) * 4 + 2] = b;
  115177. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  115178. }
  115179. }
  115180. return imageData;
  115181. };
  115182. /** @hidden */
  115183. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  115184. var image = pixel_data;
  115185. var width = header.width, height = header.height;
  115186. var i = 0, x, y;
  115187. var imageData = new Uint8Array(width * height * 4);
  115188. for (y = y_start; y !== y_end; y += y_step) {
  115189. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  115190. imageData[(x + width * y) * 4 + 3] = 255;
  115191. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  115192. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  115193. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  115194. }
  115195. }
  115196. return imageData;
  115197. };
  115198. /** @hidden */
  115199. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  115200. var image = pixel_data;
  115201. var width = header.width, height = header.height;
  115202. var i = 0, x, y;
  115203. var imageData = new Uint8Array(width * height * 4);
  115204. for (y = y_start; y !== y_end; y += y_step) {
  115205. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  115206. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  115207. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  115208. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  115209. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  115210. }
  115211. }
  115212. return imageData;
  115213. };
  115214. /** @hidden */
  115215. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  115216. var image = pixel_data;
  115217. var width = header.width, height = header.height;
  115218. var color, i = 0, x, y;
  115219. var imageData = new Uint8Array(width * height * 4);
  115220. for (y = y_start; y !== y_end; y += y_step) {
  115221. for (x = x_start; x !== x_end; x += x_step, i++) {
  115222. color = image[i];
  115223. imageData[(x + width * y) * 4 + 0] = color;
  115224. imageData[(x + width * y) * 4 + 1] = color;
  115225. imageData[(x + width * y) * 4 + 2] = color;
  115226. imageData[(x + width * y) * 4 + 3] = 255;
  115227. }
  115228. }
  115229. return imageData;
  115230. };
  115231. /** @hidden */
  115232. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  115233. var image = pixel_data;
  115234. var width = header.width, height = header.height;
  115235. var i = 0, x, y;
  115236. var imageData = new Uint8Array(width * height * 4);
  115237. for (y = y_start; y !== y_end; y += y_step) {
  115238. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  115239. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  115240. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  115241. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  115242. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  115243. }
  115244. }
  115245. return imageData;
  115246. };
  115247. //private static _TYPE_NO_DATA = 0;
  115248. TGATools._TYPE_INDEXED = 1;
  115249. TGATools._TYPE_RGB = 2;
  115250. TGATools._TYPE_GREY = 3;
  115251. TGATools._TYPE_RLE_INDEXED = 9;
  115252. TGATools._TYPE_RLE_RGB = 10;
  115253. TGATools._TYPE_RLE_GREY = 11;
  115254. TGATools._ORIGIN_MASK = 0x30;
  115255. TGATools._ORIGIN_SHIFT = 0x04;
  115256. TGATools._ORIGIN_BL = 0x00;
  115257. TGATools._ORIGIN_BR = 0x01;
  115258. TGATools._ORIGIN_UL = 0x02;
  115259. TGATools._ORIGIN_UR = 0x03;
  115260. return TGATools;
  115261. }());
  115262. /***/ }),
  115263. /***/ "./Misc/timingTools.ts":
  115264. /*!*****************************!*\
  115265. !*** ./Misc/timingTools.ts ***!
  115266. \*****************************/
  115267. /*! exports provided: TimingTools */
  115268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115269. "use strict";
  115270. __webpack_require__.r(__webpack_exports__);
  115271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TimingTools", function() { return TimingTools; });
  115272. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  115273. /**
  115274. * Class used to provide helper for timing
  115275. */
  115276. var TimingTools = /** @class */ (function () {
  115277. function TimingTools() {
  115278. }
  115279. /**
  115280. * Polyfill for setImmediate
  115281. * @param action defines the action to execute after the current execution block
  115282. */
  115283. TimingTools.SetImmediate = function (action) {
  115284. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  115285. window.setImmediate(action);
  115286. }
  115287. else {
  115288. setTimeout(action, 1);
  115289. }
  115290. };
  115291. return TimingTools;
  115292. }());
  115293. /***/ }),
  115294. /***/ "./Misc/tools.ts":
  115295. /*!***********************!*\
  115296. !*** ./Misc/tools.ts ***!
  115297. \***********************/
  115298. /*! exports provided: Tools, className, AsyncLoop */
  115299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115300. "use strict";
  115301. __webpack_require__.r(__webpack_exports__);
  115302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  115303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  115304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  115305. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  115306. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  115307. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  115308. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  115309. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  115310. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  115311. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  115312. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  115313. /* harmony import */ var _fileTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./fileTools */ "./Misc/fileTools.ts");
  115314. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  115315. /* harmony import */ var _timingTools__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./timingTools */ "./Misc/timingTools.ts");
  115316. /* harmony import */ var _instantiationTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./instantiationTools */ "./Misc/instantiationTools.ts");
  115317. /* harmony import */ var _guid__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./guid */ "./Misc/guid.ts");
  115318. /**
  115319. * Class containing a set of static utilities functions
  115320. */
  115321. var Tools = /** @class */ (function () {
  115322. function Tools() {
  115323. }
  115324. Object.defineProperty(Tools, "BaseUrl", {
  115325. /**
  115326. * Gets or sets the base URL to use to load assets
  115327. */
  115328. get: function () {
  115329. return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].BaseUrl;
  115330. },
  115331. set: function (value) {
  115332. _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].BaseUrl = value;
  115333. },
  115334. enumerable: true,
  115335. configurable: true
  115336. });
  115337. Object.defineProperty(Tools, "DefaultRetryStrategy", {
  115338. /**
  115339. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115340. */
  115341. get: function () {
  115342. return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].DefaultRetryStrategy;
  115343. },
  115344. set: function (strategy) {
  115345. _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].DefaultRetryStrategy = strategy;
  115346. },
  115347. enumerable: true,
  115348. configurable: true
  115349. });
  115350. Object.defineProperty(Tools, "UseFallbackTexture", {
  115351. /**
  115352. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115353. * @ignorenaming
  115354. */
  115355. get: function () {
  115356. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_7__["EngineStore"].UseFallbackTexture;
  115357. },
  115358. set: function (value) {
  115359. _Engines_engineStore__WEBPACK_IMPORTED_MODULE_7__["EngineStore"].UseFallbackTexture = value;
  115360. },
  115361. enumerable: true,
  115362. configurable: true
  115363. });
  115364. Object.defineProperty(Tools, "RegisteredExternalClasses", {
  115365. /**
  115366. * Use this object to register external classes like custom textures or material
  115367. * to allow the laoders to instantiate them
  115368. */
  115369. get: function () {
  115370. return _instantiationTools__WEBPACK_IMPORTED_MODULE_11__["InstantiationTools"].RegisteredExternalClasses;
  115371. },
  115372. set: function (classes) {
  115373. _instantiationTools__WEBPACK_IMPORTED_MODULE_11__["InstantiationTools"].RegisteredExternalClasses = classes;
  115374. },
  115375. enumerable: true,
  115376. configurable: true
  115377. });
  115378. Object.defineProperty(Tools, "fallbackTexture", {
  115379. /**
  115380. * Texture content used if a texture cannot loaded
  115381. * @ignorenaming
  115382. */
  115383. get: function () {
  115384. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_7__["EngineStore"].FallbackTexture;
  115385. },
  115386. set: function (value) {
  115387. _Engines_engineStore__WEBPACK_IMPORTED_MODULE_7__["EngineStore"].FallbackTexture = value;
  115388. },
  115389. enumerable: true,
  115390. configurable: true
  115391. });
  115392. /**
  115393. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115394. * @param u defines the coordinate on X axis
  115395. * @param v defines the coordinate on Y axis
  115396. * @param width defines the width of the source data
  115397. * @param height defines the height of the source data
  115398. * @param pixels defines the source byte array
  115399. * @param color defines the output color
  115400. */
  115401. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  115402. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  115403. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  115404. var position = (wrappedU + wrappedV * width) * 4;
  115405. color.r = pixels[position] / 255;
  115406. color.g = pixels[position + 1] / 255;
  115407. color.b = pixels[position + 2] / 255;
  115408. color.a = pixels[position + 3] / 255;
  115409. };
  115410. /**
  115411. * Interpolates between a and b via alpha
  115412. * @param a The lower value (returned when alpha = 0)
  115413. * @param b The upper value (returned when alpha = 1)
  115414. * @param alpha The interpolation-factor
  115415. * @return The mixed value
  115416. */
  115417. Tools.Mix = function (a, b, alpha) {
  115418. return a * (1 - alpha) + b * alpha;
  115419. };
  115420. /**
  115421. * Tries to instantiate a new object from a given class name
  115422. * @param className defines the class name to instantiate
  115423. * @returns the new object or null if the system was not able to do the instantiation
  115424. */
  115425. Tools.Instantiate = function (className) {
  115426. return _instantiationTools__WEBPACK_IMPORTED_MODULE_11__["InstantiationTools"].Instantiate(className);
  115427. };
  115428. /**
  115429. * Provides a slice function that will work even on IE
  115430. * @param data defines the array to slice
  115431. * @param start defines the start of the data (optional)
  115432. * @param end defines the end of the data (optional)
  115433. * @returns the new sliced array
  115434. */
  115435. Tools.Slice = function (data, start, end) {
  115436. if (data.slice) {
  115437. return data.slice(start, end);
  115438. }
  115439. return Array.prototype.slice.call(data, start, end);
  115440. };
  115441. /**
  115442. * Polyfill for setImmediate
  115443. * @param action defines the action to execute after the current execution block
  115444. */
  115445. Tools.SetImmediate = function (action) {
  115446. _timingTools__WEBPACK_IMPORTED_MODULE_10__["TimingTools"].SetImmediate(action);
  115447. };
  115448. /**
  115449. * Function indicating if a number is an exponent of 2
  115450. * @param value defines the value to test
  115451. * @returns true if the value is an exponent of 2
  115452. */
  115453. Tools.IsExponentOfTwo = function (value) {
  115454. var count = 1;
  115455. do {
  115456. count *= 2;
  115457. } while (count < value);
  115458. return count === value;
  115459. };
  115460. /**
  115461. * Returns the nearest 32-bit single precision float representation of a Number
  115462. * @param value A Number. If the parameter is of a different type, it will get converted
  115463. * to a number or to NaN if it cannot be converted
  115464. * @returns number
  115465. */
  115466. Tools.FloatRound = function (value) {
  115467. if (Math.fround) {
  115468. return Math.fround(value);
  115469. }
  115470. return (Tools._tmpFloatArray[0] = value);
  115471. };
  115472. /**
  115473. * Extracts the filename from a path
  115474. * @param path defines the path to use
  115475. * @returns the filename
  115476. */
  115477. Tools.GetFilename = function (path) {
  115478. var index = path.lastIndexOf("/");
  115479. if (index < 0) {
  115480. return path;
  115481. }
  115482. return path.substring(index + 1);
  115483. };
  115484. /**
  115485. * Extracts the "folder" part of a path (everything before the filename).
  115486. * @param uri The URI to extract the info from
  115487. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115488. * @returns The "folder" part of the path
  115489. */
  115490. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  115491. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  115492. var index = uri.lastIndexOf("/");
  115493. if (index < 0) {
  115494. if (returnUnchangedIfNoSlash) {
  115495. return uri;
  115496. }
  115497. return "";
  115498. }
  115499. return uri.substring(0, index + 1);
  115500. };
  115501. /**
  115502. * Convert an angle in radians to degrees
  115503. * @param angle defines the angle to convert
  115504. * @returns the angle in degrees
  115505. */
  115506. Tools.ToDegrees = function (angle) {
  115507. return angle * 180 / Math.PI;
  115508. };
  115509. /**
  115510. * Convert an angle in degrees to radians
  115511. * @param angle defines the angle to convert
  115512. * @returns the angle in radians
  115513. */
  115514. Tools.ToRadians = function (angle) {
  115515. return angle * Math.PI / 180;
  115516. };
  115517. /**
  115518. * Encode a buffer to a base64 string
  115519. * @param buffer defines the buffer to encode
  115520. * @returns the encoded string
  115521. */
  115522. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  115523. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  115524. var output = "";
  115525. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  115526. var i = 0;
  115527. var bytes = new Uint8Array(buffer);
  115528. while (i < bytes.length) {
  115529. chr1 = bytes[i++];
  115530. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  115531. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  115532. enc1 = chr1 >> 2;
  115533. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  115534. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  115535. enc4 = chr3 & 63;
  115536. if (isNaN(chr2)) {
  115537. enc3 = enc4 = 64;
  115538. }
  115539. else if (isNaN(chr3)) {
  115540. enc4 = 64;
  115541. }
  115542. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  115543. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  115544. }
  115545. return "data:image/png;base64," + output;
  115546. };
  115547. /**
  115548. * Returns an array if obj is not an array
  115549. * @param obj defines the object to evaluate as an array
  115550. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115551. * @returns either obj directly if obj is an array or a new array containing obj
  115552. */
  115553. Tools.MakeArray = function (obj, allowsNullUndefined) {
  115554. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  115555. return null;
  115556. }
  115557. return Array.isArray(obj) ? obj : [obj];
  115558. };
  115559. /**
  115560. * Gets the pointer prefix to use
  115561. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115562. */
  115563. Tools.GetPointerPrefix = function () {
  115564. var eventPrefix = "pointer";
  115565. // Check if pointer events are supported
  115566. if (_domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  115567. eventPrefix = "mouse";
  115568. }
  115569. return eventPrefix;
  115570. };
  115571. /**
  115572. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115573. * @param url define the url we are trying
  115574. * @param element define the dom element where to configure the cors policy
  115575. */
  115576. Tools.SetCorsBehavior = function (url, element) {
  115577. _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].SetCorsBehavior(url, element);
  115578. };
  115579. // External files
  115580. /**
  115581. * Removes unwanted characters from an url
  115582. * @param url defines the url to clean
  115583. * @returns the cleaned url
  115584. */
  115585. Tools.CleanUrl = function (url) {
  115586. url = url.replace(/#/mg, "%23");
  115587. return url;
  115588. };
  115589. Object.defineProperty(Tools, "PreprocessUrl", {
  115590. /**
  115591. * Gets or sets a function used to pre-process url before using them to load assets
  115592. */
  115593. get: function () {
  115594. return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].PreprocessUrl;
  115595. },
  115596. set: function (processor) {
  115597. _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].PreprocessUrl = processor;
  115598. },
  115599. enumerable: true,
  115600. configurable: true
  115601. });
  115602. /**
  115603. * Loads an image as an HTMLImageElement.
  115604. * @param input url string, ArrayBuffer, or Blob to load
  115605. * @param onLoad callback called when the image successfully loads
  115606. * @param onError callback called when the image fails to load
  115607. * @param offlineProvider offline provider for caching
  115608. * @returns the HTMLImageElement of the loaded image
  115609. */
  115610. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  115611. return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].LoadImage(input, onLoad, onError, offlineProvider);
  115612. };
  115613. /**
  115614. * Loads a file
  115615. * @param url url string, ArrayBuffer, or Blob to load
  115616. * @param onSuccess callback called when the file successfully loads
  115617. * @param onProgress callback called while file is loading (if the server supports this mode)
  115618. * @param offlineProvider defines the offline provider for caching
  115619. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115620. * @param onError callback called when the file fails to load
  115621. * @returns a file request object
  115622. */
  115623. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  115624. return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  115625. };
  115626. /**
  115627. * Loads a file from a url
  115628. * @param url the file url to load
  115629. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  115630. */
  115631. Tools.LoadFileAsync = function (url) {
  115632. return new Promise(function (resolve, reject) {
  115633. _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].LoadFile(url, function (data) {
  115634. resolve(data);
  115635. }, undefined, undefined, true, function (request, exception) {
  115636. reject(exception);
  115637. });
  115638. });
  115639. };
  115640. /**
  115641. * Load a script (identified by an url). When the url returns, the
  115642. * content of this file is added into a new script element, attached to the DOM (body element)
  115643. * @param scriptUrl defines the url of the script to laod
  115644. * @param onSuccess defines the callback called when the script is loaded
  115645. * @param onError defines the callback to call if an error occurs
  115646. * @param scriptId defines the id of the script element
  115647. */
  115648. Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
  115649. if (!_domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].IsWindowObjectExist()) {
  115650. return;
  115651. }
  115652. var head = document.getElementsByTagName('head')[0];
  115653. var script = document.createElement('script');
  115654. script.setAttribute('type', 'text/javascript');
  115655. script.setAttribute('src', scriptUrl);
  115656. if (scriptId) {
  115657. script.id = scriptId;
  115658. }
  115659. script.onload = function () {
  115660. if (onSuccess) {
  115661. onSuccess();
  115662. }
  115663. };
  115664. script.onerror = function (e) {
  115665. if (onError) {
  115666. onError("Unable to load script '" + scriptUrl + "'", e);
  115667. }
  115668. };
  115669. head.appendChild(script);
  115670. };
  115671. /**
  115672. * Load an asynchronous script (identified by an url). When the url returns, the
  115673. * content of this file is added into a new script element, attached to the DOM (body element)
  115674. * @param scriptUrl defines the url of the script to laod
  115675. * @param scriptId defines the id of the script element
  115676. * @returns a promise request object
  115677. */
  115678. Tools.LoadScriptAsync = function (scriptUrl, scriptId) {
  115679. return new Promise(function (resolve, reject) {
  115680. if (!_domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].IsWindowObjectExist()) {
  115681. resolve(false);
  115682. return;
  115683. }
  115684. var head = document.getElementsByTagName('head')[0];
  115685. var script = document.createElement('script');
  115686. script.setAttribute('type', 'text/javascript');
  115687. script.setAttribute('src', scriptUrl);
  115688. if (scriptId) {
  115689. script.id = scriptId;
  115690. }
  115691. script.onload = function () {
  115692. resolve(true);
  115693. };
  115694. script.onerror = function (e) {
  115695. resolve(false);
  115696. };
  115697. head.appendChild(script);
  115698. });
  115699. };
  115700. /**
  115701. * Loads a file from a blob
  115702. * @param fileToLoad defines the blob to use
  115703. * @param callback defines the callback to call when data is loaded
  115704. * @param progressCallback defines the callback to call during loading process
  115705. * @returns a file request object
  115706. */
  115707. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  115708. var reader = new FileReader();
  115709. var request = {
  115710. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_0__["Observable"](),
  115711. abort: function () { return reader.abort(); },
  115712. };
  115713. reader.onloadend = function (e) {
  115714. request.onCompleteObservable.notifyObservers(request);
  115715. };
  115716. reader.onload = function (e) {
  115717. //target doesn't have result from ts 1.3
  115718. callback(e.target['result']);
  115719. };
  115720. reader.onprogress = progressCallback;
  115721. reader.readAsDataURL(fileToLoad);
  115722. return request;
  115723. };
  115724. /**
  115725. * Loads a file
  115726. * @param fileToLoad defines the file to load
  115727. * @param callback defines the callback to call when data is loaded
  115728. * @param progressCallBack defines the callback to call during loading process
  115729. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115730. * @returns a file request object
  115731. */
  115732. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  115733. return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].ReadFile(fileToLoad, callback, progressCallBack, useArrayBuffer);
  115734. };
  115735. /**
  115736. * Creates a data url from a given string content
  115737. * @param content defines the content to convert
  115738. * @returns the new data url link
  115739. */
  115740. Tools.FileAsURL = function (content) {
  115741. var fileBlob = new Blob([content]);
  115742. var url = window.URL || window.webkitURL;
  115743. var link = url.createObjectURL(fileBlob);
  115744. return link;
  115745. };
  115746. /**
  115747. * Format the given number to a specific decimal format
  115748. * @param value defines the number to format
  115749. * @param decimals defines the number of decimals to use
  115750. * @returns the formatted string
  115751. */
  115752. Tools.Format = function (value, decimals) {
  115753. if (decimals === void 0) { decimals = 2; }
  115754. return value.toFixed(decimals);
  115755. };
  115756. /**
  115757. * Tries to copy an object by duplicating every property
  115758. * @param source defines the source object
  115759. * @param destination defines the target object
  115760. * @param doNotCopyList defines a list of properties to avoid
  115761. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115762. */
  115763. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  115764. _deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  115765. };
  115766. /**
  115767. * Gets a boolean indicating if the given object has no own property
  115768. * @param obj defines the object to test
  115769. * @returns true if object has no own property
  115770. */
  115771. Tools.IsEmpty = function (obj) {
  115772. for (var i in obj) {
  115773. if (obj.hasOwnProperty(i)) {
  115774. return false;
  115775. }
  115776. }
  115777. return true;
  115778. };
  115779. /**
  115780. * Function used to register events at window level
  115781. * @param events defines the events to register
  115782. */
  115783. Tools.RegisterTopRootEvents = function (events) {
  115784. for (var index = 0; index < events.length; index++) {
  115785. var event = events[index];
  115786. window.addEventListener(event.name, event.handler, false);
  115787. try {
  115788. if (window.parent) {
  115789. window.parent.addEventListener(event.name, event.handler, false);
  115790. }
  115791. }
  115792. catch (e) {
  115793. // Silently fails...
  115794. }
  115795. }
  115796. };
  115797. /**
  115798. * Function used to unregister events from window level
  115799. * @param events defines the events to unregister
  115800. */
  115801. Tools.UnregisterTopRootEvents = function (events) {
  115802. for (var index = 0; index < events.length; index++) {
  115803. var event = events[index];
  115804. window.removeEventListener(event.name, event.handler);
  115805. try {
  115806. if (window.parent) {
  115807. window.parent.removeEventListener(event.name, event.handler);
  115808. }
  115809. }
  115810. catch (e) {
  115811. // Silently fails...
  115812. }
  115813. }
  115814. };
  115815. /**
  115816. * Dumps the current bound framebuffer
  115817. * @param width defines the rendering width
  115818. * @param height defines the rendering height
  115819. * @param engine defines the hosting engine
  115820. * @param successCallback defines the callback triggered once the data are available
  115821. * @param mimeType defines the mime type of the result
  115822. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115823. */
  115824. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  115825. if (mimeType === void 0) { mimeType = "image/png"; }
  115826. // Read the contents of the framebuffer
  115827. var numberOfChannelsByLine = width * 4;
  115828. var halfHeight = height / 2;
  115829. //Reading datas from WebGL
  115830. var data = engine.readPixels(0, 0, width, height);
  115831. //To flip image on Y axis.
  115832. for (var i = 0; i < halfHeight; i++) {
  115833. for (var j = 0; j < numberOfChannelsByLine; j++) {
  115834. var currentCell = j + i * numberOfChannelsByLine;
  115835. var targetLine = height - i - 1;
  115836. var targetCell = j + targetLine * numberOfChannelsByLine;
  115837. var temp = data[currentCell];
  115838. data[currentCell] = data[targetCell];
  115839. data[targetCell] = temp;
  115840. }
  115841. }
  115842. // Create a 2D canvas to store the result
  115843. if (!Tools._ScreenshotCanvas) {
  115844. Tools._ScreenshotCanvas = document.createElement('canvas');
  115845. }
  115846. Tools._ScreenshotCanvas.width = width;
  115847. Tools._ScreenshotCanvas.height = height;
  115848. var context = Tools._ScreenshotCanvas.getContext('2d');
  115849. if (context) {
  115850. // Copy the pixels to a 2D canvas
  115851. var imageData = context.createImageData(width, height);
  115852. var castData = (imageData.data);
  115853. castData.set(data);
  115854. context.putImageData(imageData, 0, 0);
  115855. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  115856. }
  115857. };
  115858. /**
  115859. * Converts the canvas data to blob.
  115860. * This acts as a polyfill for browsers not supporting the to blob function.
  115861. * @param canvas Defines the canvas to extract the data from
  115862. * @param successCallback Defines the callback triggered once the data are available
  115863. * @param mimeType Defines the mime type of the result
  115864. */
  115865. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  115866. if (mimeType === void 0) { mimeType = "image/png"; }
  115867. // We need HTMLCanvasElement.toBlob for HD screenshots
  115868. if (!canvas.toBlob) {
  115869. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  115870. canvas.toBlob = function (callback, type, quality) {
  115871. var _this = this;
  115872. setTimeout(function () {
  115873. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  115874. for (var i = 0; i < len; i++) {
  115875. arr[i] = binStr.charCodeAt(i);
  115876. }
  115877. callback(new Blob([arr]));
  115878. });
  115879. };
  115880. }
  115881. canvas.toBlob(function (blob) {
  115882. successCallback(blob);
  115883. }, mimeType);
  115884. };
  115885. /**
  115886. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115887. * @param successCallback defines the callback triggered once the data are available
  115888. * @param mimeType defines the mime type of the result
  115889. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115890. */
  115891. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  115892. if (mimeType === void 0) { mimeType = "image/png"; }
  115893. if (successCallback) {
  115894. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  115895. successCallback(base64Image);
  115896. }
  115897. else {
  115898. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  115899. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  115900. if (("download" in document.createElement("a"))) {
  115901. if (!fileName) {
  115902. var date = new Date();
  115903. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  115904. fileName = "screenshot_" + stringDate + ".png";
  115905. }
  115906. Tools.Download(blob, fileName);
  115907. }
  115908. else {
  115909. var url = URL.createObjectURL(blob);
  115910. var newWindow = window.open("");
  115911. if (!newWindow) {
  115912. return;
  115913. }
  115914. var img = newWindow.document.createElement("img");
  115915. img.onload = function () {
  115916. // no longer need to read the blob so it's revoked
  115917. URL.revokeObjectURL(url);
  115918. };
  115919. img.src = url;
  115920. newWindow.document.body.appendChild(img);
  115921. }
  115922. }, mimeType);
  115923. }
  115924. };
  115925. /**
  115926. * Downloads a blob in the browser
  115927. * @param blob defines the blob to download
  115928. * @param fileName defines the name of the downloaded file
  115929. */
  115930. Tools.Download = function (blob, fileName) {
  115931. if (navigator && navigator.msSaveBlob) {
  115932. navigator.msSaveBlob(blob, fileName);
  115933. return;
  115934. }
  115935. var url = window.URL.createObjectURL(blob);
  115936. var a = document.createElement("a");
  115937. document.body.appendChild(a);
  115938. a.style.display = "none";
  115939. a.href = url;
  115940. a.download = fileName;
  115941. a.addEventListener("click", function () {
  115942. if (a.parentElement) {
  115943. a.parentElement.removeChild(a);
  115944. }
  115945. });
  115946. a.click();
  115947. window.URL.revokeObjectURL(url);
  115948. };
  115949. /**
  115950. * Captures a screenshot of the current rendering
  115951. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115952. * @param engine defines the rendering engine
  115953. * @param camera defines the source camera
  115954. * @param size This parameter can be set to a single number or to an object with the
  115955. * following (optional) properties: precision, width, height. If a single number is passed,
  115956. * it will be used for both width and height. If an object is passed, the screenshot size
  115957. * will be derived from the parameters. The precision property is a multiplier allowing
  115958. * rendering at a higher or lower resolution
  115959. * @param successCallback defines the callback receives a single parameter which contains the
  115960. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115961. * src parameter of an <img> to display it
  115962. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115963. * Check your browser for supported MIME types
  115964. */
  115965. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  115966. if (mimeType === void 0) { mimeType = "image/png"; }
  115967. throw _devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("ScreenshotTools");
  115968. };
  115969. /**
  115970. * Captures a screenshot of the current rendering
  115971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115972. * @param engine defines the rendering engine
  115973. * @param camera defines the source camera
  115974. * @param size This parameter can be set to a single number or to an object with the
  115975. * following (optional) properties: precision, width, height. If a single number is passed,
  115976. * it will be used for both width and height. If an object is passed, the screenshot size
  115977. * will be derived from the parameters. The precision property is a multiplier allowing
  115978. * rendering at a higher or lower resolution
  115979. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115980. * Check your browser for supported MIME types
  115981. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115982. * to the src parameter of an <img> to display it
  115983. */
  115984. Tools.CreateScreenshotAsync = function (engine, camera, size, mimeType) {
  115985. if (mimeType === void 0) { mimeType = "image/png"; }
  115986. throw _devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("ScreenshotTools");
  115987. };
  115988. /**
  115989. * Generates an image screenshot from the specified camera.
  115990. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115991. * @param engine The engine to use for rendering
  115992. * @param camera The camera to use for rendering
  115993. * @param size This parameter can be set to a single number or to an object with the
  115994. * following (optional) properties: precision, width, height. If a single number is passed,
  115995. * it will be used for both width and height. If an object is passed, the screenshot size
  115996. * will be derived from the parameters. The precision property is a multiplier allowing
  115997. * rendering at a higher or lower resolution
  115998. * @param successCallback The callback receives a single parameter which contains the
  115999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116000. * src parameter of an <img> to display it
  116001. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116002. * Check your browser for supported MIME types
  116003. * @param samples Texture samples (default: 1)
  116004. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116005. * @param fileName A name for for the downloaded file.
  116006. */
  116007. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  116008. if (mimeType === void 0) { mimeType = "image/png"; }
  116009. if (samples === void 0) { samples = 1; }
  116010. if (antialiasing === void 0) { antialiasing = false; }
  116011. throw _devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("ScreenshotTools");
  116012. };
  116013. /**
  116014. * Generates an image screenshot from the specified camera.
  116015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116016. * @param engine The engine to use for rendering
  116017. * @param camera The camera to use for rendering
  116018. * @param size This parameter can be set to a single number or to an object with the
  116019. * following (optional) properties: precision, width, height. If a single number is passed,
  116020. * it will be used for both width and height. If an object is passed, the screenshot size
  116021. * will be derived from the parameters. The precision property is a multiplier allowing
  116022. * rendering at a higher or lower resolution
  116023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116024. * Check your browser for supported MIME types
  116025. * @param samples Texture samples (default: 1)
  116026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116027. * @param fileName A name for for the downloaded file.
  116028. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116029. * to the src parameter of an <img> to display it
  116030. */
  116031. Tools.CreateScreenshotUsingRenderTargetAsync = function (engine, camera, size, mimeType, samples, antialiasing, fileName) {
  116032. if (mimeType === void 0) { mimeType = "image/png"; }
  116033. if (samples === void 0) { samples = 1; }
  116034. if (antialiasing === void 0) { antialiasing = false; }
  116035. throw _devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("ScreenshotTools");
  116036. };
  116037. /**
  116038. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  116039. * Be aware Math.random() could cause collisions, but:
  116040. * "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"
  116041. * @returns a pseudo random id
  116042. */
  116043. Tools.RandomId = function () {
  116044. return _guid__WEBPACK_IMPORTED_MODULE_12__["GUID"].RandomId();
  116045. };
  116046. /**
  116047. * Test if the given uri is a base64 string
  116048. * @param uri The uri to test
  116049. * @return True if the uri is a base64 string or false otherwise
  116050. */
  116051. Tools.IsBase64 = function (uri) {
  116052. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  116053. };
  116054. /**
  116055. * Decode the given base64 uri.
  116056. * @param uri The uri to decode
  116057. * @return The decoded base64 data.
  116058. */
  116059. Tools.DecodeBase64 = function (uri) {
  116060. var decodedString = atob(uri.split(",")[1]);
  116061. var bufferLength = decodedString.length;
  116062. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  116063. for (var i = 0; i < bufferLength; i++) {
  116064. bufferView[i] = decodedString.charCodeAt(i);
  116065. }
  116066. return bufferView.buffer;
  116067. };
  116068. /**
  116069. * Gets the absolute url.
  116070. * @param url the input url
  116071. * @return the absolute url
  116072. */
  116073. Tools.GetAbsoluteUrl = function (url) {
  116074. var a = document.createElement("a");
  116075. a.href = url;
  116076. return a.href;
  116077. };
  116078. Object.defineProperty(Tools, "errorsCount", {
  116079. /**
  116080. * Gets a value indicating the number of loading errors
  116081. * @ignorenaming
  116082. */
  116083. get: function () {
  116084. return _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].errorsCount;
  116085. },
  116086. enumerable: true,
  116087. configurable: true
  116088. });
  116089. /**
  116090. * Log a message to the console
  116091. * @param message defines the message to log
  116092. */
  116093. Tools.Log = function (message) {
  116094. _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log(message);
  116095. };
  116096. /**
  116097. * Write a warning message to the console
  116098. * @param message defines the message to log
  116099. */
  116100. Tools.Warn = function (message) {
  116101. _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn(message);
  116102. };
  116103. /**
  116104. * Write an error message to the console
  116105. * @param message defines the message to log
  116106. */
  116107. Tools.Error = function (message) {
  116108. _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error(message);
  116109. };
  116110. Object.defineProperty(Tools, "LogCache", {
  116111. /**
  116112. * Gets current log cache (list of logs)
  116113. */
  116114. get: function () {
  116115. return _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].LogCache;
  116116. },
  116117. enumerable: true,
  116118. configurable: true
  116119. });
  116120. /**
  116121. * Clears the log cache
  116122. */
  116123. Tools.ClearLogCache = function () {
  116124. _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].ClearLogCache();
  116125. };
  116126. Object.defineProperty(Tools, "LogLevels", {
  116127. /**
  116128. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  116129. */
  116130. set: function (level) {
  116131. _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].LogLevels = level;
  116132. },
  116133. enumerable: true,
  116134. configurable: true
  116135. });
  116136. Object.defineProperty(Tools, "PerformanceLogLevel", {
  116137. /**
  116138. * Sets the current performance log level
  116139. */
  116140. set: function (level) {
  116141. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  116142. Tools.StartPerformanceCounter = Tools._StartUserMark;
  116143. Tools.EndPerformanceCounter = Tools._EndUserMark;
  116144. return;
  116145. }
  116146. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  116147. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  116148. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  116149. return;
  116150. }
  116151. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  116152. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  116153. },
  116154. enumerable: true,
  116155. configurable: true
  116156. });
  116157. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  116158. };
  116159. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  116160. };
  116161. Tools._StartUserMark = function (counterName, condition) {
  116162. if (condition === void 0) { condition = true; }
  116163. if (!Tools._performance) {
  116164. if (!_domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].IsWindowObjectExist()) {
  116165. return;
  116166. }
  116167. Tools._performance = window.performance;
  116168. }
  116169. if (!condition || !Tools._performance.mark) {
  116170. return;
  116171. }
  116172. Tools._performance.mark(counterName + "-Begin");
  116173. };
  116174. Tools._EndUserMark = function (counterName, condition) {
  116175. if (condition === void 0) { condition = true; }
  116176. if (!condition || !Tools._performance.mark) {
  116177. return;
  116178. }
  116179. Tools._performance.mark(counterName + "-End");
  116180. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  116181. };
  116182. Tools._StartPerformanceConsole = function (counterName, condition) {
  116183. if (condition === void 0) { condition = true; }
  116184. if (!condition) {
  116185. return;
  116186. }
  116187. Tools._StartUserMark(counterName, condition);
  116188. if (console.time) {
  116189. console.time(counterName);
  116190. }
  116191. };
  116192. Tools._EndPerformanceConsole = function (counterName, condition) {
  116193. if (condition === void 0) { condition = true; }
  116194. if (!condition) {
  116195. return;
  116196. }
  116197. Tools._EndUserMark(counterName, condition);
  116198. if (console.time) {
  116199. console.timeEnd(counterName);
  116200. }
  116201. };
  116202. Object.defineProperty(Tools, "Now", {
  116203. /**
  116204. * Gets either window.performance.now() if supported or Date.now() else
  116205. */
  116206. get: function () {
  116207. return _precisionDate__WEBPACK_IMPORTED_MODULE_4__["PrecisionDate"].Now;
  116208. },
  116209. enumerable: true,
  116210. configurable: true
  116211. });
  116212. /**
  116213. * This method will return the name of the class used to create the instance of the given object.
  116214. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  116215. * @param object the object to get the class name from
  116216. * @param isType defines if the object is actually a type
  116217. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  116218. */
  116219. Tools.GetClassName = function (object, isType) {
  116220. if (isType === void 0) { isType = false; }
  116221. var name = null;
  116222. if (!isType && object.getClassName) {
  116223. name = object.getClassName();
  116224. }
  116225. else {
  116226. if (object instanceof Object) {
  116227. var classObj = isType ? object : Object.getPrototypeOf(object);
  116228. name = classObj.constructor["__bjsclassName__"];
  116229. }
  116230. if (!name) {
  116231. name = typeof object;
  116232. }
  116233. }
  116234. return name;
  116235. };
  116236. /**
  116237. * Gets the first element of an array satisfying a given predicate
  116238. * @param array defines the array to browse
  116239. * @param predicate defines the predicate to use
  116240. * @returns null if not found or the element
  116241. */
  116242. Tools.First = function (array, predicate) {
  116243. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  116244. var el = array_1[_i];
  116245. if (predicate(el)) {
  116246. return el;
  116247. }
  116248. }
  116249. return null;
  116250. };
  116251. /**
  116252. * This method will return the name of the full name of the class, including its owning module (if any).
  116253. * 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).
  116254. * @param object the object to get the class name from
  116255. * @param isType defines if the object is actually a type
  116256. * @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.
  116257. * @ignorenaming
  116258. */
  116259. Tools.getFullClassName = function (object, isType) {
  116260. if (isType === void 0) { isType = false; }
  116261. var className = null;
  116262. var moduleName = null;
  116263. if (!isType && object.getClassName) {
  116264. className = object.getClassName();
  116265. }
  116266. else {
  116267. if (object instanceof Object) {
  116268. var classObj = isType ? object : Object.getPrototypeOf(object);
  116269. className = classObj.constructor["__bjsclassName__"];
  116270. moduleName = classObj.constructor["__bjsmoduleName__"];
  116271. }
  116272. if (!className) {
  116273. className = typeof object;
  116274. }
  116275. }
  116276. if (!className) {
  116277. return null;
  116278. }
  116279. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  116280. };
  116281. /**
  116282. * Returns a promise that resolves after the given amount of time.
  116283. * @param delay Number of milliseconds to delay
  116284. * @returns Promise that resolves after the given amount of time
  116285. */
  116286. Tools.DelayAsync = function (delay) {
  116287. return new Promise(function (resolve) {
  116288. setTimeout(function () {
  116289. resolve();
  116290. }, delay);
  116291. });
  116292. };
  116293. /**
  116294. * Enable/Disable Custom HTTP Request Headers globally.
  116295. * default = false
  116296. * @see CustomRequestHeaders
  116297. */
  116298. Tools.UseCustomRequestHeaders = false;
  116299. /**
  116300. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  116301. * i.e. when loading files, where the server/service expects an Authorization header
  116302. */
  116303. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_6__["WebRequest"].CustomRequestHeaders;
  116304. /**
  116305. * Default behaviour for cors in the application.
  116306. * It can be a string if the expected behavior is identical in the entire app.
  116307. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  116308. */
  116309. Tools.CorsBehavior = "anonymous";
  116310. Tools._tmpFloatArray = new Float32Array(1);
  116311. /**
  116312. * Extracts text content from a DOM element hierarchy
  116313. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  116314. */
  116315. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].GetDOMTextContent;
  116316. // Logs
  116317. /**
  116318. * No log
  116319. */
  116320. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].NoneLogLevel;
  116321. /**
  116322. * Only message logs
  116323. */
  116324. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].MessageLogLevel;
  116325. /**
  116326. * Only warning logs
  116327. */
  116328. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].WarningLogLevel;
  116329. /**
  116330. * Only error logs
  116331. */
  116332. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].ErrorLogLevel;
  116333. /**
  116334. * All logs
  116335. */
  116336. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].AllLogLevel;
  116337. /**
  116338. * Checks if the window object exists
  116339. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  116340. */
  116341. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_1__["DomManagement"].IsWindowObjectExist;
  116342. // Performances
  116343. /**
  116344. * No performance log
  116345. */
  116346. Tools.PerformanceNoneLogLevel = 0;
  116347. /**
  116348. * Use user marks to log performance
  116349. */
  116350. Tools.PerformanceUserMarkLogLevel = 1;
  116351. /**
  116352. * Log performance to the console
  116353. */
  116354. Tools.PerformanceConsoleLogLevel = 2;
  116355. /**
  116356. * Starts a performance counter
  116357. */
  116358. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  116359. /**
  116360. * Ends a specific performance coutner
  116361. */
  116362. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  116363. return Tools;
  116364. }());
  116365. /**
  116366. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116367. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116368. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116369. * @param name The name of the class, case should be preserved
  116370. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116371. */
  116372. function className(name, module) {
  116373. return function (target) {
  116374. target["__bjsclassName__"] = name;
  116375. target["__bjsmoduleName__"] = (module != null) ? module : null;
  116376. };
  116377. }
  116378. /**
  116379. * An implementation of a loop for asynchronous functions.
  116380. */
  116381. var AsyncLoop = /** @class */ (function () {
  116382. /**
  116383. * Constructor.
  116384. * @param iterations the number of iterations.
  116385. * @param func the function to run each iteration
  116386. * @param successCallback the callback that will be called upon succesful execution
  116387. * @param offset starting offset.
  116388. */
  116389. function AsyncLoop(
  116390. /**
  116391. * Defines the number of iterations for the loop
  116392. */
  116393. iterations, func, successCallback, offset) {
  116394. if (offset === void 0) { offset = 0; }
  116395. this.iterations = iterations;
  116396. this.index = offset - 1;
  116397. this._done = false;
  116398. this._fn = func;
  116399. this._successCallback = successCallback;
  116400. }
  116401. /**
  116402. * Execute the next iteration. Must be called after the last iteration was finished.
  116403. */
  116404. AsyncLoop.prototype.executeNext = function () {
  116405. if (!this._done) {
  116406. if (this.index + 1 < this.iterations) {
  116407. ++this.index;
  116408. this._fn(this);
  116409. }
  116410. else {
  116411. this.breakLoop();
  116412. }
  116413. }
  116414. };
  116415. /**
  116416. * Break the loop and run the success callback.
  116417. */
  116418. AsyncLoop.prototype.breakLoop = function () {
  116419. this._done = true;
  116420. this._successCallback();
  116421. };
  116422. /**
  116423. * Create and run an async loop.
  116424. * @param iterations the number of iterations.
  116425. * @param fn the function to run each iteration
  116426. * @param successCallback the callback that will be called upon succesful execution
  116427. * @param offset starting offset.
  116428. * @returns the created async loop object
  116429. */
  116430. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  116431. if (offset === void 0) { offset = 0; }
  116432. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  116433. loop.executeNext();
  116434. return loop;
  116435. };
  116436. /**
  116437. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116438. * @param iterations total number of iterations
  116439. * @param syncedIterations number of synchronous iterations in each async iteration.
  116440. * @param fn the function to call each iteration.
  116441. * @param callback a success call back that will be called when iterating stops.
  116442. * @param breakFunction a break condition (optional)
  116443. * @param timeout timeout settings for the setTimeout function. default - 0.
  116444. * @returns the created async loop object
  116445. */
  116446. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  116447. if (timeout === void 0) { timeout = 0; }
  116448. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  116449. if (breakFunction && breakFunction()) {
  116450. loop.breakLoop();
  116451. }
  116452. else {
  116453. setTimeout(function () {
  116454. for (var i = 0; i < syncedIterations; ++i) {
  116455. var iteration = (loop.index * syncedIterations) + i;
  116456. if (iteration >= iterations) {
  116457. break;
  116458. }
  116459. fn(iteration);
  116460. if (breakFunction && breakFunction()) {
  116461. loop.breakLoop();
  116462. break;
  116463. }
  116464. }
  116465. loop.executeNext();
  116466. }, timeout);
  116467. }
  116468. }, callback);
  116469. };
  116470. return AsyncLoop;
  116471. }());
  116472. // Will only be define if Tools is imported freeing up some space when only engine is required
  116473. _Engines_engineStore__WEBPACK_IMPORTED_MODULE_7__["EngineStore"].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";
  116474. // Register promise fallback for IE
  116475. _promise__WEBPACK_IMPORTED_MODULE_9__["PromisePolyfill"].Apply();
  116476. /***/ }),
  116477. /***/ "./Misc/typeStore.ts":
  116478. /*!***************************!*\
  116479. !*** ./Misc/typeStore.ts ***!
  116480. \***************************/
  116481. /*! exports provided: _TypeStore */
  116482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116483. "use strict";
  116484. __webpack_require__.r(__webpack_exports__);
  116485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  116486. /** @hidden */
  116487. var _TypeStore = /** @class */ (function () {
  116488. function _TypeStore() {
  116489. }
  116490. /** @hidden */
  116491. _TypeStore.GetClass = function (fqdn) {
  116492. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  116493. return this.RegisteredTypes[fqdn];
  116494. }
  116495. return null;
  116496. };
  116497. /** @hidden */
  116498. _TypeStore.RegisteredTypes = {};
  116499. return _TypeStore;
  116500. }());
  116501. /***/ }),
  116502. /***/ "./Misc/uniqueIdGenerator.ts":
  116503. /*!***********************************!*\
  116504. !*** ./Misc/uniqueIdGenerator.ts ***!
  116505. \***********************************/
  116506. /*! exports provided: UniqueIdGenerator */
  116507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116508. "use strict";
  116509. __webpack_require__.r(__webpack_exports__);
  116510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniqueIdGenerator", function() { return UniqueIdGenerator; });
  116511. /**
  116512. * Helper class used to generate session unique ID
  116513. */
  116514. var UniqueIdGenerator = /** @class */ (function () {
  116515. function UniqueIdGenerator() {
  116516. }
  116517. Object.defineProperty(UniqueIdGenerator, "UniqueId", {
  116518. /**
  116519. * Gets an unique (relatively to the current scene) Id
  116520. */
  116521. get: function () {
  116522. var result = this._UniqueIdCounter;
  116523. this._UniqueIdCounter++;
  116524. return result;
  116525. },
  116526. enumerable: true,
  116527. configurable: true
  116528. });
  116529. // Statics
  116530. UniqueIdGenerator._UniqueIdCounter = 0;
  116531. return UniqueIdGenerator;
  116532. }());
  116533. /***/ }),
  116534. /***/ "./Misc/videoRecorder.ts":
  116535. /*!*******************************!*\
  116536. !*** ./Misc/videoRecorder.ts ***!
  116537. \*******************************/
  116538. /*! exports provided: VideoRecorder */
  116539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116540. "use strict";
  116541. __webpack_require__.r(__webpack_exports__);
  116542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  116543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116544. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  116545. /**
  116546. * This can help with recording videos from BabylonJS.
  116547. * This is based on the available WebRTC functionalities of the browser.
  116548. *
  116549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116550. */
  116551. var VideoRecorder = /** @class */ (function () {
  116552. /**
  116553. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  116554. * @param engine Defines the BabylonJS Engine you wish to record.
  116555. * @param options Defines options that can be used to customize the capture.
  116556. */
  116557. function VideoRecorder(engine, options) {
  116558. if (options === void 0) { options = null; }
  116559. if (!VideoRecorder.IsSupported(engine)) {
  116560. throw "Your browser does not support recording so far.";
  116561. }
  116562. var canvas = engine.getRenderingCanvas();
  116563. if (!canvas) {
  116564. throw "The babylon engine must have a canvas to be recorded";
  116565. }
  116566. this._canvas = canvas;
  116567. this._canvas.isRecording = false;
  116568. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  116569. var stream = this._canvas.captureStream(this._options.fps);
  116570. if (this._options.audioTracks) {
  116571. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  116572. var track = _a[_i];
  116573. stream.addTrack(track);
  116574. }
  116575. }
  116576. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  116577. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  116578. this._mediaRecorder.onerror = this._handleError.bind(this);
  116579. this._mediaRecorder.onstop = this._handleStop.bind(this);
  116580. }
  116581. /**
  116582. * Returns whether or not the VideoRecorder is available in your browser.
  116583. * @param engine Defines the Babylon Engine.
  116584. * @returns true if supported otherwise false.
  116585. */
  116586. VideoRecorder.IsSupported = function (engine) {
  116587. var canvas = engine.getRenderingCanvas();
  116588. return (!!canvas && typeof canvas.captureStream === "function");
  116589. };
  116590. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  116591. /**
  116592. * True when a recording is already in progress.
  116593. */
  116594. get: function () {
  116595. return !!this._canvas && this._canvas.isRecording;
  116596. },
  116597. enumerable: true,
  116598. configurable: true
  116599. });
  116600. /**
  116601. * Stops the current recording before the default capture timeout passed in the startRecording function.
  116602. */
  116603. VideoRecorder.prototype.stopRecording = function () {
  116604. if (!this._canvas || !this._mediaRecorder) {
  116605. return;
  116606. }
  116607. if (!this.isRecording) {
  116608. return;
  116609. }
  116610. this._canvas.isRecording = false;
  116611. this._mediaRecorder.stop();
  116612. };
  116613. /**
  116614. * Starts recording the canvas for a max duration specified in parameters.
  116615. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  116616. * If null no automatic download will start and you can rely on the promise to get the data back.
  116617. * @param maxDuration Defines the maximum recording time in seconds.
  116618. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116619. * @return A promise callback at the end of the recording with the video data in Blob.
  116620. */
  116621. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  116622. var _this = this;
  116623. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  116624. if (maxDuration === void 0) { maxDuration = 7; }
  116625. if (!this._canvas || !this._mediaRecorder) {
  116626. throw "Recorder has already been disposed";
  116627. }
  116628. if (this.isRecording) {
  116629. throw "Recording already in progress";
  116630. }
  116631. if (maxDuration > 0) {
  116632. setTimeout(function () {
  116633. _this.stopRecording();
  116634. }, maxDuration * 1000);
  116635. }
  116636. this._fileName = fileName;
  116637. this._recordedChunks = [];
  116638. this._resolve = null;
  116639. this._reject = null;
  116640. this._canvas.isRecording = true;
  116641. this._mediaRecorder.start(this._options.recordChunckSize);
  116642. return new Promise(function (resolve, reject) {
  116643. _this._resolve = resolve;
  116644. _this._reject = reject;
  116645. });
  116646. };
  116647. /**
  116648. * Releases internal resources used during the recording.
  116649. */
  116650. VideoRecorder.prototype.dispose = function () {
  116651. this._canvas = null;
  116652. this._mediaRecorder = null;
  116653. this._recordedChunks = [];
  116654. this._fileName = null;
  116655. this._resolve = null;
  116656. this._reject = null;
  116657. };
  116658. VideoRecorder.prototype._handleDataAvailable = function (event) {
  116659. if (event.data.size > 0) {
  116660. this._recordedChunks.push(event.data);
  116661. }
  116662. };
  116663. VideoRecorder.prototype._handleError = function (event) {
  116664. this.stopRecording();
  116665. if (this._reject) {
  116666. this._reject(event.error);
  116667. }
  116668. else {
  116669. throw new event.error();
  116670. }
  116671. };
  116672. VideoRecorder.prototype._handleStop = function () {
  116673. this.stopRecording();
  116674. var superBuffer = new Blob(this._recordedChunks);
  116675. if (this._resolve) {
  116676. this._resolve(superBuffer);
  116677. }
  116678. window.URL.createObjectURL(superBuffer);
  116679. if (this._fileName) {
  116680. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  116681. }
  116682. };
  116683. VideoRecorder._defaultOptions = {
  116684. mimeType: "video/webm",
  116685. fps: 25,
  116686. recordChunckSize: 3000
  116687. };
  116688. return VideoRecorder;
  116689. }());
  116690. /***/ }),
  116691. /***/ "./Misc/virtualJoystick.ts":
  116692. /*!*********************************!*\
  116693. !*** ./Misc/virtualJoystick.ts ***!
  116694. \*********************************/
  116695. /*! exports provided: JoystickAxis, VirtualJoystick */
  116696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116697. "use strict";
  116698. __webpack_require__.r(__webpack_exports__);
  116699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  116700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  116701. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  116702. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  116703. // Mainly based on these 2 articles :
  116704. // 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
  116705. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  116706. /**
  116707. * Defines the potential axis of a Joystick
  116708. */
  116709. var JoystickAxis;
  116710. (function (JoystickAxis) {
  116711. /** X axis */
  116712. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  116713. /** Y axis */
  116714. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  116715. /** Z axis */
  116716. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  116717. })(JoystickAxis || (JoystickAxis = {}));
  116718. /**
  116719. * Class used to define virtual joystick (used in touch mode)
  116720. */
  116721. var VirtualJoystick = /** @class */ (function () {
  116722. /**
  116723. * Creates a new virtual joystick
  116724. * @param leftJoystick defines that the joystick is for left hand (false by default)
  116725. */
  116726. function VirtualJoystick(leftJoystick) {
  116727. var _this = this;
  116728. if (leftJoystick) {
  116729. this._leftJoystick = true;
  116730. }
  116731. else {
  116732. this._leftJoystick = false;
  116733. }
  116734. VirtualJoystick._globalJoystickIndex++;
  116735. // By default left & right arrow keys are moving the X
  116736. // and up & down keys are moving the Y
  116737. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  116738. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  116739. this.reverseLeftRight = false;
  116740. this.reverseUpDown = false;
  116741. // collections of pointers
  116742. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  116743. this.deltaPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116744. this._joystickSensibility = 25;
  116745. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  116746. this._onResize = function (evt) {
  116747. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  116748. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  116749. if (VirtualJoystick.Canvas) {
  116750. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  116751. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  116752. }
  116753. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  116754. };
  116755. // injecting a canvas element on top of the canvas 3D game
  116756. if (!VirtualJoystick.Canvas) {
  116757. window.addEventListener("resize", this._onResize, false);
  116758. VirtualJoystick.Canvas = document.createElement("canvas");
  116759. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  116760. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  116761. VirtualJoystick.Canvas.width = window.innerWidth;
  116762. VirtualJoystick.Canvas.height = window.innerHeight;
  116763. VirtualJoystick.Canvas.style.width = "100%";
  116764. VirtualJoystick.Canvas.style.height = "100%";
  116765. VirtualJoystick.Canvas.style.position = "absolute";
  116766. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  116767. VirtualJoystick.Canvas.style.top = "0px";
  116768. VirtualJoystick.Canvas.style.left = "0px";
  116769. VirtualJoystick.Canvas.style.zIndex = "5";
  116770. VirtualJoystick.Canvas.style.msTouchAction = "none";
  116771. // Support for jQuery PEP polyfill
  116772. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  116773. var context = VirtualJoystick.Canvas.getContext('2d');
  116774. if (!context) {
  116775. throw new Error("Unable to create canvas for virtual joystick");
  116776. }
  116777. VirtualJoystick.vjCanvasContext = context;
  116778. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  116779. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  116780. document.body.appendChild(VirtualJoystick.Canvas);
  116781. }
  116782. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  116783. this.pressed = false;
  116784. // default joystick color
  116785. this._joystickColor = "cyan";
  116786. this._joystickPointerID = -1;
  116787. // current joystick position
  116788. this._joystickPointerPos = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  116789. this._joystickPreviousPointerPos = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  116790. // origin joystick position
  116791. this._joystickPointerStartPos = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  116792. this._deltaJoystickVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  116793. this._onPointerDownHandlerRef = function (evt) {
  116794. _this._onPointerDown(evt);
  116795. };
  116796. this._onPointerMoveHandlerRef = function (evt) {
  116797. _this._onPointerMove(evt);
  116798. };
  116799. this._onPointerUpHandlerRef = function (evt) {
  116800. _this._onPointerUp(evt);
  116801. };
  116802. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  116803. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  116804. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  116805. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  116806. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  116807. evt.preventDefault(); // Disables system menu
  116808. }, false);
  116809. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  116810. }
  116811. /**
  116812. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  116813. * @param newJoystickSensibility defines the new sensibility
  116814. */
  116815. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  116816. this._joystickSensibility = newJoystickSensibility;
  116817. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  116818. };
  116819. VirtualJoystick.prototype._onPointerDown = function (e) {
  116820. var positionOnScreenCondition;
  116821. e.preventDefault();
  116822. if (this._leftJoystick === true) {
  116823. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  116824. }
  116825. else {
  116826. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  116827. }
  116828. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  116829. // First contact will be dedicated to the virtual joystick
  116830. this._joystickPointerID = e.pointerId;
  116831. this._joystickPointerStartPos.x = e.clientX;
  116832. this._joystickPointerStartPos.y = e.clientY;
  116833. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  116834. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  116835. this._deltaJoystickVector.x = 0;
  116836. this._deltaJoystickVector.y = 0;
  116837. this.pressed = true;
  116838. this._touches.add(e.pointerId.toString(), e);
  116839. }
  116840. else {
  116841. // You can only trigger the action buttons with a joystick declared
  116842. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  116843. this._action();
  116844. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  116845. }
  116846. }
  116847. };
  116848. VirtualJoystick.prototype._onPointerMove = function (e) {
  116849. // If the current pointer is the one associated to the joystick (first touch contact)
  116850. if (this._joystickPointerID == e.pointerId) {
  116851. this._joystickPointerPos.x = e.clientX;
  116852. this._joystickPointerPos.y = e.clientY;
  116853. this._deltaJoystickVector = this._joystickPointerPos.clone();
  116854. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  116855. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  116856. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  116857. switch (this._axisTargetedByLeftAndRight) {
  116858. case JoystickAxis.X:
  116859. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  116860. break;
  116861. case JoystickAxis.Y:
  116862. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  116863. break;
  116864. case JoystickAxis.Z:
  116865. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  116866. break;
  116867. }
  116868. var directionUpDown = this.reverseUpDown ? 1 : -1;
  116869. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  116870. switch (this._axisTargetedByUpAndDown) {
  116871. case JoystickAxis.X:
  116872. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  116873. break;
  116874. case JoystickAxis.Y:
  116875. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  116876. break;
  116877. case JoystickAxis.Z:
  116878. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  116879. break;
  116880. }
  116881. }
  116882. else {
  116883. var data = this._touches.get(e.pointerId.toString());
  116884. if (data) {
  116885. data.x = e.clientX;
  116886. data.y = e.clientY;
  116887. }
  116888. }
  116889. };
  116890. VirtualJoystick.prototype._onPointerUp = function (e) {
  116891. if (this._joystickPointerID == e.pointerId) {
  116892. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  116893. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  116894. this._joystickPointerID = -1;
  116895. this.pressed = false;
  116896. }
  116897. else {
  116898. var touch = this._touches.get(e.pointerId.toString());
  116899. if (touch) {
  116900. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  116901. }
  116902. }
  116903. this._deltaJoystickVector.x = 0;
  116904. this._deltaJoystickVector.y = 0;
  116905. this._touches.remove(e.pointerId.toString());
  116906. };
  116907. /**
  116908. * Change the color of the virtual joystick
  116909. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  116910. */
  116911. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  116912. this._joystickColor = newColor;
  116913. };
  116914. /**
  116915. * Defines a callback to call when the joystick is touched
  116916. * @param action defines the callback
  116917. */
  116918. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  116919. this._action = action;
  116920. };
  116921. /**
  116922. * Defines which axis you'd like to control for left & right
  116923. * @param axis defines the axis to use
  116924. */
  116925. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  116926. switch (axis) {
  116927. case JoystickAxis.X:
  116928. case JoystickAxis.Y:
  116929. case JoystickAxis.Z:
  116930. this._axisTargetedByLeftAndRight = axis;
  116931. break;
  116932. default:
  116933. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  116934. break;
  116935. }
  116936. };
  116937. /**
  116938. * Defines which axis you'd like to control for up & down
  116939. * @param axis defines the axis to use
  116940. */
  116941. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  116942. switch (axis) {
  116943. case JoystickAxis.X:
  116944. case JoystickAxis.Y:
  116945. case JoystickAxis.Z:
  116946. this._axisTargetedByUpAndDown = axis;
  116947. break;
  116948. default:
  116949. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  116950. break;
  116951. }
  116952. };
  116953. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  116954. var _this = this;
  116955. if (this.pressed) {
  116956. this._touches.forEach(function (key, touch) {
  116957. if (touch.pointerId === _this._joystickPointerID) {
  116958. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  116959. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  116960. VirtualJoystick.vjCanvasContext.beginPath();
  116961. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  116962. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  116963. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  116964. VirtualJoystick.vjCanvasContext.stroke();
  116965. VirtualJoystick.vjCanvasContext.closePath();
  116966. VirtualJoystick.vjCanvasContext.beginPath();
  116967. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  116968. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  116969. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  116970. VirtualJoystick.vjCanvasContext.stroke();
  116971. VirtualJoystick.vjCanvasContext.closePath();
  116972. VirtualJoystick.vjCanvasContext.beginPath();
  116973. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  116974. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  116975. VirtualJoystick.vjCanvasContext.stroke();
  116976. VirtualJoystick.vjCanvasContext.closePath();
  116977. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  116978. }
  116979. else {
  116980. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  116981. VirtualJoystick.vjCanvasContext.beginPath();
  116982. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  116983. VirtualJoystick.vjCanvasContext.beginPath();
  116984. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  116985. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  116986. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  116987. VirtualJoystick.vjCanvasContext.stroke();
  116988. VirtualJoystick.vjCanvasContext.closePath();
  116989. touch.prevX = touch.x;
  116990. touch.prevY = touch.y;
  116991. }
  116992. });
  116993. }
  116994. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  116995. };
  116996. /**
  116997. * Release internal HTML canvas
  116998. */
  116999. VirtualJoystick.prototype.releaseCanvas = function () {
  117000. if (VirtualJoystick.Canvas) {
  117001. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  117002. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  117003. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  117004. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  117005. window.removeEventListener("resize", this._onResize);
  117006. document.body.removeChild(VirtualJoystick.Canvas);
  117007. VirtualJoystick.Canvas = null;
  117008. }
  117009. };
  117010. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  117011. VirtualJoystick._globalJoystickIndex = 0;
  117012. return VirtualJoystick;
  117013. }());
  117014. /***/ }),
  117015. /***/ "./Misc/webRequest.ts":
  117016. /*!****************************!*\
  117017. !*** ./Misc/webRequest.ts ***!
  117018. \****************************/
  117019. /*! exports provided: WebRequest */
  117020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117021. "use strict";
  117022. __webpack_require__.r(__webpack_exports__);
  117023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  117024. /**
  117025. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  117026. */
  117027. var WebRequest = /** @class */ (function () {
  117028. function WebRequest() {
  117029. this._xhr = new XMLHttpRequest();
  117030. }
  117031. WebRequest.prototype._injectCustomRequestHeaders = function () {
  117032. for (var key in WebRequest.CustomRequestHeaders) {
  117033. var val = WebRequest.CustomRequestHeaders[key];
  117034. if (val) {
  117035. this._xhr.setRequestHeader(key, val);
  117036. }
  117037. }
  117038. };
  117039. Object.defineProperty(WebRequest.prototype, "onprogress", {
  117040. /**
  117041. * Gets or sets a function to be called when loading progress changes
  117042. */
  117043. get: function () {
  117044. return this._xhr.onprogress;
  117045. },
  117046. set: function (value) {
  117047. this._xhr.onprogress = value;
  117048. },
  117049. enumerable: true,
  117050. configurable: true
  117051. });
  117052. Object.defineProperty(WebRequest.prototype, "readyState", {
  117053. /**
  117054. * Returns client's state
  117055. */
  117056. get: function () {
  117057. return this._xhr.readyState;
  117058. },
  117059. enumerable: true,
  117060. configurable: true
  117061. });
  117062. Object.defineProperty(WebRequest.prototype, "status", {
  117063. /**
  117064. * Returns client's status
  117065. */
  117066. get: function () {
  117067. return this._xhr.status;
  117068. },
  117069. enumerable: true,
  117070. configurable: true
  117071. });
  117072. Object.defineProperty(WebRequest.prototype, "statusText", {
  117073. /**
  117074. * Returns client's status as a text
  117075. */
  117076. get: function () {
  117077. return this._xhr.statusText;
  117078. },
  117079. enumerable: true,
  117080. configurable: true
  117081. });
  117082. Object.defineProperty(WebRequest.prototype, "response", {
  117083. /**
  117084. * Returns client's response
  117085. */
  117086. get: function () {
  117087. return this._xhr.response;
  117088. },
  117089. enumerable: true,
  117090. configurable: true
  117091. });
  117092. Object.defineProperty(WebRequest.prototype, "responseURL", {
  117093. /**
  117094. * Returns client's response url
  117095. */
  117096. get: function () {
  117097. return this._xhr.responseURL;
  117098. },
  117099. enumerable: true,
  117100. configurable: true
  117101. });
  117102. Object.defineProperty(WebRequest.prototype, "responseText", {
  117103. /**
  117104. * Returns client's response as text
  117105. */
  117106. get: function () {
  117107. return this._xhr.responseText;
  117108. },
  117109. enumerable: true,
  117110. configurable: true
  117111. });
  117112. Object.defineProperty(WebRequest.prototype, "responseType", {
  117113. /**
  117114. * Gets or sets the expected response type
  117115. */
  117116. get: function () {
  117117. return this._xhr.responseType;
  117118. },
  117119. set: function (value) {
  117120. this._xhr.responseType = value;
  117121. },
  117122. enumerable: true,
  117123. configurable: true
  117124. });
  117125. WebRequest.prototype.addEventListener = function (type, listener, options) {
  117126. this._xhr.addEventListener(type, listener, options);
  117127. };
  117128. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  117129. this._xhr.removeEventListener(type, listener, options);
  117130. };
  117131. /**
  117132. * Cancels any network activity
  117133. */
  117134. WebRequest.prototype.abort = function () {
  117135. this._xhr.abort();
  117136. };
  117137. /**
  117138. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  117139. * @param body defines an optional request body
  117140. */
  117141. WebRequest.prototype.send = function (body) {
  117142. if (WebRequest.CustomRequestHeaders) {
  117143. this._injectCustomRequestHeaders();
  117144. }
  117145. this._xhr.send(body);
  117146. };
  117147. /**
  117148. * Sets the request method, request URL
  117149. * @param method defines the method to use (GET, POST, etc..)
  117150. * @param url defines the url to connect with
  117151. */
  117152. WebRequest.prototype.open = function (method, url) {
  117153. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  117154. var update = _a[_i];
  117155. update(this._xhr, url);
  117156. }
  117157. // Clean url
  117158. url = url.replace("file:http:", "http:");
  117159. url = url.replace("file:https:", "https:");
  117160. return this._xhr.open(method, url, true);
  117161. };
  117162. /**
  117163. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117164. * i.e. when loading files, where the server/service expects an Authorization header
  117165. */
  117166. WebRequest.CustomRequestHeaders = {};
  117167. /**
  117168. * Add callback functions in this array to update all the requests before they get sent to the network
  117169. */
  117170. WebRequest.CustomRequestModifiers = new Array();
  117171. return WebRequest;
  117172. }());
  117173. /***/ }),
  117174. /***/ "./Misc/workerPool.ts":
  117175. /*!****************************!*\
  117176. !*** ./Misc/workerPool.ts ***!
  117177. \****************************/
  117178. /*! exports provided: WorkerPool */
  117179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117180. "use strict";
  117181. __webpack_require__.r(__webpack_exports__);
  117182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  117183. /**
  117184. * Helper class to push actions to a pool of workers.
  117185. */
  117186. var WorkerPool = /** @class */ (function () {
  117187. /**
  117188. * Constructor
  117189. * @param workers Array of workers to use for actions
  117190. */
  117191. function WorkerPool(workers) {
  117192. this._pendingActions = new Array();
  117193. this._workerInfos = workers.map(function (worker) { return ({
  117194. worker: worker,
  117195. active: false
  117196. }); });
  117197. }
  117198. /**
  117199. * Terminates all workers and clears any pending actions.
  117200. */
  117201. WorkerPool.prototype.dispose = function () {
  117202. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  117203. var workerInfo = _a[_i];
  117204. workerInfo.worker.terminate();
  117205. }
  117206. delete this._workerInfos;
  117207. delete this._pendingActions;
  117208. };
  117209. /**
  117210. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117211. * pended until a worker has completed its action.
  117212. * @param action The action to perform. Call onComplete when the action is complete.
  117213. */
  117214. WorkerPool.prototype.push = function (action) {
  117215. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  117216. var workerInfo = _a[_i];
  117217. if (!workerInfo.active) {
  117218. this._execute(workerInfo, action);
  117219. return;
  117220. }
  117221. }
  117222. this._pendingActions.push(action);
  117223. };
  117224. WorkerPool.prototype._execute = function (workerInfo, action) {
  117225. var _this = this;
  117226. workerInfo.active = true;
  117227. action(workerInfo.worker, function () {
  117228. workerInfo.active = false;
  117229. var nextAction = _this._pendingActions.shift();
  117230. if (nextAction) {
  117231. _this._execute(workerInfo, nextAction);
  117232. }
  117233. });
  117234. };
  117235. return WorkerPool;
  117236. }());
  117237. /***/ }),
  117238. /***/ "./Morph/index.ts":
  117239. /*!************************!*\
  117240. !*** ./Morph/index.ts ***!
  117241. \************************/
  117242. /*! exports provided: MorphTarget, MorphTargetManager */
  117243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117244. "use strict";
  117245. __webpack_require__.r(__webpack_exports__);
  117246. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  117247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  117248. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  117249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  117250. /***/ }),
  117251. /***/ "./Morph/morphTarget.ts":
  117252. /*!******************************!*\
  117253. !*** ./Morph/morphTarget.ts ***!
  117254. \******************************/
  117255. /*! exports provided: MorphTarget */
  117256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117257. "use strict";
  117258. __webpack_require__.r(__webpack_exports__);
  117259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  117260. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117261. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  117262. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117263. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  117264. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  117265. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  117266. /**
  117267. * Defines a target to use with MorphTargetManager
  117268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  117269. */
  117270. var MorphTarget = /** @class */ (function () {
  117271. /**
  117272. * Creates a new MorphTarget
  117273. * @param name defines the name of the target
  117274. * @param influence defines the influence to use
  117275. * @param scene defines the scene the morphtarget belongs to
  117276. */
  117277. function MorphTarget(
  117278. /** defines the name of the target */
  117279. name, influence, scene) {
  117280. if (influence === void 0) { influence = 0; }
  117281. if (scene === void 0) { scene = null; }
  117282. this.name = name;
  117283. /**
  117284. * Gets or sets the list of animations
  117285. */
  117286. this.animations = new Array();
  117287. this._positions = null;
  117288. this._normals = null;
  117289. this._tangents = null;
  117290. this._uvs = null;
  117291. /**
  117292. * Observable raised when the influence changes
  117293. */
  117294. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  117295. /** @hidden */
  117296. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  117297. this._animationPropertiesOverride = null;
  117298. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  117299. this.influence = influence;
  117300. }
  117301. Object.defineProperty(MorphTarget.prototype, "influence", {
  117302. /**
  117303. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  117304. */
  117305. get: function () {
  117306. return this._influence;
  117307. },
  117308. set: function (influence) {
  117309. if (this._influence === influence) {
  117310. return;
  117311. }
  117312. var previous = this._influence;
  117313. this._influence = influence;
  117314. if (this.onInfluenceChanged.hasObservers) {
  117315. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  117316. }
  117317. },
  117318. enumerable: true,
  117319. configurable: true
  117320. });
  117321. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  117322. /**
  117323. * Gets or sets the animation properties override
  117324. */
  117325. get: function () {
  117326. if (!this._animationPropertiesOverride && this._scene) {
  117327. return this._scene.animationPropertiesOverride;
  117328. }
  117329. return this._animationPropertiesOverride;
  117330. },
  117331. set: function (value) {
  117332. this._animationPropertiesOverride = value;
  117333. },
  117334. enumerable: true,
  117335. configurable: true
  117336. });
  117337. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  117338. /**
  117339. * Gets a boolean defining if the target contains position data
  117340. */
  117341. get: function () {
  117342. return !!this._positions;
  117343. },
  117344. enumerable: true,
  117345. configurable: true
  117346. });
  117347. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  117348. /**
  117349. * Gets a boolean defining if the target contains normal data
  117350. */
  117351. get: function () {
  117352. return !!this._normals;
  117353. },
  117354. enumerable: true,
  117355. configurable: true
  117356. });
  117357. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  117358. /**
  117359. * Gets a boolean defining if the target contains tangent data
  117360. */
  117361. get: function () {
  117362. return !!this._tangents;
  117363. },
  117364. enumerable: true,
  117365. configurable: true
  117366. });
  117367. Object.defineProperty(MorphTarget.prototype, "hasUVs", {
  117368. /**
  117369. * Gets a boolean defining if the target contains texture coordinates data
  117370. */
  117371. get: function () {
  117372. return !!this._uvs;
  117373. },
  117374. enumerable: true,
  117375. configurable: true
  117376. });
  117377. /**
  117378. * Affects position data to this target
  117379. * @param data defines the position data to use
  117380. */
  117381. MorphTarget.prototype.setPositions = function (data) {
  117382. var hadPositions = this.hasPositions;
  117383. this._positions = data;
  117384. if (hadPositions !== this.hasPositions) {
  117385. this._onDataLayoutChanged.notifyObservers(undefined);
  117386. }
  117387. };
  117388. /**
  117389. * Gets the position data stored in this target
  117390. * @returns a FloatArray containing the position data (or null if not present)
  117391. */
  117392. MorphTarget.prototype.getPositions = function () {
  117393. return this._positions;
  117394. };
  117395. /**
  117396. * Affects normal data to this target
  117397. * @param data defines the normal data to use
  117398. */
  117399. MorphTarget.prototype.setNormals = function (data) {
  117400. var hadNormals = this.hasNormals;
  117401. this._normals = data;
  117402. if (hadNormals !== this.hasNormals) {
  117403. this._onDataLayoutChanged.notifyObservers(undefined);
  117404. }
  117405. };
  117406. /**
  117407. * Gets the normal data stored in this target
  117408. * @returns a FloatArray containing the normal data (or null if not present)
  117409. */
  117410. MorphTarget.prototype.getNormals = function () {
  117411. return this._normals;
  117412. };
  117413. /**
  117414. * Affects tangent data to this target
  117415. * @param data defines the tangent data to use
  117416. */
  117417. MorphTarget.prototype.setTangents = function (data) {
  117418. var hadTangents = this.hasTangents;
  117419. this._tangents = data;
  117420. if (hadTangents !== this.hasTangents) {
  117421. this._onDataLayoutChanged.notifyObservers(undefined);
  117422. }
  117423. };
  117424. /**
  117425. * Gets the tangent data stored in this target
  117426. * @returns a FloatArray containing the tangent data (or null if not present)
  117427. */
  117428. MorphTarget.prototype.getTangents = function () {
  117429. return this._tangents;
  117430. };
  117431. /**
  117432. * Affects texture coordinates data to this target
  117433. * @param data defines the texture coordinates data to use
  117434. */
  117435. MorphTarget.prototype.setUVs = function (data) {
  117436. var hadUVs = this.hasUVs;
  117437. this._uvs = data;
  117438. if (hadUVs !== this.hasUVs) {
  117439. this._onDataLayoutChanged.notifyObservers(undefined);
  117440. }
  117441. };
  117442. /**
  117443. * Gets the texture coordinates data stored in this target
  117444. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  117445. */
  117446. MorphTarget.prototype.getUVs = function () {
  117447. return this._uvs;
  117448. };
  117449. /**
  117450. * Serializes the current target into a Serialization object
  117451. * @returns the serialized object
  117452. */
  117453. MorphTarget.prototype.serialize = function () {
  117454. var serializationObject = {};
  117455. serializationObject.name = this.name;
  117456. serializationObject.influence = this.influence;
  117457. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  117458. if (this.id != null) {
  117459. serializationObject.id = this.id;
  117460. }
  117461. if (this.hasNormals) {
  117462. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  117463. }
  117464. if (this.hasTangents) {
  117465. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  117466. }
  117467. if (this.hasUVs) {
  117468. serializationObject.uvs = Array.prototype.slice.call(this.getUVs());
  117469. }
  117470. // Animations
  117471. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  117472. return serializationObject;
  117473. };
  117474. /**
  117475. * Returns the string "MorphTarget"
  117476. * @returns "MorphTarget"
  117477. */
  117478. MorphTarget.prototype.getClassName = function () {
  117479. return "MorphTarget";
  117480. };
  117481. // Statics
  117482. /**
  117483. * Creates a new target from serialized data
  117484. * @param serializationObject defines the serialized data to use
  117485. * @returns a new MorphTarget
  117486. */
  117487. MorphTarget.Parse = function (serializationObject) {
  117488. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  117489. result.setPositions(serializationObject.positions);
  117490. if (serializationObject.id != null) {
  117491. result.id = serializationObject.id;
  117492. }
  117493. if (serializationObject.normals) {
  117494. result.setNormals(serializationObject.normals);
  117495. }
  117496. if (serializationObject.tangents) {
  117497. result.setTangents(serializationObject.tangents);
  117498. }
  117499. if (serializationObject.uvs) {
  117500. result.setUVs(serializationObject.uvs);
  117501. }
  117502. // Animations
  117503. if (serializationObject.animations) {
  117504. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  117505. var parsedAnimation = serializationObject.animations[animationIndex];
  117506. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  117507. if (internalClass) {
  117508. result.animations.push(internalClass.Parse(parsedAnimation));
  117509. }
  117510. }
  117511. }
  117512. return result;
  117513. };
  117514. /**
  117515. * Creates a MorphTarget from mesh data
  117516. * @param mesh defines the source mesh
  117517. * @param name defines the name to use for the new target
  117518. * @param influence defines the influence to attach to the target
  117519. * @returns a new MorphTarget
  117520. */
  117521. MorphTarget.FromMesh = function (mesh, name, influence) {
  117522. if (!name) {
  117523. name = mesh.name;
  117524. }
  117525. var result = new MorphTarget(name, influence, mesh.getScene());
  117526. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  117527. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  117528. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  117529. }
  117530. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  117531. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  117532. }
  117533. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  117534. result.setUVs(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind));
  117535. }
  117536. return result;
  117537. };
  117538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  117540. ], MorphTarget.prototype, "id", void 0);
  117541. return MorphTarget;
  117542. }());
  117543. /***/ }),
  117544. /***/ "./Morph/morphTargetManager.ts":
  117545. /*!*************************************!*\
  117546. !*** ./Morph/morphTargetManager.ts ***!
  117547. \*************************************/
  117548. /*! exports provided: MorphTargetManager */
  117549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117550. "use strict";
  117551. __webpack_require__.r(__webpack_exports__);
  117552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  117553. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  117554. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117555. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117556. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  117557. /**
  117558. * This class is used to deform meshes using morphing between different targets
  117559. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  117560. */
  117561. var MorphTargetManager = /** @class */ (function () {
  117562. /**
  117563. * Creates a new MorphTargetManager
  117564. * @param scene defines the current scene
  117565. */
  117566. function MorphTargetManager(scene) {
  117567. if (scene === void 0) { scene = null; }
  117568. this._targets = new Array();
  117569. this._targetInfluenceChangedObservers = new Array();
  117570. this._targetDataLayoutChangedObservers = new Array();
  117571. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  117572. this._supportsNormals = false;
  117573. this._supportsTangents = false;
  117574. this._supportsUVs = false;
  117575. this._vertexCount = 0;
  117576. this._uniqueId = 0;
  117577. this._tempInfluences = new Array();
  117578. /**
  117579. * Gets or sets a boolean indicating if normals must be morphed
  117580. */
  117581. this.enableNormalMorphing = true;
  117582. /**
  117583. * Gets or sets a boolean indicating if tangents must be morphed
  117584. */
  117585. this.enableTangentMorphing = true;
  117586. /**
  117587. * Gets or sets a boolean indicating if UV must be morphed
  117588. */
  117589. this.enableUVMorphing = true;
  117590. if (!scene) {
  117591. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  117592. }
  117593. this._scene = scene;
  117594. if (this._scene) {
  117595. this._scene.morphTargetManagers.push(this);
  117596. this._uniqueId = this._scene.getUniqueId();
  117597. }
  117598. }
  117599. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  117600. /**
  117601. * Gets the unique ID of this manager
  117602. */
  117603. get: function () {
  117604. return this._uniqueId;
  117605. },
  117606. enumerable: true,
  117607. configurable: true
  117608. });
  117609. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  117610. /**
  117611. * Gets the number of vertices handled by this manager
  117612. */
  117613. get: function () {
  117614. return this._vertexCount;
  117615. },
  117616. enumerable: true,
  117617. configurable: true
  117618. });
  117619. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  117620. /**
  117621. * Gets a boolean indicating if this manager supports morphing of normals
  117622. */
  117623. get: function () {
  117624. return this._supportsNormals && this.enableNormalMorphing;
  117625. },
  117626. enumerable: true,
  117627. configurable: true
  117628. });
  117629. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  117630. /**
  117631. * Gets a boolean indicating if this manager supports morphing of tangents
  117632. */
  117633. get: function () {
  117634. return this._supportsTangents && this.enableTangentMorphing;
  117635. },
  117636. enumerable: true,
  117637. configurable: true
  117638. });
  117639. Object.defineProperty(MorphTargetManager.prototype, "supportsUVs", {
  117640. /**
  117641. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  117642. */
  117643. get: function () {
  117644. return this._supportsUVs && this.enableUVMorphing;
  117645. },
  117646. enumerable: true,
  117647. configurable: true
  117648. });
  117649. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  117650. /**
  117651. * Gets the number of targets stored in this manager
  117652. */
  117653. get: function () {
  117654. return this._targets.length;
  117655. },
  117656. enumerable: true,
  117657. configurable: true
  117658. });
  117659. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  117660. /**
  117661. * Gets the number of influencers (ie. the number of targets with influences > 0)
  117662. */
  117663. get: function () {
  117664. return this._activeTargets.length;
  117665. },
  117666. enumerable: true,
  117667. configurable: true
  117668. });
  117669. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  117670. /**
  117671. * Gets the list of influences (one per target)
  117672. */
  117673. get: function () {
  117674. return this._influences;
  117675. },
  117676. enumerable: true,
  117677. configurable: true
  117678. });
  117679. /**
  117680. * Gets the active target at specified index. An active target is a target with an influence > 0
  117681. * @param index defines the index to check
  117682. * @returns the requested target
  117683. */
  117684. MorphTargetManager.prototype.getActiveTarget = function (index) {
  117685. return this._activeTargets.data[index];
  117686. };
  117687. /**
  117688. * Gets the target at specified index
  117689. * @param index defines the index to check
  117690. * @returns the requested target
  117691. */
  117692. MorphTargetManager.prototype.getTarget = function (index) {
  117693. return this._targets[index];
  117694. };
  117695. /**
  117696. * Add a new target to this manager
  117697. * @param target defines the target to add
  117698. */
  117699. MorphTargetManager.prototype.addTarget = function (target) {
  117700. var _this = this;
  117701. this._targets.push(target);
  117702. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  117703. _this._syncActiveTargets(needUpdate);
  117704. }));
  117705. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  117706. _this._syncActiveTargets(true);
  117707. }));
  117708. this._syncActiveTargets(true);
  117709. };
  117710. /**
  117711. * Removes a target from the manager
  117712. * @param target defines the target to remove
  117713. */
  117714. MorphTargetManager.prototype.removeTarget = function (target) {
  117715. var index = this._targets.indexOf(target);
  117716. if (index >= 0) {
  117717. this._targets.splice(index, 1);
  117718. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  117719. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  117720. this._syncActiveTargets(true);
  117721. }
  117722. };
  117723. /**
  117724. * Serializes the current manager into a Serialization object
  117725. * @returns the serialized object
  117726. */
  117727. MorphTargetManager.prototype.serialize = function () {
  117728. var serializationObject = {};
  117729. serializationObject.id = this.uniqueId;
  117730. serializationObject.targets = [];
  117731. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  117732. var target = _a[_i];
  117733. serializationObject.targets.push(target.serialize());
  117734. }
  117735. return serializationObject;
  117736. };
  117737. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  117738. var influenceCount = 0;
  117739. this._activeTargets.reset();
  117740. this._supportsNormals = true;
  117741. this._supportsTangents = true;
  117742. this._supportsUVs = true;
  117743. this._vertexCount = 0;
  117744. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  117745. var target = _a[_i];
  117746. if (target.influence === 0) {
  117747. continue;
  117748. }
  117749. this._activeTargets.push(target);
  117750. this._tempInfluences[influenceCount++] = target.influence;
  117751. this._supportsNormals = this._supportsNormals && target.hasNormals;
  117752. this._supportsTangents = this._supportsTangents && target.hasTangents;
  117753. this._supportsUVs = this._supportsUVs && target.hasUVs;
  117754. var positions = target.getPositions();
  117755. if (positions) {
  117756. var vertexCount = positions.length / 3;
  117757. if (this._vertexCount === 0) {
  117758. this._vertexCount = vertexCount;
  117759. }
  117760. else if (this._vertexCount !== vertexCount) {
  117761. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  117762. return;
  117763. }
  117764. }
  117765. }
  117766. if (!this._influences || this._influences.length !== influenceCount) {
  117767. this._influences = new Float32Array(influenceCount);
  117768. }
  117769. for (var index = 0; index < influenceCount; index++) {
  117770. this._influences[index] = this._tempInfluences[index];
  117771. }
  117772. if (needUpdate) {
  117773. this.synchronize();
  117774. }
  117775. };
  117776. /**
  117777. * Syncrhonize the targets with all the meshes using this morph target manager
  117778. */
  117779. MorphTargetManager.prototype.synchronize = function () {
  117780. if (!this._scene) {
  117781. return;
  117782. }
  117783. // Flag meshes as dirty to resync with the active targets
  117784. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  117785. var mesh = _a[_i];
  117786. if (mesh.morphTargetManager === this) {
  117787. mesh._syncGeometryWithMorphTargetManager();
  117788. }
  117789. }
  117790. };
  117791. // Statics
  117792. /**
  117793. * Creates a new MorphTargetManager from serialized data
  117794. * @param serializationObject defines the serialized data
  117795. * @param scene defines the hosting scene
  117796. * @returns the new MorphTargetManager
  117797. */
  117798. MorphTargetManager.Parse = function (serializationObject, scene) {
  117799. var result = new MorphTargetManager(scene);
  117800. result._uniqueId = serializationObject.id;
  117801. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  117802. var targetData = _a[_i];
  117803. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  117804. }
  117805. return result;
  117806. };
  117807. return MorphTargetManager;
  117808. }());
  117809. /***/ }),
  117810. /***/ "./Navigation/Plugins/index.ts":
  117811. /*!*************************************!*\
  117812. !*** ./Navigation/Plugins/index.ts ***!
  117813. \*************************************/
  117814. /*! exports provided: RecastJSPlugin, RecastJSCrowd */
  117815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117816. "use strict";
  117817. __webpack_require__.r(__webpack_exports__);
  117818. /* harmony import */ var _recastJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./recastJSPlugin */ "./Navigation/Plugins/recastJSPlugin.ts");
  117819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSPlugin", function() { return _recastJSPlugin__WEBPACK_IMPORTED_MODULE_0__["RecastJSPlugin"]; });
  117820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSCrowd", function() { return _recastJSPlugin__WEBPACK_IMPORTED_MODULE_0__["RecastJSCrowd"]; });
  117821. /***/ }),
  117822. /***/ "./Navigation/Plugins/recastJSPlugin.ts":
  117823. /*!**********************************************!*\
  117824. !*** ./Navigation/Plugins/recastJSPlugin.ts ***!
  117825. \**********************************************/
  117826. /*! exports provided: RecastJSPlugin, RecastJSCrowd */
  117827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117828. "use strict";
  117829. __webpack_require__.r(__webpack_exports__);
  117830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RecastJSPlugin", function() { return RecastJSPlugin; });
  117831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RecastJSCrowd", function() { return RecastJSCrowd; });
  117832. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  117833. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  117834. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  117835. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  117836. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  117837. /**
  117838. * RecastJS navigation plugin
  117839. */
  117840. var RecastJSPlugin = /** @class */ (function () {
  117841. /**
  117842. * Initializes the recastJS plugin
  117843. * @param recastInjection can be used to inject your own recast reference
  117844. */
  117845. function RecastJSPlugin(recastInjection) {
  117846. if (recastInjection === void 0) { recastInjection = Recast; }
  117847. /**
  117848. * Reference to the Recast library
  117849. */
  117850. this.bjsRECAST = {};
  117851. /**
  117852. * plugin name
  117853. */
  117854. this.name = "RecastJSPlugin";
  117855. if (typeof recastInjection === "function") {
  117856. recastInjection(this.bjsRECAST);
  117857. }
  117858. else {
  117859. this.bjsRECAST = recastInjection;
  117860. }
  117861. if (!this.isSupported()) {
  117862. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("RecastJS is not available. Please make sure you included the js file.");
  117863. return;
  117864. }
  117865. }
  117866. /**
  117867. * Creates a navigation mesh
  117868. * @param meshes array of all the geometry used to compute the navigatio mesh
  117869. * @param parameters bunch of parameters used to filter geometry
  117870. */
  117871. RecastJSPlugin.prototype.createMavMesh = function (meshes, parameters) {
  117872. var rc = new this.bjsRECAST.rcConfig();
  117873. rc.cs = parameters.cs;
  117874. rc.ch = parameters.ch;
  117875. rc.borderSize = 0;
  117876. rc.tileSize = 0;
  117877. rc.walkableSlopeAngle = parameters.walkableSlopeAngle;
  117878. rc.walkableHeight = parameters.walkableHeight;
  117879. rc.walkableClimb = parameters.walkableClimb;
  117880. rc.walkableRadius = parameters.walkableRadius;
  117881. rc.maxEdgeLen = parameters.maxEdgeLen;
  117882. rc.maxSimplificationError = parameters.maxSimplificationError;
  117883. rc.minRegionArea = parameters.minRegionArea;
  117884. rc.mergeRegionArea = parameters.mergeRegionArea;
  117885. rc.maxVertsPerPoly = parameters.maxVertsPerPoly;
  117886. rc.detailSampleDist = parameters.detailSampleDist;
  117887. rc.detailSampleMaxError = parameters.detailSampleMaxError;
  117888. this.navMesh = new this.bjsRECAST.NavMesh();
  117889. var index;
  117890. var tri;
  117891. var pt;
  117892. var indices = [];
  117893. var positions = [];
  117894. var offset = 0;
  117895. for (index = 0; index < meshes.length; index++) {
  117896. if (meshes[index]) {
  117897. var mesh = meshes[index];
  117898. var meshIndices = mesh.getIndices();
  117899. if (!meshIndices) {
  117900. continue;
  117901. }
  117902. var meshPositions = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, false, false);
  117903. if (!meshPositions) {
  117904. continue;
  117905. }
  117906. var wm = mesh.computeWorldMatrix(false);
  117907. for (tri = 0; tri < meshIndices.length; tri++) {
  117908. indices.push(meshIndices[tri] + offset);
  117909. }
  117910. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  117911. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  117912. for (pt = 0; pt < meshPositions.length; pt += 3) {
  117913. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArrayToRef(meshPositions, pt, position);
  117914. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, wm, transformed);
  117915. positions.push(transformed.x, transformed.y, transformed.z);
  117916. }
  117917. offset += meshPositions.length / 3;
  117918. }
  117919. }
  117920. this.navMesh.build(positions, offset, indices, indices.length, rc);
  117921. };
  117922. /**
  117923. * Create a navigation mesh debug mesh
  117924. * @param scene is where the mesh will be added
  117925. * @returns debug display mesh
  117926. */
  117927. RecastJSPlugin.prototype.createDebugNavMesh = function (scene) {
  117928. var tri;
  117929. var pt;
  117930. var debugNavMesh = this.navMesh.getDebugNavMesh();
  117931. var triangleCount = debugNavMesh.getTriangleCount();
  117932. var indices = [];
  117933. var positions = [];
  117934. for (tri = 0; tri < triangleCount * 3; tri++) {
  117935. indices.push(tri);
  117936. }
  117937. for (tri = 0; tri < triangleCount; tri++) {
  117938. for (pt = 0; pt < 3; pt++) {
  117939. var point = debugNavMesh.getTriangle(tri).getPoint(pt);
  117940. positions.push(point.x, point.y, point.z);
  117941. }
  117942. }
  117943. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("NavMeshDebug", scene);
  117944. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  117945. vertexData.indices = indices;
  117946. vertexData.positions = positions;
  117947. vertexData.applyToMesh(mesh, false);
  117948. return mesh;
  117949. };
  117950. /**
  117951. * Get a navigation mesh constrained position, closest to the parameter position
  117952. * @param position world position
  117953. * @returns the closest point to position constrained by the navigation mesh
  117954. */
  117955. RecastJSPlugin.prototype.getClosestPoint = function (position) {
  117956. var p = new this.bjsRECAST.Vec3(position.x, position.y, position.z);
  117957. var ret = this.navMesh.getClosestPoint(p);
  117958. var pr = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](ret.x, ret.y, ret.z);
  117959. return pr;
  117960. };
  117961. /**
  117962. * Get a navigation mesh constrained position, within a particular radius
  117963. * @param position world position
  117964. * @param maxRadius the maximum distance to the constrained world position
  117965. * @returns the closest point to position constrained by the navigation mesh
  117966. */
  117967. RecastJSPlugin.prototype.getRandomPointAround = function (position, maxRadius) {
  117968. var p = new this.bjsRECAST.Vec3(position.x, position.y, position.z);
  117969. var ret = this.navMesh.getRandomPointAround(p, maxRadius);
  117970. var pr = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](ret.x, ret.y, ret.z);
  117971. return pr;
  117972. };
  117973. /**
  117974. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  117975. * @param start world position
  117976. * @param end world position
  117977. * @returns array containing world position composing the path
  117978. */
  117979. RecastJSPlugin.prototype.computePath = function (start, end) {
  117980. var pt;
  117981. var startPos = new this.bjsRECAST.Vec3(start.x, start.y, start.z);
  117982. var endPos = new this.bjsRECAST.Vec3(end.x, end.y, end.z);
  117983. var navPath = this.navMesh.computePath(startPos, endPos);
  117984. var pointCount = navPath.getPointCount();
  117985. var positions = [];
  117986. for (pt = 0; pt < pointCount; pt++) {
  117987. var p = navPath.getPoint(pt);
  117988. positions.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](p.x, p.y, p.z));
  117989. }
  117990. return positions;
  117991. };
  117992. /**
  117993. * Create a new Crowd so you can add agents
  117994. * @param maxAgents the maximum agent count in the crowd
  117995. * @param maxAgentRadius the maximum radius an agent can have
  117996. * @param scene to attach the crowd to
  117997. * @returns the crowd you can add agents to
  117998. */
  117999. RecastJSPlugin.prototype.createCrowd = function (maxAgents, maxAgentRadius, scene) {
  118000. var crowd = new RecastJSCrowd(this, maxAgents, maxAgentRadius, scene);
  118001. return crowd;
  118002. };
  118003. /**
  118004. * Disposes
  118005. */
  118006. RecastJSPlugin.prototype.dispose = function () {
  118007. };
  118008. /**
  118009. * If this plugin is supported
  118010. * @returns true if plugin is supported
  118011. */
  118012. RecastJSPlugin.prototype.isSupported = function () {
  118013. return this.bjsRECAST !== undefined;
  118014. };
  118015. return RecastJSPlugin;
  118016. }());
  118017. /**
  118018. * Recast detour crowd implementation
  118019. */
  118020. var RecastJSCrowd = /** @class */ (function () {
  118021. /**
  118022. * Constructor
  118023. * @param plugin recastJS plugin
  118024. * @param maxAgents the maximum agent count in the crowd
  118025. * @param maxAgentRadius the maximum radius an agent can have
  118026. * @param scene to attach the crowd to
  118027. * @returns the crowd you can add agents to
  118028. */
  118029. function RecastJSCrowd(plugin, maxAgents, maxAgentRadius, scene) {
  118030. var _this = this;
  118031. /**
  118032. * Link to the detour crowd
  118033. */
  118034. this.recastCrowd = {};
  118035. /**
  118036. * One transform per agent
  118037. */
  118038. this.transforms = new Array();
  118039. /**
  118040. * All agents created
  118041. */
  118042. this.agents = new Array();
  118043. /**
  118044. * Observer for crowd updates
  118045. */
  118046. this._onBeforeAnimationsObserver = null;
  118047. this.bjsRECASTPlugin = plugin;
  118048. this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(maxAgents, maxAgentRadius, this.bjsRECASTPlugin.navMesh.getNavMesh());
  118049. this._scene = scene;
  118050. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  118051. _this.update(scene.getEngine().getDeltaTime() * 0.001);
  118052. });
  118053. }
  118054. /**
  118055. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118056. * You can attach anything to that node. The node position is updated in the scene update tick.
  118057. * @param pos world position that will be constrained by the navigation mesh
  118058. * @param parameters agent parameters
  118059. * @param transform hooked to the agent that will be update by the scene
  118060. * @returns agent index
  118061. */
  118062. RecastJSCrowd.prototype.addAgent = function (pos, parameters, transform) {
  118063. var agentParams = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams();
  118064. agentParams.radius = parameters.radius;
  118065. agentParams.height = parameters.height;
  118066. agentParams.maxAcceleration = parameters.maxAcceleration;
  118067. agentParams.maxSpeed = parameters.maxSpeed;
  118068. agentParams.collisionQueryRange = parameters.collisionQueryRange;
  118069. agentParams.pathOptimizationRange = parameters.pathOptimizationRange;
  118070. agentParams.separationWeight = parameters.separationWeight;
  118071. agentParams.updateFlags = 7;
  118072. agentParams.obstacleAvoidanceType = 0;
  118073. agentParams.queryFilterType = 0;
  118074. agentParams.userData = 0;
  118075. var agentIndex = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(pos.x, pos.y, pos.z), agentParams);
  118076. this.transforms.push(transform);
  118077. this.agents.push(agentIndex);
  118078. return agentIndex;
  118079. };
  118080. /**
  118081. * Returns the agent position in world space
  118082. * @param index agent index returned by addAgent
  118083. * @returns world space position
  118084. */
  118085. RecastJSCrowd.prototype.getAgentPosition = function (index) {
  118086. var agentPos = this.recastCrowd.getAgentPosition(index);
  118087. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](agentPos.x, agentPos.y, agentPos.z);
  118088. };
  118089. /**
  118090. * Returns the agent velocity in world space
  118091. * @param index agent index returned by addAgent
  118092. * @returns world space velocity
  118093. */
  118094. RecastJSCrowd.prototype.getAgentVelocity = function (index) {
  118095. var agentVel = this.recastCrowd.getAgentVelocity(index);
  118096. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](agentVel.x, agentVel.y, agentVel.z);
  118097. };
  118098. /**
  118099. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118100. * @param index agent index returned by addAgent
  118101. * @param destination targeted world position
  118102. */
  118103. RecastJSCrowd.prototype.agentGoto = function (index, destination) {
  118104. this.recastCrowd.agentGoto(index, new this.bjsRECASTPlugin.bjsRECAST.Vec3(destination.x, destination.y, destination.z));
  118105. };
  118106. /**
  118107. * remove a particular agent previously created
  118108. * @param index agent index returned by addAgent
  118109. */
  118110. RecastJSCrowd.prototype.removeAgent = function (index) {
  118111. this.recastCrowd.removeAgent(index);
  118112. var item = this.agents.indexOf(index);
  118113. if (item > -1) {
  118114. this.agents.splice(item, 1);
  118115. this.transforms.splice(item, 1);
  118116. }
  118117. };
  118118. /**
  118119. * get the list of all agents attached to this crowd
  118120. * @returns list of agent indices
  118121. */
  118122. RecastJSCrowd.prototype.getAgents = function () {
  118123. return this.agents;
  118124. };
  118125. /**
  118126. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118127. * @param deltaTime in seconds
  118128. */
  118129. RecastJSCrowd.prototype.update = function (deltaTime) {
  118130. // update crowd
  118131. this.recastCrowd.update(deltaTime);
  118132. // update transforms
  118133. for (var index = 0; index < this.agents.length; index++) {
  118134. this.transforms[index].position = this.getAgentPosition(this.agents[index]);
  118135. }
  118136. };
  118137. /**
  118138. * Release all resources
  118139. */
  118140. RecastJSCrowd.prototype.dispose = function () {
  118141. this.recastCrowd.destroy();
  118142. this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  118143. this._onBeforeAnimationsObserver = null;
  118144. };
  118145. return RecastJSCrowd;
  118146. }());
  118147. /***/ }),
  118148. /***/ "./Navigation/index.ts":
  118149. /*!*****************************!*\
  118150. !*** ./Navigation/index.ts ***!
  118151. \*****************************/
  118152. /*! exports provided: RecastJSPlugin, RecastJSCrowd */
  118153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118154. "use strict";
  118155. __webpack_require__.r(__webpack_exports__);
  118156. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Plugins/index */ "./Navigation/Plugins/index.ts");
  118157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_0__["RecastJSPlugin"]; });
  118158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSCrowd", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_0__["RecastJSCrowd"]; });
  118159. /***/ }),
  118160. /***/ "./Offline/database.ts":
  118161. /*!*****************************!*\
  118162. !*** ./Offline/database.ts ***!
  118163. \*****************************/
  118164. /*! exports provided: Database */
  118165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118166. "use strict";
  118167. __webpack_require__.r(__webpack_exports__);
  118168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  118169. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  118170. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118171. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  118172. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  118173. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  118174. // Sets the default offline provider to Babylon.js
  118175. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  118176. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  118177. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  118178. };
  118179. /**
  118180. * Class used to enable access to IndexedDB
  118181. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118182. */
  118183. var Database = /** @class */ (function () {
  118184. /**
  118185. * Creates a new Database
  118186. * @param urlToScene defines the url to load the scene
  118187. * @param callbackManifestChecked defines the callback to use when manifest is checked
  118188. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  118189. */
  118190. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  118191. var _this = this;
  118192. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  118193. // Handling various flavors of prefixed version of IndexedDB
  118194. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  118195. this._callbackManifestChecked = callbackManifestChecked;
  118196. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  118197. this._db = null;
  118198. this._enableSceneOffline = false;
  118199. this._enableTexturesOffline = false;
  118200. this._manifestVersionFound = 0;
  118201. this._mustUpdateRessources = false;
  118202. this._hasReachedQuota = false;
  118203. if (!Database.IDBStorageEnabled) {
  118204. this._callbackManifestChecked(true);
  118205. }
  118206. else {
  118207. if (disableManifestCheck) {
  118208. this._enableSceneOffline = true;
  118209. this._enableTexturesOffline = true;
  118210. this._manifestVersionFound = 1;
  118211. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  118212. _this._callbackManifestChecked(true);
  118213. });
  118214. }
  118215. else {
  118216. this._checkManifestFile();
  118217. }
  118218. }
  118219. }
  118220. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  118221. /**
  118222. * Gets a boolean indicating if scene must be saved in the database
  118223. */
  118224. get: function () {
  118225. return this._enableSceneOffline;
  118226. },
  118227. enumerable: true,
  118228. configurable: true
  118229. });
  118230. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  118231. /**
  118232. * Gets a boolean indicating if textures must be saved in the database
  118233. */
  118234. get: function () {
  118235. return this._enableTexturesOffline;
  118236. },
  118237. enumerable: true,
  118238. configurable: true
  118239. });
  118240. Database.prototype._checkManifestFile = function () {
  118241. var _this = this;
  118242. var noManifestFile = function () {
  118243. _this._enableSceneOffline = false;
  118244. _this._enableTexturesOffline = false;
  118245. _this._callbackManifestChecked(false);
  118246. };
  118247. var timeStampUsed = false;
  118248. var manifestURL = this._currentSceneUrl + ".manifest";
  118249. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  118250. if (navigator.onLine) {
  118251. // Adding a timestamp to by-pass browsers' cache
  118252. timeStampUsed = true;
  118253. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  118254. }
  118255. xhr.open("GET", manifestURL);
  118256. xhr.addEventListener("load", function () {
  118257. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  118258. try {
  118259. var manifestFile = JSON.parse(xhr.response);
  118260. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  118261. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  118262. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  118263. _this._manifestVersionFound = manifestFile.version;
  118264. }
  118265. if (_this._callbackManifestChecked) {
  118266. _this._callbackManifestChecked(true);
  118267. }
  118268. }
  118269. catch (ex) {
  118270. noManifestFile();
  118271. }
  118272. }
  118273. else {
  118274. noManifestFile();
  118275. }
  118276. }, false);
  118277. xhr.addEventListener("error", function () {
  118278. if (timeStampUsed) {
  118279. timeStampUsed = false;
  118280. // Let's retry without the timeStamp
  118281. // It could fail when coupled with HTML5 Offline API
  118282. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  118283. xhr.open("GET", retryManifestURL);
  118284. xhr.send();
  118285. }
  118286. else {
  118287. noManifestFile();
  118288. }
  118289. }, false);
  118290. try {
  118291. xhr.send();
  118292. }
  118293. catch (ex) {
  118294. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  118295. this._callbackManifestChecked(false);
  118296. }
  118297. };
  118298. /**
  118299. * Open the database and make it available
  118300. * @param successCallback defines the callback to call on success
  118301. * @param errorCallback defines the callback to call on error
  118302. */
  118303. Database.prototype.open = function (successCallback, errorCallback) {
  118304. var _this = this;
  118305. var handleError = function () {
  118306. _this._isSupported = false;
  118307. if (errorCallback) {
  118308. errorCallback();
  118309. }
  118310. };
  118311. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  118312. // Your browser doesn't support IndexedDB
  118313. this._isSupported = false;
  118314. if (errorCallback) {
  118315. errorCallback();
  118316. }
  118317. }
  118318. else {
  118319. // If the DB hasn't been opened or created yet
  118320. if (!this._db) {
  118321. this._hasReachedQuota = false;
  118322. this._isSupported = true;
  118323. var request = this._idbFactory.open("babylonjs", 1);
  118324. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  118325. request.onerror = function () {
  118326. handleError();
  118327. };
  118328. // executes when a version change transaction cannot complete due to other active transactions
  118329. request.onblocked = function () {
  118330. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  118331. handleError();
  118332. };
  118333. // DB has been opened successfully
  118334. request.onsuccess = function () {
  118335. _this._db = request.result;
  118336. successCallback();
  118337. };
  118338. // Initialization of the DB. Creating Scenes & Textures stores
  118339. request.onupgradeneeded = function (event) {
  118340. _this._db = (event.target).result;
  118341. if (_this._db) {
  118342. try {
  118343. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  118344. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  118345. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  118346. }
  118347. catch (ex) {
  118348. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  118349. handleError();
  118350. }
  118351. }
  118352. };
  118353. }
  118354. // DB has already been created and opened
  118355. else {
  118356. if (successCallback) {
  118357. successCallback();
  118358. }
  118359. }
  118360. }
  118361. };
  118362. /**
  118363. * Loads an image from the database
  118364. * @param url defines the url to load from
  118365. * @param image defines the target DOM image
  118366. */
  118367. Database.prototype.loadImage = function (url, image) {
  118368. var _this = this;
  118369. var completeURL = Database._ReturnFullUrlLocation(url);
  118370. var saveAndLoadImage = function () {
  118371. if (!_this._hasReachedQuota && _this._db !== null) {
  118372. // the texture is not yet in the DB, let's try to save it
  118373. _this._saveImageIntoDBAsync(completeURL, image);
  118374. }
  118375. // If the texture is not in the DB and we've reached the DB quota limit
  118376. // let's load it directly from the web
  118377. else {
  118378. image.src = url;
  118379. }
  118380. };
  118381. if (!this._mustUpdateRessources) {
  118382. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  118383. }
  118384. // First time we're download the images or update requested in the manifest file by a version change
  118385. else {
  118386. saveAndLoadImage();
  118387. }
  118388. };
  118389. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  118390. if (this._isSupported && this._db !== null) {
  118391. var texture;
  118392. var transaction = this._db.transaction(["textures"]);
  118393. transaction.onabort = function () {
  118394. image.src = url;
  118395. };
  118396. transaction.oncomplete = function () {
  118397. var blobTextureURL;
  118398. if (texture) {
  118399. var URL = window.URL || window.webkitURL;
  118400. blobTextureURL = URL.createObjectURL(texture.data);
  118401. image.onerror = function () {
  118402. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  118403. image.src = url;
  118404. };
  118405. image.src = blobTextureURL;
  118406. }
  118407. else {
  118408. notInDBCallback();
  118409. }
  118410. };
  118411. var getRequest = transaction.objectStore("textures").get(url);
  118412. getRequest.onsuccess = function (event) {
  118413. texture = (event.target).result;
  118414. };
  118415. getRequest.onerror = function () {
  118416. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  118417. image.src = url;
  118418. };
  118419. }
  118420. else {
  118421. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  118422. image.src = url;
  118423. }
  118424. };
  118425. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  118426. var _this = this;
  118427. if (this._isSupported) {
  118428. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  118429. var generateBlobUrl = function () {
  118430. var blobTextureURL;
  118431. if (blob) {
  118432. var URL = window.URL || window.webkitURL;
  118433. try {
  118434. blobTextureURL = URL.createObjectURL(blob);
  118435. }
  118436. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  118437. catch (ex) {
  118438. blobTextureURL = URL.createObjectURL(blob);
  118439. }
  118440. }
  118441. if (blobTextureURL) {
  118442. image.src = blobTextureURL;
  118443. }
  118444. };
  118445. if (Database.IsUASupportingBlobStorage) { // Create XHR
  118446. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  118447. xhr.open("GET", url);
  118448. xhr.responseType = "blob";
  118449. xhr.addEventListener("load", function () {
  118450. if (xhr.status === 200 && _this._db) {
  118451. // Blob as response (XHR2)
  118452. blob = xhr.response;
  118453. var transaction = _this._db.transaction(["textures"], "readwrite");
  118454. // the transaction could abort because of a QuotaExceededError error
  118455. transaction.onabort = function (event) {
  118456. try {
  118457. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  118458. var srcElement = (event.srcElement || event.target);
  118459. var error = srcElement.error;
  118460. if (error && error.name === "QuotaExceededError") {
  118461. _this._hasReachedQuota = true;
  118462. }
  118463. }
  118464. catch (ex) { }
  118465. generateBlobUrl();
  118466. };
  118467. transaction.oncomplete = function () {
  118468. generateBlobUrl();
  118469. };
  118470. var newTexture = { textureUrl: url, data: blob };
  118471. try {
  118472. // Put the blob into the dabase
  118473. var addRequest = transaction.objectStore("textures").put(newTexture);
  118474. addRequest.onsuccess = function () {
  118475. };
  118476. addRequest.onerror = function () {
  118477. generateBlobUrl();
  118478. };
  118479. }
  118480. catch (ex) {
  118481. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  118482. if (ex.code === 25) {
  118483. Database.IsUASupportingBlobStorage = false;
  118484. _this._enableTexturesOffline = false;
  118485. }
  118486. image.src = url;
  118487. }
  118488. }
  118489. else {
  118490. image.src = url;
  118491. }
  118492. }, false);
  118493. xhr.addEventListener("error", function () {
  118494. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  118495. image.src = url;
  118496. }, false);
  118497. xhr.send();
  118498. }
  118499. else {
  118500. image.src = url;
  118501. }
  118502. }
  118503. else {
  118504. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  118505. image.src = url;
  118506. }
  118507. };
  118508. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  118509. var _this = this;
  118510. var updateVersion = function () {
  118511. // the version is not yet in the DB or we need to update it
  118512. _this._saveVersionIntoDBAsync(url, versionLoaded);
  118513. };
  118514. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  118515. };
  118516. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  118517. var _this = this;
  118518. if (this._isSupported && this._db) {
  118519. var version;
  118520. try {
  118521. var transaction = this._db.transaction(["versions"]);
  118522. transaction.oncomplete = function () {
  118523. if (version) {
  118524. // If the version in the JSON file is different from the version in DB
  118525. if (_this._manifestVersionFound !== version.data) {
  118526. _this._mustUpdateRessources = true;
  118527. updateInDBCallback();
  118528. }
  118529. else {
  118530. callback(version.data);
  118531. }
  118532. }
  118533. // version was not found in DB
  118534. else {
  118535. _this._mustUpdateRessources = true;
  118536. updateInDBCallback();
  118537. }
  118538. };
  118539. transaction.onabort = function () {
  118540. callback(-1);
  118541. };
  118542. var getRequest = transaction.objectStore("versions").get(url);
  118543. getRequest.onsuccess = function (event) {
  118544. version = (event.target).result;
  118545. };
  118546. getRequest.onerror = function () {
  118547. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  118548. callback(-1);
  118549. };
  118550. }
  118551. catch (ex) {
  118552. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  118553. callback(-1);
  118554. }
  118555. }
  118556. else {
  118557. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  118558. callback(-1);
  118559. }
  118560. };
  118561. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  118562. var _this = this;
  118563. if (this._isSupported && !this._hasReachedQuota && this._db) {
  118564. try {
  118565. // Open a transaction to the database
  118566. var transaction = this._db.transaction(["versions"], "readwrite");
  118567. // the transaction could abort because of a QuotaExceededError error
  118568. transaction.onabort = function (event) {
  118569. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  118570. var error = event.srcElement['error'];
  118571. if (error && error.name === "QuotaExceededError") {
  118572. _this._hasReachedQuota = true;
  118573. }
  118574. }
  118575. catch (ex) { }
  118576. callback(-1);
  118577. };
  118578. transaction.oncomplete = function () {
  118579. callback(_this._manifestVersionFound);
  118580. };
  118581. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  118582. // Put the scene into the database
  118583. var addRequest = transaction.objectStore("versions").put(newVersion);
  118584. addRequest.onsuccess = function () {
  118585. };
  118586. addRequest.onerror = function () {
  118587. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  118588. };
  118589. }
  118590. catch (ex) {
  118591. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  118592. callback(-1);
  118593. }
  118594. }
  118595. else {
  118596. callback(-1);
  118597. }
  118598. };
  118599. /**
  118600. * Loads a file from database
  118601. * @param url defines the URL to load from
  118602. * @param sceneLoaded defines a callback to call on success
  118603. * @param progressCallBack defines a callback to call when progress changed
  118604. * @param errorCallback defines a callback to call on error
  118605. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  118606. */
  118607. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  118608. var _this = this;
  118609. var completeUrl = Database._ReturnFullUrlLocation(url);
  118610. var saveAndLoadFile = function () {
  118611. // the scene is not yet in the DB, let's try to save it
  118612. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  118613. };
  118614. this._checkVersionFromDB(completeUrl, function (version) {
  118615. if (version !== -1) {
  118616. if (!_this._mustUpdateRessources) {
  118617. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  118618. }
  118619. else {
  118620. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  118621. }
  118622. }
  118623. else {
  118624. if (errorCallback) {
  118625. errorCallback();
  118626. }
  118627. }
  118628. });
  118629. };
  118630. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  118631. if (this._isSupported && this._db) {
  118632. var targetStore;
  118633. if (url.indexOf(".babylon") !== -1) {
  118634. targetStore = "scenes";
  118635. }
  118636. else {
  118637. targetStore = "textures";
  118638. }
  118639. var file;
  118640. var transaction = this._db.transaction([targetStore]);
  118641. transaction.oncomplete = function () {
  118642. if (file) {
  118643. callback(file.data);
  118644. }
  118645. // file was not found in DB
  118646. else {
  118647. notInDBCallback();
  118648. }
  118649. };
  118650. transaction.onabort = function () {
  118651. notInDBCallback();
  118652. };
  118653. var getRequest = transaction.objectStore(targetStore).get(url);
  118654. getRequest.onsuccess = function (event) {
  118655. file = (event.target).result;
  118656. };
  118657. getRequest.onerror = function () {
  118658. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  118659. notInDBCallback();
  118660. };
  118661. }
  118662. else {
  118663. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  118664. callback();
  118665. }
  118666. };
  118667. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  118668. var _this = this;
  118669. if (this._isSupported) {
  118670. var targetStore;
  118671. if (url.indexOf(".babylon") !== -1) {
  118672. targetStore = "scenes";
  118673. }
  118674. else {
  118675. targetStore = "textures";
  118676. }
  118677. // Create XHR
  118678. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  118679. var fileData;
  118680. xhr.open("GET", url + "?" + Date.now());
  118681. if (useArrayBuffer) {
  118682. xhr.responseType = "arraybuffer";
  118683. }
  118684. if (progressCallback) {
  118685. xhr.onprogress = progressCallback;
  118686. }
  118687. xhr.addEventListener("load", function () {
  118688. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  118689. // Blob as response (XHR2)
  118690. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  118691. if (!_this._hasReachedQuota && _this._db) {
  118692. // Open a transaction to the database
  118693. var transaction = _this._db.transaction([targetStore], "readwrite");
  118694. // the transaction could abort because of a QuotaExceededError error
  118695. transaction.onabort = function (event) {
  118696. try {
  118697. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  118698. var error = event.srcElement['error'];
  118699. if (error && error.name === "QuotaExceededError") {
  118700. _this._hasReachedQuota = true;
  118701. }
  118702. }
  118703. catch (ex) { }
  118704. callback(fileData);
  118705. };
  118706. transaction.oncomplete = function () {
  118707. callback(fileData);
  118708. };
  118709. var newFile;
  118710. if (targetStore === "scenes") {
  118711. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  118712. }
  118713. else {
  118714. newFile = { textureUrl: url, data: fileData };
  118715. }
  118716. try {
  118717. // Put the scene into the database
  118718. var addRequest = transaction.objectStore(targetStore).put(newFile);
  118719. addRequest.onsuccess = function () {
  118720. };
  118721. addRequest.onerror = function () {
  118722. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  118723. };
  118724. }
  118725. catch (ex) {
  118726. callback(fileData);
  118727. }
  118728. }
  118729. else {
  118730. callback(fileData);
  118731. }
  118732. }
  118733. else {
  118734. if (xhr.status >= 400 && errorCallback) {
  118735. errorCallback(xhr);
  118736. }
  118737. else {
  118738. callback();
  118739. }
  118740. }
  118741. }, false);
  118742. xhr.addEventListener("error", function () {
  118743. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  118744. callback();
  118745. }, false);
  118746. xhr.send();
  118747. }
  118748. else {
  118749. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  118750. callback();
  118751. }
  118752. };
  118753. /**
  118754. * Validates if xhr data is correct
  118755. * @param xhr defines the request to validate
  118756. * @param dataType defines the expected data type
  118757. * @returns true if data is correct
  118758. */
  118759. Database._ValidateXHRData = function (xhr, dataType) {
  118760. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  118761. if (dataType === void 0) { dataType = 7; }
  118762. try {
  118763. if (dataType & 1) {
  118764. if (xhr.responseText && xhr.responseText.length > 0) {
  118765. return true;
  118766. }
  118767. else if (dataType === 1) {
  118768. return false;
  118769. }
  118770. }
  118771. if (dataType & 2) {
  118772. // Check header width and height since there is no "TGA" magic number
  118773. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  118774. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  118775. return true;
  118776. }
  118777. else if (dataType === 2) {
  118778. return false;
  118779. }
  118780. }
  118781. if (dataType & 4) {
  118782. // Check for the "DDS" magic number
  118783. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  118784. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  118785. return true;
  118786. }
  118787. else {
  118788. return false;
  118789. }
  118790. }
  118791. }
  118792. catch (e) {
  118793. // Global protection
  118794. }
  118795. return false;
  118796. };
  118797. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  118798. Database.IsUASupportingBlobStorage = true;
  118799. /**
  118800. * Gets a boolean indicating if Database storate is enabled (off by default)
  118801. */
  118802. Database.IDBStorageEnabled = false;
  118803. Database._ParseURL = function (url) {
  118804. var a = document.createElement('a');
  118805. a.href = url;
  118806. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  118807. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  118808. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  118809. return absLocation;
  118810. };
  118811. Database._ReturnFullUrlLocation = function (url) {
  118812. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  118813. return (Database._ParseURL(window.location.href) + url);
  118814. }
  118815. else {
  118816. return url;
  118817. }
  118818. };
  118819. return Database;
  118820. }());
  118821. /***/ }),
  118822. /***/ "./Offline/index.ts":
  118823. /*!**************************!*\
  118824. !*** ./Offline/index.ts ***!
  118825. \**************************/
  118826. /*! exports provided: Database */
  118827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118828. "use strict";
  118829. __webpack_require__.r(__webpack_exports__);
  118830. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  118831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  118832. /***/ }),
  118833. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  118834. /*!******************************************************!*\
  118835. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  118836. \******************************************************/
  118837. /*! exports provided: BoxParticleEmitter */
  118838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118839. "use strict";
  118840. __webpack_require__.r(__webpack_exports__);
  118841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  118842. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  118843. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  118844. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  118845. /**
  118846. * Particle emitter emitting particles from the inside of a box.
  118847. * It emits the particles randomly between 2 given directions.
  118848. */
  118849. var BoxParticleEmitter = /** @class */ (function () {
  118850. /**
  118851. * Creates a new instance BoxParticleEmitter
  118852. */
  118853. function BoxParticleEmitter() {
  118854. /**
  118855. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  118856. */
  118857. this.direction1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  118858. /**
  118859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  118860. */
  118861. this.direction2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  118862. /**
  118863. * 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.
  118864. */
  118865. this.minEmitBox = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  118866. /**
  118867. * 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.
  118868. */
  118869. this.maxEmitBox = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  118870. }
  118871. /**
  118872. * Called by the particle System when the direction is computed for the created particle.
  118873. * @param worldMatrix is the world matrix of the particle system
  118874. * @param directionToUpdate is the direction vector to update with the result
  118875. * @param particle is the particle we are computed the direction for
  118876. */
  118877. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  118878. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  118879. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  118880. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  118881. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  118882. };
  118883. /**
  118884. * Called by the particle System when the position is computed for the created particle.
  118885. * @param worldMatrix is the world matrix of the particle system
  118886. * @param positionToUpdate is the position vector to update with the result
  118887. * @param particle is the particle we are computed the position for
  118888. */
  118889. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  118890. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  118891. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  118892. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  118893. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  118894. };
  118895. /**
  118896. * Clones the current emitter and returns a copy of it
  118897. * @returns the new emitter
  118898. */
  118899. BoxParticleEmitter.prototype.clone = function () {
  118900. var newOne = new BoxParticleEmitter();
  118901. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  118902. return newOne;
  118903. };
  118904. /**
  118905. * Called by the GPUParticleSystem to setup the update shader
  118906. * @param effect defines the update shader
  118907. */
  118908. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  118909. effect.setVector3("direction1", this.direction1);
  118910. effect.setVector3("direction2", this.direction2);
  118911. effect.setVector3("minEmitBox", this.minEmitBox);
  118912. effect.setVector3("maxEmitBox", this.maxEmitBox);
  118913. };
  118914. /**
  118915. * Returns a string to use to update the GPU particles update shader
  118916. * @returns a string containng the defines string
  118917. */
  118918. BoxParticleEmitter.prototype.getEffectDefines = function () {
  118919. return "#define BOXEMITTER";
  118920. };
  118921. /**
  118922. * Returns the string "BoxParticleEmitter"
  118923. * @returns a string containing the class name
  118924. */
  118925. BoxParticleEmitter.prototype.getClassName = function () {
  118926. return "BoxParticleEmitter";
  118927. };
  118928. /**
  118929. * Serializes the particle system to a JSON object.
  118930. * @returns the JSON object
  118931. */
  118932. BoxParticleEmitter.prototype.serialize = function () {
  118933. var serializationObject = {};
  118934. serializationObject.type = this.getClassName();
  118935. serializationObject.direction1 = this.direction1.asArray();
  118936. serializationObject.direction2 = this.direction2.asArray();
  118937. serializationObject.minEmitBox = this.minEmitBox.asArray();
  118938. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  118939. return serializationObject;
  118940. };
  118941. /**
  118942. * Parse properties from a JSON object
  118943. * @param serializationObject defines the JSON object
  118944. */
  118945. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  118946. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  118947. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  118948. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  118949. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  118950. };
  118951. return BoxParticleEmitter;
  118952. }());
  118953. /***/ }),
  118954. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  118955. /*!*******************************************************!*\
  118956. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  118957. \*******************************************************/
  118958. /*! exports provided: ConeParticleEmitter */
  118959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118960. "use strict";
  118961. __webpack_require__.r(__webpack_exports__);
  118962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  118963. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  118964. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  118965. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  118966. /**
  118967. * Particle emitter emitting particles from the inside of a cone.
  118968. * It emits the particles alongside the cone volume from the base to the particle.
  118969. * The emission direction might be randomized.
  118970. */
  118971. var ConeParticleEmitter = /** @class */ (function () {
  118972. /**
  118973. * Creates a new instance ConeParticleEmitter
  118974. * @param radius the radius of the emission cone (1 by default)
  118975. * @param angle the cone base angle (PI by default)
  118976. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  118977. */
  118978. function ConeParticleEmitter(radius, angle,
  118979. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  118980. directionRandomizer) {
  118981. if (radius === void 0) { radius = 1; }
  118982. if (angle === void 0) { angle = Math.PI; }
  118983. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  118984. this.directionRandomizer = directionRandomizer;
  118985. /**
  118986. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  118987. */
  118988. this.radiusRange = 1;
  118989. /**
  118990. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  118991. */
  118992. this.heightRange = 1;
  118993. /**
  118994. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  118995. */
  118996. this.emitFromSpawnPointOnly = false;
  118997. this.angle = angle;
  118998. this.radius = radius;
  118999. }
  119000. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  119001. /**
  119002. * Gets or sets the radius of the emission cone
  119003. */
  119004. get: function () {
  119005. return this._radius;
  119006. },
  119007. set: function (value) {
  119008. this._radius = value;
  119009. this._buildHeight();
  119010. },
  119011. enumerable: true,
  119012. configurable: true
  119013. });
  119014. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  119015. /**
  119016. * Gets or sets the angle of the emission cone
  119017. */
  119018. get: function () {
  119019. return this._angle;
  119020. },
  119021. set: function (value) {
  119022. this._angle = value;
  119023. this._buildHeight();
  119024. },
  119025. enumerable: true,
  119026. configurable: true
  119027. });
  119028. ConeParticleEmitter.prototype._buildHeight = function () {
  119029. if (this._angle !== 0) {
  119030. this._height = this._radius / Math.tan(this._angle / 2);
  119031. }
  119032. else {
  119033. this._height = 1;
  119034. }
  119035. };
  119036. /**
  119037. * Called by the particle System when the direction is computed for the created particle.
  119038. * @param worldMatrix is the world matrix of the particle system
  119039. * @param directionToUpdate is the direction vector to update with the result
  119040. * @param particle is the particle we are computed the direction for
  119041. */
  119042. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119043. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  119044. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  119045. }
  119046. else {
  119047. // measure the direction Vector from the emitter to the particle.
  119048. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  119049. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119050. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119051. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119052. direction.x += randX;
  119053. direction.y += randY;
  119054. direction.z += randZ;
  119055. direction.normalize();
  119056. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  119057. }
  119058. };
  119059. /**
  119060. * Called by the particle System when the position is computed for the created particle.
  119061. * @param worldMatrix is the world matrix of the particle system
  119062. * @param positionToUpdate is the position vector to update with the result
  119063. * @param particle is the particle we are computed the position for
  119064. */
  119065. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  119066. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  119067. var h;
  119068. if (!this.emitFromSpawnPointOnly) {
  119069. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  119070. // Better distribution in a cone at normal angles.
  119071. h = 1 - h * h;
  119072. }
  119073. else {
  119074. h = 0.0001;
  119075. }
  119076. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  119077. radius = radius * h;
  119078. var randX = radius * Math.sin(s);
  119079. var randZ = radius * Math.cos(s);
  119080. var randY = h * this._height;
  119081. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  119082. };
  119083. /**
  119084. * Clones the current emitter and returns a copy of it
  119085. * @returns the new emitter
  119086. */
  119087. ConeParticleEmitter.prototype.clone = function () {
  119088. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  119089. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  119090. return newOne;
  119091. };
  119092. /**
  119093. * Called by the GPUParticleSystem to setup the update shader
  119094. * @param effect defines the update shader
  119095. */
  119096. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  119097. effect.setFloat2("radius", this._radius, this.radiusRange);
  119098. effect.setFloat("coneAngle", this._angle);
  119099. effect.setFloat2("height", this._height, this.heightRange);
  119100. effect.setFloat("directionRandomizer", this.directionRandomizer);
  119101. };
  119102. /**
  119103. * Returns a string to use to update the GPU particles update shader
  119104. * @returns a string containng the defines string
  119105. */
  119106. ConeParticleEmitter.prototype.getEffectDefines = function () {
  119107. var defines = "#define CONEEMITTER";
  119108. if (this.emitFromSpawnPointOnly) {
  119109. defines += "\n#define CONEEMITTERSPAWNPOINT";
  119110. }
  119111. return defines;
  119112. };
  119113. /**
  119114. * Returns the string "ConeParticleEmitter"
  119115. * @returns a string containing the class name
  119116. */
  119117. ConeParticleEmitter.prototype.getClassName = function () {
  119118. return "ConeParticleEmitter";
  119119. };
  119120. /**
  119121. * Serializes the particle system to a JSON object.
  119122. * @returns the JSON object
  119123. */
  119124. ConeParticleEmitter.prototype.serialize = function () {
  119125. var serializationObject = {};
  119126. serializationObject.type = this.getClassName();
  119127. serializationObject.radius = this._radius;
  119128. serializationObject.angle = this._angle;
  119129. serializationObject.directionRandomizer = this.directionRandomizer;
  119130. return serializationObject;
  119131. };
  119132. /**
  119133. * Parse properties from a JSON object
  119134. * @param serializationObject defines the JSON object
  119135. */
  119136. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  119137. this.radius = serializationObject.radius;
  119138. this.angle = serializationObject.angle;
  119139. this.directionRandomizer = serializationObject.directionRandomizer;
  119140. };
  119141. return ConeParticleEmitter;
  119142. }());
  119143. /***/ }),
  119144. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  119145. /*!***********************************************************!*\
  119146. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  119147. \***********************************************************/
  119148. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  119149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119150. "use strict";
  119151. __webpack_require__.r(__webpack_exports__);
  119152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  119153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  119154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119155. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  119156. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  119157. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  119158. /**
  119159. * Particle emitter emitting particles from the inside of a cylinder.
  119160. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  119161. */
  119162. var CylinderParticleEmitter = /** @class */ (function () {
  119163. /**
  119164. * Creates a new instance CylinderParticleEmitter
  119165. * @param radius the radius of the emission cylinder (1 by default)
  119166. * @param height the height of the emission cylinder (1 by default)
  119167. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  119168. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  119169. */
  119170. function CylinderParticleEmitter(
  119171. /**
  119172. * The radius of the emission cylinder.
  119173. */
  119174. radius,
  119175. /**
  119176. * The height of the emission cylinder.
  119177. */
  119178. height,
  119179. /**
  119180. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  119181. */
  119182. radiusRange,
  119183. /**
  119184. * How much to randomize the particle direction [0-1].
  119185. */
  119186. directionRandomizer) {
  119187. if (radius === void 0) { radius = 1; }
  119188. if (height === void 0) { height = 1; }
  119189. if (radiusRange === void 0) { radiusRange = 1; }
  119190. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  119191. this.radius = radius;
  119192. this.height = height;
  119193. this.radiusRange = radiusRange;
  119194. this.directionRandomizer = directionRandomizer;
  119195. }
  119196. /**
  119197. * Called by the particle System when the direction is computed for the created particle.
  119198. * @param worldMatrix is the world matrix of the particle system
  119199. * @param directionToUpdate is the direction vector to update with the result
  119200. * @param particle is the particle we are computed the direction for
  119201. */
  119202. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119203. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  119204. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  119205. var angle = Math.atan2(direction.x, direction.z);
  119206. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  119207. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  119208. direction.x = Math.sin(angle);
  119209. direction.z = Math.cos(angle);
  119210. direction.normalize();
  119211. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  119212. };
  119213. /**
  119214. * Called by the particle System when the position is computed for the created particle.
  119215. * @param worldMatrix is the world matrix of the particle system
  119216. * @param positionToUpdate is the position vector to update with the result
  119217. * @param particle is the particle we are computed the position for
  119218. */
  119219. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  119220. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  119221. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  119222. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  119223. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  119224. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  119225. var xPos = positionRadius * Math.cos(angle);
  119226. var zPos = positionRadius * Math.sin(angle);
  119227. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  119228. };
  119229. /**
  119230. * Clones the current emitter and returns a copy of it
  119231. * @returns the new emitter
  119232. */
  119233. CylinderParticleEmitter.prototype.clone = function () {
  119234. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  119235. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  119236. return newOne;
  119237. };
  119238. /**
  119239. * Called by the GPUParticleSystem to setup the update shader
  119240. * @param effect defines the update shader
  119241. */
  119242. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  119243. effect.setFloat("radius", this.radius);
  119244. effect.setFloat("height", this.height);
  119245. effect.setFloat("radiusRange", this.radiusRange);
  119246. effect.setFloat("directionRandomizer", this.directionRandomizer);
  119247. };
  119248. /**
  119249. * Returns a string to use to update the GPU particles update shader
  119250. * @returns a string containng the defines string
  119251. */
  119252. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  119253. return "#define CYLINDEREMITTER";
  119254. };
  119255. /**
  119256. * Returns the string "CylinderParticleEmitter"
  119257. * @returns a string containing the class name
  119258. */
  119259. CylinderParticleEmitter.prototype.getClassName = function () {
  119260. return "CylinderParticleEmitter";
  119261. };
  119262. /**
  119263. * Serializes the particle system to a JSON object.
  119264. * @returns the JSON object
  119265. */
  119266. CylinderParticleEmitter.prototype.serialize = function () {
  119267. var serializationObject = {};
  119268. serializationObject.type = this.getClassName();
  119269. serializationObject.radius = this.radius;
  119270. serializationObject.height = this.height;
  119271. serializationObject.radiusRange = this.radiusRange;
  119272. serializationObject.directionRandomizer = this.directionRandomizer;
  119273. return serializationObject;
  119274. };
  119275. /**
  119276. * Parse properties from a JSON object
  119277. * @param serializationObject defines the JSON object
  119278. */
  119279. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  119280. this.radius = serializationObject.radius;
  119281. this.height = serializationObject.height;
  119282. this.radiusRange = serializationObject.radiusRange;
  119283. this.directionRandomizer = serializationObject.directionRandomizer;
  119284. };
  119285. return CylinderParticleEmitter;
  119286. }());
  119287. /**
  119288. * Particle emitter emitting particles from the inside of a cylinder.
  119289. * It emits the particles randomly between two vectors.
  119290. */
  119291. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  119292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  119293. /**
  119294. * Creates a new instance CylinderDirectedParticleEmitter
  119295. * @param radius the radius of the emission cylinder (1 by default)
  119296. * @param height the height of the emission cylinder (1 by default)
  119297. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  119298. * @param direction1 the min limit of the emission direction (up vector by default)
  119299. * @param direction2 the max limit of the emission direction (up vector by default)
  119300. */
  119301. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  119302. /**
  119303. * The min limit of the emission direction.
  119304. */
  119305. direction1,
  119306. /**
  119307. * The max limit of the emission direction.
  119308. */
  119309. direction2) {
  119310. if (radius === void 0) { radius = 1; }
  119311. if (height === void 0) { height = 1; }
  119312. if (radiusRange === void 0) { radiusRange = 1; }
  119313. if (direction1 === void 0) { direction1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  119314. if (direction2 === void 0) { direction2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  119315. var _this = _super.call(this, radius, height, radiusRange) || this;
  119316. _this.direction1 = direction1;
  119317. _this.direction2 = direction2;
  119318. return _this;
  119319. }
  119320. /**
  119321. * Called by the particle System when the direction is computed for the created particle.
  119322. * @param worldMatrix is the world matrix of the particle system
  119323. * @param directionToUpdate is the direction vector to update with the result
  119324. * @param particle is the particle we are computed the direction for
  119325. */
  119326. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119327. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  119328. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  119329. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  119330. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  119331. };
  119332. /**
  119333. * Clones the current emitter and returns a copy of it
  119334. * @returns the new emitter
  119335. */
  119336. CylinderDirectedParticleEmitter.prototype.clone = function () {
  119337. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  119338. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  119339. return newOne;
  119340. };
  119341. /**
  119342. * Called by the GPUParticleSystem to setup the update shader
  119343. * @param effect defines the update shader
  119344. */
  119345. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  119346. effect.setFloat("radius", this.radius);
  119347. effect.setFloat("height", this.height);
  119348. effect.setFloat("radiusRange", this.radiusRange);
  119349. effect.setVector3("direction1", this.direction1);
  119350. effect.setVector3("direction2", this.direction2);
  119351. };
  119352. /**
  119353. * Returns a string to use to update the GPU particles update shader
  119354. * @returns a string containng the defines string
  119355. */
  119356. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  119357. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  119358. };
  119359. /**
  119360. * Returns the string "CylinderDirectedParticleEmitter"
  119361. * @returns a string containing the class name
  119362. */
  119363. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  119364. return "CylinderDirectedParticleEmitter";
  119365. };
  119366. /**
  119367. * Serializes the particle system to a JSON object.
  119368. * @returns the JSON object
  119369. */
  119370. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  119371. var serializationObject = _super.prototype.serialize.call(this);
  119372. serializationObject.direction1 = this.direction1.asArray();
  119373. serializationObject.direction2 = this.direction2.asArray();
  119374. return serializationObject;
  119375. };
  119376. /**
  119377. * Parse properties from a JSON object
  119378. * @param serializationObject defines the JSON object
  119379. */
  119380. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  119381. _super.prototype.parse.call(this, serializationObject);
  119382. this.direction1.copyFrom(serializationObject.direction1);
  119383. this.direction2.copyFrom(serializationObject.direction2);
  119384. };
  119385. return CylinderDirectedParticleEmitter;
  119386. }(CylinderParticleEmitter));
  119387. /***/ }),
  119388. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  119389. /*!**************************************************************!*\
  119390. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  119391. \**************************************************************/
  119392. /*! exports provided: HemisphericParticleEmitter */
  119393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119394. "use strict";
  119395. __webpack_require__.r(__webpack_exports__);
  119396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  119397. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  119398. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  119399. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  119400. /**
  119401. * Particle emitter emitting particles from the inside of a hemisphere.
  119402. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  119403. */
  119404. var HemisphericParticleEmitter = /** @class */ (function () {
  119405. /**
  119406. * Creates a new instance HemisphericParticleEmitter
  119407. * @param radius the radius of the emission hemisphere (1 by default)
  119408. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  119409. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  119410. */
  119411. function HemisphericParticleEmitter(
  119412. /**
  119413. * The radius of the emission hemisphere.
  119414. */
  119415. radius,
  119416. /**
  119417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  119418. */
  119419. radiusRange,
  119420. /**
  119421. * How much to randomize the particle direction [0-1].
  119422. */
  119423. directionRandomizer) {
  119424. if (radius === void 0) { radius = 1; }
  119425. if (radiusRange === void 0) { radiusRange = 1; }
  119426. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  119427. this.radius = radius;
  119428. this.radiusRange = radiusRange;
  119429. this.directionRandomizer = directionRandomizer;
  119430. }
  119431. /**
  119432. * Called by the particle System when the direction is computed for the created particle.
  119433. * @param worldMatrix is the world matrix of the particle system
  119434. * @param directionToUpdate is the direction vector to update with the result
  119435. * @param particle is the particle we are computed the direction for
  119436. */
  119437. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119438. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  119439. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119440. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119441. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119442. direction.x += randX;
  119443. direction.y += randY;
  119444. direction.z += randZ;
  119445. direction.normalize();
  119446. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  119447. };
  119448. /**
  119449. * Called by the particle System when the position is computed for the created particle.
  119450. * @param worldMatrix is the world matrix of the particle system
  119451. * @param positionToUpdate is the position vector to update with the result
  119452. * @param particle is the particle we are computed the position for
  119453. */
  119454. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  119455. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  119456. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  119457. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  119458. var theta = Math.acos(2 * v - 1);
  119459. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  119460. var randY = randRadius * Math.cos(theta);
  119461. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  119462. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  119463. };
  119464. /**
  119465. * Clones the current emitter and returns a copy of it
  119466. * @returns the new emitter
  119467. */
  119468. HemisphericParticleEmitter.prototype.clone = function () {
  119469. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  119470. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  119471. return newOne;
  119472. };
  119473. /**
  119474. * Called by the GPUParticleSystem to setup the update shader
  119475. * @param effect defines the update shader
  119476. */
  119477. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  119478. effect.setFloat("radius", this.radius);
  119479. effect.setFloat("radiusRange", this.radiusRange);
  119480. effect.setFloat("directionRandomizer", this.directionRandomizer);
  119481. };
  119482. /**
  119483. * Returns a string to use to update the GPU particles update shader
  119484. * @returns a string containng the defines string
  119485. */
  119486. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  119487. return "#define HEMISPHERICEMITTER";
  119488. };
  119489. /**
  119490. * Returns the string "HemisphericParticleEmitter"
  119491. * @returns a string containing the class name
  119492. */
  119493. HemisphericParticleEmitter.prototype.getClassName = function () {
  119494. return "HemisphericParticleEmitter";
  119495. };
  119496. /**
  119497. * Serializes the particle system to a JSON object.
  119498. * @returns the JSON object
  119499. */
  119500. HemisphericParticleEmitter.prototype.serialize = function () {
  119501. var serializationObject = {};
  119502. serializationObject.type = this.getClassName();
  119503. serializationObject.radius = this.radius;
  119504. serializationObject.radiusRange = this.radiusRange;
  119505. serializationObject.directionRandomizer = this.directionRandomizer;
  119506. return serializationObject;
  119507. };
  119508. /**
  119509. * Parse properties from a JSON object
  119510. * @param serializationObject defines the JSON object
  119511. */
  119512. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  119513. this.radius = serializationObject.radius;
  119514. this.radiusRange = serializationObject.radiusRange;
  119515. this.directionRandomizer = serializationObject.directionRandomizer;
  119516. };
  119517. return HemisphericParticleEmitter;
  119518. }());
  119519. /***/ }),
  119520. /***/ "./Particles/EmitterTypes/index.ts":
  119521. /*!*****************************************!*\
  119522. !*** ./Particles/EmitterTypes/index.ts ***!
  119523. \*****************************************/
  119524. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  119525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119526. "use strict";
  119527. __webpack_require__.r(__webpack_exports__);
  119528. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  119529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  119530. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  119531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  119532. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  119533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  119534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  119535. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  119536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  119537. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  119538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  119539. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  119540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  119541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  119542. /***/ }),
  119543. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  119544. /*!********************************************************!*\
  119545. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  119546. \********************************************************/
  119547. /*! exports provided: PointParticleEmitter */
  119548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119549. "use strict";
  119550. __webpack_require__.r(__webpack_exports__);
  119551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  119552. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  119553. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  119554. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  119555. /**
  119556. * Particle emitter emitting particles from a point.
  119557. * It emits the particles randomly between 2 given directions.
  119558. */
  119559. var PointParticleEmitter = /** @class */ (function () {
  119560. /**
  119561. * Creates a new instance PointParticleEmitter
  119562. */
  119563. function PointParticleEmitter() {
  119564. /**
  119565. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  119566. */
  119567. this.direction1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  119568. /**
  119569. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  119570. */
  119571. this.direction2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  119572. }
  119573. /**
  119574. * Called by the particle System when the direction is computed for the created particle.
  119575. * @param worldMatrix is the world matrix of the particle system
  119576. * @param directionToUpdate is the direction vector to update with the result
  119577. * @param particle is the particle we are computed the direction for
  119578. */
  119579. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119580. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  119581. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  119582. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  119583. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  119584. };
  119585. /**
  119586. * Called by the particle System when the position is computed for the created particle.
  119587. * @param worldMatrix is the world matrix of the particle system
  119588. * @param positionToUpdate is the position vector to update with the result
  119589. * @param particle is the particle we are computed the position for
  119590. */
  119591. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  119592. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  119593. };
  119594. /**
  119595. * Clones the current emitter and returns a copy of it
  119596. * @returns the new emitter
  119597. */
  119598. PointParticleEmitter.prototype.clone = function () {
  119599. var newOne = new PointParticleEmitter();
  119600. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  119601. return newOne;
  119602. };
  119603. /**
  119604. * Called by the GPUParticleSystem to setup the update shader
  119605. * @param effect defines the update shader
  119606. */
  119607. PointParticleEmitter.prototype.applyToShader = function (effect) {
  119608. effect.setVector3("direction1", this.direction1);
  119609. effect.setVector3("direction2", this.direction2);
  119610. };
  119611. /**
  119612. * Returns a string to use to update the GPU particles update shader
  119613. * @returns a string containng the defines string
  119614. */
  119615. PointParticleEmitter.prototype.getEffectDefines = function () {
  119616. return "#define POINTEMITTER";
  119617. };
  119618. /**
  119619. * Returns the string "PointParticleEmitter"
  119620. * @returns a string containing the class name
  119621. */
  119622. PointParticleEmitter.prototype.getClassName = function () {
  119623. return "PointParticleEmitter";
  119624. };
  119625. /**
  119626. * Serializes the particle system to a JSON object.
  119627. * @returns the JSON object
  119628. */
  119629. PointParticleEmitter.prototype.serialize = function () {
  119630. var serializationObject = {};
  119631. serializationObject.type = this.getClassName();
  119632. serializationObject.direction1 = this.direction1.asArray();
  119633. serializationObject.direction2 = this.direction2.asArray();
  119634. return serializationObject;
  119635. };
  119636. /**
  119637. * Parse properties from a JSON object
  119638. * @param serializationObject defines the JSON object
  119639. */
  119640. PointParticleEmitter.prototype.parse = function (serializationObject) {
  119641. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  119642. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  119643. };
  119644. return PointParticleEmitter;
  119645. }());
  119646. /***/ }),
  119647. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  119648. /*!*********************************************************!*\
  119649. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  119650. \*********************************************************/
  119651. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  119652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119653. "use strict";
  119654. __webpack_require__.r(__webpack_exports__);
  119655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  119656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  119657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119658. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  119659. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  119660. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  119661. /**
  119662. * Particle emitter emitting particles from the inside of a sphere.
  119663. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  119664. */
  119665. var SphereParticleEmitter = /** @class */ (function () {
  119666. /**
  119667. * Creates a new instance SphereParticleEmitter
  119668. * @param radius the radius of the emission sphere (1 by default)
  119669. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  119670. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  119671. */
  119672. function SphereParticleEmitter(
  119673. /**
  119674. * The radius of the emission sphere.
  119675. */
  119676. radius,
  119677. /**
  119678. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  119679. */
  119680. radiusRange,
  119681. /**
  119682. * How much to randomize the particle direction [0-1].
  119683. */
  119684. directionRandomizer) {
  119685. if (radius === void 0) { radius = 1; }
  119686. if (radiusRange === void 0) { radiusRange = 1; }
  119687. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  119688. this.radius = radius;
  119689. this.radiusRange = radiusRange;
  119690. this.directionRandomizer = directionRandomizer;
  119691. }
  119692. /**
  119693. * Called by the particle System when the direction is computed for the created particle.
  119694. * @param worldMatrix is the world matrix of the particle system
  119695. * @param directionToUpdate is the direction vector to update with the result
  119696. * @param particle is the particle we are computed the direction for
  119697. */
  119698. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119699. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  119700. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119701. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119702. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  119703. direction.x += randX;
  119704. direction.y += randY;
  119705. direction.z += randZ;
  119706. direction.normalize();
  119707. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  119708. };
  119709. /**
  119710. * Called by the particle System when the position is computed for the created particle.
  119711. * @param worldMatrix is the world matrix of the particle system
  119712. * @param positionToUpdate is the position vector to update with the result
  119713. * @param particle is the particle we are computed the position for
  119714. */
  119715. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  119716. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  119717. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  119718. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  119719. var theta = Math.acos(2 * v - 1);
  119720. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  119721. var randY = randRadius * Math.cos(theta);
  119722. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  119723. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  119724. };
  119725. /**
  119726. * Clones the current emitter and returns a copy of it
  119727. * @returns the new emitter
  119728. */
  119729. SphereParticleEmitter.prototype.clone = function () {
  119730. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  119731. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  119732. return newOne;
  119733. };
  119734. /**
  119735. * Called by the GPUParticleSystem to setup the update shader
  119736. * @param effect defines the update shader
  119737. */
  119738. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  119739. effect.setFloat("radius", this.radius);
  119740. effect.setFloat("radiusRange", this.radiusRange);
  119741. effect.setFloat("directionRandomizer", this.directionRandomizer);
  119742. };
  119743. /**
  119744. * Returns a string to use to update the GPU particles update shader
  119745. * @returns a string containng the defines string
  119746. */
  119747. SphereParticleEmitter.prototype.getEffectDefines = function () {
  119748. return "#define SPHEREEMITTER";
  119749. };
  119750. /**
  119751. * Returns the string "SphereParticleEmitter"
  119752. * @returns a string containing the class name
  119753. */
  119754. SphereParticleEmitter.prototype.getClassName = function () {
  119755. return "SphereParticleEmitter";
  119756. };
  119757. /**
  119758. * Serializes the particle system to a JSON object.
  119759. * @returns the JSON object
  119760. */
  119761. SphereParticleEmitter.prototype.serialize = function () {
  119762. var serializationObject = {};
  119763. serializationObject.type = this.getClassName();
  119764. serializationObject.radius = this.radius;
  119765. serializationObject.radiusRange = this.radiusRange;
  119766. serializationObject.directionRandomizer = this.directionRandomizer;
  119767. return serializationObject;
  119768. };
  119769. /**
  119770. * Parse properties from a JSON object
  119771. * @param serializationObject defines the JSON object
  119772. */
  119773. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  119774. this.radius = serializationObject.radius;
  119775. this.radiusRange = serializationObject.radiusRange;
  119776. this.directionRandomizer = serializationObject.directionRandomizer;
  119777. };
  119778. return SphereParticleEmitter;
  119779. }());
  119780. /**
  119781. * Particle emitter emitting particles from the inside of a sphere.
  119782. * It emits the particles randomly between two vectors.
  119783. */
  119784. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  119785. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  119786. /**
  119787. * Creates a new instance SphereDirectedParticleEmitter
  119788. * @param radius the radius of the emission sphere (1 by default)
  119789. * @param direction1 the min limit of the emission direction (up vector by default)
  119790. * @param direction2 the max limit of the emission direction (up vector by default)
  119791. */
  119792. function SphereDirectedParticleEmitter(radius,
  119793. /**
  119794. * The min limit of the emission direction.
  119795. */
  119796. direction1,
  119797. /**
  119798. * The max limit of the emission direction.
  119799. */
  119800. direction2) {
  119801. if (radius === void 0) { radius = 1; }
  119802. if (direction1 === void 0) { direction1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  119803. if (direction2 === void 0) { direction2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  119804. var _this = _super.call(this, radius) || this;
  119805. _this.direction1 = direction1;
  119806. _this.direction2 = direction2;
  119807. return _this;
  119808. }
  119809. /**
  119810. * Called by the particle System when the direction is computed for the created particle.
  119811. * @param worldMatrix is the world matrix of the particle system
  119812. * @param directionToUpdate is the direction vector to update with the result
  119813. * @param particle is the particle we are computed the direction for
  119814. */
  119815. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  119816. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  119817. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  119818. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  119819. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  119820. };
  119821. /**
  119822. * Clones the current emitter and returns a copy of it
  119823. * @returns the new emitter
  119824. */
  119825. SphereDirectedParticleEmitter.prototype.clone = function () {
  119826. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  119827. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  119828. return newOne;
  119829. };
  119830. /**
  119831. * Called by the GPUParticleSystem to setup the update shader
  119832. * @param effect defines the update shader
  119833. */
  119834. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  119835. effect.setFloat("radius", this.radius);
  119836. effect.setFloat("radiusRange", this.radiusRange);
  119837. effect.setVector3("direction1", this.direction1);
  119838. effect.setVector3("direction2", this.direction2);
  119839. };
  119840. /**
  119841. * Returns a string to use to update the GPU particles update shader
  119842. * @returns a string containng the defines string
  119843. */
  119844. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  119845. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  119846. };
  119847. /**
  119848. * Returns the string "SphereDirectedParticleEmitter"
  119849. * @returns a string containing the class name
  119850. */
  119851. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  119852. return "SphereDirectedParticleEmitter";
  119853. };
  119854. /**
  119855. * Serializes the particle system to a JSON object.
  119856. * @returns the JSON object
  119857. */
  119858. SphereDirectedParticleEmitter.prototype.serialize = function () {
  119859. var serializationObject = _super.prototype.serialize.call(this);
  119860. serializationObject.direction1 = this.direction1.asArray();
  119861. serializationObject.direction2 = this.direction2.asArray();
  119862. return serializationObject;
  119863. };
  119864. /**
  119865. * Parse properties from a JSON object
  119866. * @param serializationObject defines the JSON object
  119867. */
  119868. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  119869. _super.prototype.parse.call(this, serializationObject);
  119870. this.direction1.copyFrom(serializationObject.direction1);
  119871. this.direction2.copyFrom(serializationObject.direction2);
  119872. };
  119873. return SphereDirectedParticleEmitter;
  119874. }(SphereParticleEmitter));
  119875. /***/ }),
  119876. /***/ "./Particles/baseParticleSystem.ts":
  119877. /*!*****************************************!*\
  119878. !*** ./Particles/baseParticleSystem.ts ***!
  119879. \*****************************************/
  119880. /*! exports provided: BaseParticleSystem */
  119881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119882. "use strict";
  119883. __webpack_require__.r(__webpack_exports__);
  119884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  119885. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  119886. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  119887. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  119888. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119889. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  119890. /**
  119891. * This represents the base class for particle system in Babylon.
  119892. * 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.
  119893. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  119894. * @example https://doc.babylonjs.com/babylon101/particles
  119895. */
  119896. var BaseParticleSystem = /** @class */ (function () {
  119897. /**
  119898. * Instantiates a particle system.
  119899. * 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.
  119900. * @param name The name of the particle system
  119901. */
  119902. function BaseParticleSystem(name) {
  119903. /**
  119904. * List of animations used by the particle system.
  119905. */
  119906. this.animations = [];
  119907. /**
  119908. * The rendering group used by the Particle system to chose when to render.
  119909. */
  119910. this.renderingGroupId = 0;
  119911. /**
  119912. * The emitter represents the Mesh or position we are attaching the particle system to.
  119913. */
  119914. this.emitter = null;
  119915. /**
  119916. * The maximum number of particles to emit per frame
  119917. */
  119918. this.emitRate = 10;
  119919. /**
  119920. * If you want to launch only a few particles at once, that can be done, as well.
  119921. */
  119922. this.manualEmitCount = -1;
  119923. /**
  119924. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  119925. */
  119926. this.updateSpeed = 0.01;
  119927. /**
  119928. * The amount of time the particle system is running (depends of the overall update speed).
  119929. */
  119930. this.targetStopDuration = 0;
  119931. /**
  119932. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  119933. */
  119934. this.disposeOnStop = false;
  119935. /**
  119936. * Minimum power of emitting particles.
  119937. */
  119938. this.minEmitPower = 1;
  119939. /**
  119940. * Maximum power of emitting particles.
  119941. */
  119942. this.maxEmitPower = 1;
  119943. /**
  119944. * Minimum life time of emitting particles.
  119945. */
  119946. this.minLifeTime = 1;
  119947. /**
  119948. * Maximum life time of emitting particles.
  119949. */
  119950. this.maxLifeTime = 1;
  119951. /**
  119952. * Minimum Size of emitting particles.
  119953. */
  119954. this.minSize = 1;
  119955. /**
  119956. * Maximum Size of emitting particles.
  119957. */
  119958. this.maxSize = 1;
  119959. /**
  119960. * Minimum scale of emitting particles on X axis.
  119961. */
  119962. this.minScaleX = 1;
  119963. /**
  119964. * Maximum scale of emitting particles on X axis.
  119965. */
  119966. this.maxScaleX = 1;
  119967. /**
  119968. * Minimum scale of emitting particles on Y axis.
  119969. */
  119970. this.minScaleY = 1;
  119971. /**
  119972. * Maximum scale of emitting particles on Y axis.
  119973. */
  119974. this.maxScaleY = 1;
  119975. /**
  119976. * Gets or sets the minimal initial rotation in radians.
  119977. */
  119978. this.minInitialRotation = 0;
  119979. /**
  119980. * Gets or sets the maximal initial rotation in radians.
  119981. */
  119982. this.maxInitialRotation = 0;
  119983. /**
  119984. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  119985. */
  119986. this.minAngularSpeed = 0;
  119987. /**
  119988. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  119989. */
  119990. this.maxAngularSpeed = 0;
  119991. /**
  119992. * The layer mask we are rendering the particles through.
  119993. */
  119994. this.layerMask = 0x0FFFFFFF;
  119995. /**
  119996. * This can help using your own shader to render the particle system.
  119997. * The according effect will be created
  119998. */
  119999. this.customShader = null;
  120000. /**
  120001. * By default particle system starts as soon as they are created. This prevents the
  120002. * automatic start to happen and let you decide when to start emitting particles.
  120003. */
  120004. this.preventAutoStart = false;
  120005. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  120006. this.noiseStrength = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  120007. /**
  120008. * Callback triggered when the particle animation is ending.
  120009. */
  120010. this.onAnimationEnd = null;
  120011. /**
  120012. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  120013. */
  120014. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  120015. /**
  120016. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  120017. * to override the particles.
  120018. */
  120019. this.forceDepthWrite = false;
  120020. /** 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 */
  120021. this.preWarmCycles = 0;
  120022. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  120023. this.preWarmStepOffset = 1;
  120024. /**
  120025. * 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)
  120026. */
  120027. this.spriteCellChangeSpeed = 1;
  120028. /**
  120029. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  120030. */
  120031. this.startSpriteCellID = 0;
  120032. /**
  120033. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  120034. */
  120035. this.endSpriteCellID = 0;
  120036. /**
  120037. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  120038. */
  120039. this.spriteCellWidth = 0;
  120040. /**
  120041. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  120042. */
  120043. this.spriteCellHeight = 0;
  120044. /**
  120045. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  120046. */
  120047. this.spriteRandomStartCell = false;
  120048. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  120049. this.translationPivot = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  120050. /**
  120051. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  120052. */
  120053. this.beginAnimationOnStart = false;
  120054. /**
  120055. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  120056. */
  120057. this.beginAnimationFrom = 0;
  120058. /**
  120059. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  120060. */
  120061. this.beginAnimationTo = 60;
  120062. /**
  120063. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  120064. */
  120065. this.beginAnimationLoop = false;
  120066. /**
  120067. * Gets or sets a world offset applied to all particles
  120068. */
  120069. this.worldOffset = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  120070. /**
  120071. * You can use gravity if you want to give an orientation to your particles.
  120072. */
  120073. this.gravity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120074. this._colorGradients = null;
  120075. this._sizeGradients = null;
  120076. this._lifeTimeGradients = null;
  120077. this._angularSpeedGradients = null;
  120078. this._velocityGradients = null;
  120079. this._limitVelocityGradients = null;
  120080. this._dragGradients = null;
  120081. this._emitRateGradients = null;
  120082. this._startSizeGradients = null;
  120083. this._rampGradients = null;
  120084. this._colorRemapGradients = null;
  120085. this._alphaRemapGradients = null;
  120086. /**
  120087. * Defines the delay in milliseconds before starting the system (0 by default)
  120088. */
  120089. this.startDelay = 0;
  120090. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  120091. this.limitVelocityDamping = 0.4;
  120092. /**
  120093. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  120094. */
  120095. this.color1 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](1.0, 1.0, 1.0, 1.0);
  120096. /**
  120097. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  120098. */
  120099. this.color2 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](1.0, 1.0, 1.0, 1.0);
  120100. /**
  120101. * Color the particle will have at the end of its lifetime
  120102. */
  120103. this.colorDead = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 1.0);
  120104. /**
  120105. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  120106. */
  120107. this.textureMask = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"](1.0, 1.0, 1.0, 1.0);
  120108. /** @hidden */
  120109. this._isSubEmitter = false;
  120110. /**
  120111. * Gets or sets the billboard mode to use when isBillboardBased = true.
  120112. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  120113. */
  120114. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  120115. this._isBillboardBased = true;
  120116. /**
  120117. * Local cache of defines for image processing.
  120118. */
  120119. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  120120. this.id = name;
  120121. this.name = name;
  120122. }
  120123. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  120124. /**
  120125. * Gets or sets a texture used to add random noise to particle positions
  120126. */
  120127. get: function () {
  120128. return this._noiseTexture;
  120129. },
  120130. set: function (value) {
  120131. if (this._noiseTexture === value) {
  120132. return;
  120133. }
  120134. this._noiseTexture = value;
  120135. this._reset();
  120136. },
  120137. enumerable: true,
  120138. configurable: true
  120139. });
  120140. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  120141. /**
  120142. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  120143. */
  120144. get: function () {
  120145. return this._isAnimationSheetEnabled;
  120146. },
  120147. set: function (value) {
  120148. if (this._isAnimationSheetEnabled == value) {
  120149. return;
  120150. }
  120151. this._isAnimationSheetEnabled = value;
  120152. this._reset();
  120153. },
  120154. enumerable: true,
  120155. configurable: true
  120156. });
  120157. /**
  120158. * Get hosting scene
  120159. * @returns the scene
  120160. */
  120161. BaseParticleSystem.prototype.getScene = function () {
  120162. return this._scene;
  120163. };
  120164. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  120165. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  120166. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  120167. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  120168. };
  120169. /**
  120170. * Gets the current list of drag gradients.
  120171. * You must use addDragGradient and removeDragGradient to udpate this list
  120172. * @returns the list of drag gradients
  120173. */
  120174. BaseParticleSystem.prototype.getDragGradients = function () {
  120175. return this._dragGradients;
  120176. };
  120177. /**
  120178. * Gets the current list of limit velocity gradients.
  120179. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  120180. * @returns the list of limit velocity gradients
  120181. */
  120182. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  120183. return this._limitVelocityGradients;
  120184. };
  120185. /**
  120186. * Gets the current list of color gradients.
  120187. * You must use addColorGradient and removeColorGradient to udpate this list
  120188. * @returns the list of color gradients
  120189. */
  120190. BaseParticleSystem.prototype.getColorGradients = function () {
  120191. return this._colorGradients;
  120192. };
  120193. /**
  120194. * Gets the current list of size gradients.
  120195. * You must use addSizeGradient and removeSizeGradient to udpate this list
  120196. * @returns the list of size gradients
  120197. */
  120198. BaseParticleSystem.prototype.getSizeGradients = function () {
  120199. return this._sizeGradients;
  120200. };
  120201. /**
  120202. * Gets the current list of color remap gradients.
  120203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  120204. * @returns the list of color remap gradients
  120205. */
  120206. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  120207. return this._colorRemapGradients;
  120208. };
  120209. /**
  120210. * Gets the current list of alpha remap gradients.
  120211. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  120212. * @returns the list of alpha remap gradients
  120213. */
  120214. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  120215. return this._alphaRemapGradients;
  120216. };
  120217. /**
  120218. * Gets the current list of life time gradients.
  120219. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  120220. * @returns the list of life time gradients
  120221. */
  120222. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  120223. return this._lifeTimeGradients;
  120224. };
  120225. /**
  120226. * Gets the current list of angular speed gradients.
  120227. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  120228. * @returns the list of angular speed gradients
  120229. */
  120230. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  120231. return this._angularSpeedGradients;
  120232. };
  120233. /**
  120234. * Gets the current list of velocity gradients.
  120235. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  120236. * @returns the list of velocity gradients
  120237. */
  120238. BaseParticleSystem.prototype.getVelocityGradients = function () {
  120239. return this._velocityGradients;
  120240. };
  120241. /**
  120242. * Gets the current list of start size gradients.
  120243. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  120244. * @returns the list of start size gradients
  120245. */
  120246. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  120247. return this._startSizeGradients;
  120248. };
  120249. /**
  120250. * Gets the current list of emit rate gradients.
  120251. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  120252. * @returns the list of emit rate gradients
  120253. */
  120254. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  120255. return this._emitRateGradients;
  120256. };
  120257. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  120258. /**
  120259. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  120260. * This only works when particleEmitterTyps is a BoxParticleEmitter
  120261. */
  120262. get: function () {
  120263. if (this.particleEmitterType.direction1) {
  120264. return this.particleEmitterType.direction1;
  120265. }
  120266. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120267. },
  120268. set: function (value) {
  120269. if (this.particleEmitterType.direction1) {
  120270. this.particleEmitterType.direction1 = value;
  120271. }
  120272. },
  120273. enumerable: true,
  120274. configurable: true
  120275. });
  120276. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  120277. /**
  120278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  120279. * This only works when particleEmitterTyps is a BoxParticleEmitter
  120280. */
  120281. get: function () {
  120282. if (this.particleEmitterType.direction2) {
  120283. return this.particleEmitterType.direction2;
  120284. }
  120285. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120286. },
  120287. set: function (value) {
  120288. if (this.particleEmitterType.direction2) {
  120289. this.particleEmitterType.direction2 = value;
  120290. }
  120291. },
  120292. enumerable: true,
  120293. configurable: true
  120294. });
  120295. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  120296. /**
  120297. * 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.
  120298. * This only works when particleEmitterTyps is a BoxParticleEmitter
  120299. */
  120300. get: function () {
  120301. if (this.particleEmitterType.minEmitBox) {
  120302. return this.particleEmitterType.minEmitBox;
  120303. }
  120304. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120305. },
  120306. set: function (value) {
  120307. if (this.particleEmitterType.minEmitBox) {
  120308. this.particleEmitterType.minEmitBox = value;
  120309. }
  120310. },
  120311. enumerable: true,
  120312. configurable: true
  120313. });
  120314. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  120315. /**
  120316. * 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.
  120317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  120318. */
  120319. get: function () {
  120320. if (this.particleEmitterType.maxEmitBox) {
  120321. return this.particleEmitterType.maxEmitBox;
  120322. }
  120323. return _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120324. },
  120325. set: function (value) {
  120326. if (this.particleEmitterType.maxEmitBox) {
  120327. this.particleEmitterType.maxEmitBox = value;
  120328. }
  120329. },
  120330. enumerable: true,
  120331. configurable: true
  120332. });
  120333. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  120334. /**
  120335. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  120336. */
  120337. get: function () {
  120338. return this._isBillboardBased;
  120339. },
  120340. set: function (value) {
  120341. if (this._isBillboardBased === value) {
  120342. return;
  120343. }
  120344. this._isBillboardBased = value;
  120345. this._reset();
  120346. },
  120347. enumerable: true,
  120348. configurable: true
  120349. });
  120350. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  120351. /**
  120352. * Gets the image processing configuration used either in this material.
  120353. */
  120354. get: function () {
  120355. return this._imageProcessingConfiguration;
  120356. },
  120357. /**
  120358. * Sets the Default image processing configuration used either in the this material.
  120359. *
  120360. * If sets to null, the scene one is in use.
  120361. */
  120362. set: function (value) {
  120363. this._attachImageProcessingConfiguration(value);
  120364. },
  120365. enumerable: true,
  120366. configurable: true
  120367. });
  120368. /**
  120369. * Attaches a new image processing configuration to the Standard Material.
  120370. * @param configuration
  120371. */
  120372. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  120373. if (configuration === this._imageProcessingConfiguration) {
  120374. return;
  120375. }
  120376. // Pick the scene configuration if needed.
  120377. if (!configuration) {
  120378. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  120379. }
  120380. else {
  120381. this._imageProcessingConfiguration = configuration;
  120382. }
  120383. };
  120384. /** @hidden */
  120385. BaseParticleSystem.prototype._reset = function () {
  120386. };
  120387. /** @hidden */
  120388. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  120389. if (!gradients) {
  120390. return this;
  120391. }
  120392. var index = 0;
  120393. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  120394. var valueGradient = gradients_1[_i];
  120395. if (valueGradient.gradient === gradient) {
  120396. gradients.splice(index, 1);
  120397. break;
  120398. }
  120399. index++;
  120400. }
  120401. if (texture) {
  120402. texture.dispose();
  120403. }
  120404. return this;
  120405. };
  120406. /**
  120407. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  120408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  120409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  120410. * @returns the emitter
  120411. */
  120412. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  120413. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  120414. particleEmitter.direction1 = direction1;
  120415. particleEmitter.direction2 = direction2;
  120416. this.particleEmitterType = particleEmitter;
  120417. return particleEmitter;
  120418. };
  120419. /**
  120420. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  120421. * @param radius The radius of the hemisphere to emit from
  120422. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  120423. * @returns the emitter
  120424. */
  120425. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  120426. if (radius === void 0) { radius = 1; }
  120427. if (radiusRange === void 0) { radiusRange = 1; }
  120428. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  120429. this.particleEmitterType = particleEmitter;
  120430. return particleEmitter;
  120431. };
  120432. /**
  120433. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  120434. * @param radius The radius of the sphere to emit from
  120435. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  120436. * @returns the emitter
  120437. */
  120438. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  120439. if (radius === void 0) { radius = 1; }
  120440. if (radiusRange === void 0) { radiusRange = 1; }
  120441. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  120442. this.particleEmitterType = particleEmitter;
  120443. return particleEmitter;
  120444. };
  120445. /**
  120446. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  120447. * @param radius The radius of the sphere to emit from
  120448. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  120449. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  120450. * @returns the emitter
  120451. */
  120452. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  120453. if (radius === void 0) { radius = 1; }
  120454. if (direction1 === void 0) { direction1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  120455. if (direction2 === void 0) { direction2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  120456. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  120457. this.particleEmitterType = particleEmitter;
  120458. return particleEmitter;
  120459. };
  120460. /**
  120461. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  120462. * @param radius The radius of the emission cylinder
  120463. * @param height The height of the emission cylinder
  120464. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  120465. * @param directionRandomizer How much to randomize the particle direction [0-1]
  120466. * @returns the emitter
  120467. */
  120468. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  120469. if (radius === void 0) { radius = 1; }
  120470. if (height === void 0) { height = 1; }
  120471. if (radiusRange === void 0) { radiusRange = 1; }
  120472. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  120473. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  120474. this.particleEmitterType = particleEmitter;
  120475. return particleEmitter;
  120476. };
  120477. /**
  120478. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  120479. * @param radius The radius of the cylinder to emit from
  120480. * @param height The height of the emission cylinder
  120481. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  120482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  120483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  120484. * @returns the emitter
  120485. */
  120486. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  120487. if (radius === void 0) { radius = 1; }
  120488. if (height === void 0) { height = 1; }
  120489. if (radiusRange === void 0) { radiusRange = 1; }
  120490. if (direction1 === void 0) { direction1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  120491. if (direction2 === void 0) { direction2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  120492. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  120493. this.particleEmitterType = particleEmitter;
  120494. return particleEmitter;
  120495. };
  120496. /**
  120497. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  120498. * @param radius The radius of the cone to emit from
  120499. * @param angle The base angle of the cone
  120500. * @returns the emitter
  120501. */
  120502. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  120503. if (radius === void 0) { radius = 1; }
  120504. if (angle === void 0) { angle = Math.PI / 4; }
  120505. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  120506. this.particleEmitterType = particleEmitter;
  120507. return particleEmitter;
  120508. };
  120509. /**
  120510. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  120511. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  120512. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  120513. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  120514. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  120515. * @returns the emitter
  120516. */
  120517. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  120518. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  120519. this.particleEmitterType = particleEmitter;
  120520. this.direction1 = direction1;
  120521. this.direction2 = direction2;
  120522. this.minEmitBox = minEmitBox;
  120523. this.maxEmitBox = maxEmitBox;
  120524. return particleEmitter;
  120525. };
  120526. /**
  120527. * Source color is added to the destination color without alpha affecting the result
  120528. */
  120529. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  120530. /**
  120531. * Blend current color and particle color using particle’s alpha
  120532. */
  120533. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  120534. /**
  120535. * Add current color and particle color multiplied by particle’s alpha
  120536. */
  120537. BaseParticleSystem.BLENDMODE_ADD = 2;
  120538. /**
  120539. * Multiply current color with particle color
  120540. */
  120541. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  120542. /**
  120543. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  120544. */
  120545. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  120546. return BaseParticleSystem;
  120547. }());
  120548. /***/ }),
  120549. /***/ "./Particles/gpuParticleSystem.ts":
  120550. /*!****************************************!*\
  120551. !*** ./Particles/gpuParticleSystem.ts ***!
  120552. \****************************************/
  120553. /*! exports provided: GPUParticleSystem */
  120554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120555. "use strict";
  120556. __webpack_require__.r(__webpack_exports__);
  120557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  120558. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120559. /* harmony import */ var _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/gradients */ "./Misc/gradients.ts");
  120560. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  120561. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  120562. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  120563. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  120564. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120565. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  120566. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  120567. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  120568. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  120569. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120570. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  120571. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  120572. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120573. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  120574. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120575. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  120576. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  120577. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  120578. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  120579. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  120580. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  120581. /**
  120582. * This represents a GPU particle system in Babylon
  120583. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  120584. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  120585. */
  120586. var GPUParticleSystem = /** @class */ (function (_super) {
  120587. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  120588. /**
  120589. * Instantiates a GPU particle system.
  120590. * 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.
  120591. * @param name The name of the particle system
  120592. * @param options The options used to create the system
  120593. * @param scene The scene the particle system belongs to
  120594. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  120595. */
  120596. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  120597. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  120598. var _this = _super.call(this, name) || this;
  120599. /**
  120600. * The layer mask we are rendering the particles through.
  120601. */
  120602. _this.layerMask = 0x0FFFFFFF;
  120603. _this._accumulatedCount = 0;
  120604. _this._targetIndex = 0;
  120605. _this._currentRenderId = -1;
  120606. _this._started = false;
  120607. _this._stopped = false;
  120608. _this._timeDelta = 0;
  120609. _this._actualFrame = 0;
  120610. _this._rawTextureWidth = 256;
  120611. /**
  120612. * An event triggered when the system is disposed.
  120613. */
  120614. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120615. /**
  120616. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  120617. * to override the particles.
  120618. */
  120619. _this.forceDepthWrite = false;
  120620. _this._preWarmDone = false;
  120621. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_17__["EngineStore"].LastCreatedScene;
  120622. // Setup the default processing configuration to the scene.
  120623. _this._attachImageProcessingConfiguration(null);
  120624. _this._engine = _this._scene.getEngine();
  120625. if (!options.randomTextureSize) {
  120626. delete options.randomTextureSize;
  120627. }
  120628. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  120629. var optionsAsNumber = options;
  120630. if (isFinite(optionsAsNumber)) {
  120631. fullOptions.capacity = optionsAsNumber;
  120632. }
  120633. _this._capacity = fullOptions.capacity;
  120634. _this._activeCount = fullOptions.capacity;
  120635. _this._currentActiveCount = 0;
  120636. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  120637. _this._scene.particleSystems.push(_this);
  120638. _this._updateEffectOptions = {
  120639. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  120640. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  120641. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  120642. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  120643. uniformBuffersNames: [],
  120644. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  120645. defines: "",
  120646. fallbacks: null,
  120647. onCompiled: null,
  120648. onError: null,
  120649. indexParameters: null,
  120650. maxSimultaneousLights: 0,
  120651. transformFeedbackVaryings: []
  120652. };
  120653. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_9__["BoxParticleEmitter"]();
  120654. // Random data
  120655. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  120656. var d = [];
  120657. for (var i = 0; i < maxTextureSize; ++i) {
  120658. d.push(Math.random());
  120659. d.push(Math.random());
  120660. d.push(Math.random());
  120661. d.push(Math.random());
  120662. }
  120663. _this._randomTexture = new _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_15__["RawTexture"](new Float32Array(d), maxTextureSize, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].TEXTUREFORMAT_RGBA, _this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].TEXTURETYPE_FLOAT);
  120664. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"].WRAP_ADDRESSMODE;
  120665. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"].WRAP_ADDRESSMODE;
  120666. d = [];
  120667. for (var i = 0; i < maxTextureSize; ++i) {
  120668. d.push(Math.random());
  120669. d.push(Math.random());
  120670. d.push(Math.random());
  120671. d.push(Math.random());
  120672. }
  120673. _this._randomTexture2 = new _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_15__["RawTexture"](new Float32Array(d), maxTextureSize, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].TEXTUREFORMAT_RGBA, _this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].TEXTURETYPE_FLOAT);
  120674. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"].WRAP_ADDRESSMODE;
  120675. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"].WRAP_ADDRESSMODE;
  120676. _this._randomTextureSize = maxTextureSize;
  120677. return _this;
  120678. }
  120679. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  120680. /**
  120681. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  120682. */
  120683. get: function () {
  120684. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_17__["EngineStore"].LastCreatedEngine) {
  120685. return false;
  120686. }
  120687. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_17__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  120688. },
  120689. enumerable: true,
  120690. configurable: true
  120691. });
  120692. /**
  120693. * Gets the maximum number of particles active at the same time.
  120694. * @returns The max number of active particles.
  120695. */
  120696. GPUParticleSystem.prototype.getCapacity = function () {
  120697. return this._capacity;
  120698. };
  120699. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  120700. /**
  120701. * Gets or set the number of active particles
  120702. */
  120703. get: function () {
  120704. return this._activeCount;
  120705. },
  120706. set: function (value) {
  120707. this._activeCount = Math.min(value, this._capacity);
  120708. },
  120709. enumerable: true,
  120710. configurable: true
  120711. });
  120712. /**
  120713. * Is this system ready to be used/rendered
  120714. * @return true if the system is ready
  120715. */
  120716. GPUParticleSystem.prototype.isReady = function () {
  120717. if (!this._updateEffect) {
  120718. this._recreateUpdateEffect();
  120719. this._recreateRenderEffect();
  120720. return false;
  120721. }
  120722. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  120723. return false;
  120724. }
  120725. return true;
  120726. };
  120727. /**
  120728. * Gets if the system has been started. (Note: this will still be true after stop is called)
  120729. * @returns True if it has been started, otherwise false.
  120730. */
  120731. GPUParticleSystem.prototype.isStarted = function () {
  120732. return this._started;
  120733. };
  120734. /**
  120735. * Starts the particle system and begins to emit
  120736. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  120737. */
  120738. GPUParticleSystem.prototype.start = function (delay) {
  120739. var _this = this;
  120740. if (delay === void 0) { delay = this.startDelay; }
  120741. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  120742. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  120743. }
  120744. if (delay) {
  120745. setTimeout(function () {
  120746. _this.start(0);
  120747. }, delay);
  120748. return;
  120749. }
  120750. this._started = true;
  120751. this._stopped = false;
  120752. this._preWarmDone = false;
  120753. // Animations
  120754. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  120755. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  120756. }
  120757. };
  120758. /**
  120759. * Stops the particle system.
  120760. */
  120761. GPUParticleSystem.prototype.stop = function () {
  120762. this._stopped = true;
  120763. };
  120764. /**
  120765. * Remove all active particles
  120766. */
  120767. GPUParticleSystem.prototype.reset = function () {
  120768. this._releaseBuffers();
  120769. this._releaseVAOs();
  120770. this._currentActiveCount = 0;
  120771. this._targetIndex = 0;
  120772. };
  120773. /**
  120774. * Returns the string "GPUParticleSystem"
  120775. * @returns a string containing the class name
  120776. */
  120777. GPUParticleSystem.prototype.getClassName = function () {
  120778. return "GPUParticleSystem";
  120779. };
  120780. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  120781. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  120782. this._releaseBuffers();
  120783. return this;
  120784. };
  120785. /**
  120786. * Adds a new color gradient
  120787. * @param gradient defines the gradient to use (between 0 and 1)
  120788. * @param color1 defines the color to affect to the specified gradient
  120789. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  120790. * @returns the current particle system
  120791. */
  120792. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  120793. if (!this._colorGradients) {
  120794. this._colorGradients = [];
  120795. }
  120796. var colorGradient = new _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  120797. colorGradient.gradient = gradient;
  120798. colorGradient.color1 = color1;
  120799. this._colorGradients.push(colorGradient);
  120800. this._colorGradients.sort(function (a, b) {
  120801. if (a.gradient < b.gradient) {
  120802. return -1;
  120803. }
  120804. else if (a.gradient > b.gradient) {
  120805. return 1;
  120806. }
  120807. return 0;
  120808. });
  120809. if (this._colorGradientsTexture) {
  120810. this._colorGradientsTexture.dispose();
  120811. this._colorGradientsTexture = null;
  120812. }
  120813. this._releaseBuffers();
  120814. return this;
  120815. };
  120816. /**
  120817. * Remove a specific color gradient
  120818. * @param gradient defines the gradient to remove
  120819. * @returns the current particle system
  120820. */
  120821. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  120822. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  120823. this._colorGradientsTexture = null;
  120824. return this;
  120825. };
  120826. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  120827. var valueGradient = new _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  120828. valueGradient.gradient = gradient;
  120829. valueGradient.factor1 = factor;
  120830. factorGradients.push(valueGradient);
  120831. factorGradients.sort(function (a, b) {
  120832. if (a.gradient < b.gradient) {
  120833. return -1;
  120834. }
  120835. else if (a.gradient > b.gradient) {
  120836. return 1;
  120837. }
  120838. return 0;
  120839. });
  120840. this._releaseBuffers();
  120841. };
  120842. /**
  120843. * Adds a new size gradient
  120844. * @param gradient defines the gradient to use (between 0 and 1)
  120845. * @param factor defines the size factor to affect to the specified gradient
  120846. * @returns the current particle system
  120847. */
  120848. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  120849. if (!this._sizeGradients) {
  120850. this._sizeGradients = [];
  120851. }
  120852. this._addFactorGradient(this._sizeGradients, gradient, factor);
  120853. if (this._sizeGradientsTexture) {
  120854. this._sizeGradientsTexture.dispose();
  120855. this._sizeGradientsTexture = null;
  120856. }
  120857. this._releaseBuffers();
  120858. return this;
  120859. };
  120860. /**
  120861. * Remove a specific size gradient
  120862. * @param gradient defines the gradient to remove
  120863. * @returns the current particle system
  120864. */
  120865. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  120866. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  120867. this._sizeGradientsTexture = null;
  120868. return this;
  120869. };
  120870. /**
  120871. * Adds a new angular speed gradient
  120872. * @param gradient defines the gradient to use (between 0 and 1)
  120873. * @param factor defines the angular speed to affect to the specified gradient
  120874. * @returns the current particle system
  120875. */
  120876. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  120877. if (!this._angularSpeedGradients) {
  120878. this._angularSpeedGradients = [];
  120879. }
  120880. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  120881. if (this._angularSpeedGradientsTexture) {
  120882. this._angularSpeedGradientsTexture.dispose();
  120883. this._angularSpeedGradientsTexture = null;
  120884. }
  120885. this._releaseBuffers();
  120886. return this;
  120887. };
  120888. /**
  120889. * Remove a specific angular speed gradient
  120890. * @param gradient defines the gradient to remove
  120891. * @returns the current particle system
  120892. */
  120893. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  120894. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  120895. this._angularSpeedGradientsTexture = null;
  120896. return this;
  120897. };
  120898. /**
  120899. * Adds a new velocity gradient
  120900. * @param gradient defines the gradient to use (between 0 and 1)
  120901. * @param factor defines the velocity to affect to the specified gradient
  120902. * @returns the current particle system
  120903. */
  120904. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  120905. if (!this._velocityGradients) {
  120906. this._velocityGradients = [];
  120907. }
  120908. this._addFactorGradient(this._velocityGradients, gradient, factor);
  120909. if (this._velocityGradientsTexture) {
  120910. this._velocityGradientsTexture.dispose();
  120911. this._velocityGradientsTexture = null;
  120912. }
  120913. this._releaseBuffers();
  120914. return this;
  120915. };
  120916. /**
  120917. * Remove a specific velocity gradient
  120918. * @param gradient defines the gradient to remove
  120919. * @returns the current particle system
  120920. */
  120921. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  120922. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  120923. this._velocityGradientsTexture = null;
  120924. return this;
  120925. };
  120926. /**
  120927. * Adds a new limit velocity gradient
  120928. * @param gradient defines the gradient to use (between 0 and 1)
  120929. * @param factor defines the limit velocity value to affect to the specified gradient
  120930. * @returns the current particle system
  120931. */
  120932. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  120933. if (!this._limitVelocityGradients) {
  120934. this._limitVelocityGradients = [];
  120935. }
  120936. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  120937. if (this._limitVelocityGradientsTexture) {
  120938. this._limitVelocityGradientsTexture.dispose();
  120939. this._limitVelocityGradientsTexture = null;
  120940. }
  120941. this._releaseBuffers();
  120942. return this;
  120943. };
  120944. /**
  120945. * Remove a specific limit velocity gradient
  120946. * @param gradient defines the gradient to remove
  120947. * @returns the current particle system
  120948. */
  120949. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  120950. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  120951. this._limitVelocityGradientsTexture = null;
  120952. return this;
  120953. };
  120954. /**
  120955. * Adds a new drag gradient
  120956. * @param gradient defines the gradient to use (between 0 and 1)
  120957. * @param factor defines the drag value to affect to the specified gradient
  120958. * @returns the current particle system
  120959. */
  120960. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  120961. if (!this._dragGradients) {
  120962. this._dragGradients = [];
  120963. }
  120964. this._addFactorGradient(this._dragGradients, gradient, factor);
  120965. if (this._dragGradientsTexture) {
  120966. this._dragGradientsTexture.dispose();
  120967. this._dragGradientsTexture = null;
  120968. }
  120969. this._releaseBuffers();
  120970. return this;
  120971. };
  120972. /**
  120973. * Remove a specific drag gradient
  120974. * @param gradient defines the gradient to remove
  120975. * @returns the current particle system
  120976. */
  120977. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  120978. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  120979. this._dragGradientsTexture = null;
  120980. return this;
  120981. };
  120982. /**
  120983. * Not supported by GPUParticleSystem
  120984. * @param gradient defines the gradient to use (between 0 and 1)
  120985. * @param factor defines the emit rate value to affect to the specified gradient
  120986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120987. * @returns the current particle system
  120988. */
  120989. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  120990. // Do nothing as emit rate is not supported by GPUParticleSystem
  120991. return this;
  120992. };
  120993. /**
  120994. * Not supported by GPUParticleSystem
  120995. * @param gradient defines the gradient to remove
  120996. * @returns the current particle system
  120997. */
  120998. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  120999. // Do nothing as emit rate is not supported by GPUParticleSystem
  121000. return this;
  121001. };
  121002. /**
  121003. * Not supported by GPUParticleSystem
  121004. * @param gradient defines the gradient to use (between 0 and 1)
  121005. * @param factor defines the start size value to affect to the specified gradient
  121006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121007. * @returns the current particle system
  121008. */
  121009. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  121010. // Do nothing as start size is not supported by GPUParticleSystem
  121011. return this;
  121012. };
  121013. /**
  121014. * Not supported by GPUParticleSystem
  121015. * @param gradient defines the gradient to remove
  121016. * @returns the current particle system
  121017. */
  121018. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  121019. // Do nothing as start size is not supported by GPUParticleSystem
  121020. return this;
  121021. };
  121022. /**
  121023. * Not supported by GPUParticleSystem
  121024. * @param gradient defines the gradient to use (between 0 and 1)
  121025. * @param min defines the color remap minimal range
  121026. * @param max defines the color remap maximal range
  121027. * @returns the current particle system
  121028. */
  121029. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  121030. // Do nothing as start size is not supported by GPUParticleSystem
  121031. return this;
  121032. };
  121033. /**
  121034. * Not supported by GPUParticleSystem
  121035. * @param gradient defines the gradient to remove
  121036. * @returns the current particle system
  121037. */
  121038. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  121039. // Do nothing as start size is not supported by GPUParticleSystem
  121040. return this;
  121041. };
  121042. /**
  121043. * Not supported by GPUParticleSystem
  121044. * @param gradient defines the gradient to use (between 0 and 1)
  121045. * @param min defines the alpha remap minimal range
  121046. * @param max defines the alpha remap maximal range
  121047. * @returns the current particle system
  121048. */
  121049. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  121050. // Do nothing as start size is not supported by GPUParticleSystem
  121051. return this;
  121052. };
  121053. /**
  121054. * Not supported by GPUParticleSystem
  121055. * @param gradient defines the gradient to remove
  121056. * @returns the current particle system
  121057. */
  121058. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  121059. // Do nothing as start size is not supported by GPUParticleSystem
  121060. return this;
  121061. };
  121062. /**
  121063. * Not supported by GPUParticleSystem
  121064. * @param gradient defines the gradient to use (between 0 and 1)
  121065. * @param color defines the color to affect to the specified gradient
  121066. * @returns the current particle system
  121067. */
  121068. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  121069. //Not supported by GPUParticleSystem
  121070. return this;
  121071. };
  121072. /**
  121073. * Not supported by GPUParticleSystem
  121074. * @param gradient defines the gradient to remove
  121075. * @returns the current particle system
  121076. */
  121077. GPUParticleSystem.prototype.removeRampGradient = function () {
  121078. //Not supported by GPUParticleSystem
  121079. return this;
  121080. };
  121081. /**
  121082. * Not supported by GPUParticleSystem
  121083. * @returns the list of ramp gradients
  121084. */
  121085. GPUParticleSystem.prototype.getRampGradients = function () {
  121086. return null;
  121087. };
  121088. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  121089. /**
  121090. * Not supported by GPUParticleSystem
  121091. * Gets or sets a boolean indicating that ramp gradients must be used
  121092. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  121093. */
  121094. get: function () {
  121095. //Not supported by GPUParticleSystem
  121096. return false;
  121097. },
  121098. set: function (value) {
  121099. //Not supported by GPUParticleSystem
  121100. },
  121101. enumerable: true,
  121102. configurable: true
  121103. });
  121104. /**
  121105. * Not supported by GPUParticleSystem
  121106. * @param gradient defines the gradient to use (between 0 and 1)
  121107. * @param factor defines the life time factor to affect to the specified gradient
  121108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121109. * @returns the current particle system
  121110. */
  121111. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  121112. //Not supported by GPUParticleSystem
  121113. return this;
  121114. };
  121115. /**
  121116. * Not supported by GPUParticleSystem
  121117. * @param gradient defines the gradient to remove
  121118. * @returns the current particle system
  121119. */
  121120. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  121121. //Not supported by GPUParticleSystem
  121122. return this;
  121123. };
  121124. GPUParticleSystem.prototype._reset = function () {
  121125. this._releaseBuffers();
  121126. };
  121127. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  121128. var updateVertexBuffers = {};
  121129. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  121130. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  121131. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  121132. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  121133. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  121134. var offset = 12;
  121135. if (!this._colorGradientsTexture) {
  121136. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  121137. offset += 4;
  121138. }
  121139. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  121140. offset += 3;
  121141. if (!this._isBillboardBased) {
  121142. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  121143. offset += 3;
  121144. }
  121145. if (this._angularSpeedGradientsTexture) {
  121146. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  121147. offset += 1;
  121148. }
  121149. else {
  121150. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  121151. offset += 2;
  121152. }
  121153. if (this._isAnimationSheetEnabled) {
  121154. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  121155. offset += 1;
  121156. if (this.spriteRandomStartCell) {
  121157. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  121158. offset += 1;
  121159. }
  121160. }
  121161. if (this.noiseTexture) {
  121162. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  121163. offset += 3;
  121164. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  121165. offset += 3;
  121166. }
  121167. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  121168. this._engine.bindArrayBuffer(null);
  121169. return vao;
  121170. };
  121171. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  121172. var renderVertexBuffers = {};
  121173. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  121174. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  121175. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  121176. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  121177. var offset = 12;
  121178. if (!this._colorGradientsTexture) {
  121179. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  121180. offset += 4;
  121181. }
  121182. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  121183. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  121184. }
  121185. offset += 3; // Direction
  121186. if (!this._isBillboardBased) {
  121187. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  121188. offset += 3;
  121189. }
  121190. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  121191. if (this._angularSpeedGradientsTexture) {
  121192. offset++;
  121193. }
  121194. else {
  121195. offset += 2;
  121196. }
  121197. if (this._isAnimationSheetEnabled) {
  121198. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  121199. offset += 1;
  121200. if (this.spriteRandomStartCell) {
  121201. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  121202. offset += 1;
  121203. }
  121204. }
  121205. if (this.noiseTexture) {
  121206. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  121207. offset += 3;
  121208. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  121209. offset += 3;
  121210. }
  121211. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  121212. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  121213. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  121214. this._engine.bindArrayBuffer(null);
  121215. return vao;
  121216. };
  121217. GPUParticleSystem.prototype._initialize = function (force) {
  121218. if (force === void 0) { force = false; }
  121219. if (this._buffer0 && !force) {
  121220. return;
  121221. }
  121222. var engine = this._scene.getEngine();
  121223. var data = new Array();
  121224. this._attributesStrideSize = 21;
  121225. this._targetIndex = 0;
  121226. if (!this.isBillboardBased) {
  121227. this._attributesStrideSize += 3;
  121228. }
  121229. if (this._colorGradientsTexture) {
  121230. this._attributesStrideSize -= 4;
  121231. }
  121232. if (this._angularSpeedGradientsTexture) {
  121233. this._attributesStrideSize -= 1;
  121234. }
  121235. if (this._isAnimationSheetEnabled) {
  121236. this._attributesStrideSize += 1;
  121237. if (this.spriteRandomStartCell) {
  121238. this._attributesStrideSize += 1;
  121239. }
  121240. }
  121241. if (this.noiseTexture) {
  121242. this._attributesStrideSize += 6;
  121243. }
  121244. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  121245. // position
  121246. data.push(0.0);
  121247. data.push(0.0);
  121248. data.push(0.0);
  121249. // Age and life
  121250. data.push(0.0); // create the particle as a dead one to create a new one at start
  121251. data.push(0.0);
  121252. // Seed
  121253. data.push(Math.random());
  121254. data.push(Math.random());
  121255. data.push(Math.random());
  121256. data.push(Math.random());
  121257. // Size
  121258. data.push(0.0);
  121259. data.push(0.0);
  121260. data.push(0.0);
  121261. if (!this._colorGradientsTexture) {
  121262. // color
  121263. data.push(0.0);
  121264. data.push(0.0);
  121265. data.push(0.0);
  121266. data.push(0.0);
  121267. }
  121268. // direction
  121269. data.push(0.0);
  121270. data.push(0.0);
  121271. data.push(0.0);
  121272. if (!this.isBillboardBased) {
  121273. // initialDirection
  121274. data.push(0.0);
  121275. data.push(0.0);
  121276. data.push(0.0);
  121277. }
  121278. // angle
  121279. data.push(0.0);
  121280. if (!this._angularSpeedGradientsTexture) {
  121281. data.push(0.0);
  121282. }
  121283. if (this._isAnimationSheetEnabled) {
  121284. data.push(0.0);
  121285. if (this.spriteRandomStartCell) {
  121286. data.push(0.0);
  121287. }
  121288. }
  121289. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  121290. data.push(Math.random());
  121291. data.push(Math.random());
  121292. data.push(Math.random());
  121293. data.push(Math.random());
  121294. data.push(Math.random());
  121295. data.push(Math.random());
  121296. }
  121297. }
  121298. // Sprite data
  121299. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  121300. -0.5, 0.5, 0, 1,
  121301. -0.5, -0.5, 0, 0,
  121302. 0.5, -0.5, 1, 0]);
  121303. // Buffers
  121304. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["Buffer"](engine, data, false, this._attributesStrideSize);
  121305. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["Buffer"](engine, data, false, this._attributesStrideSize);
  121306. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["Buffer"](engine, spriteData, false, 4);
  121307. // Update VAO
  121308. this._updateVAO = [];
  121309. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  121310. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  121311. // Render VAO
  121312. this._renderVAO = [];
  121313. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  121314. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  121315. // Links
  121316. this._sourceBuffer = this._buffer0;
  121317. this._targetBuffer = this._buffer1;
  121318. };
  121319. /** @hidden */
  121320. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  121321. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  121322. if (this._isBillboardBased) {
  121323. defines += "\n#define BILLBOARD";
  121324. }
  121325. if (this._colorGradientsTexture) {
  121326. defines += "\n#define COLORGRADIENTS";
  121327. }
  121328. if (this._sizeGradientsTexture) {
  121329. defines += "\n#define SIZEGRADIENTS";
  121330. }
  121331. if (this._angularSpeedGradientsTexture) {
  121332. defines += "\n#define ANGULARSPEEDGRADIENTS";
  121333. }
  121334. if (this._velocityGradientsTexture) {
  121335. defines += "\n#define VELOCITYGRADIENTS";
  121336. }
  121337. if (this._limitVelocityGradientsTexture) {
  121338. defines += "\n#define LIMITVELOCITYGRADIENTS";
  121339. }
  121340. if (this._dragGradientsTexture) {
  121341. defines += "\n#define DRAGGRADIENTS";
  121342. }
  121343. if (this.isAnimationSheetEnabled) {
  121344. defines += "\n#define ANIMATESHEET";
  121345. if (this.spriteRandomStartCell) {
  121346. defines += "\n#define ANIMATESHEETRANDOMSTART";
  121347. }
  121348. }
  121349. if (this.noiseTexture) {
  121350. defines += "\n#define NOISE";
  121351. }
  121352. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  121353. return;
  121354. }
  121355. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  121356. if (!this._colorGradientsTexture) {
  121357. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  121358. }
  121359. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  121360. if (!this._isBillboardBased) {
  121361. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  121362. }
  121363. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  121364. if (this.isAnimationSheetEnabled) {
  121365. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  121366. if (this.spriteRandomStartCell) {
  121367. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  121368. }
  121369. }
  121370. if (this.noiseTexture) {
  121371. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  121372. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  121373. }
  121374. this._updateEffectOptions.defines = defines;
  121375. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_10__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  121376. };
  121377. /** @hidden */
  121378. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  121379. var defines = "";
  121380. if (this._scene.clipPlane) {
  121381. defines = "\n#define CLIPPLANE";
  121382. }
  121383. if (this._scene.clipPlane2) {
  121384. defines = "\n#define CLIPPLANE2";
  121385. }
  121386. if (this._scene.clipPlane3) {
  121387. defines = "\n#define CLIPPLANE3";
  121388. }
  121389. if (this._scene.clipPlane4) {
  121390. defines = "\n#define CLIPPLANE4";
  121391. }
  121392. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  121393. defines = "\n#define BLENDMULTIPLYMODE";
  121394. }
  121395. if (this._isBillboardBased) {
  121396. defines += "\n#define BILLBOARD";
  121397. switch (this.billboardMode) {
  121398. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BILLBOARDMODE_Y:
  121399. defines += "\n#define BILLBOARDY";
  121400. break;
  121401. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  121402. defines += "\n#define BILLBOARDSTRETCHED";
  121403. break;
  121404. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BILLBOARDMODE_ALL:
  121405. default:
  121406. break;
  121407. }
  121408. }
  121409. if (this._colorGradientsTexture) {
  121410. defines += "\n#define COLORGRADIENTS";
  121411. }
  121412. if (this.isAnimationSheetEnabled) {
  121413. defines += "\n#define ANIMATESHEET";
  121414. }
  121415. if (this._imageProcessingConfiguration) {
  121416. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  121417. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  121418. }
  121419. if (this._renderEffect && this._renderEffect.defines === defines) {
  121420. return;
  121421. }
  121422. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  121423. var samplers = ["textureSampler", "colorGradientSampler"];
  121424. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"]) {
  121425. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  121426. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  121427. }
  121428. this._renderEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_10__["Effect"]("gpuRenderParticles", ["position", "age", "life", "size", "color", "offset", "uv", "direction", "initialDirection", "angle", "cellIndex"], uniforms, samplers, this._scene.getEngine(), defines);
  121429. };
  121430. /**
  121431. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  121432. * @param preWarm defines if we are in the pre-warmimg phase
  121433. */
  121434. GPUParticleSystem.prototype.animate = function (preWarm) {
  121435. if (preWarm === void 0) { preWarm = false; }
  121436. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  121437. this._actualFrame += this._timeDelta;
  121438. if (!this._stopped) {
  121439. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  121440. this.stop();
  121441. }
  121442. }
  121443. };
  121444. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  121445. var texture = this[textureName];
  121446. if (!factorGradients || !factorGradients.length || texture) {
  121447. return;
  121448. }
  121449. var data = new Float32Array(this._rawTextureWidth);
  121450. for (var x = 0; x < this._rawTextureWidth; x++) {
  121451. var ratio = x / this._rawTextureWidth;
  121452. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  121453. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_5__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  121454. });
  121455. }
  121456. this[textureName] = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_15__["RawTexture"].CreateRTexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"].NEAREST_SAMPLINGMODE);
  121457. };
  121458. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  121459. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  121460. };
  121461. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  121462. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  121463. };
  121464. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  121465. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  121466. };
  121467. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  121468. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  121469. };
  121470. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  121471. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  121472. };
  121473. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  121474. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  121475. return;
  121476. }
  121477. var data = new Uint8Array(this._rawTextureWidth * 4);
  121478. var tmpColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["TmpColors"].Color4[0];
  121479. for (var x = 0; x < this._rawTextureWidth; x++) {
  121480. var ratio = x / this._rawTextureWidth;
  121481. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  121482. _Maths_math_color__WEBPACK_IMPORTED_MODULE_4__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  121483. data[x * 4] = tmpColor.r * 255;
  121484. data[x * 4 + 1] = tmpColor.g * 255;
  121485. data[x * 4 + 2] = tmpColor.b * 255;
  121486. data[x * 4 + 3] = tmpColor.a * 255;
  121487. });
  121488. }
  121489. this._colorGradientsTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_15__["RawTexture"].CreateRGBATexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"].NEAREST_SAMPLINGMODE);
  121490. };
  121491. /**
  121492. * Renders the particle system in its current state
  121493. * @param preWarm defines if the system should only update the particles but not render them
  121494. * @returns the current number of particles
  121495. */
  121496. GPUParticleSystem.prototype.render = function (preWarm) {
  121497. if (preWarm === void 0) { preWarm = false; }
  121498. if (!this._started) {
  121499. return 0;
  121500. }
  121501. this._createColorGradientTexture();
  121502. this._createSizeGradientTexture();
  121503. this._createAngularSpeedGradientTexture();
  121504. this._createVelocityGradientTexture();
  121505. this._createLimitVelocityGradientTexture();
  121506. this._createDragGradientTexture();
  121507. this._recreateUpdateEffect();
  121508. this._recreateRenderEffect();
  121509. if (!this.isReady()) {
  121510. return 0;
  121511. }
  121512. if (!preWarm) {
  121513. if (!this._preWarmDone && this.preWarmCycles) {
  121514. for (var index = 0; index < this.preWarmCycles; index++) {
  121515. this.animate(true);
  121516. this.render(true);
  121517. }
  121518. this._preWarmDone = true;
  121519. }
  121520. if (this._currentRenderId === this._scene.getFrameId()) {
  121521. return 0;
  121522. }
  121523. this._currentRenderId = this._scene.getFrameId();
  121524. }
  121525. // Get everything ready to render
  121526. this._initialize();
  121527. this._accumulatedCount += this.emitRate * this._timeDelta;
  121528. if (this._accumulatedCount > 1) {
  121529. var intPart = this._accumulatedCount | 0;
  121530. this._accumulatedCount -= intPart;
  121531. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  121532. }
  121533. if (!this._currentActiveCount) {
  121534. return 0;
  121535. }
  121536. // Enable update effect
  121537. this._engine.enableEffect(this._updateEffect);
  121538. this._engine.setState(false);
  121539. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  121540. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  121541. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  121542. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  121543. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  121544. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  121545. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  121546. if (!this._colorGradientsTexture) {
  121547. this._updateEffect.setDirectColor4("color1", this.color1);
  121548. this._updateEffect.setDirectColor4("color2", this.color2);
  121549. }
  121550. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  121551. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  121552. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  121553. this._updateEffect.setVector3("gravity", this.gravity);
  121554. if (this._sizeGradientsTexture) {
  121555. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  121556. }
  121557. if (this._angularSpeedGradientsTexture) {
  121558. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  121559. }
  121560. if (this._velocityGradientsTexture) {
  121561. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  121562. }
  121563. if (this._limitVelocityGradientsTexture) {
  121564. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  121565. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  121566. }
  121567. if (this._dragGradientsTexture) {
  121568. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  121569. }
  121570. if (this.particleEmitterType) {
  121571. this.particleEmitterType.applyToShader(this._updateEffect);
  121572. }
  121573. if (this._isAnimationSheetEnabled) {
  121574. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  121575. }
  121576. if (this.noiseTexture) {
  121577. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  121578. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  121579. }
  121580. var emitterWM;
  121581. if (this.emitter.position) {
  121582. var emitterMesh = this.emitter;
  121583. emitterWM = emitterMesh.getWorldMatrix();
  121584. }
  121585. else {
  121586. var emitterPosition = this.emitter;
  121587. emitterWM = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  121588. }
  121589. this._updateEffect.setMatrix("emitterWM", emitterWM);
  121590. // Bind source VAO
  121591. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  121592. // Update
  121593. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  121594. this._engine.setRasterizerState(false);
  121595. this._engine.beginTransformFeedback(true);
  121596. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_11__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  121597. this._engine.endTransformFeedback();
  121598. this._engine.setRasterizerState(true);
  121599. this._engine.bindTransformFeedbackBuffer(null);
  121600. if (!preWarm) {
  121601. // Enable render effect
  121602. this._engine.enableEffect(this._renderEffect);
  121603. var viewMatrix = this._scene.getViewMatrix();
  121604. this._renderEffect.setMatrix("view", viewMatrix);
  121605. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  121606. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  121607. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  121608. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  121609. if (this._colorGradientsTexture) {
  121610. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  121611. }
  121612. else {
  121613. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  121614. }
  121615. if (this._isAnimationSheetEnabled && this.particleTexture) {
  121616. var baseSize = this.particleTexture.getBaseSize();
  121617. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  121618. }
  121619. if (this._isBillboardBased) {
  121620. var camera = this._scene.activeCamera;
  121621. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  121622. }
  121623. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  121624. var invView = viewMatrix.clone();
  121625. invView.invert();
  121626. this._renderEffect.setMatrix("invView", invView);
  121627. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  121628. }
  121629. // image processing
  121630. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  121631. this._imageProcessingConfiguration.bind(this._renderEffect);
  121632. }
  121633. // Draw order
  121634. switch (this.blendMode) {
  121635. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BLENDMODE_ADD:
  121636. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_ADD);
  121637. break;
  121638. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BLENDMODE_ONEONE:
  121639. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_ONEONE);
  121640. break;
  121641. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BLENDMODE_STANDARD:
  121642. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_COMBINE);
  121643. break;
  121644. case _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].BLENDMODE_MULTIPLY:
  121645. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_MULTIPLY);
  121646. break;
  121647. }
  121648. if (this.forceDepthWrite) {
  121649. this._engine.setDepthWrite(true);
  121650. }
  121651. // Bind source VAO
  121652. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  121653. // Render
  121654. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_11__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  121655. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_DISABLE);
  121656. }
  121657. // Switch VAOs
  121658. this._targetIndex++;
  121659. if (this._targetIndex === 2) {
  121660. this._targetIndex = 0;
  121661. }
  121662. // Switch buffers
  121663. var tmpBuffer = this._sourceBuffer;
  121664. this._sourceBuffer = this._targetBuffer;
  121665. this._targetBuffer = tmpBuffer;
  121666. return this._currentActiveCount;
  121667. };
  121668. /**
  121669. * Rebuilds the particle system
  121670. */
  121671. GPUParticleSystem.prototype.rebuild = function () {
  121672. this._initialize(true);
  121673. };
  121674. GPUParticleSystem.prototype._releaseBuffers = function () {
  121675. if (this._buffer0) {
  121676. this._buffer0.dispose();
  121677. this._buffer0 = null;
  121678. }
  121679. if (this._buffer1) {
  121680. this._buffer1.dispose();
  121681. this._buffer1 = null;
  121682. }
  121683. if (this._spriteBuffer) {
  121684. this._spriteBuffer.dispose();
  121685. this._spriteBuffer = null;
  121686. }
  121687. };
  121688. GPUParticleSystem.prototype._releaseVAOs = function () {
  121689. if (!this._updateVAO) {
  121690. return;
  121691. }
  121692. for (var index = 0; index < this._updateVAO.length; index++) {
  121693. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  121694. }
  121695. this._updateVAO = [];
  121696. for (var index = 0; index < this._renderVAO.length; index++) {
  121697. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  121698. }
  121699. this._renderVAO = [];
  121700. };
  121701. /**
  121702. * Disposes the particle system and free the associated resources
  121703. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  121704. */
  121705. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  121706. if (disposeTexture === void 0) { disposeTexture = true; }
  121707. var index = this._scene.particleSystems.indexOf(this);
  121708. if (index > -1) {
  121709. this._scene.particleSystems.splice(index, 1);
  121710. }
  121711. this._releaseBuffers();
  121712. this._releaseVAOs();
  121713. if (this._colorGradientsTexture) {
  121714. this._colorGradientsTexture.dispose();
  121715. this._colorGradientsTexture = null;
  121716. }
  121717. if (this._sizeGradientsTexture) {
  121718. this._sizeGradientsTexture.dispose();
  121719. this._sizeGradientsTexture = null;
  121720. }
  121721. if (this._angularSpeedGradientsTexture) {
  121722. this._angularSpeedGradientsTexture.dispose();
  121723. this._angularSpeedGradientsTexture = null;
  121724. }
  121725. if (this._velocityGradientsTexture) {
  121726. this._velocityGradientsTexture.dispose();
  121727. this._velocityGradientsTexture = null;
  121728. }
  121729. if (this._limitVelocityGradientsTexture) {
  121730. this._limitVelocityGradientsTexture.dispose();
  121731. this._limitVelocityGradientsTexture = null;
  121732. }
  121733. if (this._dragGradientsTexture) {
  121734. this._dragGradientsTexture.dispose();
  121735. this._dragGradientsTexture = null;
  121736. }
  121737. if (this._randomTexture) {
  121738. this._randomTexture.dispose();
  121739. this._randomTexture = null;
  121740. }
  121741. if (this._randomTexture2) {
  121742. this._randomTexture2.dispose();
  121743. this._randomTexture2 = null;
  121744. }
  121745. if (disposeTexture && this.particleTexture) {
  121746. this.particleTexture.dispose();
  121747. this.particleTexture = null;
  121748. }
  121749. if (disposeTexture && this.noiseTexture) {
  121750. this.noiseTexture.dispose();
  121751. this.noiseTexture = null;
  121752. }
  121753. // Callback
  121754. this.onDisposeObservable.notifyObservers(this);
  121755. this.onDisposeObservable.clear();
  121756. };
  121757. /**
  121758. * Clones the particle system.
  121759. * @param name The name of the cloned object
  121760. * @param newEmitter The new emitter to use
  121761. * @returns the cloned particle system
  121762. */
  121763. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  121764. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  121765. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_18__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture", "particleTexture", "onDisposeObservable"]);
  121766. if (newEmitter === undefined) {
  121767. newEmitter = this.emitter;
  121768. }
  121769. result.emitter = newEmitter;
  121770. if (this.particleTexture) {
  121771. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"](this.particleTexture.url, this._scene);
  121772. }
  121773. result.noiseTexture = this.noiseTexture;
  121774. result.emitter = newEmitter;
  121775. if (this.particleTexture) {
  121776. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_14__["Texture"](this.particleTexture.url, this._scene);
  121777. }
  121778. // Clone gradients
  121779. if (this._colorGradients) {
  121780. this._colorGradients.forEach(function (v) {
  121781. result.addColorGradient(v.gradient, v.color1, v.color2);
  121782. });
  121783. }
  121784. if (this._dragGradients) {
  121785. this._dragGradients.forEach(function (v) {
  121786. result.addDragGradient(v.gradient, v.factor1);
  121787. });
  121788. }
  121789. if (this._angularSpeedGradients) {
  121790. this._angularSpeedGradients.forEach(function (v) {
  121791. result.addAngularSpeedGradient(v.gradient, v.factor1);
  121792. });
  121793. }
  121794. if (this._emitRateGradients) {
  121795. this._emitRateGradients.forEach(function (v) {
  121796. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  121797. });
  121798. }
  121799. if (this._lifeTimeGradients) {
  121800. this._lifeTimeGradients.forEach(function (v) {
  121801. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  121802. });
  121803. }
  121804. if (this._limitVelocityGradients) {
  121805. this._limitVelocityGradients.forEach(function (v) {
  121806. result.addLimitVelocityGradient(v.gradient, v.factor1);
  121807. });
  121808. }
  121809. if (this._sizeGradients) {
  121810. this._sizeGradients.forEach(function (v) {
  121811. result.addSizeGradient(v.gradient, v.factor1);
  121812. });
  121813. }
  121814. if (this._startSizeGradients) {
  121815. this._startSizeGradients.forEach(function (v) {
  121816. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  121817. });
  121818. }
  121819. if (this._velocityGradients) {
  121820. this._velocityGradients.forEach(function (v) {
  121821. result.addVelocityGradient(v.gradient, v.factor1);
  121822. });
  121823. }
  121824. if (this._rampGradients) {
  121825. this._rampGradients.forEach(function (v) {
  121826. result.addRampGradient(v.gradient, v.color);
  121827. });
  121828. }
  121829. if (this._colorRemapGradients) {
  121830. this._colorRemapGradients.forEach(function (v) {
  121831. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  121832. });
  121833. }
  121834. if (this._alphaRemapGradients) {
  121835. this._alphaRemapGradients.forEach(function (v) {
  121836. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  121837. });
  121838. }
  121839. return result;
  121840. };
  121841. /**
  121842. * Serializes the particle system to a JSON object.
  121843. * @returns the JSON object
  121844. */
  121845. GPUParticleSystem.prototype.serialize = function () {
  121846. var serializationObject = {};
  121847. _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"]._Serialize(serializationObject, this);
  121848. serializationObject.activeParticleCount = this.activeParticleCount;
  121849. return serializationObject;
  121850. };
  121851. /**
  121852. * Parses a JSON object to create a GPU particle system.
  121853. * @param parsedParticleSystem The JSON object to parse
  121854. * @param scene The scene to create the particle system in
  121855. * @param rootUrl The root url to use to load external dependencies like texture
  121856. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  121857. * @returns the parsed GPU particle system
  121858. */
  121859. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  121860. if (doNotStart === void 0) { doNotStart = false; }
  121861. var name = parsedParticleSystem.name;
  121862. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  121863. if (parsedParticleSystem.activeParticleCount) {
  121864. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  121865. }
  121866. _particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  121867. // Auto start
  121868. if (parsedParticleSystem.preventAutoStart) {
  121869. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  121870. }
  121871. if (!doNotStart && !particleSystem.preventAutoStart) {
  121872. particleSystem.start();
  121873. }
  121874. return particleSystem;
  121875. };
  121876. return GPUParticleSystem;
  121877. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_7__["BaseParticleSystem"]));
  121878. /***/ }),
  121879. /***/ "./Particles/index.ts":
  121880. /*!****************************!*\
  121881. !*** ./Particles/index.ts ***!
  121882. \****************************/
  121883. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  121884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121885. "use strict";
  121886. __webpack_require__.r(__webpack_exports__);
  121887. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  121888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  121889. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  121890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  121891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  121892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  121893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  121894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  121895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  121896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  121897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  121898. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  121899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  121900. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  121901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  121902. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  121903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  121904. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  121905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  121906. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  121907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  121908. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  121909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  121910. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  121911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  121912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  121913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  121914. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  121915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  121916. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  121917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  121918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  121919. /***/ }),
  121920. /***/ "./Particles/particle.ts":
  121921. /*!*******************************!*\
  121922. !*** ./Particles/particle.ts ***!
  121923. \*******************************/
  121924. /*! exports provided: Particle */
  121925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121926. "use strict";
  121927. __webpack_require__.r(__webpack_exports__);
  121928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  121929. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  121930. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  121931. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  121932. /**
  121933. * A particle represents one of the element emitted by a particle system.
  121934. * This is mainly define by its coordinates, direction, velocity and age.
  121935. */
  121936. var Particle = /** @class */ (function () {
  121937. /**
  121938. * Creates a new instance Particle
  121939. * @param particleSystem the particle system the particle belongs to
  121940. */
  121941. function Particle(
  121942. /**
  121943. * The particle system the particle belongs to.
  121944. */
  121945. particleSystem) {
  121946. this.particleSystem = particleSystem;
  121947. /**
  121948. * The world position of the particle in the scene.
  121949. */
  121950. this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  121951. /**
  121952. * The world direction of the particle in the scene.
  121953. */
  121954. this.direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  121955. /**
  121956. * The color of the particle.
  121957. */
  121958. this.color = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  121959. /**
  121960. * The color change of the particle per step.
  121961. */
  121962. this.colorStep = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  121963. /**
  121964. * Defines how long will the life of the particle be.
  121965. */
  121966. this.lifeTime = 1.0;
  121967. /**
  121968. * The current age of the particle.
  121969. */
  121970. this.age = 0;
  121971. /**
  121972. * The current size of the particle.
  121973. */
  121974. this.size = 0;
  121975. /**
  121976. * The current scale of the particle.
  121977. */
  121978. this.scale = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  121979. /**
  121980. * The current angle of the particle.
  121981. */
  121982. this.angle = 0;
  121983. /**
  121984. * Defines how fast is the angle changing.
  121985. */
  121986. this.angularSpeed = 0;
  121987. /**
  121988. * Defines the cell index used by the particle to be rendered from a sprite.
  121989. */
  121990. this.cellIndex = 0;
  121991. /** @hidden */
  121992. this._attachedSubEmitters = null;
  121993. /** @hidden */
  121994. this._currentColor1 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  121995. /** @hidden */
  121996. this._currentColor2 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  121997. /** @hidden */
  121998. this._currentSize1 = 0;
  121999. /** @hidden */
  122000. this._currentSize2 = 0;
  122001. /** @hidden */
  122002. this._currentAngularSpeed1 = 0;
  122003. /** @hidden */
  122004. this._currentAngularSpeed2 = 0;
  122005. /** @hidden */
  122006. this._currentVelocity1 = 0;
  122007. /** @hidden */
  122008. this._currentVelocity2 = 0;
  122009. /** @hidden */
  122010. this._currentLimitVelocity1 = 0;
  122011. /** @hidden */
  122012. this._currentLimitVelocity2 = 0;
  122013. /** @hidden */
  122014. this._currentDrag1 = 0;
  122015. /** @hidden */
  122016. this._currentDrag2 = 0;
  122017. this.id = Particle._Count++;
  122018. if (!this.particleSystem.isAnimationSheetEnabled) {
  122019. return;
  122020. }
  122021. this.updateCellInfoFromSystem();
  122022. }
  122023. Particle.prototype.updateCellInfoFromSystem = function () {
  122024. this.cellIndex = this.particleSystem.startSpriteCellID;
  122025. };
  122026. /**
  122027. * Defines how the sprite cell index is updated for the particle
  122028. */
  122029. Particle.prototype.updateCellIndex = function () {
  122030. var offsetAge = this.age;
  122031. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  122032. if (this.particleSystem.spriteRandomStartCell) {
  122033. if (this._randomCellOffset === undefined) {
  122034. this._randomCellOffset = Math.random() * this.lifeTime;
  122035. }
  122036. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  122037. changeSpeed = 1;
  122038. offsetAge = this._randomCellOffset;
  122039. }
  122040. else {
  122041. offsetAge += this._randomCellOffset;
  122042. }
  122043. }
  122044. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  122045. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  122046. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  122047. };
  122048. /** @hidden */
  122049. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  122050. if (subEmitter.particleSystem.emitter.position) {
  122051. var emitterMesh = subEmitter.particleSystem.emitter;
  122052. emitterMesh.position.copyFrom(this.position);
  122053. if (subEmitter.inheritDirection) {
  122054. emitterMesh.position.subtractToRef(this.direction, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0]);
  122055. // Look at using Y as forward
  122056. emitterMesh.lookAt(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0], 0, Math.PI / 2);
  122057. }
  122058. }
  122059. else {
  122060. var emitterPosition = subEmitter.particleSystem.emitter;
  122061. emitterPosition.copyFrom(this.position);
  122062. }
  122063. // Set inheritedVelocityOffset to be used when new particles are created
  122064. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0]);
  122065. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0]);
  122066. };
  122067. /** @hidden */
  122068. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  122069. var _this = this;
  122070. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  122071. this._attachedSubEmitters.forEach(function (subEmitter) {
  122072. _this._inheritParticleInfoToSubEmitter(subEmitter);
  122073. });
  122074. }
  122075. };
  122076. /** @hidden */
  122077. Particle.prototype._reset = function () {
  122078. this.age = 0;
  122079. this._currentColorGradient = null;
  122080. this._currentSizeGradient = null;
  122081. this._currentAngularSpeedGradient = null;
  122082. this._currentVelocityGradient = null;
  122083. this._currentLimitVelocityGradient = null;
  122084. this._currentDragGradient = null;
  122085. this.cellIndex = this.particleSystem.startSpriteCellID;
  122086. this._randomCellOffset = undefined;
  122087. };
  122088. /**
  122089. * Copy the properties of particle to another one.
  122090. * @param other the particle to copy the information to.
  122091. */
  122092. Particle.prototype.copyTo = function (other) {
  122093. other.position.copyFrom(this.position);
  122094. if (this._initialDirection) {
  122095. if (other._initialDirection) {
  122096. other._initialDirection.copyFrom(this._initialDirection);
  122097. }
  122098. else {
  122099. other._initialDirection = this._initialDirection.clone();
  122100. }
  122101. }
  122102. else {
  122103. other._initialDirection = null;
  122104. }
  122105. other.direction.copyFrom(this.direction);
  122106. other.color.copyFrom(this.color);
  122107. other.colorStep.copyFrom(this.colorStep);
  122108. other.lifeTime = this.lifeTime;
  122109. other.age = this.age;
  122110. other._randomCellOffset = this._randomCellOffset;
  122111. other.size = this.size;
  122112. other.scale.copyFrom(this.scale);
  122113. other.angle = this.angle;
  122114. other.angularSpeed = this.angularSpeed;
  122115. other.particleSystem = this.particleSystem;
  122116. other.cellIndex = this.cellIndex;
  122117. other.id = this.id;
  122118. other._attachedSubEmitters = this._attachedSubEmitters;
  122119. if (this._currentColorGradient) {
  122120. other._currentColorGradient = this._currentColorGradient;
  122121. other._currentColor1.copyFrom(this._currentColor1);
  122122. other._currentColor2.copyFrom(this._currentColor2);
  122123. }
  122124. if (this._currentSizeGradient) {
  122125. other._currentSizeGradient = this._currentSizeGradient;
  122126. other._currentSize1 = this._currentSize1;
  122127. other._currentSize2 = this._currentSize2;
  122128. }
  122129. if (this._currentAngularSpeedGradient) {
  122130. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  122131. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  122132. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  122133. }
  122134. if (this._currentVelocityGradient) {
  122135. other._currentVelocityGradient = this._currentVelocityGradient;
  122136. other._currentVelocity1 = this._currentVelocity1;
  122137. other._currentVelocity2 = this._currentVelocity2;
  122138. }
  122139. if (this._currentLimitVelocityGradient) {
  122140. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  122141. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  122142. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  122143. }
  122144. if (this._currentDragGradient) {
  122145. other._currentDragGradient = this._currentDragGradient;
  122146. other._currentDrag1 = this._currentDrag1;
  122147. other._currentDrag2 = this._currentDrag2;
  122148. }
  122149. if (this.particleSystem.isAnimationSheetEnabled) {
  122150. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  122151. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  122152. }
  122153. if (this.particleSystem.useRampGradients) {
  122154. other.remapData.copyFrom(this.remapData);
  122155. }
  122156. if (this._randomNoiseCoordinates1) {
  122157. if (other._randomNoiseCoordinates1) {
  122158. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  122159. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  122160. }
  122161. else {
  122162. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  122163. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  122164. }
  122165. }
  122166. };
  122167. Particle._Count = 0;
  122168. return Particle;
  122169. }());
  122170. /***/ }),
  122171. /***/ "./Particles/particleHelper.ts":
  122172. /*!*************************************!*\
  122173. !*** ./Particles/particleHelper.ts ***!
  122174. \*************************************/
  122175. /*! exports provided: ParticleHelper */
  122176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122177. "use strict";
  122178. __webpack_require__.r(__webpack_exports__);
  122179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  122180. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  122181. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  122182. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122183. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122184. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  122185. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  122186. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  122187. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122188. /**
  122189. * This class is made for on one-liner static method to help creating particle system set.
  122190. */
  122191. var ParticleHelper = /** @class */ (function () {
  122192. function ParticleHelper() {
  122193. }
  122194. /**
  122195. * Create a default particle system that you can tweak
  122196. * @param emitter defines the emitter to use
  122197. * @param capacity defines the system capacity (default is 500 particles)
  122198. * @param scene defines the hosting scene
  122199. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  122200. * @returns the new Particle system
  122201. */
  122202. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  122203. if (capacity === void 0) { capacity = 500; }
  122204. if (useGPU === void 0) { useGPU = false; }
  122205. var system;
  122206. if (useGPU) {
  122207. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  122208. }
  122209. else {
  122210. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  122211. }
  122212. system.emitter = emitter;
  122213. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  122214. system.createConeEmitter(0.1, Math.PI / 4);
  122215. // Particle color
  122216. system.color1 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  122217. system.color2 = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  122218. system.colorDead = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  122219. // Particle Size
  122220. system.minSize = 0.1;
  122221. system.maxSize = 0.1;
  122222. // Emission speed
  122223. system.minEmitPower = 2;
  122224. system.maxEmitPower = 2;
  122225. // Update speed
  122226. system.updateSpeed = 1 / 60;
  122227. system.emitRate = 30;
  122228. return system;
  122229. };
  122230. /**
  122231. * This is the main static method (one-liner) of this helper to create different particle systems
  122232. * @param type This string represents the type to the particle system to create
  122233. * @param scene The scene where the particle system should live
  122234. * @param gpu If the system will use gpu
  122235. * @returns the ParticleSystemSet created
  122236. */
  122237. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  122238. if (gpu === void 0) { gpu = false; }
  122239. if (!scene) {
  122240. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  122241. }
  122242. var token = {};
  122243. scene._addPendingData(token);
  122244. return new Promise(function (resolve, reject) {
  122245. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  122246. scene._removePendingData(token);
  122247. return reject("Particle system with GPU is not supported.");
  122248. }
  122249. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  122250. scene._removePendingData(token);
  122251. var newData = JSON.parse(data.toString());
  122252. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  122253. }, undefined, undefined, undefined, function () {
  122254. scene._removePendingData(token);
  122255. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  122256. });
  122257. });
  122258. };
  122259. /**
  122260. * Static function used to export a particle system to a ParticleSystemSet variable.
  122261. * Please note that the emitter shape is not exported
  122262. * @param systems defines the particle systems to export
  122263. * @returns the created particle system set
  122264. */
  122265. ParticleHelper.ExportSet = function (systems) {
  122266. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  122267. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  122268. var system = systems_1[_i];
  122269. set.systems.push(system);
  122270. }
  122271. return set;
  122272. };
  122273. /**
  122274. * Gets or sets base Assets URL
  122275. */
  122276. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  122277. return ParticleHelper;
  122278. }());
  122279. /***/ }),
  122280. /***/ "./Particles/particleSystem.ts":
  122281. /*!*************************************!*\
  122282. !*** ./Particles/particleSystem.ts ***!
  122283. \*************************************/
  122284. /*! exports provided: ParticleSystem */
  122285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122286. "use strict";
  122287. __webpack_require__.r(__webpack_exports__);
  122288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  122289. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122290. /* harmony import */ var _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/gradients */ "./Misc/gradients.ts");
  122291. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  122292. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  122293. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  122294. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122295. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  122296. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122297. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  122298. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  122299. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122300. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  122301. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  122302. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122303. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  122304. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  122305. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  122306. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  122307. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122308. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  122309. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  122310. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  122311. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  122312. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  122313. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  122314. /**
  122315. * This represents a particle system in Babylon.
  122316. * 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.
  122317. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  122318. * @example https://doc.babylonjs.com/babylon101/particles
  122319. */
  122320. var ParticleSystem = /** @class */ (function (_super) {
  122321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  122322. /**
  122323. * Instantiates a particle system.
  122324. * 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.
  122325. * @param name The name of the particle system
  122326. * @param capacity The max number of particles alive at the same time
  122327. * @param scene The scene the particle system belongs to
  122328. * @param customEffect a custom effect used to change the way particles are rendered by default
  122329. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122330. * @param epsilon Offset used to render the particles
  122331. */
  122332. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  122333. if (customEffect === void 0) { customEffect = null; }
  122334. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  122335. if (epsilon === void 0) { epsilon = 0.01; }
  122336. var _this = _super.call(this, name) || this;
  122337. /**
  122338. * @hidden
  122339. */
  122340. _this._inheritedVelocityOffset = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  122341. /**
  122342. * An event triggered when the system is disposed
  122343. */
  122344. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  122345. _this._particles = new Array();
  122346. _this._stockParticles = new Array();
  122347. _this._newPartsExcess = 0;
  122348. _this._vertexBuffers = {};
  122349. _this._scaledColorStep = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"](0, 0, 0, 0);
  122350. _this._colorDiff = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"](0, 0, 0, 0);
  122351. _this._scaledDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  122352. _this._scaledGravity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  122353. _this._currentRenderId = -1;
  122354. _this._useInstancing = false;
  122355. _this._started = false;
  122356. _this._stopped = false;
  122357. _this._actualFrame = 0;
  122358. /** @hidden */
  122359. _this._currentEmitRate1 = 0;
  122360. /** @hidden */
  122361. _this._currentEmitRate2 = 0;
  122362. /** @hidden */
  122363. _this._currentStartSize1 = 0;
  122364. /** @hidden */
  122365. _this._currentStartSize2 = 0;
  122366. _this._rawTextureWidth = 256;
  122367. _this._useRampGradients = false;
  122368. /**
  122369. * @hidden
  122370. * If the particle systems emitter should be disposed when the particle system is disposed
  122371. */
  122372. _this._disposeEmitterOnDispose = false;
  122373. // start of sub system methods
  122374. /**
  122375. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  122376. * Its lifetime will start back at 0.
  122377. */
  122378. _this.recycleParticle = function (particle) {
  122379. // move particle from activeParticle list to stock particles
  122380. var lastParticle = _this._particles.pop();
  122381. if (lastParticle !== particle) {
  122382. lastParticle.copyTo(particle);
  122383. }
  122384. _this._stockParticles.push(lastParticle);
  122385. };
  122386. _this._createParticle = function () {
  122387. var particle;
  122388. if (_this._stockParticles.length !== 0) {
  122389. particle = _this._stockParticles.pop();
  122390. particle._reset();
  122391. }
  122392. else {
  122393. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  122394. }
  122395. // Attach emitters
  122396. if (_this._subEmitters && _this._subEmitters.length > 0) {
  122397. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  122398. particle._attachedSubEmitters = [];
  122399. subEmitters.forEach(function (subEmitter) {
  122400. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  122401. var newEmitter = subEmitter.clone();
  122402. particle._attachedSubEmitters.push(newEmitter);
  122403. newEmitter.particleSystem.start();
  122404. }
  122405. });
  122406. }
  122407. return particle;
  122408. };
  122409. _this._emitFromParticle = function (particle) {
  122410. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  122411. return;
  122412. }
  122413. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  122414. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  122415. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  122416. var subSystem = subEmitter.clone();
  122417. particle._inheritParticleInfoToSubEmitter(subSystem);
  122418. subSystem.particleSystem._rootParticleSystem = _this;
  122419. _this.activeSubSystems.push(subSystem.particleSystem);
  122420. subSystem.particleSystem.start();
  122421. }
  122422. });
  122423. };
  122424. _this._capacity = capacity;
  122425. _this._epsilon = epsilon;
  122426. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  122427. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  122428. // Setup the default processing configuration to the scene.
  122429. _this._attachImageProcessingConfiguration(null);
  122430. _this._customEffect = customEffect;
  122431. _this._scene.particleSystems.push(_this);
  122432. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  122433. _this._createIndexBuffer();
  122434. _this._createVertexBuffers();
  122435. // Default emitter type
  122436. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  122437. // Update
  122438. _this.updateFunction = function (particles) {
  122439. var noiseTextureSize = null;
  122440. var noiseTextureData = null;
  122441. if (_this.noiseTexture) { // We need to get texture data back to CPU
  122442. noiseTextureSize = _this.noiseTexture.getSize();
  122443. noiseTextureData = (_this.noiseTexture.getContent());
  122444. }
  122445. var _loop_1 = function () {
  122446. particle = particles[index];
  122447. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  122448. var previousAge = particle.age;
  122449. particle.age += scaledUpdateSpeed;
  122450. // Evaluate step to death
  122451. if (particle.age > particle.lifeTime) {
  122452. var diff = particle.age - previousAge;
  122453. var oldDiff = particle.lifeTime - previousAge;
  122454. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  122455. particle.age = particle.lifeTime;
  122456. }
  122457. var ratio = particle.age / particle.lifeTime;
  122458. // Color
  122459. if (_this._colorGradients && _this._colorGradients.length > 0) {
  122460. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  122461. if (currentGradient !== particle._currentColorGradient) {
  122462. particle._currentColor1.copyFrom(particle._currentColor2);
  122463. nextGradient.getColorToRef(particle._currentColor2);
  122464. particle._currentColorGradient = currentGradient;
  122465. }
  122466. _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  122467. });
  122468. }
  122469. else {
  122470. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  122471. particle.color.addInPlace(_this._scaledColorStep);
  122472. if (particle.color.a < 0) {
  122473. particle.color.a = 0;
  122474. }
  122475. }
  122476. // Angular speed
  122477. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  122478. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  122479. if (currentGradient !== particle._currentAngularSpeedGradient) {
  122480. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  122481. particle._currentAngularSpeed2 = nextGradient.getFactor();
  122482. particle._currentAngularSpeedGradient = currentGradient;
  122483. }
  122484. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  122485. });
  122486. }
  122487. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  122488. // Direction
  122489. var directionScale = scaledUpdateSpeed;
  122490. /// Velocity
  122491. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  122492. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  122493. if (currentGradient !== particle._currentVelocityGradient) {
  122494. particle._currentVelocity1 = particle._currentVelocity2;
  122495. particle._currentVelocity2 = nextGradient.getFactor();
  122496. particle._currentVelocityGradient = currentGradient;
  122497. }
  122498. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  122499. });
  122500. }
  122501. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  122502. /// Limit velocity
  122503. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  122504. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  122505. if (currentGradient !== particle._currentLimitVelocityGradient) {
  122506. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  122507. particle._currentLimitVelocity2 = nextGradient.getFactor();
  122508. particle._currentLimitVelocityGradient = currentGradient;
  122509. }
  122510. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  122511. var currentVelocity = particle.direction.length();
  122512. if (currentVelocity > limitVelocity) {
  122513. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  122514. }
  122515. });
  122516. }
  122517. /// Drag
  122518. if (_this._dragGradients && _this._dragGradients.length > 0) {
  122519. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  122520. if (currentGradient !== particle._currentDragGradient) {
  122521. particle._currentDrag1 = particle._currentDrag2;
  122522. particle._currentDrag2 = nextGradient.getFactor();
  122523. particle._currentDragGradient = currentGradient;
  122524. }
  122525. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  122526. _this._scaledDirection.scaleInPlace(1.0 - drag);
  122527. });
  122528. }
  122529. particle.position.addInPlace(_this._scaledDirection);
  122530. // Noise
  122531. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  122532. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  122533. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  122534. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  122535. var force = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  122536. var scaledForce = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
  122537. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  122538. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  122539. particle.direction.addInPlace(scaledForce);
  122540. }
  122541. // Gravity
  122542. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  122543. particle.direction.addInPlace(_this._scaledGravity);
  122544. // Size
  122545. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  122546. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  122547. if (currentGradient !== particle._currentSizeGradient) {
  122548. particle._currentSize1 = particle._currentSize2;
  122549. particle._currentSize2 = nextGradient.getFactor();
  122550. particle._currentSizeGradient = currentGradient;
  122551. }
  122552. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  122553. });
  122554. }
  122555. // Remap data
  122556. if (_this._useRampGradients) {
  122557. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  122558. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  122559. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  122560. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  122561. particle.remapData.x = min;
  122562. particle.remapData.y = max - min;
  122563. });
  122564. }
  122565. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  122566. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  122567. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  122568. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  122569. particle.remapData.z = min;
  122570. particle.remapData.w = max - min;
  122571. });
  122572. }
  122573. }
  122574. if (_this._isAnimationSheetEnabled) {
  122575. particle.updateCellIndex();
  122576. }
  122577. // Update the position of the attached sub-emitters to match their attached particle
  122578. particle._inheritParticleInfoToSubEmitters();
  122579. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  122580. _this._emitFromParticle(particle);
  122581. if (particle._attachedSubEmitters) {
  122582. particle._attachedSubEmitters.forEach(function (subEmitter) {
  122583. subEmitter.particleSystem.disposeOnStop = true;
  122584. subEmitter.particleSystem.stop();
  122585. });
  122586. particle._attachedSubEmitters = null;
  122587. }
  122588. _this.recycleParticle(particle);
  122589. index--;
  122590. return "continue";
  122591. }
  122592. };
  122593. var particle;
  122594. for (var index = 0; index < particles.length; index++) {
  122595. _loop_1();
  122596. }
  122597. };
  122598. return _this;
  122599. }
  122600. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  122601. /**
  122602. * Sets a callback that will be triggered when the system is disposed
  122603. */
  122604. set: function (callback) {
  122605. if (this._onDisposeObserver) {
  122606. this.onDisposeObservable.remove(this._onDisposeObserver);
  122607. }
  122608. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  122609. },
  122610. enumerable: true,
  122611. configurable: true
  122612. });
  122613. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  122614. /** Gets or sets a boolean indicating that ramp gradients must be used
  122615. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122616. */
  122617. get: function () {
  122618. return this._useRampGradients;
  122619. },
  122620. set: function (value) {
  122621. if (this._useRampGradients === value) {
  122622. return;
  122623. }
  122624. this._useRampGradients = value;
  122625. this._resetEffect();
  122626. },
  122627. enumerable: true,
  122628. configurable: true
  122629. });
  122630. Object.defineProperty(ParticleSystem.prototype, "particles", {
  122631. //end of Sub-emitter
  122632. /**
  122633. * Gets the current list of active particles
  122634. */
  122635. get: function () {
  122636. return this._particles;
  122637. },
  122638. enumerable: true,
  122639. configurable: true
  122640. });
  122641. /**
  122642. * Returns the string "ParticleSystem"
  122643. * @returns a string containing the class name
  122644. */
  122645. ParticleSystem.prototype.getClassName = function () {
  122646. return "ParticleSystem";
  122647. };
  122648. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  122649. var newGradient = new _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  122650. newGradient.gradient = gradient;
  122651. newGradient.factor1 = factor;
  122652. newGradient.factor2 = factor2;
  122653. factorGradients.push(newGradient);
  122654. factorGradients.sort(function (a, b) {
  122655. if (a.gradient < b.gradient) {
  122656. return -1;
  122657. }
  122658. else if (a.gradient > b.gradient) {
  122659. return 1;
  122660. }
  122661. return 0;
  122662. });
  122663. };
  122664. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  122665. if (!factorGradients) {
  122666. return;
  122667. }
  122668. var index = 0;
  122669. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  122670. var factorGradient = factorGradients_1[_i];
  122671. if (factorGradient.gradient === gradient) {
  122672. factorGradients.splice(index, 1);
  122673. break;
  122674. }
  122675. index++;
  122676. }
  122677. };
  122678. /**
  122679. * Adds a new life time gradient
  122680. * @param gradient defines the gradient to use (between 0 and 1)
  122681. * @param factor defines the life time factor to affect to the specified gradient
  122682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122683. * @returns the current particle system
  122684. */
  122685. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  122686. if (!this._lifeTimeGradients) {
  122687. this._lifeTimeGradients = [];
  122688. }
  122689. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  122690. return this;
  122691. };
  122692. /**
  122693. * Remove a specific life time gradient
  122694. * @param gradient defines the gradient to remove
  122695. * @returns the current particle system
  122696. */
  122697. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  122698. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  122699. return this;
  122700. };
  122701. /**
  122702. * Adds a new size gradient
  122703. * @param gradient defines the gradient to use (between 0 and 1)
  122704. * @param factor defines the size factor to affect to the specified gradient
  122705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122706. * @returns the current particle system
  122707. */
  122708. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  122709. if (!this._sizeGradients) {
  122710. this._sizeGradients = [];
  122711. }
  122712. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  122713. return this;
  122714. };
  122715. /**
  122716. * Remove a specific size gradient
  122717. * @param gradient defines the gradient to remove
  122718. * @returns the current particle system
  122719. */
  122720. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  122721. this._removeFactorGradient(this._sizeGradients, gradient);
  122722. return this;
  122723. };
  122724. /**
  122725. * Adds a new color remap gradient
  122726. * @param gradient defines the gradient to use (between 0 and 1)
  122727. * @param min defines the color remap minimal range
  122728. * @param max defines the color remap maximal range
  122729. * @returns the current particle system
  122730. */
  122731. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  122732. if (!this._colorRemapGradients) {
  122733. this._colorRemapGradients = [];
  122734. }
  122735. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  122736. return this;
  122737. };
  122738. /**
  122739. * Remove a specific color remap gradient
  122740. * @param gradient defines the gradient to remove
  122741. * @returns the current particle system
  122742. */
  122743. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  122744. this._removeFactorGradient(this._colorRemapGradients, gradient);
  122745. return this;
  122746. };
  122747. /**
  122748. * Adds a new alpha remap gradient
  122749. * @param gradient defines the gradient to use (between 0 and 1)
  122750. * @param min defines the alpha remap minimal range
  122751. * @param max defines the alpha remap maximal range
  122752. * @returns the current particle system
  122753. */
  122754. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  122755. if (!this._alphaRemapGradients) {
  122756. this._alphaRemapGradients = [];
  122757. }
  122758. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  122759. return this;
  122760. };
  122761. /**
  122762. * Remove a specific alpha remap gradient
  122763. * @param gradient defines the gradient to remove
  122764. * @returns the current particle system
  122765. */
  122766. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  122767. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  122768. return this;
  122769. };
  122770. /**
  122771. * Adds a new angular speed gradient
  122772. * @param gradient defines the gradient to use (between 0 and 1)
  122773. * @param factor defines the angular speed to affect to the specified gradient
  122774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122775. * @returns the current particle system
  122776. */
  122777. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  122778. if (!this._angularSpeedGradients) {
  122779. this._angularSpeedGradients = [];
  122780. }
  122781. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  122782. return this;
  122783. };
  122784. /**
  122785. * Remove a specific angular speed gradient
  122786. * @param gradient defines the gradient to remove
  122787. * @returns the current particle system
  122788. */
  122789. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  122790. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  122791. return this;
  122792. };
  122793. /**
  122794. * Adds a new velocity gradient
  122795. * @param gradient defines the gradient to use (between 0 and 1)
  122796. * @param factor defines the velocity to affect to the specified gradient
  122797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122798. * @returns the current particle system
  122799. */
  122800. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  122801. if (!this._velocityGradients) {
  122802. this._velocityGradients = [];
  122803. }
  122804. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  122805. return this;
  122806. };
  122807. /**
  122808. * Remove a specific velocity gradient
  122809. * @param gradient defines the gradient to remove
  122810. * @returns the current particle system
  122811. */
  122812. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  122813. this._removeFactorGradient(this._velocityGradients, gradient);
  122814. return this;
  122815. };
  122816. /**
  122817. * Adds a new limit velocity gradient
  122818. * @param gradient defines the gradient to use (between 0 and 1)
  122819. * @param factor defines the limit velocity value to affect to the specified gradient
  122820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122821. * @returns the current particle system
  122822. */
  122823. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  122824. if (!this._limitVelocityGradients) {
  122825. this._limitVelocityGradients = [];
  122826. }
  122827. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  122828. return this;
  122829. };
  122830. /**
  122831. * Remove a specific limit velocity gradient
  122832. * @param gradient defines the gradient to remove
  122833. * @returns the current particle system
  122834. */
  122835. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  122836. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  122837. return this;
  122838. };
  122839. /**
  122840. * Adds a new drag gradient
  122841. * @param gradient defines the gradient to use (between 0 and 1)
  122842. * @param factor defines the drag value to affect to the specified gradient
  122843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122844. * @returns the current particle system
  122845. */
  122846. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  122847. if (!this._dragGradients) {
  122848. this._dragGradients = [];
  122849. }
  122850. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  122851. return this;
  122852. };
  122853. /**
  122854. * Remove a specific drag gradient
  122855. * @param gradient defines the gradient to remove
  122856. * @returns the current particle system
  122857. */
  122858. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  122859. this._removeFactorGradient(this._dragGradients, gradient);
  122860. return this;
  122861. };
  122862. /**
  122863. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  122864. * @param gradient defines the gradient to use (between 0 and 1)
  122865. * @param factor defines the emit rate value to affect to the specified gradient
  122866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122867. * @returns the current particle system
  122868. */
  122869. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  122870. if (!this._emitRateGradients) {
  122871. this._emitRateGradients = [];
  122872. }
  122873. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  122874. return this;
  122875. };
  122876. /**
  122877. * Remove a specific emit rate gradient
  122878. * @param gradient defines the gradient to remove
  122879. * @returns the current particle system
  122880. */
  122881. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  122882. this._removeFactorGradient(this._emitRateGradients, gradient);
  122883. return this;
  122884. };
  122885. /**
  122886. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  122887. * @param gradient defines the gradient to use (between 0 and 1)
  122888. * @param factor defines the start size value to affect to the specified gradient
  122889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122890. * @returns the current particle system
  122891. */
  122892. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  122893. if (!this._startSizeGradients) {
  122894. this._startSizeGradients = [];
  122895. }
  122896. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  122897. return this;
  122898. };
  122899. /**
  122900. * Remove a specific start size gradient
  122901. * @param gradient defines the gradient to remove
  122902. * @returns the current particle system
  122903. */
  122904. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  122905. this._removeFactorGradient(this._emitRateGradients, gradient);
  122906. return this;
  122907. };
  122908. ParticleSystem.prototype._createRampGradientTexture = function () {
  122909. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  122910. return;
  122911. }
  122912. var data = new Uint8Array(this._rawTextureWidth * 4);
  122913. var tmpColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["TmpColors"].Color3[0];
  122914. for (var x = 0; x < this._rawTextureWidth; x++) {
  122915. var ratio = x / this._rawTextureWidth;
  122916. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  122917. _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  122918. data[x * 4] = tmpColor.r * 255;
  122919. data[x * 4 + 1] = tmpColor.g * 255;
  122920. data[x * 4 + 2] = tmpColor.b * 255;
  122921. data[x * 4 + 3] = 255;
  122922. });
  122923. }
  122924. 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);
  122925. };
  122926. /**
  122927. * Gets the current list of ramp gradients.
  122928. * You must use addRampGradient and removeRampGradient to udpate this list
  122929. * @returns the list of ramp gradients
  122930. */
  122931. ParticleSystem.prototype.getRampGradients = function () {
  122932. return this._rampGradients;
  122933. };
  122934. /**
  122935. * Adds a new ramp gradient used to remap particle colors
  122936. * @param gradient defines the gradient to use (between 0 and 1)
  122937. * @param color defines the color to affect to the specified gradient
  122938. * @returns the current particle system
  122939. */
  122940. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  122941. if (!this._rampGradients) {
  122942. this._rampGradients = [];
  122943. }
  122944. var rampGradient = new _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  122945. rampGradient.gradient = gradient;
  122946. rampGradient.color = color;
  122947. this._rampGradients.push(rampGradient);
  122948. this._rampGradients.sort(function (a, b) {
  122949. if (a.gradient < b.gradient) {
  122950. return -1;
  122951. }
  122952. else if (a.gradient > b.gradient) {
  122953. return 1;
  122954. }
  122955. return 0;
  122956. });
  122957. if (this._rampGradientsTexture) {
  122958. this._rampGradientsTexture.dispose();
  122959. this._rampGradientsTexture = null;
  122960. }
  122961. this._createRampGradientTexture();
  122962. return this;
  122963. };
  122964. /**
  122965. * Remove a specific ramp gradient
  122966. * @param gradient defines the gradient to remove
  122967. * @returns the current particle system
  122968. */
  122969. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  122970. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  122971. this._rampGradientsTexture = null;
  122972. if (this._rampGradients && this._rampGradients.length > 0) {
  122973. this._createRampGradientTexture();
  122974. }
  122975. return this;
  122976. };
  122977. /**
  122978. * Adds a new color gradient
  122979. * @param gradient defines the gradient to use (between 0 and 1)
  122980. * @param color1 defines the color to affect to the specified gradient
  122981. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122982. * @returns this particle system
  122983. */
  122984. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  122985. if (!this._colorGradients) {
  122986. this._colorGradients = [];
  122987. }
  122988. var colorGradient = new _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  122989. colorGradient.gradient = gradient;
  122990. colorGradient.color1 = color1;
  122991. colorGradient.color2 = color2;
  122992. this._colorGradients.push(colorGradient);
  122993. this._colorGradients.sort(function (a, b) {
  122994. if (a.gradient < b.gradient) {
  122995. return -1;
  122996. }
  122997. else if (a.gradient > b.gradient) {
  122998. return 1;
  122999. }
  123000. return 0;
  123001. });
  123002. return this;
  123003. };
  123004. /**
  123005. * Remove a specific color gradient
  123006. * @param gradient defines the gradient to remove
  123007. * @returns this particle system
  123008. */
  123009. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  123010. if (!this._colorGradients) {
  123011. return this;
  123012. }
  123013. var index = 0;
  123014. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  123015. var colorGradient = _a[_i];
  123016. if (colorGradient.gradient === gradient) {
  123017. this._colorGradients.splice(index, 1);
  123018. break;
  123019. }
  123020. index++;
  123021. }
  123022. return this;
  123023. };
  123024. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  123025. u = Math.abs(u) * 0.5 + 0.5;
  123026. v = Math.abs(v) * 0.5 + 0.5;
  123027. var wrappedU = ((u * width) % width) | 0;
  123028. var wrappedV = ((v * height) % height) | 0;
  123029. var position = (wrappedU + wrappedV * width) * 4;
  123030. return pixels[position] / 255;
  123031. };
  123032. ParticleSystem.prototype._reset = function () {
  123033. this._resetEffect();
  123034. };
  123035. ParticleSystem.prototype._resetEffect = function () {
  123036. if (this._vertexBuffer) {
  123037. this._vertexBuffer.dispose();
  123038. this._vertexBuffer = null;
  123039. }
  123040. if (this._spriteBuffer) {
  123041. this._spriteBuffer.dispose();
  123042. this._spriteBuffer = null;
  123043. }
  123044. this._createVertexBuffers();
  123045. };
  123046. ParticleSystem.prototype._createVertexBuffers = function () {
  123047. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  123048. if (this._isAnimationSheetEnabled) {
  123049. this._vertexBufferSize += 1;
  123050. }
  123051. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  123052. this._vertexBufferSize += 3;
  123053. }
  123054. if (this._useRampGradients) {
  123055. this._vertexBufferSize += 4;
  123056. }
  123057. var engine = this._scene.getEngine();
  123058. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  123059. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  123060. var dataOffset = 0;
  123061. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  123062. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  123063. dataOffset += 3;
  123064. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  123065. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  123066. dataOffset += 4;
  123067. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  123068. this._vertexBuffers["angle"] = options;
  123069. dataOffset += 1;
  123070. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  123071. this._vertexBuffers["size"] = size;
  123072. dataOffset += 2;
  123073. if (this._isAnimationSheetEnabled) {
  123074. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  123075. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  123076. dataOffset += 1;
  123077. }
  123078. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  123079. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  123080. this._vertexBuffers["direction"] = directionBuffer;
  123081. dataOffset += 3;
  123082. }
  123083. if (this._useRampGradients) {
  123084. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  123085. this._vertexBuffers["remapData"] = rampDataBuffer;
  123086. dataOffset += 4;
  123087. }
  123088. var offsets;
  123089. if (this._useInstancing) {
  123090. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  123091. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  123092. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  123093. }
  123094. else {
  123095. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  123096. dataOffset += 2;
  123097. }
  123098. this._vertexBuffers["offset"] = offsets;
  123099. };
  123100. ParticleSystem.prototype._createIndexBuffer = function () {
  123101. if (this._useInstancing) {
  123102. return;
  123103. }
  123104. var indices = [];
  123105. var index = 0;
  123106. for (var count = 0; count < this._capacity; count++) {
  123107. indices.push(index);
  123108. indices.push(index + 1);
  123109. indices.push(index + 2);
  123110. indices.push(index);
  123111. indices.push(index + 2);
  123112. indices.push(index + 3);
  123113. index += 4;
  123114. }
  123115. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  123116. };
  123117. /**
  123118. * Gets the maximum number of particles active at the same time.
  123119. * @returns The max number of active particles.
  123120. */
  123121. ParticleSystem.prototype.getCapacity = function () {
  123122. return this._capacity;
  123123. };
  123124. /**
  123125. * Gets whether there are still active particles in the system.
  123126. * @returns True if it is alive, otherwise false.
  123127. */
  123128. ParticleSystem.prototype.isAlive = function () {
  123129. return this._alive;
  123130. };
  123131. /**
  123132. * Gets if the system has been started. (Note: this will still be true after stop is called)
  123133. * @returns True if it has been started, otherwise false.
  123134. */
  123135. ParticleSystem.prototype.isStarted = function () {
  123136. return this._started;
  123137. };
  123138. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  123139. var _this = this;
  123140. this._subEmitters = new Array();
  123141. if (this.subEmitters) {
  123142. this.subEmitters.forEach(function (subEmitter) {
  123143. if (subEmitter instanceof ParticleSystem) {
  123144. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  123145. }
  123146. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  123147. _this._subEmitters.push([subEmitter]);
  123148. }
  123149. else if (subEmitter instanceof Array) {
  123150. _this._subEmitters.push(subEmitter);
  123151. }
  123152. });
  123153. }
  123154. };
  123155. /**
  123156. * Starts the particle system and begins to emit
  123157. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  123158. */
  123159. ParticleSystem.prototype.start = function (delay) {
  123160. var _this = this;
  123161. if (delay === void 0) { delay = this.startDelay; }
  123162. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  123163. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  123164. }
  123165. if (delay) {
  123166. setTimeout(function () {
  123167. _this.start(0);
  123168. }, delay);
  123169. return;
  123170. }
  123171. // Convert the subEmitters field to the constant type field _subEmitters
  123172. this._prepareSubEmitterInternalArray();
  123173. this._started = true;
  123174. this._stopped = false;
  123175. this._actualFrame = 0;
  123176. if (this._subEmitters && this._subEmitters.length != 0) {
  123177. this.activeSubSystems = new Array();
  123178. }
  123179. // Reset emit gradient so it acts the same on every start
  123180. if (this._emitRateGradients) {
  123181. if (this._emitRateGradients.length > 0) {
  123182. this._currentEmitRateGradient = this._emitRateGradients[0];
  123183. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  123184. this._currentEmitRate2 = this._currentEmitRate1;
  123185. }
  123186. if (this._emitRateGradients.length > 1) {
  123187. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  123188. }
  123189. }
  123190. // Reset start size gradient so it acts the same on every start
  123191. if (this._startSizeGradients) {
  123192. if (this._startSizeGradients.length > 0) {
  123193. this._currentStartSizeGradient = this._startSizeGradients[0];
  123194. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  123195. this._currentStartSize2 = this._currentStartSize1;
  123196. }
  123197. if (this._startSizeGradients.length > 1) {
  123198. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  123199. }
  123200. }
  123201. if (this.preWarmCycles) {
  123202. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  123203. this.emitter.computeWorldMatrix(true);
  123204. }
  123205. var noiseTextureAsProcedural_1 = this.noiseTexture;
  123206. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  123207. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  123208. setTimeout(function () {
  123209. for (var index = 0; index < _this.preWarmCycles; index++) {
  123210. _this.animate(true);
  123211. noiseTextureAsProcedural_1.render();
  123212. }
  123213. });
  123214. });
  123215. }
  123216. else {
  123217. for (var index = 0; index < this.preWarmCycles; index++) {
  123218. this.animate(true);
  123219. }
  123220. }
  123221. }
  123222. // Animations
  123223. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  123224. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  123225. }
  123226. };
  123227. /**
  123228. * Stops the particle system.
  123229. * @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.
  123230. */
  123231. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  123232. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  123233. this._stopped = true;
  123234. if (stopSubEmitters) {
  123235. this._stopSubEmitters();
  123236. }
  123237. };
  123238. // animation sheet
  123239. /**
  123240. * Remove all active particles
  123241. */
  123242. ParticleSystem.prototype.reset = function () {
  123243. this._stockParticles = [];
  123244. this._particles = [];
  123245. };
  123246. /**
  123247. * @hidden (for internal use only)
  123248. */
  123249. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  123250. var offset = index * this._vertexBufferSize;
  123251. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  123252. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  123253. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  123254. this._vertexData[offset++] = particle.color.r;
  123255. this._vertexData[offset++] = particle.color.g;
  123256. this._vertexData[offset++] = particle.color.b;
  123257. this._vertexData[offset++] = particle.color.a;
  123258. this._vertexData[offset++] = particle.angle;
  123259. this._vertexData[offset++] = particle.scale.x * particle.size;
  123260. this._vertexData[offset++] = particle.scale.y * particle.size;
  123261. if (this._isAnimationSheetEnabled) {
  123262. this._vertexData[offset++] = particle.cellIndex;
  123263. }
  123264. if (!this._isBillboardBased) {
  123265. if (particle._initialDirection) {
  123266. this._vertexData[offset++] = particle._initialDirection.x;
  123267. this._vertexData[offset++] = particle._initialDirection.y;
  123268. this._vertexData[offset++] = particle._initialDirection.z;
  123269. }
  123270. else {
  123271. this._vertexData[offset++] = particle.direction.x;
  123272. this._vertexData[offset++] = particle.direction.y;
  123273. this._vertexData[offset++] = particle.direction.z;
  123274. }
  123275. }
  123276. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  123277. this._vertexData[offset++] = particle.direction.x;
  123278. this._vertexData[offset++] = particle.direction.y;
  123279. this._vertexData[offset++] = particle.direction.z;
  123280. }
  123281. if (this._useRampGradients) {
  123282. this._vertexData[offset++] = particle.remapData.x;
  123283. this._vertexData[offset++] = particle.remapData.y;
  123284. this._vertexData[offset++] = particle.remapData.z;
  123285. this._vertexData[offset++] = particle.remapData.w;
  123286. }
  123287. if (!this._useInstancing) {
  123288. if (this._isAnimationSheetEnabled) {
  123289. if (offsetX === 0) {
  123290. offsetX = this._epsilon;
  123291. }
  123292. else if (offsetX === 1) {
  123293. offsetX = 1 - this._epsilon;
  123294. }
  123295. if (offsetY === 0) {
  123296. offsetY = this._epsilon;
  123297. }
  123298. else if (offsetY === 1) {
  123299. offsetY = 1 - this._epsilon;
  123300. }
  123301. }
  123302. this._vertexData[offset++] = offsetX;
  123303. this._vertexData[offset++] = offsetY;
  123304. }
  123305. };
  123306. ParticleSystem.prototype._stopSubEmitters = function () {
  123307. if (!this.activeSubSystems) {
  123308. return;
  123309. }
  123310. this.activeSubSystems.forEach(function (subSystem) {
  123311. subSystem.stop(true);
  123312. });
  123313. this.activeSubSystems = new Array();
  123314. };
  123315. ParticleSystem.prototype._removeFromRoot = function () {
  123316. if (!this._rootParticleSystem) {
  123317. return;
  123318. }
  123319. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  123320. if (index !== -1) {
  123321. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  123322. }
  123323. this._rootParticleSystem = null;
  123324. };
  123325. // End of sub system methods
  123326. ParticleSystem.prototype._update = function (newParticles) {
  123327. var _this = this;
  123328. // Update current
  123329. this._alive = this._particles.length > 0;
  123330. if (this.emitter.position) {
  123331. var emitterMesh = this.emitter;
  123332. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  123333. }
  123334. else {
  123335. var emitterPosition = this.emitter;
  123336. this._emitterWorldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  123337. }
  123338. this.updateFunction(this._particles);
  123339. // Add new ones
  123340. var particle;
  123341. var _loop_2 = function () {
  123342. if (this_1._particles.length === this_1._capacity) {
  123343. return "break";
  123344. }
  123345. particle = this_1._createParticle();
  123346. this_1._particles.push(particle);
  123347. // Emitter
  123348. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  123349. if (this_1.startPositionFunction) {
  123350. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  123351. }
  123352. else {
  123353. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  123354. }
  123355. if (this_1.startDirectionFunction) {
  123356. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  123357. }
  123358. else {
  123359. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  123360. }
  123361. if (emitPower === 0) {
  123362. if (!particle._initialDirection) {
  123363. particle._initialDirection = particle.direction.clone();
  123364. }
  123365. else {
  123366. particle._initialDirection.copyFrom(particle.direction);
  123367. }
  123368. }
  123369. else {
  123370. particle._initialDirection = null;
  123371. }
  123372. particle.direction.scaleInPlace(emitPower);
  123373. // Life time
  123374. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  123375. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  123376. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  123377. var factorGradient1 = currentGradient;
  123378. var factorGradient2 = nextGradient;
  123379. var lifeTime1 = factorGradient1.getFactor();
  123380. var lifeTime2 = factorGradient2.getFactor();
  123381. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  123382. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  123383. });
  123384. }
  123385. else {
  123386. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  123387. }
  123388. // Size
  123389. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  123390. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  123391. }
  123392. else {
  123393. particle._currentSizeGradient = this_1._sizeGradients[0];
  123394. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  123395. particle.size = particle._currentSize1;
  123396. if (this_1._sizeGradients.length > 1) {
  123397. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  123398. }
  123399. else {
  123400. particle._currentSize2 = particle._currentSize1;
  123401. }
  123402. }
  123403. // Size and scale
  123404. 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));
  123405. // Adjust scale by start size
  123406. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  123407. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  123408. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  123409. if (currentGradient !== _this._currentStartSizeGradient) {
  123410. _this._currentStartSize1 = _this._currentStartSize2;
  123411. _this._currentStartSize2 = nextGradient.getFactor();
  123412. _this._currentStartSizeGradient = currentGradient;
  123413. }
  123414. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  123415. particle.scale.scaleInPlace(value);
  123416. });
  123417. }
  123418. // Angle
  123419. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  123420. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  123421. }
  123422. else {
  123423. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  123424. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  123425. particle._currentAngularSpeed1 = particle.angularSpeed;
  123426. if (this_1._angularSpeedGradients.length > 1) {
  123427. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  123428. }
  123429. else {
  123430. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  123431. }
  123432. }
  123433. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  123434. // Velocity
  123435. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  123436. particle._currentVelocityGradient = this_1._velocityGradients[0];
  123437. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  123438. if (this_1._velocityGradients.length > 1) {
  123439. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  123440. }
  123441. else {
  123442. particle._currentVelocity2 = particle._currentVelocity1;
  123443. }
  123444. }
  123445. // Limit velocity
  123446. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  123447. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  123448. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  123449. if (this_1._limitVelocityGradients.length > 1) {
  123450. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  123451. }
  123452. else {
  123453. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  123454. }
  123455. }
  123456. // Drag
  123457. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  123458. particle._currentDragGradient = this_1._dragGradients[0];
  123459. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  123460. if (this_1._dragGradients.length > 1) {
  123461. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  123462. }
  123463. else {
  123464. particle._currentDrag2 = particle._currentDrag1;
  123465. }
  123466. }
  123467. // Color
  123468. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  123469. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  123470. _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  123471. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  123472. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  123473. }
  123474. else {
  123475. particle._currentColorGradient = this_1._colorGradients[0];
  123476. particle._currentColorGradient.getColorToRef(particle.color);
  123477. particle._currentColor1.copyFrom(particle.color);
  123478. if (this_1._colorGradients.length > 1) {
  123479. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  123480. }
  123481. else {
  123482. particle._currentColor2.copyFrom(particle.color);
  123483. }
  123484. }
  123485. // Sheet
  123486. if (this_1._isAnimationSheetEnabled) {
  123487. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  123488. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  123489. }
  123490. // Inherited Velocity
  123491. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  123492. // Ramp
  123493. if (this_1._useRampGradients) {
  123494. particle.remapData = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  123495. }
  123496. // Noise texture coordinates
  123497. if (this_1.noiseTexture) {
  123498. if (particle._randomNoiseCoordinates1) {
  123499. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  123500. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  123501. }
  123502. else {
  123503. particle._randomNoiseCoordinates1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  123504. particle._randomNoiseCoordinates2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  123505. }
  123506. }
  123507. // Update the position of the attached sub-emitters to match their attached particle
  123508. particle._inheritParticleInfoToSubEmitters();
  123509. };
  123510. var this_1 = this, step;
  123511. for (var index = 0; index < newParticles; index++) {
  123512. var state_1 = _loop_2();
  123513. if (state_1 === "break")
  123514. break;
  123515. }
  123516. };
  123517. /** @hidden */
  123518. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  123519. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  123520. if (isBillboardBased === void 0) { isBillboardBased = false; }
  123521. if (useRampGradients === void 0) { useRampGradients = false; }
  123522. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  123523. if (isAnimationSheetEnabled) {
  123524. attributeNamesOrOptions.push("cellIndex");
  123525. }
  123526. if (!isBillboardBased) {
  123527. attributeNamesOrOptions.push("direction");
  123528. }
  123529. if (useRampGradients) {
  123530. attributeNamesOrOptions.push("remapData");
  123531. }
  123532. return attributeNamesOrOptions;
  123533. };
  123534. /** @hidden */
  123535. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  123536. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  123537. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  123538. if (isAnimationSheetEnabled) {
  123539. effectCreationOption.push("particlesInfos");
  123540. }
  123541. return effectCreationOption;
  123542. };
  123543. /** @hidden */
  123544. ParticleSystem.prototype._getEffect = function (blendMode) {
  123545. if (this._customEffect) {
  123546. return this._customEffect;
  123547. }
  123548. var defines = [];
  123549. if (this._scene.clipPlane) {
  123550. defines.push("#define CLIPPLANE");
  123551. }
  123552. if (this._scene.clipPlane2) {
  123553. defines.push("#define CLIPPLANE2");
  123554. }
  123555. if (this._scene.clipPlane3) {
  123556. defines.push("#define CLIPPLANE3");
  123557. }
  123558. if (this._scene.clipPlane4) {
  123559. defines.push("#define CLIPPLANE4");
  123560. }
  123561. if (this._isAnimationSheetEnabled) {
  123562. defines.push("#define ANIMATESHEET");
  123563. }
  123564. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  123565. defines.push("#define BLENDMULTIPLYMODE");
  123566. }
  123567. if (this._useRampGradients) {
  123568. defines.push("#define RAMPGRADIENT");
  123569. }
  123570. if (this._isBillboardBased) {
  123571. defines.push("#define BILLBOARD");
  123572. switch (this.billboardMode) {
  123573. case ParticleSystem.BILLBOARDMODE_Y:
  123574. defines.push("#define BILLBOARDY");
  123575. break;
  123576. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  123577. defines.push("#define BILLBOARDSTRETCHED");
  123578. break;
  123579. case ParticleSystem.BILLBOARDMODE_ALL:
  123580. default:
  123581. break;
  123582. }
  123583. }
  123584. if (this._imageProcessingConfiguration) {
  123585. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  123586. defines.push(this._imageProcessingConfigurationDefines.toString());
  123587. }
  123588. // Effect
  123589. var join = defines.join("\n");
  123590. if (this._cachedDefines !== join) {
  123591. this._cachedDefines = join;
  123592. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  123593. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  123594. var samplers = ["diffuseSampler", "rampSampler"];
  123595. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  123596. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  123597. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  123598. }
  123599. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  123600. }
  123601. return this._effect;
  123602. };
  123603. /**
  123604. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  123605. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  123606. */
  123607. ParticleSystem.prototype.animate = function (preWarmOnly) {
  123608. var _this = this;
  123609. if (preWarmOnly === void 0) { preWarmOnly = false; }
  123610. if (!this._started) {
  123611. return;
  123612. }
  123613. if (!preWarmOnly) {
  123614. // Check
  123615. if (!this.isReady()) {
  123616. return;
  123617. }
  123618. if (this._currentRenderId === this._scene.getFrameId()) {
  123619. return;
  123620. }
  123621. this._currentRenderId = this._scene.getFrameId();
  123622. }
  123623. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  123624. // Determine the number of particles we need to create
  123625. var newParticles;
  123626. if (this.manualEmitCount > -1) {
  123627. newParticles = this.manualEmitCount;
  123628. this._newPartsExcess = 0;
  123629. this.manualEmitCount = 0;
  123630. }
  123631. else {
  123632. var rate_1 = this.emitRate;
  123633. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  123634. var ratio = this._actualFrame / this.targetStopDuration;
  123635. _Misc_gradients__WEBPACK_IMPORTED_MODULE_1__["GradientHelper"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  123636. if (currentGradient !== _this._currentEmitRateGradient) {
  123637. _this._currentEmitRate1 = _this._currentEmitRate2;
  123638. _this._currentEmitRate2 = nextGradient.getFactor();
  123639. _this._currentEmitRateGradient = currentGradient;
  123640. }
  123641. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  123642. });
  123643. }
  123644. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  123645. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  123646. }
  123647. if (this._newPartsExcess > 1.0) {
  123648. newParticles += this._newPartsExcess >> 0;
  123649. this._newPartsExcess -= this._newPartsExcess >> 0;
  123650. }
  123651. this._alive = false;
  123652. if (!this._stopped) {
  123653. this._actualFrame += this._scaledUpdateSpeed;
  123654. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  123655. this.stop();
  123656. }
  123657. }
  123658. else {
  123659. newParticles = 0;
  123660. }
  123661. this._update(newParticles);
  123662. // Stopped?
  123663. if (this._stopped) {
  123664. if (!this._alive) {
  123665. this._started = false;
  123666. if (this.onAnimationEnd) {
  123667. this.onAnimationEnd();
  123668. }
  123669. if (this.disposeOnStop) {
  123670. this._scene._toBeDisposed.push(this);
  123671. }
  123672. }
  123673. }
  123674. if (!preWarmOnly) {
  123675. // Update VBO
  123676. var offset = 0;
  123677. for (var index = 0; index < this._particles.length; index++) {
  123678. var particle = this._particles[index];
  123679. this._appendParticleVertices(offset, particle);
  123680. offset += this._useInstancing ? 1 : 4;
  123681. }
  123682. if (this._vertexBuffer) {
  123683. this._vertexBuffer.update(this._vertexData);
  123684. }
  123685. }
  123686. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  123687. this.stop();
  123688. }
  123689. };
  123690. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  123691. this._appendParticleVertex(offset++, particle, 0, 0);
  123692. if (!this._useInstancing) {
  123693. this._appendParticleVertex(offset++, particle, 1, 0);
  123694. this._appendParticleVertex(offset++, particle, 1, 1);
  123695. this._appendParticleVertex(offset++, particle, 0, 1);
  123696. }
  123697. };
  123698. /**
  123699. * Rebuilds the particle system.
  123700. */
  123701. ParticleSystem.prototype.rebuild = function () {
  123702. this._createIndexBuffer();
  123703. if (this._vertexBuffer) {
  123704. this._vertexBuffer._rebuild();
  123705. }
  123706. for (var key in this._vertexBuffers) {
  123707. this._vertexBuffers[key]._rebuild();
  123708. }
  123709. };
  123710. /**
  123711. * Is this system ready to be used/rendered
  123712. * @return true if the system is ready
  123713. */
  123714. ParticleSystem.prototype.isReady = function () {
  123715. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  123716. return false;
  123717. }
  123718. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  123719. if (!this._getEffect(this.blendMode).isReady()) {
  123720. return false;
  123721. }
  123722. }
  123723. else {
  123724. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  123725. return false;
  123726. }
  123727. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  123728. return false;
  123729. }
  123730. }
  123731. return true;
  123732. };
  123733. ParticleSystem.prototype._render = function (blendMode) {
  123734. var effect = this._getEffect(blendMode);
  123735. var engine = this._scene.getEngine();
  123736. // Render
  123737. engine.enableEffect(effect);
  123738. var viewMatrix = this._scene.getViewMatrix();
  123739. effect.setTexture("diffuseSampler", this.particleTexture);
  123740. effect.setMatrix("view", viewMatrix);
  123741. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  123742. if (this._isAnimationSheetEnabled && this.particleTexture) {
  123743. var baseSize = this.particleTexture.getBaseSize();
  123744. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  123745. }
  123746. effect.setVector2("translationPivot", this.translationPivot);
  123747. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  123748. if (this._isBillboardBased) {
  123749. var camera = this._scene.activeCamera;
  123750. effect.setVector3("eyePosition", camera.globalPosition);
  123751. }
  123752. if (this._rampGradientsTexture) {
  123753. effect.setTexture("rampSampler", this._rampGradientsTexture);
  123754. }
  123755. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  123756. var invView = viewMatrix.clone();
  123757. invView.invert();
  123758. effect.setMatrix("invView", invView);
  123759. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  123760. }
  123761. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  123762. // image processing
  123763. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  123764. this._imageProcessingConfiguration.bind(effect);
  123765. }
  123766. // Draw order
  123767. switch (blendMode) {
  123768. case ParticleSystem.BLENDMODE_ADD:
  123769. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  123770. break;
  123771. case ParticleSystem.BLENDMODE_ONEONE:
  123772. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  123773. break;
  123774. case ParticleSystem.BLENDMODE_STANDARD:
  123775. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  123776. break;
  123777. case ParticleSystem.BLENDMODE_MULTIPLY:
  123778. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  123779. break;
  123780. }
  123781. if (this._useInstancing) {
  123782. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  123783. }
  123784. else {
  123785. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  123786. }
  123787. return this._particles.length;
  123788. };
  123789. /**
  123790. * Renders the particle system in its current state.
  123791. * @returns the current number of particles
  123792. */
  123793. ParticleSystem.prototype.render = function () {
  123794. // Check
  123795. if (!this.isReady() || !this._particles.length) {
  123796. return 0;
  123797. }
  123798. var engine = this._scene.getEngine();
  123799. engine.setState(false);
  123800. if (this.forceDepthWrite) {
  123801. engine.setDepthWrite(true);
  123802. }
  123803. var outparticles = 0;
  123804. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  123805. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  123806. }
  123807. outparticles = this._render(this.blendMode);
  123808. engine.unbindInstanceAttributes();
  123809. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  123810. return outparticles;
  123811. };
  123812. /**
  123813. * Disposes the particle system and free the associated resources
  123814. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123815. */
  123816. ParticleSystem.prototype.dispose = function (disposeTexture) {
  123817. if (disposeTexture === void 0) { disposeTexture = true; }
  123818. if (this._vertexBuffer) {
  123819. this._vertexBuffer.dispose();
  123820. this._vertexBuffer = null;
  123821. }
  123822. if (this._spriteBuffer) {
  123823. this._spriteBuffer.dispose();
  123824. this._spriteBuffer = null;
  123825. }
  123826. if (this._indexBuffer) {
  123827. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  123828. this._indexBuffer = null;
  123829. }
  123830. if (disposeTexture && this.particleTexture) {
  123831. this.particleTexture.dispose();
  123832. this.particleTexture = null;
  123833. }
  123834. if (disposeTexture && this.noiseTexture) {
  123835. this.noiseTexture.dispose();
  123836. this.noiseTexture = null;
  123837. }
  123838. if (this._rampGradientsTexture) {
  123839. this._rampGradientsTexture.dispose();
  123840. this._rampGradientsTexture = null;
  123841. }
  123842. this._removeFromRoot();
  123843. if (this._subEmitters && this._subEmitters.length) {
  123844. for (var index = 0; index < this._subEmitters.length; index++) {
  123845. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  123846. var subEmitter = _a[_i];
  123847. subEmitter.dispose();
  123848. }
  123849. }
  123850. this._subEmitters = [];
  123851. this.subEmitters = [];
  123852. }
  123853. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  123854. this.emitter.dispose(true);
  123855. }
  123856. // Remove from scene
  123857. var index = this._scene.particleSystems.indexOf(this);
  123858. if (index > -1) {
  123859. this._scene.particleSystems.splice(index, 1);
  123860. }
  123861. this._scene._activeParticleSystems.dispose();
  123862. // Callback
  123863. this.onDisposeObservable.notifyObservers(this);
  123864. this.onDisposeObservable.clear();
  123865. this.reset();
  123866. };
  123867. // Clone
  123868. /**
  123869. * Clones the particle system.
  123870. * @param name The name of the cloned object
  123871. * @param newEmitter The new emitter to use
  123872. * @returns the cloned particle system
  123873. */
  123874. ParticleSystem.prototype.clone = function (name, newEmitter) {
  123875. var custom = null;
  123876. var program = null;
  123877. if (this.customShader != null) {
  123878. program = this.customShader;
  123879. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  123880. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  123881. }
  123882. else if (this._customEffect) {
  123883. custom = this._customEffect;
  123884. }
  123885. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  123886. result.customShader = program;
  123887. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture", "particleTexture", "onDisposeObservable"]);
  123888. if (newEmitter === undefined) {
  123889. newEmitter = this.emitter;
  123890. }
  123891. result.noiseTexture = this.noiseTexture;
  123892. result.emitter = newEmitter;
  123893. if (this.particleTexture) {
  123894. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  123895. }
  123896. // Clone gradients
  123897. if (this._colorGradients) {
  123898. this._colorGradients.forEach(function (v) {
  123899. result.addColorGradient(v.gradient, v.color1, v.color2);
  123900. });
  123901. }
  123902. if (this._dragGradients) {
  123903. this._dragGradients.forEach(function (v) {
  123904. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  123905. });
  123906. }
  123907. if (this._angularSpeedGradients) {
  123908. this._angularSpeedGradients.forEach(function (v) {
  123909. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  123910. });
  123911. }
  123912. if (this._emitRateGradients) {
  123913. this._emitRateGradients.forEach(function (v) {
  123914. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  123915. });
  123916. }
  123917. if (this._lifeTimeGradients) {
  123918. this._lifeTimeGradients.forEach(function (v) {
  123919. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  123920. });
  123921. }
  123922. if (this._limitVelocityGradients) {
  123923. this._limitVelocityGradients.forEach(function (v) {
  123924. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  123925. });
  123926. }
  123927. if (this._sizeGradients) {
  123928. this._sizeGradients.forEach(function (v) {
  123929. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  123930. });
  123931. }
  123932. if (this._startSizeGradients) {
  123933. this._startSizeGradients.forEach(function (v) {
  123934. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  123935. });
  123936. }
  123937. if (this._velocityGradients) {
  123938. this._velocityGradients.forEach(function (v) {
  123939. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  123940. });
  123941. }
  123942. if (this._rampGradients) {
  123943. this._rampGradients.forEach(function (v) {
  123944. result.addRampGradient(v.gradient, v.color);
  123945. });
  123946. }
  123947. if (this._colorRemapGradients) {
  123948. this._colorRemapGradients.forEach(function (v) {
  123949. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  123950. });
  123951. }
  123952. if (this._alphaRemapGradients) {
  123953. this._alphaRemapGradients.forEach(function (v) {
  123954. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  123955. });
  123956. }
  123957. if (!this.preventAutoStart) {
  123958. result.start();
  123959. }
  123960. return result;
  123961. };
  123962. /**
  123963. * Serializes the particle system to a JSON object.
  123964. * @returns the JSON object
  123965. */
  123966. ParticleSystem.prototype.serialize = function () {
  123967. var serializationObject = {};
  123968. ParticleSystem._Serialize(serializationObject, this);
  123969. serializationObject.textureMask = this.textureMask.asArray();
  123970. serializationObject.customShader = this.customShader;
  123971. serializationObject.preventAutoStart = this.preventAutoStart;
  123972. // SubEmitters
  123973. if (this.subEmitters) {
  123974. serializationObject.subEmitters = [];
  123975. if (!this._subEmitters) {
  123976. this._prepareSubEmitterInternalArray();
  123977. }
  123978. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  123979. var subs = _a[_i];
  123980. var cell = [];
  123981. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  123982. var sub = subs_1[_b];
  123983. cell.push(sub.serialize());
  123984. }
  123985. serializationObject.subEmitters.push(cell);
  123986. }
  123987. }
  123988. return serializationObject;
  123989. };
  123990. /** @hidden */
  123991. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  123992. serializationObject.name = particleSystem.name;
  123993. serializationObject.id = particleSystem.id;
  123994. serializationObject.capacity = particleSystem.getCapacity();
  123995. // Emitter
  123996. if (particleSystem.emitter.position) {
  123997. var emitterMesh = particleSystem.emitter;
  123998. serializationObject.emitterId = emitterMesh.id;
  123999. }
  124000. else {
  124001. var emitterPosition = particleSystem.emitter;
  124002. serializationObject.emitter = emitterPosition.asArray();
  124003. }
  124004. // Emitter
  124005. if (particleSystem.particleEmitterType) {
  124006. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  124007. }
  124008. if (particleSystem.particleTexture) {
  124009. serializationObject.textureName = particleSystem.particleTexture.name;
  124010. serializationObject.invertY = particleSystem.particleTexture._invertY;
  124011. }
  124012. // Animations
  124013. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  124014. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  124015. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  124016. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  124017. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  124018. // Particle system
  124019. serializationObject.startDelay = particleSystem.startDelay;
  124020. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  124021. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  124022. serializationObject.billboardMode = particleSystem.billboardMode;
  124023. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  124024. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  124025. serializationObject.minSize = particleSystem.minSize;
  124026. serializationObject.maxSize = particleSystem.maxSize;
  124027. serializationObject.minScaleX = particleSystem.minScaleX;
  124028. serializationObject.maxScaleX = particleSystem.maxScaleX;
  124029. serializationObject.minScaleY = particleSystem.minScaleY;
  124030. serializationObject.maxScaleY = particleSystem.maxScaleY;
  124031. serializationObject.minEmitPower = particleSystem.minEmitPower;
  124032. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  124033. serializationObject.minLifeTime = particleSystem.minLifeTime;
  124034. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  124035. serializationObject.emitRate = particleSystem.emitRate;
  124036. serializationObject.gravity = particleSystem.gravity.asArray();
  124037. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  124038. serializationObject.color1 = particleSystem.color1.asArray();
  124039. serializationObject.color2 = particleSystem.color2.asArray();
  124040. serializationObject.colorDead = particleSystem.colorDead.asArray();
  124041. serializationObject.updateSpeed = particleSystem.updateSpeed;
  124042. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  124043. serializationObject.blendMode = particleSystem.blendMode;
  124044. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  124045. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  124046. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  124047. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  124048. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  124049. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  124050. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  124051. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  124052. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  124053. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  124054. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  124055. var colorGradients = particleSystem.getColorGradients();
  124056. if (colorGradients) {
  124057. serializationObject.colorGradients = [];
  124058. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  124059. var colorGradient = colorGradients_1[_i];
  124060. var serializedGradient = {
  124061. gradient: colorGradient.gradient,
  124062. color1: colorGradient.color1.asArray()
  124063. };
  124064. if (colorGradient.color2) {
  124065. serializedGradient.color2 = colorGradient.color2.asArray();
  124066. }
  124067. serializationObject.colorGradients.push(serializedGradient);
  124068. }
  124069. }
  124070. var rampGradients = particleSystem.getRampGradients();
  124071. if (rampGradients) {
  124072. serializationObject.rampGradients = [];
  124073. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  124074. var rampGradient = rampGradients_1[_a];
  124075. var serializedGradient = {
  124076. gradient: rampGradient.gradient,
  124077. color: rampGradient.color.asArray()
  124078. };
  124079. serializationObject.rampGradients.push(serializedGradient);
  124080. }
  124081. serializationObject.useRampGradients = particleSystem.useRampGradients;
  124082. }
  124083. var colorRemapGradients = particleSystem.getColorRemapGradients();
  124084. if (colorRemapGradients) {
  124085. serializationObject.colorRemapGradients = [];
  124086. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  124087. var colorRemapGradient = colorRemapGradients_1[_b];
  124088. var serializedGradient = {
  124089. gradient: colorRemapGradient.gradient,
  124090. factor1: colorRemapGradient.factor1
  124091. };
  124092. if (colorRemapGradient.factor2 !== undefined) {
  124093. serializedGradient.factor2 = colorRemapGradient.factor2;
  124094. }
  124095. serializationObject.colorRemapGradients.push(serializedGradient);
  124096. }
  124097. }
  124098. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  124099. if (alphaRemapGradients) {
  124100. serializationObject.alphaRemapGradients = [];
  124101. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  124102. var alphaRemapGradient = alphaRemapGradients_1[_c];
  124103. var serializedGradient = {
  124104. gradient: alphaRemapGradient.gradient,
  124105. factor1: alphaRemapGradient.factor1
  124106. };
  124107. if (alphaRemapGradient.factor2 !== undefined) {
  124108. serializedGradient.factor2 = alphaRemapGradient.factor2;
  124109. }
  124110. serializationObject.alphaRemapGradients.push(serializedGradient);
  124111. }
  124112. }
  124113. var sizeGradients = particleSystem.getSizeGradients();
  124114. if (sizeGradients) {
  124115. serializationObject.sizeGradients = [];
  124116. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  124117. var sizeGradient = sizeGradients_1[_d];
  124118. var serializedGradient = {
  124119. gradient: sizeGradient.gradient,
  124120. factor1: sizeGradient.factor1
  124121. };
  124122. if (sizeGradient.factor2 !== undefined) {
  124123. serializedGradient.factor2 = sizeGradient.factor2;
  124124. }
  124125. serializationObject.sizeGradients.push(serializedGradient);
  124126. }
  124127. }
  124128. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  124129. if (angularSpeedGradients) {
  124130. serializationObject.angularSpeedGradients = [];
  124131. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  124132. var angularSpeedGradient = angularSpeedGradients_1[_e];
  124133. var serializedGradient = {
  124134. gradient: angularSpeedGradient.gradient,
  124135. factor1: angularSpeedGradient.factor1
  124136. };
  124137. if (angularSpeedGradient.factor2 !== undefined) {
  124138. serializedGradient.factor2 = angularSpeedGradient.factor2;
  124139. }
  124140. serializationObject.angularSpeedGradients.push(serializedGradient);
  124141. }
  124142. }
  124143. var velocityGradients = particleSystem.getVelocityGradients();
  124144. if (velocityGradients) {
  124145. serializationObject.velocityGradients = [];
  124146. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  124147. var velocityGradient = velocityGradients_1[_f];
  124148. var serializedGradient = {
  124149. gradient: velocityGradient.gradient,
  124150. factor1: velocityGradient.factor1
  124151. };
  124152. if (velocityGradient.factor2 !== undefined) {
  124153. serializedGradient.factor2 = velocityGradient.factor2;
  124154. }
  124155. serializationObject.velocityGradients.push(serializedGradient);
  124156. }
  124157. }
  124158. var dragGradients = particleSystem.getDragGradients();
  124159. if (dragGradients) {
  124160. serializationObject.dragGradients = [];
  124161. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  124162. var dragGradient = dragGradients_1[_g];
  124163. var serializedGradient = {
  124164. gradient: dragGradient.gradient,
  124165. factor1: dragGradient.factor1
  124166. };
  124167. if (dragGradient.factor2 !== undefined) {
  124168. serializedGradient.factor2 = dragGradient.factor2;
  124169. }
  124170. serializationObject.dragGradients.push(serializedGradient);
  124171. }
  124172. }
  124173. var emitRateGradients = particleSystem.getEmitRateGradients();
  124174. if (emitRateGradients) {
  124175. serializationObject.emitRateGradients = [];
  124176. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  124177. var emitRateGradient = emitRateGradients_1[_h];
  124178. var serializedGradient = {
  124179. gradient: emitRateGradient.gradient,
  124180. factor1: emitRateGradient.factor1
  124181. };
  124182. if (emitRateGradient.factor2 !== undefined) {
  124183. serializedGradient.factor2 = emitRateGradient.factor2;
  124184. }
  124185. serializationObject.emitRateGradients.push(serializedGradient);
  124186. }
  124187. }
  124188. var startSizeGradients = particleSystem.getStartSizeGradients();
  124189. if (startSizeGradients) {
  124190. serializationObject.startSizeGradients = [];
  124191. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  124192. var startSizeGradient = startSizeGradients_1[_j];
  124193. var serializedGradient = {
  124194. gradient: startSizeGradient.gradient,
  124195. factor1: startSizeGradient.factor1
  124196. };
  124197. if (startSizeGradient.factor2 !== undefined) {
  124198. serializedGradient.factor2 = startSizeGradient.factor2;
  124199. }
  124200. serializationObject.startSizeGradients.push(serializedGradient);
  124201. }
  124202. }
  124203. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  124204. if (lifeTimeGradients) {
  124205. serializationObject.lifeTimeGradients = [];
  124206. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  124207. var lifeTimeGradient = lifeTimeGradients_1[_k];
  124208. var serializedGradient = {
  124209. gradient: lifeTimeGradient.gradient,
  124210. factor1: lifeTimeGradient.factor1
  124211. };
  124212. if (lifeTimeGradient.factor2 !== undefined) {
  124213. serializedGradient.factor2 = lifeTimeGradient.factor2;
  124214. }
  124215. serializationObject.lifeTimeGradients.push(serializedGradient);
  124216. }
  124217. }
  124218. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  124219. if (limitVelocityGradients) {
  124220. serializationObject.limitVelocityGradients = [];
  124221. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  124222. var limitVelocityGradient = limitVelocityGradients_1[_l];
  124223. var serializedGradient = {
  124224. gradient: limitVelocityGradient.gradient,
  124225. factor1: limitVelocityGradient.factor1
  124226. };
  124227. if (limitVelocityGradient.factor2 !== undefined) {
  124228. serializedGradient.factor2 = limitVelocityGradient.factor2;
  124229. }
  124230. serializationObject.limitVelocityGradients.push(serializedGradient);
  124231. }
  124232. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  124233. }
  124234. if (particleSystem.noiseTexture) {
  124235. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  124236. }
  124237. };
  124238. /** @hidden */
  124239. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  124240. // Texture
  124241. if (parsedParticleSystem.textureName) {
  124242. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  124243. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  124244. }
  124245. // Emitter
  124246. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  124247. particleSystem.emitter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124248. }
  124249. else if (parsedParticleSystem.emitterId) {
  124250. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  124251. }
  124252. else {
  124253. particleSystem.emitter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  124254. }
  124255. // Misc.
  124256. if (parsedParticleSystem.renderingGroupId !== undefined) {
  124257. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  124258. }
  124259. if (parsedParticleSystem.isBillboardBased !== undefined) {
  124260. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  124261. }
  124262. if (parsedParticleSystem.billboardMode !== undefined) {
  124263. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  124264. }
  124265. // Animations
  124266. if (parsedParticleSystem.animations) {
  124267. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  124268. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  124269. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  124270. if (internalClass) {
  124271. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  124272. }
  124273. }
  124274. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  124275. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  124276. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  124277. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  124278. }
  124279. if (parsedParticleSystem.autoAnimate) {
  124280. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  124281. }
  124282. // Particle system
  124283. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  124284. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  124285. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  124286. particleSystem.minSize = parsedParticleSystem.minSize;
  124287. particleSystem.maxSize = parsedParticleSystem.maxSize;
  124288. if (parsedParticleSystem.minScaleX) {
  124289. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  124290. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  124291. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  124292. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  124293. }
  124294. if (parsedParticleSystem.preWarmCycles !== undefined) {
  124295. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  124296. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  124297. }
  124298. if (parsedParticleSystem.minInitialRotation !== undefined) {
  124299. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  124300. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  124301. }
  124302. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  124303. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  124304. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  124305. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  124306. particleSystem.emitRate = parsedParticleSystem.emitRate;
  124307. particleSystem.gravity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  124308. if (parsedParticleSystem.noiseStrength) {
  124309. particleSystem.noiseStrength = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  124310. }
  124311. particleSystem.color1 = _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].FromArray(parsedParticleSystem.color1);
  124312. particleSystem.color2 = _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].FromArray(parsedParticleSystem.color2);
  124313. particleSystem.colorDead = _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].FromArray(parsedParticleSystem.colorDead);
  124314. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  124315. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  124316. particleSystem.blendMode = parsedParticleSystem.blendMode;
  124317. if (parsedParticleSystem.colorGradients) {
  124318. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  124319. var colorGradient = _a[_i];
  124320. particleSystem.addColorGradient(colorGradient.gradient, _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].FromArray(colorGradient.color1), colorGradient.color2 ? _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].FromArray(colorGradient.color2) : undefined);
  124321. }
  124322. }
  124323. if (parsedParticleSystem.rampGradients) {
  124324. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  124325. var rampGradient = _c[_b];
  124326. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color3"].FromArray(rampGradient.color));
  124327. }
  124328. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  124329. }
  124330. if (parsedParticleSystem.colorRemapGradients) {
  124331. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  124332. var colorRemapGradient = _e[_d];
  124333. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  124334. }
  124335. }
  124336. if (parsedParticleSystem.alphaRemapGradients) {
  124337. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  124338. var alphaRemapGradient = _g[_f];
  124339. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  124340. }
  124341. }
  124342. if (parsedParticleSystem.sizeGradients) {
  124343. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  124344. var sizeGradient = _j[_h];
  124345. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  124346. }
  124347. }
  124348. if (parsedParticleSystem.angularSpeedGradients) {
  124349. for (var _k = 0, _l = parsedParticleSystem.angularSpeedGradients; _k < _l.length; _k++) {
  124350. var angularSpeedGradient = _l[_k];
  124351. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  124352. }
  124353. }
  124354. if (parsedParticleSystem.velocityGradients) {
  124355. for (var _m = 0, _o = parsedParticleSystem.velocityGradients; _m < _o.length; _m++) {
  124356. var velocityGradient = _o[_m];
  124357. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  124358. }
  124359. }
  124360. if (parsedParticleSystem.dragGradients) {
  124361. for (var _p = 0, _q = parsedParticleSystem.dragGradients; _p < _q.length; _p++) {
  124362. var dragGradient = _q[_p];
  124363. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  124364. }
  124365. }
  124366. if (parsedParticleSystem.emitRateGradients) {
  124367. for (var _r = 0, _s = parsedParticleSystem.emitRateGradients; _r < _s.length; _r++) {
  124368. var emitRateGradient = _s[_r];
  124369. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  124370. }
  124371. }
  124372. if (parsedParticleSystem.startSizeGradients) {
  124373. for (var _t = 0, _u = parsedParticleSystem.startSizeGradients; _t < _u.length; _t++) {
  124374. var startSizeGradient = _u[_t];
  124375. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  124376. }
  124377. }
  124378. if (parsedParticleSystem.lifeTimeGradients) {
  124379. for (var _v = 0, _w = parsedParticleSystem.lifeTimeGradients; _v < _w.length; _v++) {
  124380. var lifeTimeGradient = _w[_v];
  124381. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  124382. }
  124383. }
  124384. if (parsedParticleSystem.limitVelocityGradients) {
  124385. for (var _x = 0, _y = parsedParticleSystem.limitVelocityGradients; _x < _y.length; _x++) {
  124386. var limitVelocityGradient = _y[_x];
  124387. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  124388. }
  124389. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  124390. }
  124391. if (parsedParticleSystem.noiseTexture) {
  124392. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  124393. }
  124394. // Emitter
  124395. var emitterType;
  124396. if (parsedParticleSystem.particleEmitterType) {
  124397. switch (parsedParticleSystem.particleEmitterType.type) {
  124398. case "SphereParticleEmitter":
  124399. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  124400. break;
  124401. case "SphereDirectedParticleEmitter":
  124402. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  124403. break;
  124404. case "ConeEmitter":
  124405. case "ConeParticleEmitter":
  124406. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  124407. break;
  124408. case "CylinderParticleEmitter":
  124409. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  124410. break;
  124411. case "HemisphericParticleEmitter":
  124412. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  124413. break;
  124414. case "BoxEmitter":
  124415. case "BoxParticleEmitter":
  124416. default:
  124417. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  124418. break;
  124419. }
  124420. emitterType.parse(parsedParticleSystem.particleEmitterType);
  124421. }
  124422. else {
  124423. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  124424. emitterType.parse(parsedParticleSystem);
  124425. }
  124426. particleSystem.particleEmitterType = emitterType;
  124427. // Animation sheet
  124428. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  124429. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  124430. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  124431. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  124432. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  124433. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  124434. };
  124435. /**
  124436. * Parses a JSON object to create a particle system.
  124437. * @param parsedParticleSystem The JSON object to parse
  124438. * @param scene The scene to create the particle system in
  124439. * @param rootUrl The root url to use to load external dependencies like texture
  124440. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124441. * @returns the Parsed particle system
  124442. */
  124443. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  124444. if (doNotStart === void 0) { doNotStart = false; }
  124445. var name = parsedParticleSystem.name;
  124446. var custom = null;
  124447. var program = null;
  124448. if (parsedParticleSystem.customShader) {
  124449. program = parsedParticleSystem.customShader;
  124450. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  124451. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  124452. }
  124453. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  124454. particleSystem.customShader = program;
  124455. if (parsedParticleSystem.id) {
  124456. particleSystem.id = parsedParticleSystem.id;
  124457. }
  124458. // SubEmitters
  124459. if (parsedParticleSystem.subEmitters) {
  124460. particleSystem.subEmitters = [];
  124461. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  124462. var cell = _a[_i];
  124463. var cellArray = [];
  124464. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  124465. var sub = cell_1[_b];
  124466. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  124467. }
  124468. particleSystem.subEmitters.push(cellArray);
  124469. }
  124470. }
  124471. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  124472. particleSystem.textureMask = _Maths_math_color__WEBPACK_IMPORTED_MODULE_24__["Color4"].FromArray(parsedParticleSystem.textureMask);
  124473. // Auto start
  124474. if (parsedParticleSystem.preventAutoStart) {
  124475. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  124476. }
  124477. if (!doNotStart && !particleSystem.preventAutoStart) {
  124478. particleSystem.start();
  124479. }
  124480. return particleSystem;
  124481. };
  124482. /**
  124483. * Billboard mode will only apply to Y axis
  124484. */
  124485. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  124486. /**
  124487. * Billboard mode will apply to all axes
  124488. */
  124489. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  124490. /**
  124491. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  124492. */
  124493. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  124494. return ParticleSystem;
  124495. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  124496. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  124497. /***/ }),
  124498. /***/ "./Particles/particleSystemComponent.ts":
  124499. /*!**********************************************!*\
  124500. !*** ./Particles/particleSystemComponent.ts ***!
  124501. \**********************************************/
  124502. /*! exports provided: _IDoNeedToBeInTheBuild */
  124503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124504. "use strict";
  124505. __webpack_require__.r(__webpack_exports__);
  124506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  124507. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  124508. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  124509. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  124510. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  124511. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  124512. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124513. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  124514. // Adds the parsers to the scene parsers.
  124515. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  124516. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  124517. if (!individualParser) {
  124518. return;
  124519. }
  124520. // Particles Systems
  124521. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  124522. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  124523. var parsedParticleSystem = parsedData.particleSystems[index];
  124524. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  124525. }
  124526. }
  124527. });
  124528. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  124529. if (parsedParticleSystem.activeParticleCount) {
  124530. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  124531. return ps;
  124532. }
  124533. else {
  124534. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  124535. return ps;
  124536. }
  124537. });
  124538. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  124539. if (uniformsNames === void 0) { uniformsNames = []; }
  124540. if (samplers === void 0) { samplers = []; }
  124541. if (defines === void 0) { defines = ""; }
  124542. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  124543. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  124544. if (defines.indexOf(" BILLBOARD") === -1) {
  124545. defines += "\n#define BILLBOARD\n";
  124546. }
  124547. if (samplers.indexOf("diffuseSampler") === -1) {
  124548. samplers.push("diffuseSampler");
  124549. }
  124550. return this.createEffect({
  124551. vertex: "particles",
  124552. fragmentElement: fragmentName
  124553. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  124554. };
  124555. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  124556. var results = new Array();
  124557. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  124558. var particleSystem = this.getScene().particleSystems[index];
  124559. if (particleSystem.emitter === this) {
  124560. results.push(particleSystem);
  124561. }
  124562. }
  124563. return results;
  124564. };
  124565. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  124566. var results = new Array();
  124567. var descendants = this.getDescendants();
  124568. descendants.push(this);
  124569. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  124570. var particleSystem = this.getScene().particleSystems[index];
  124571. var emitter = particleSystem.emitter;
  124572. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  124573. results.push(particleSystem);
  124574. }
  124575. }
  124576. return results;
  124577. };
  124578. /**
  124579. * @hidden
  124580. */
  124581. var _IDoNeedToBeInTheBuild = 42;
  124582. /***/ }),
  124583. /***/ "./Particles/particleSystemSet.ts":
  124584. /*!****************************************!*\
  124585. !*** ./Particles/particleSystemSet.ts ***!
  124586. \****************************************/
  124587. /*! exports provided: ParticleSystemSet */
  124588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124589. "use strict";
  124590. __webpack_require__.r(__webpack_exports__);
  124591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  124592. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  124593. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  124594. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  124595. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  124596. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  124597. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  124598. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124599. /** Internal class used to store shapes for emitters */
  124600. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  124601. function ParticleSystemSetEmitterCreationOptions() {
  124602. }
  124603. return ParticleSystemSetEmitterCreationOptions;
  124604. }());
  124605. /**
  124606. * Represents a set of particle systems working together to create a specific effect
  124607. */
  124608. var ParticleSystemSet = /** @class */ (function () {
  124609. function ParticleSystemSet() {
  124610. /**
  124611. * Gets the particle system list
  124612. */
  124613. this.systems = new Array();
  124614. }
  124615. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  124616. /**
  124617. * Gets the emitter node used with this set
  124618. */
  124619. get: function () {
  124620. return this._emitterNode;
  124621. },
  124622. enumerable: true,
  124623. configurable: true
  124624. });
  124625. /**
  124626. * Creates a new emitter mesh as a sphere
  124627. * @param options defines the options used to create the sphere
  124628. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124629. * @param scene defines the hosting scene
  124630. */
  124631. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  124632. if (this._emitterNode) {
  124633. this._emitterNode.dispose();
  124634. }
  124635. this._emitterCreationOptions = {
  124636. kind: "Sphere",
  124637. options: options,
  124638. renderingGroupId: renderingGroupId
  124639. };
  124640. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  124641. emitterMesh.renderingGroupId = renderingGroupId;
  124642. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  124643. material.emissiveColor = options.color;
  124644. emitterMesh.material = material;
  124645. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  124646. var system = _a[_i];
  124647. system.emitter = emitterMesh;
  124648. }
  124649. this._emitterNode = emitterMesh;
  124650. };
  124651. /**
  124652. * Starts all particle systems of the set
  124653. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124654. */
  124655. ParticleSystemSet.prototype.start = function (emitter) {
  124656. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  124657. var system = _a[_i];
  124658. if (emitter) {
  124659. system.emitter = emitter;
  124660. }
  124661. system.start();
  124662. }
  124663. };
  124664. /**
  124665. * Release all associated resources
  124666. */
  124667. ParticleSystemSet.prototype.dispose = function () {
  124668. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  124669. var system = _a[_i];
  124670. system.dispose();
  124671. }
  124672. this.systems = [];
  124673. if (this._emitterNode) {
  124674. this._emitterNode.dispose();
  124675. this._emitterNode = null;
  124676. }
  124677. };
  124678. /**
  124679. * Serialize the set into a JSON compatible object
  124680. * @returns a JSON compatible representation of the set
  124681. */
  124682. ParticleSystemSet.prototype.serialize = function () {
  124683. var result = {};
  124684. result.systems = [];
  124685. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  124686. var system = _a[_i];
  124687. result.systems.push(system.serialize());
  124688. }
  124689. if (this._emitterNode) {
  124690. result.emitter = this._emitterCreationOptions;
  124691. }
  124692. return result;
  124693. };
  124694. /**
  124695. * Parse a new ParticleSystemSet from a serialized source
  124696. * @param data defines a JSON compatible representation of the set
  124697. * @param scene defines the hosting scene
  124698. * @param gpu defines if we want GPU particles or CPU particles
  124699. * @returns a new ParticleSystemSet
  124700. */
  124701. ParticleSystemSet.Parse = function (data, scene, gpu) {
  124702. if (gpu === void 0) { gpu = false; }
  124703. var result = new ParticleSystemSet();
  124704. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  124705. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  124706. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  124707. var system = _a[_i];
  124708. 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));
  124709. }
  124710. if (data.emitter) {
  124711. var options = data.emitter.options;
  124712. switch (data.emitter.kind) {
  124713. case "Sphere":
  124714. result.setEmitterAsSphere({
  124715. diameter: options.diameter,
  124716. segments: options.segments,
  124717. color: _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  124718. }, data.emitter.renderingGroupId, scene);
  124719. break;
  124720. }
  124721. }
  124722. return result;
  124723. };
  124724. return ParticleSystemSet;
  124725. }());
  124726. /***/ }),
  124727. /***/ "./Particles/solidParticle.ts":
  124728. /*!************************************!*\
  124729. !*** ./Particles/solidParticle.ts ***!
  124730. \************************************/
  124731. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  124732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124733. "use strict";
  124734. __webpack_require__.r(__webpack_exports__);
  124735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  124736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  124737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  124738. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  124739. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  124740. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  124741. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  124742. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  124743. /**
  124744. * Represents one particle of a solid particle system.
  124745. */
  124746. var SolidParticle = /** @class */ (function () {
  124747. /**
  124748. * Creates a Solid Particle object.
  124749. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  124750. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  124751. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  124752. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  124753. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  124754. * @param shapeId (integer) is the model shape identifier in the SPS.
  124755. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  124756. * @param sps defines the sps it is associated to
  124757. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  124758. */
  124759. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  124760. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  124761. /**
  124762. * particle global index
  124763. */
  124764. this.idx = 0;
  124765. /**
  124766. * The color of the particle
  124767. */
  124768. this.color = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  124769. /**
  124770. * The world space position of the particle.
  124771. */
  124772. this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124773. /**
  124774. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  124775. */
  124776. this.rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124777. /**
  124778. * The scaling of the particle.
  124779. */
  124780. this.scaling = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  124781. /**
  124782. * The uvs of the particle.
  124783. */
  124784. this.uvs = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  124785. /**
  124786. * The current speed of the particle.
  124787. */
  124788. this.velocity = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124789. /**
  124790. * The pivot point in the particle local space.
  124791. */
  124792. this.pivot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124793. /**
  124794. * Must the particle be translated from its pivot point in its local space ?
  124795. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  124796. * Default : false
  124797. */
  124798. this.translateFromPivot = false;
  124799. /**
  124800. * Is the particle active or not ?
  124801. */
  124802. this.alive = true;
  124803. /**
  124804. * Is the particle visible or not ?
  124805. */
  124806. this.isVisible = true;
  124807. /**
  124808. * Index of this particle in the global "positions" array (Internal use)
  124809. * @hidden
  124810. */
  124811. this._pos = 0;
  124812. /**
  124813. * @hidden Index of this particle in the global "indices" array (Internal use)
  124814. */
  124815. this._ind = 0;
  124816. /**
  124817. * ModelShape id of this particle
  124818. */
  124819. this.shapeId = 0;
  124820. /**
  124821. * Index of the particle in its shape id (Internal use)
  124822. */
  124823. this.idxInShape = 0;
  124824. /**
  124825. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  124826. */
  124827. this._stillInvisible = false;
  124828. /**
  124829. * @hidden Last computed particle rotation matrix
  124830. */
  124831. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  124832. /**
  124833. * Parent particle Id, if any.
  124834. * Default null.
  124835. */
  124836. this.parentId = null;
  124837. /**
  124838. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  124839. * The possible values are :
  124840. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  124841. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  124842. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  124843. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  124844. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  124845. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  124846. * */
  124847. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  124848. /**
  124849. * @hidden Internal global position in the SPS.
  124850. */
  124851. this._globalPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124852. this.idx = particleIndex;
  124853. this._pos = positionIndex;
  124854. this._ind = indiceIndex;
  124855. this._model = model;
  124856. this.shapeId = shapeId;
  124857. this.idxInShape = idxInShape;
  124858. this._sps = sps;
  124859. if (modelBoundingInfo) {
  124860. this._modelBoundingInfo = modelBoundingInfo;
  124861. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_2__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  124862. }
  124863. }
  124864. Object.defineProperty(SolidParticle.prototype, "scale", {
  124865. /**
  124866. * Legacy support, changed scale to scaling
  124867. */
  124868. get: function () {
  124869. return this.scaling;
  124870. },
  124871. /**
  124872. * Legacy support, changed scale to scaling
  124873. */
  124874. set: function (scale) {
  124875. this.scaling = scale;
  124876. },
  124877. enumerable: true,
  124878. configurable: true
  124879. });
  124880. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  124881. /**
  124882. * Legacy support, changed quaternion to rotationQuaternion
  124883. */
  124884. get: function () {
  124885. return this.rotationQuaternion;
  124886. },
  124887. /**
  124888. * Legacy support, changed quaternion to rotationQuaternion
  124889. */
  124890. set: function (q) {
  124891. this.rotationQuaternion = q;
  124892. },
  124893. enumerable: true,
  124894. configurable: true
  124895. });
  124896. /**
  124897. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  124898. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  124899. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  124900. * @returns true if it intersects
  124901. */
  124902. SolidParticle.prototype.intersectsMesh = function (target) {
  124903. if (!this._boundingInfo || !target._boundingInfo) {
  124904. return false;
  124905. }
  124906. if (this._sps._bSphereOnly) {
  124907. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_3__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  124908. }
  124909. return this._boundingInfo.intersects(target._boundingInfo, false);
  124910. };
  124911. /**
  124912. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  124913. * A particle is in the frustum if its bounding box intersects the frustum
  124914. * @param frustumPlanes defines the frustum to test
  124915. * @returns true if the particle is in the frustum planes
  124916. */
  124917. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  124918. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  124919. };
  124920. /**
  124921. * get the rotation matrix of the particle
  124922. * @hidden
  124923. */
  124924. SolidParticle.prototype.getRotationMatrix = function (m) {
  124925. var quaternion;
  124926. if (this.rotationQuaternion) {
  124927. quaternion = this.rotationQuaternion;
  124928. }
  124929. else {
  124930. quaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Quaternion[0];
  124931. var rotation = this.rotation;
  124932. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  124933. }
  124934. quaternion.toRotationMatrix(m);
  124935. };
  124936. return SolidParticle;
  124937. }());
  124938. /**
  124939. * Represents the shape of the model used by one particle of a solid particle system.
  124940. * SPS internal tool, don't use it manually.
  124941. */
  124942. var ModelShape = /** @class */ (function () {
  124943. /**
  124944. * 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.
  124945. * SPS internal tool, don't use it manually.
  124946. * @hidden
  124947. */
  124948. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  124949. /**
  124950. * length of the shape in the model indices array (internal use)
  124951. * @hidden
  124952. */
  124953. this._indicesLength = 0;
  124954. this.shapeID = id;
  124955. this._shape = shape;
  124956. this._indicesLength = indicesLength;
  124957. this._shapeUV = shapeUV;
  124958. this._positionFunction = posFunction;
  124959. this._vertexFunction = vtxFunction;
  124960. }
  124961. return ModelShape;
  124962. }());
  124963. /**
  124964. * Represents a Depth Sorted Particle in the solid particle system.
  124965. */
  124966. var DepthSortedParticle = /** @class */ (function () {
  124967. function DepthSortedParticle() {
  124968. /**
  124969. * Index of the particle in the "indices" array
  124970. */
  124971. this.ind = 0;
  124972. /**
  124973. * Length of the particle shape in the "indices" array
  124974. */
  124975. this.indicesLength = 0;
  124976. /**
  124977. * Squared distance from the particle to the camera
  124978. */
  124979. this.sqDistance = 0.0;
  124980. }
  124981. return DepthSortedParticle;
  124982. }());
  124983. /***/ }),
  124984. /***/ "./Particles/solidParticleSystem.ts":
  124985. /*!******************************************!*\
  124986. !*** ./Particles/solidParticleSystem.ts ***!
  124987. \******************************************/
  124988. /*! exports provided: SolidParticleSystem */
  124989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124990. "use strict";
  124991. __webpack_require__.r(__webpack_exports__);
  124992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  124993. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  124994. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  124995. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124996. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  124997. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  124998. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  124999. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  125000. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  125001. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  125002. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  125003. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  125004. /**
  125005. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  125006. *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.
  125007. * The SPS is also a particle system. It provides some methods to manage the particles.
  125008. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125009. *
  125010. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  125011. */
  125012. var SolidParticleSystem = /** @class */ (function () {
  125013. /**
  125014. * Creates a SPS (Solid Particle System) object.
  125015. * @param name (String) is the SPS name, this will be the underlying mesh name.
  125016. * @param scene (Scene) is the scene in which the SPS is added.
  125017. * @param options defines the options of the sps e.g.
  125018. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  125019. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  125020. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  125021. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  125022. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  125023. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  125024. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  125025. */
  125026. function SolidParticleSystem(name, scene, options) {
  125027. /**
  125028. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  125029. * Example : var p = SPS.particles[i];
  125030. */
  125031. this.particles = new Array();
  125032. /**
  125033. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  125034. */
  125035. this.nbParticles = 0;
  125036. /**
  125037. * If the particles must ever face the camera (default false). Useful for planar particles.
  125038. */
  125039. this.billboard = false;
  125040. /**
  125041. * Recompute normals when adding a shape
  125042. */
  125043. this.recomputeNormals = true;
  125044. /**
  125045. * This a counter ofr your own usage. It's not set by any SPS functions.
  125046. */
  125047. this.counter = 0;
  125048. /**
  125049. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  125050. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  125051. */
  125052. this.vars = {};
  125053. /**
  125054. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  125055. * @hidden
  125056. */
  125057. this._bSphereOnly = false;
  125058. /**
  125059. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  125060. * @hidden
  125061. */
  125062. this._bSphereRadiusFactor = 1.0;
  125063. this._positions = new Array();
  125064. this._indices = new Array();
  125065. this._normals = new Array();
  125066. this._colors = new Array();
  125067. this._uvs = new Array();
  125068. this._index = 0; // indices index
  125069. this._updatable = true;
  125070. this._pickable = false;
  125071. this._isVisibilityBoxLocked = false;
  125072. this._alwaysVisible = false;
  125073. this._depthSort = false;
  125074. this._shapeCounter = 0;
  125075. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  125076. this._color = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  125077. this._computeParticleColor = true;
  125078. this._computeParticleTexture = true;
  125079. this._computeParticleRotation = true;
  125080. this._computeParticleVertex = false;
  125081. this._computeBoundingBox = false;
  125082. this._depthSortParticles = true;
  125083. this._mustUnrotateFixedNormals = false;
  125084. this._particlesIntersect = false;
  125085. this._needs32Bits = false;
  125086. this.name = name;
  125087. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  125088. this._camera = scene.activeCamera;
  125089. this._pickable = options ? options.isPickable : false;
  125090. this._depthSort = options ? options.enableDepthSort : false;
  125091. this._particlesIntersect = options ? options.particleIntersection : false;
  125092. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  125093. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  125094. if (options && options.updatable !== undefined) {
  125095. this._updatable = options.updatable;
  125096. }
  125097. else {
  125098. this._updatable = true;
  125099. }
  125100. if (this._pickable) {
  125101. this.pickedParticles = [];
  125102. }
  125103. if (this._depthSort) {
  125104. this.depthSortedParticles = [];
  125105. }
  125106. }
  125107. /**
  125108. * Builds the SPS underlying mesh. Returns a standard Mesh.
  125109. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  125110. * @returns the created mesh
  125111. */
  125112. SolidParticleSystem.prototype.buildMesh = function () {
  125113. if (this.nbParticles === 0) {
  125114. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_5__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  125115. this.addShape(triangle, 1);
  125116. triangle.dispose();
  125117. }
  125118. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  125119. this._positions32 = new Float32Array(this._positions);
  125120. this._uvs32 = new Float32Array(this._uvs);
  125121. this._colors32 = new Float32Array(this._colors);
  125122. if (this.recomputeNormals) {
  125123. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  125124. }
  125125. this._normals32 = new Float32Array(this._normals);
  125126. this._fixedNormal32 = new Float32Array(this._normals);
  125127. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  125128. this._unrotateFixedNormals();
  125129. }
  125130. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  125131. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  125132. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  125133. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  125134. if (this._uvs32.length > 0) {
  125135. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  125136. }
  125137. if (this._colors32.length > 0) {
  125138. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  125139. }
  125140. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.name, this._scene);
  125141. vertexData.applyToMesh(mesh, this._updatable);
  125142. this.mesh = mesh;
  125143. this.mesh.isPickable = this._pickable;
  125144. // free memory
  125145. if (!this._depthSort) {
  125146. this._indices = null;
  125147. }
  125148. this._positions = null;
  125149. this._normals = null;
  125150. this._uvs = null;
  125151. this._colors = null;
  125152. if (!this._updatable) {
  125153. this.particles.length = 0;
  125154. }
  125155. return mesh;
  125156. };
  125157. /**
  125158. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  125159. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  125160. * Thus the particles generated from `digest()` have their property `position` set yet.
  125161. * @param mesh ( Mesh ) is the mesh to be digested
  125162. * @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
  125163. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  125164. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  125165. * @returns the current SPS
  125166. */
  125167. SolidParticleSystem.prototype.digest = function (mesh, options) {
  125168. var size = (options && options.facetNb) || 1;
  125169. var number = (options && options.number) || 0;
  125170. var delta = (options && options.delta) || 0;
  125171. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  125172. var meshInd = mesh.getIndices();
  125173. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  125174. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  125175. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  125176. var f = 0; // facet counter
  125177. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  125178. // compute size from number
  125179. if (number) {
  125180. number = (number > totalFacets) ? totalFacets : number;
  125181. size = Math.round(totalFacets / number);
  125182. delta = 0;
  125183. }
  125184. else {
  125185. size = (size > totalFacets) ? totalFacets : size;
  125186. }
  125187. var facetPos = []; // submesh positions
  125188. var facetInd = []; // submesh indices
  125189. var facetUV = []; // submesh UV
  125190. var facetCol = []; // submesh colors
  125191. var barycenter = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  125192. var sizeO = size;
  125193. while (f < totalFacets) {
  125194. size = sizeO + Math.floor((1 + delta) * Math.random());
  125195. if (f > totalFacets - size) {
  125196. size = totalFacets - f;
  125197. }
  125198. // reset temp arrays
  125199. facetPos.length = 0;
  125200. facetInd.length = 0;
  125201. facetUV.length = 0;
  125202. facetCol.length = 0;
  125203. // iterate over "size" facets
  125204. var fi = 0;
  125205. for (var j = f * 3; j < (f + size) * 3; j++) {
  125206. facetInd.push(fi);
  125207. var i = meshInd[j];
  125208. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  125209. if (meshUV) {
  125210. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  125211. }
  125212. if (meshCol) {
  125213. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  125214. }
  125215. fi++;
  125216. }
  125217. // create a model shape for each single particle
  125218. var idx = this.nbParticles;
  125219. var shape = this._posToShape(facetPos);
  125220. var shapeUV = this._uvsToShapeUV(facetUV);
  125221. // compute the barycenter of the shape
  125222. var v;
  125223. for (v = 0; v < shape.length; v++) {
  125224. barycenter.addInPlace(shape[v]);
  125225. }
  125226. barycenter.scaleInPlace(1 / shape.length);
  125227. // shift the shape from its barycenter to the origin
  125228. for (v = 0; v < shape.length; v++) {
  125229. shape[v].subtractInPlace(barycenter);
  125230. }
  125231. var bInfo;
  125232. if (this._particlesIntersect) {
  125233. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_8__["BoundingInfo"](barycenter, barycenter);
  125234. }
  125235. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  125236. // add the particle in the SPS
  125237. var currentPos = this._positions.length;
  125238. var currentInd = this._indices.length;
  125239. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  125240. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  125241. // initialize the particle position
  125242. this.particles[this.nbParticles].position.addInPlace(barycenter);
  125243. this._index += shape.length;
  125244. idx++;
  125245. this.nbParticles++;
  125246. this._shapeCounter++;
  125247. f += size;
  125248. }
  125249. return this;
  125250. };
  125251. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  125252. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  125253. var index = 0;
  125254. var idx = 0;
  125255. var tmpNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0];
  125256. var quaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Quaternion[0];
  125257. var invertedRotMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  125258. for (var p = 0; p < this.particles.length; p++) {
  125259. var particle = this.particles[p];
  125260. var shape = particle._model._shape;
  125261. // computing the inverse of the rotation matrix from the quaternion
  125262. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  125263. if (particle.rotationQuaternion) {
  125264. particle.rotationQuaternion.conjugateToRef(quaternion);
  125265. }
  125266. else {
  125267. var rotation = particle.rotation;
  125268. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  125269. quaternion.conjugateInPlace();
  125270. }
  125271. quaternion.toRotationMatrix(invertedRotMatrix);
  125272. for (var pt = 0; pt < shape.length; pt++) {
  125273. idx = index + pt * 3;
  125274. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  125275. tmpNormal.toArray(this._fixedNormal32, idx);
  125276. }
  125277. index = idx + 3;
  125278. }
  125279. };
  125280. //reset copy
  125281. SolidParticleSystem.prototype._resetCopy = function () {
  125282. var copy = this._copy;
  125283. copy.position.setAll(0);
  125284. copy.rotation.setAll(0);
  125285. copy.rotationQuaternion = null;
  125286. copy.scaling.setAll(1);
  125287. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  125288. copy.color = null;
  125289. copy.translateFromPivot = false;
  125290. };
  125291. // _meshBuilder : inserts the shape model in the global SPS mesh
  125292. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  125293. var i;
  125294. var u = 0;
  125295. var c = 0;
  125296. var n = 0;
  125297. this._resetCopy();
  125298. var copy = this._copy;
  125299. if (options && options.positionFunction) { // call to custom positionFunction
  125300. options.positionFunction(copy, idx, idxInShape);
  125301. this._mustUnrotateFixedNormals = true;
  125302. }
  125303. var rotMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  125304. var tmpVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0];
  125305. var tmpRotated = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[1];
  125306. var pivotBackTranslation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[2];
  125307. var scaledPivot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[3];
  125308. copy.getRotationMatrix(rotMatrix);
  125309. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  125310. if (copy.translateFromPivot) {
  125311. pivotBackTranslation.setAll(0.0);
  125312. }
  125313. else {
  125314. pivotBackTranslation.copyFrom(scaledPivot);
  125315. }
  125316. for (i = 0; i < shape.length; i++) {
  125317. tmpVertex.copyFrom(shape[i]);
  125318. if (options && options.vertexFunction) {
  125319. options.vertexFunction(copy, tmpVertex, i);
  125320. }
  125321. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  125322. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  125323. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  125324. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  125325. if (meshUV) {
  125326. var copyUvs = copy.uvs;
  125327. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  125328. u += 2;
  125329. }
  125330. if (copy.color) {
  125331. this._color = copy.color;
  125332. }
  125333. else {
  125334. var color = this._color;
  125335. if (meshCol && meshCol[c] !== undefined) {
  125336. color.r = meshCol[c];
  125337. color.g = meshCol[c + 1];
  125338. color.b = meshCol[c + 2];
  125339. color.a = meshCol[c + 3];
  125340. }
  125341. else {
  125342. color.r = 1.0;
  125343. color.g = 1.0;
  125344. color.b = 1.0;
  125345. color.a = 1.0;
  125346. }
  125347. }
  125348. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  125349. c += 4;
  125350. if (!this.recomputeNormals && meshNor) {
  125351. tmpVertex.x = meshNor[n];
  125352. tmpVertex.y = meshNor[n + 1];
  125353. tmpVertex.z = meshNor[n + 2];
  125354. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  125355. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  125356. n += 3;
  125357. }
  125358. }
  125359. for (i = 0; i < meshInd.length; i++) {
  125360. var current_ind = p + meshInd[i];
  125361. indices.push(current_ind);
  125362. if (current_ind > 65535) {
  125363. this._needs32Bits = true;
  125364. }
  125365. }
  125366. if (this._pickable) {
  125367. var nbfaces = meshInd.length / 3;
  125368. for (i = 0; i < nbfaces; i++) {
  125369. this.pickedParticles.push({ idx: idx, faceId: i });
  125370. }
  125371. }
  125372. if (this._depthSort) {
  125373. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["DepthSortedParticle"]());
  125374. }
  125375. return copy;
  125376. };
  125377. // returns a shape array from positions array
  125378. SolidParticleSystem.prototype._posToShape = function (positions) {
  125379. var shape = [];
  125380. for (var i = 0; i < positions.length; i += 3) {
  125381. shape.push(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  125382. }
  125383. return shape;
  125384. };
  125385. // returns a shapeUV array from a Vector4 uvs
  125386. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  125387. var shapeUV = [];
  125388. if (uvs) {
  125389. for (var i = 0; i < uvs.length; i++) {
  125390. shapeUV.push(uvs[i]);
  125391. }
  125392. }
  125393. return shapeUV;
  125394. };
  125395. // adds a new particle object in the particles array
  125396. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  125397. if (bInfo === void 0) { bInfo = null; }
  125398. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  125399. this.particles.push(sp);
  125400. return sp;
  125401. };
  125402. /**
  125403. * Adds some particles to the SPS from the model shape. Returns the shape id.
  125404. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  125405. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  125406. * @param nb (positive integer) the number of particles to be created from this model
  125407. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  125408. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  125409. * @returns the number of shapes in the system
  125410. */
  125411. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  125412. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  125413. var meshInd = mesh.getIndices();
  125414. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  125415. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  125416. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  125417. var bbInfo;
  125418. if (this._particlesIntersect) {
  125419. bbInfo = mesh.getBoundingInfo();
  125420. }
  125421. var shape = this._posToShape(meshPos);
  125422. var shapeUV = this._uvsToShapeUV(meshUV);
  125423. var posfunc = options ? options.positionFunction : null;
  125424. var vtxfunc = options ? options.vertexFunction : null;
  125425. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_7__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  125426. // particles
  125427. var sp;
  125428. var currentCopy;
  125429. var idx = this.nbParticles;
  125430. for (var i = 0; i < nb; i++) {
  125431. var currentPos = this._positions.length;
  125432. var currentInd = this._indices.length;
  125433. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  125434. if (this._updatable) {
  125435. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  125436. sp.position.copyFrom(currentCopy.position);
  125437. sp.rotation.copyFrom(currentCopy.rotation);
  125438. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  125439. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  125440. }
  125441. if (currentCopy.color && sp.color) {
  125442. sp.color.copyFrom(currentCopy.color);
  125443. }
  125444. sp.scaling.copyFrom(currentCopy.scaling);
  125445. sp.uvs.copyFrom(currentCopy.uvs);
  125446. }
  125447. this._index += shape.length;
  125448. idx++;
  125449. }
  125450. this.nbParticles += nb;
  125451. this._shapeCounter++;
  125452. return this._shapeCounter - 1;
  125453. };
  125454. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  125455. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  125456. this._resetCopy();
  125457. var copy = this._copy;
  125458. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  125459. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  125460. }
  125461. var rotMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  125462. var tmpVertex = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[0];
  125463. var tmpRotated = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[1];
  125464. var pivotBackTranslation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[2];
  125465. var scaledPivot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3[3];
  125466. copy.getRotationMatrix(rotMatrix);
  125467. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  125468. if (copy.translateFromPivot) {
  125469. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  125470. }
  125471. else {
  125472. pivotBackTranslation.copyFrom(scaledPivot);
  125473. }
  125474. var shape = particle._model._shape;
  125475. for (var pt = 0; pt < shape.length; pt++) {
  125476. tmpVertex.copyFrom(shape[pt]);
  125477. if (particle._model._vertexFunction) {
  125478. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  125479. }
  125480. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  125481. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  125482. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  125483. }
  125484. particle.position.setAll(0.0);
  125485. particle.rotation.setAll(0.0);
  125486. particle.rotationQuaternion = null;
  125487. particle.scaling.setAll(1.0);
  125488. particle.uvs.setAll(0.0);
  125489. particle.pivot.setAll(0.0);
  125490. particle.translateFromPivot = false;
  125491. particle.parentId = null;
  125492. };
  125493. /**
  125494. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  125495. * @returns the SPS.
  125496. */
  125497. SolidParticleSystem.prototype.rebuildMesh = function () {
  125498. for (var p = 0; p < this.particles.length; p++) {
  125499. this._rebuildParticle(this.particles[p]);
  125500. }
  125501. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, this._positions32, false, false);
  125502. return this;
  125503. };
  125504. /**
  125505. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  125506. * This method calls `updateParticle()` for each particle of the SPS.
  125507. * For an animated SPS, it is usually called within the render loop.
  125508. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  125509. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  125510. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  125511. * @returns the SPS.
  125512. */
  125513. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  125514. if (start === void 0) { start = 0; }
  125515. if (end === void 0) { end = this.nbParticles - 1; }
  125516. if (update === void 0) { update = true; }
  125517. if (!this._updatable) {
  125518. return this;
  125519. }
  125520. // custom beforeUpdate
  125521. this.beforeUpdateParticles(start, end, update);
  125522. var rotMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[0];
  125523. var invertedMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Matrix[1];
  125524. var mesh = this.mesh;
  125525. var colors32 = this._colors32;
  125526. var positions32 = this._positions32;
  125527. var normals32 = this._normals32;
  125528. var uvs32 = this._uvs32;
  125529. var indices32 = this._indices32;
  125530. var indices = this._indices;
  125531. var fixedNormal32 = this._fixedNormal32;
  125532. var tempVectors = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["TmpVectors"].Vector3;
  125533. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  125534. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  125535. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  125536. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  125537. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  125538. var camInvertedPosition = tempVectors[10].setAll(0);
  125539. // cases when the World Matrix is to be computed first
  125540. if (this.billboard || this._depthSort) {
  125541. this.mesh.computeWorldMatrix(true);
  125542. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  125543. }
  125544. // if the particles will always face the camera
  125545. if (this.billboard) {
  125546. // compute the camera position and un-rotate it by the current mesh rotation
  125547. var tmpVertex = tempVectors[0];
  125548. this._camera.getDirectionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_9__["Axis"].Z, tmpVertex);
  125549. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  125550. camAxisZ.normalize();
  125551. // same for camera up vector extracted from the cam view matrix
  125552. var view = this._camera.getViewMatrix(true);
  125553. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  125554. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  125555. camAxisY.normalize();
  125556. camAxisX.normalize();
  125557. }
  125558. // if depthSort, compute the camera global position in the mesh local system
  125559. if (this._depthSort) {
  125560. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  125561. }
  125562. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  125563. var idx = 0; // current position index in the global array positions32
  125564. var index = 0; // position start index in the global array positions32 of the current particle
  125565. var colidx = 0; // current color index in the global array colors32
  125566. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  125567. var uvidx = 0; // current uv index in the global array uvs32
  125568. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  125569. var pt = 0; // current index in the particle model shape
  125570. if (this.mesh.isFacetDataEnabled) {
  125571. this._computeBoundingBox = true;
  125572. }
  125573. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  125574. if (this._computeBoundingBox) {
  125575. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  125576. var boundingInfo = this.mesh._boundingInfo;
  125577. if (boundingInfo) {
  125578. minimum.copyFrom(boundingInfo.minimum);
  125579. maximum.copyFrom(boundingInfo.maximum);
  125580. }
  125581. }
  125582. }
  125583. // particle loop
  125584. index = this.particles[start]._pos;
  125585. var vpos = (index / 3) | 0;
  125586. colorIndex = vpos * 4;
  125587. uvIndex = vpos * 2;
  125588. for (var p = start; p <= end; p++) {
  125589. var particle = this.particles[p];
  125590. // call to custom user function to update the particle properties
  125591. this.updateParticle(particle);
  125592. var shape = particle._model._shape;
  125593. var shapeUV = particle._model._shapeUV;
  125594. var particleRotationMatrix = particle._rotationMatrix;
  125595. var particlePosition = particle.position;
  125596. var particleRotation = particle.rotation;
  125597. var particleScaling = particle.scaling;
  125598. var particleGlobalPosition = particle._globalPosition;
  125599. // camera-particle distance for depth sorting
  125600. if (this._depthSort && this._depthSortParticles) {
  125601. var dsp = this.depthSortedParticles[p];
  125602. dsp.ind = particle._ind;
  125603. dsp.indicesLength = particle._model._indicesLength;
  125604. dsp.sqDistance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  125605. }
  125606. // skip the computations for inactive or already invisible particles
  125607. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  125608. // increment indexes for the next particle
  125609. pt = shape.length;
  125610. index += pt * 3;
  125611. colorIndex += pt * 4;
  125612. uvIndex += pt * 2;
  125613. continue;
  125614. }
  125615. if (particle.isVisible) {
  125616. particle._stillInvisible = false; // un-mark permanent invisibility
  125617. var scaledPivot = tempVectors[12];
  125618. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  125619. // particle rotation matrix
  125620. if (this.billboard) {
  125621. particleRotation.x = 0.0;
  125622. particleRotation.y = 0.0;
  125623. }
  125624. if (this._computeParticleRotation || this.billboard) {
  125625. particle.getRotationMatrix(rotMatrix);
  125626. }
  125627. var particleHasParent = (particle.parentId !== null);
  125628. if (particleHasParent) {
  125629. var parent_1 = this.particles[particle.parentId];
  125630. var parentRotationMatrix = parent_1._rotationMatrix;
  125631. var parentGlobalPosition = parent_1._globalPosition;
  125632. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  125633. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  125634. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  125635. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  125636. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  125637. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  125638. if (this._computeParticleRotation || this.billboard) {
  125639. var rotMatrixValues = rotMatrix.m;
  125640. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  125641. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  125642. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  125643. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  125644. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  125645. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  125646. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  125647. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  125648. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  125649. }
  125650. }
  125651. else {
  125652. particleGlobalPosition.x = particlePosition.x;
  125653. particleGlobalPosition.y = particlePosition.y;
  125654. particleGlobalPosition.z = particlePosition.z;
  125655. if (this._computeParticleRotation || this.billboard) {
  125656. var rotMatrixValues = rotMatrix.m;
  125657. particleRotationMatrix[0] = rotMatrixValues[0];
  125658. particleRotationMatrix[1] = rotMatrixValues[1];
  125659. particleRotationMatrix[2] = rotMatrixValues[2];
  125660. particleRotationMatrix[3] = rotMatrixValues[4];
  125661. particleRotationMatrix[4] = rotMatrixValues[5];
  125662. particleRotationMatrix[5] = rotMatrixValues[6];
  125663. particleRotationMatrix[6] = rotMatrixValues[8];
  125664. particleRotationMatrix[7] = rotMatrixValues[9];
  125665. particleRotationMatrix[8] = rotMatrixValues[10];
  125666. }
  125667. }
  125668. var pivotBackTranslation = tempVectors[11];
  125669. if (particle.translateFromPivot) {
  125670. pivotBackTranslation.setAll(0.0);
  125671. }
  125672. else {
  125673. pivotBackTranslation.copyFrom(scaledPivot);
  125674. }
  125675. // particle vertex loop
  125676. for (pt = 0; pt < shape.length; pt++) {
  125677. idx = index + pt * 3;
  125678. colidx = colorIndex + pt * 4;
  125679. uvidx = uvIndex + pt * 2;
  125680. var tmpVertex = tempVectors[0];
  125681. tmpVertex.copyFrom(shape[pt]);
  125682. if (this._computeParticleVertex) {
  125683. this.updateParticleVertex(particle, tmpVertex, pt);
  125684. }
  125685. // positions
  125686. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  125687. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  125688. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  125689. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  125690. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  125691. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  125692. rotatedX += pivotBackTranslation.x;
  125693. rotatedY += pivotBackTranslation.y;
  125694. rotatedZ += pivotBackTranslation.z;
  125695. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  125696. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  125697. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  125698. if (this._computeBoundingBox) {
  125699. minimum.minimizeInPlaceFromFloats(px, py, pz);
  125700. maximum.maximizeInPlaceFromFloats(px, py, pz);
  125701. }
  125702. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  125703. if (!this._computeParticleVertex) {
  125704. var normalx = fixedNormal32[idx];
  125705. var normaly = fixedNormal32[idx + 1];
  125706. var normalz = fixedNormal32[idx + 2];
  125707. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  125708. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  125709. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  125710. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  125711. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  125712. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  125713. }
  125714. if (this._computeParticleColor && particle.color) {
  125715. var color = particle.color;
  125716. var colors32_1 = this._colors32;
  125717. colors32_1[colidx] = color.r;
  125718. colors32_1[colidx + 1] = color.g;
  125719. colors32_1[colidx + 2] = color.b;
  125720. colors32_1[colidx + 3] = color.a;
  125721. }
  125722. if (this._computeParticleTexture) {
  125723. var uvs = particle.uvs;
  125724. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  125725. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  125726. }
  125727. }
  125728. }
  125729. // particle just set invisible : scaled to zero and positioned at the origin
  125730. else {
  125731. particle._stillInvisible = true; // mark the particle as invisible
  125732. for (pt = 0; pt < shape.length; pt++) {
  125733. idx = index + pt * 3;
  125734. colidx = colorIndex + pt * 4;
  125735. uvidx = uvIndex + pt * 2;
  125736. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  125737. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  125738. if (this._computeParticleColor && particle.color) {
  125739. var color = particle.color;
  125740. colors32[colidx] = color.r;
  125741. colors32[colidx + 1] = color.g;
  125742. colors32[colidx + 2] = color.b;
  125743. colors32[colidx + 3] = color.a;
  125744. }
  125745. if (this._computeParticleTexture) {
  125746. var uvs = particle.uvs;
  125747. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  125748. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  125749. }
  125750. }
  125751. }
  125752. // if the particle intersections must be computed : update the bbInfo
  125753. if (this._particlesIntersect) {
  125754. var bInfo = particle._boundingInfo;
  125755. var bBox = bInfo.boundingBox;
  125756. var bSphere = bInfo.boundingSphere;
  125757. var modelBoundingInfo = particle._modelBoundingInfo;
  125758. if (!this._bSphereOnly) {
  125759. // place, scale and rotate the particle bbox within the SPS local system, then update it
  125760. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  125761. var tempMin = tempVectors[1];
  125762. var tempMax = tempVectors[2];
  125763. tempMin.setAll(Number.MAX_VALUE);
  125764. tempMax.setAll(-Number.MAX_VALUE);
  125765. for (var b = 0; b < 8; b++) {
  125766. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  125767. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  125768. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  125769. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  125770. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  125771. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  125772. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  125773. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  125774. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  125775. tempMin.minimizeInPlaceFromFloats(x, y, z);
  125776. tempMax.maximizeInPlaceFromFloats(x, y, z);
  125777. }
  125778. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  125779. }
  125780. // place and scale the particle bouding sphere in the SPS local system, then update it
  125781. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  125782. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  125783. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  125784. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  125785. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  125786. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  125787. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  125788. }
  125789. // increment indexes for the next particle
  125790. index = idx + 3;
  125791. colorIndex = colidx + 4;
  125792. uvIndex = uvidx + 2;
  125793. }
  125794. // if the VBO must be updated
  125795. if (update) {
  125796. if (this._computeParticleColor) {
  125797. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors32, false, false);
  125798. }
  125799. if (this._computeParticleTexture) {
  125800. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs32, false, false);
  125801. }
  125802. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions32, false, false);
  125803. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  125804. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  125805. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  125806. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  125807. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  125808. for (var i = 0; i < normals32.length; i++) {
  125809. fixedNormal32[i] = normals32[i];
  125810. }
  125811. }
  125812. if (!mesh.areNormalsFrozen) {
  125813. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals32, false, false);
  125814. }
  125815. }
  125816. if (this._depthSort && this._depthSortParticles) {
  125817. var depthSortedParticles = this.depthSortedParticles;
  125818. depthSortedParticles.sort(depthSortFunction);
  125819. var dspl = depthSortedParticles.length;
  125820. var sid = 0;
  125821. for (var sorted = 0; sorted < dspl; sorted++) {
  125822. var lind = depthSortedParticles[sorted].indicesLength;
  125823. var sind = depthSortedParticles[sorted].ind;
  125824. for (var i = 0; i < lind; i++) {
  125825. indices32[sid] = indices[sind + i];
  125826. sid++;
  125827. }
  125828. }
  125829. mesh.updateIndices(indices32);
  125830. }
  125831. }
  125832. if (this._computeBoundingBox) {
  125833. if (mesh._boundingInfo) {
  125834. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  125835. }
  125836. else {
  125837. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_8__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  125838. }
  125839. }
  125840. this.afterUpdateParticles(start, end, update);
  125841. return this;
  125842. };
  125843. /**
  125844. * Disposes the SPS.
  125845. */
  125846. SolidParticleSystem.prototype.dispose = function () {
  125847. this.mesh.dispose();
  125848. this.vars = null;
  125849. // drop references to internal big arrays for the GC
  125850. this._positions = null;
  125851. this._indices = null;
  125852. this._normals = null;
  125853. this._uvs = null;
  125854. this._colors = null;
  125855. this._indices32 = null;
  125856. this._positions32 = null;
  125857. this._normals32 = null;
  125858. this._fixedNormal32 = null;
  125859. this._uvs32 = null;
  125860. this._colors32 = null;
  125861. this.pickedParticles = null;
  125862. };
  125863. /**
  125864. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  125865. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  125866. * @returns the SPS.
  125867. */
  125868. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  125869. if (!this._isVisibilityBoxLocked) {
  125870. this.mesh.refreshBoundingInfo();
  125871. }
  125872. return this;
  125873. };
  125874. /**
  125875. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  125876. * @param size the size (float) of the visibility box
  125877. * note : this doesn't lock the SPS mesh bounding box.
  125878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  125879. */
  125880. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  125881. var vis = size / 2;
  125882. this.mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_8__["BoundingInfo"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-vis, -vis, -vis), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vis, vis, vis));
  125883. };
  125884. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  125885. /**
  125886. * Gets whether the SPS as always visible or not
  125887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  125888. */
  125889. get: function () {
  125890. return this._alwaysVisible;
  125891. },
  125892. /**
  125893. * Sets the SPS as always visible or not
  125894. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  125895. */
  125896. set: function (val) {
  125897. this._alwaysVisible = val;
  125898. this.mesh.alwaysSelectAsActiveMesh = val;
  125899. },
  125900. enumerable: true,
  125901. configurable: true
  125902. });
  125903. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  125904. /**
  125905. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  125906. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  125907. */
  125908. get: function () {
  125909. return this._isVisibilityBoxLocked;
  125910. },
  125911. /**
  125912. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  125913. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  125914. */
  125915. set: function (val) {
  125916. this._isVisibilityBoxLocked = val;
  125917. var boundingInfo = this.mesh.getBoundingInfo();
  125918. boundingInfo.isLocked = val;
  125919. },
  125920. enumerable: true,
  125921. configurable: true
  125922. });
  125923. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  125924. /**
  125925. * Gets if `setParticles()` computes the particle rotations or not.
  125926. * Default value : true. The SPS is faster when it's set to false.
  125927. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  125928. */
  125929. get: function () {
  125930. return this._computeParticleRotation;
  125931. },
  125932. /**
  125933. * Tells to `setParticles()` to compute the particle rotations or not.
  125934. * Default value : true. The SPS is faster when it's set to false.
  125935. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  125936. */
  125937. set: function (val) {
  125938. this._computeParticleRotation = val;
  125939. },
  125940. enumerable: true,
  125941. configurable: true
  125942. });
  125943. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  125944. /**
  125945. * Gets if `setParticles()` computes the particle colors or not.
  125946. * Default value : true. The SPS is faster when it's set to false.
  125947. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125948. */
  125949. get: function () {
  125950. return this._computeParticleColor;
  125951. },
  125952. /**
  125953. * Tells to `setParticles()` to compute the particle colors or not.
  125954. * Default value : true. The SPS is faster when it's set to false.
  125955. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125956. */
  125957. set: function (val) {
  125958. this._computeParticleColor = val;
  125959. },
  125960. enumerable: true,
  125961. configurable: true
  125962. });
  125963. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  125964. /**
  125965. * Gets if `setParticles()` computes the particle textures or not.
  125966. * Default value : true. The SPS is faster when it's set to false.
  125967. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  125968. */
  125969. get: function () {
  125970. return this._computeParticleTexture;
  125971. },
  125972. set: function (val) {
  125973. this._computeParticleTexture = val;
  125974. },
  125975. enumerable: true,
  125976. configurable: true
  125977. });
  125978. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  125979. /**
  125980. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  125981. * Default value : false. The SPS is faster when it's set to false.
  125982. * Note : the particle custom vertex positions aren't stored values.
  125983. */
  125984. get: function () {
  125985. return this._computeParticleVertex;
  125986. },
  125987. /**
  125988. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  125989. * Default value : false. The SPS is faster when it's set to false.
  125990. * Note : the particle custom vertex positions aren't stored values.
  125991. */
  125992. set: function (val) {
  125993. this._computeParticleVertex = val;
  125994. },
  125995. enumerable: true,
  125996. configurable: true
  125997. });
  125998. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  125999. /**
  126000. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126001. */
  126002. get: function () {
  126003. return this._computeBoundingBox;
  126004. },
  126005. /**
  126006. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126007. */
  126008. set: function (val) {
  126009. this._computeBoundingBox = val;
  126010. },
  126011. enumerable: true,
  126012. configurable: true
  126013. });
  126014. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  126015. /**
  126016. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  126017. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  126018. * Default : `true`
  126019. */
  126020. get: function () {
  126021. return this._depthSortParticles;
  126022. },
  126023. /**
  126024. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  126025. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  126026. * Default : `true`
  126027. */
  126028. set: function (val) {
  126029. this._depthSortParticles = val;
  126030. },
  126031. enumerable: true,
  126032. configurable: true
  126033. });
  126034. // =======================================================================
  126035. // Particle behavior logic
  126036. // these following methods may be overwritten by the user to fit his needs
  126037. /**
  126038. * This function does nothing. It may be overwritten to set all the particle first values.
  126039. * The SPS doesn't call this function, you may have to call it by your own.
  126040. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  126041. */
  126042. SolidParticleSystem.prototype.initParticles = function () {
  126043. };
  126044. /**
  126045. * This function does nothing. It may be overwritten to recycle a particle.
  126046. * The SPS doesn't call this function, you may have to call it by your own.
  126047. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  126048. * @param particle The particle to recycle
  126049. * @returns the recycled particle
  126050. */
  126051. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  126052. return particle;
  126053. };
  126054. /**
  126055. * Updates a particle : this function should be overwritten by the user.
  126056. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126057. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  126058. * @example : just set a particle position or velocity and recycle conditions
  126059. * @param particle The particle to update
  126060. * @returns the updated particle
  126061. */
  126062. SolidParticleSystem.prototype.updateParticle = function (particle) {
  126063. return particle;
  126064. };
  126065. /**
  126066. * Updates a vertex of a particle : it can be overwritten by the user.
  126067. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  126068. * @param particle the current particle
  126069. * @param vertex the current index of the current particle
  126070. * @param pt the index of the current vertex in the particle shape
  126071. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  126072. * @example : just set a vertex particle position
  126073. * @returns the updated vertex
  126074. */
  126075. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  126076. return vertex;
  126077. };
  126078. /**
  126079. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126080. * This does nothing and may be overwritten by the user.
  126081. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126082. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126083. * @param update the boolean update value actually passed to setParticles()
  126084. */
  126085. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  126086. };
  126087. /**
  126088. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126089. * This will be passed three parameters.
  126090. * This does nothing and may be overwritten by the user.
  126091. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126092. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126093. * @param update the boolean update value actually passed to setParticles()
  126094. */
  126095. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  126096. };
  126097. return SolidParticleSystem;
  126098. }());
  126099. /***/ }),
  126100. /***/ "./Particles/subEmitter.ts":
  126101. /*!*********************************!*\
  126102. !*** ./Particles/subEmitter.ts ***!
  126103. \*********************************/
  126104. /*! exports provided: SubEmitterType, SubEmitter */
  126105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126106. "use strict";
  126107. __webpack_require__.r(__webpack_exports__);
  126108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  126109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  126110. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  126111. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126112. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  126113. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  126114. /**
  126115. * Type of sub emitter
  126116. */
  126117. var SubEmitterType;
  126118. (function (SubEmitterType) {
  126119. /**
  126120. * Attached to the particle over it's lifetime
  126121. */
  126122. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  126123. /**
  126124. * Created when the particle dies
  126125. */
  126126. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  126127. })(SubEmitterType || (SubEmitterType = {}));
  126128. /**
  126129. * Sub emitter class used to emit particles from an existing particle
  126130. */
  126131. var SubEmitter = /** @class */ (function () {
  126132. /**
  126133. * Creates a sub emitter
  126134. * @param particleSystem the particle system to be used by the sub emitter
  126135. */
  126136. function SubEmitter(
  126137. /**
  126138. * the particle system to be used by the sub emitter
  126139. */
  126140. particleSystem) {
  126141. this.particleSystem = particleSystem;
  126142. /**
  126143. * Type of the submitter (Default: END)
  126144. */
  126145. this.type = SubEmitterType.END;
  126146. /**
  126147. * 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)
  126148. * Note: This only is supported when using an emitter of type Mesh
  126149. */
  126150. this.inheritDirection = false;
  126151. /**
  126152. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  126153. */
  126154. this.inheritedVelocityAmount = 0;
  126155. // Create mesh as emitter to support rotation
  126156. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  126157. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  126158. }
  126159. // Automatically dispose of subemitter when system is disposed
  126160. particleSystem.onDisposeObservable.add(function () {
  126161. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  126162. particleSystem.emitter.dispose();
  126163. }
  126164. });
  126165. }
  126166. /**
  126167. * Clones the sub emitter
  126168. * @returns the cloned sub emitter
  126169. */
  126170. SubEmitter.prototype.clone = function () {
  126171. // Clone particle system
  126172. var emitter = this.particleSystem.emitter;
  126173. if (!emitter) {
  126174. emitter = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  126175. }
  126176. else if (emitter instanceof _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  126177. emitter = emitter.clone();
  126178. }
  126179. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  126180. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  126181. emitter.isVisible = false;
  126182. }
  126183. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  126184. // Clone properties
  126185. clone.particleSystem.name += "Clone";
  126186. clone.type = this.type;
  126187. clone.inheritDirection = this.inheritDirection;
  126188. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  126189. clone.particleSystem._disposeEmitterOnDispose = true;
  126190. clone.particleSystem.disposeOnStop = true;
  126191. return clone;
  126192. };
  126193. /**
  126194. * Serialize current object to a JSON object
  126195. * @returns the serialized object
  126196. */
  126197. SubEmitter.prototype.serialize = function () {
  126198. var serializationObject = {};
  126199. serializationObject.type = this.type;
  126200. serializationObject.inheritDirection = this.inheritDirection;
  126201. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  126202. serializationObject.particleSystem = this.particleSystem.serialize();
  126203. return serializationObject;
  126204. };
  126205. /** @hidden */
  126206. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  126207. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  126208. };
  126209. /**
  126210. * Creates a new SubEmitter from a serialized JSON version
  126211. * @param serializationObject defines the JSON object to read from
  126212. * @param scene defines the hosting scene
  126213. * @param rootUrl defines the rootUrl for data loading
  126214. * @returns a new SubEmitter
  126215. */
  126216. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  126217. var system = serializationObject.particleSystem;
  126218. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  126219. subEmitter.type = serializationObject.type;
  126220. subEmitter.inheritDirection = serializationObject.inheritDirection;
  126221. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  126222. subEmitter.particleSystem._isSubEmitter = true;
  126223. return subEmitter;
  126224. };
  126225. /** Release associated resources */
  126226. SubEmitter.prototype.dispose = function () {
  126227. this.particleSystem.dispose();
  126228. };
  126229. return SubEmitter;
  126230. }());
  126231. /***/ }),
  126232. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  126233. /*!*****************************************!*\
  126234. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  126235. \*****************************************/
  126236. /*! exports provided: AmmoJSPlugin */
  126237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126238. "use strict";
  126239. __webpack_require__.r(__webpack_exports__);
  126240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  126241. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  126242. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  126243. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  126244. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  126245. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  126246. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  126247. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  126248. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  126249. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  126250. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  126251. /**
  126252. * AmmoJS Physics plugin
  126253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  126254. * @see https://github.com/kripken/ammo.js/
  126255. */
  126256. var AmmoJSPlugin = /** @class */ (function () {
  126257. /**
  126258. * Initializes the ammoJS plugin
  126259. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  126260. * @param ammoInjection can be used to inject your own ammo reference
  126261. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  126262. */
  126263. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection, overlappingPairCache) {
  126264. var _this = this;
  126265. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  126266. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  126267. if (overlappingPairCache === void 0) { overlappingPairCache = null; }
  126268. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  126269. /**
  126270. * Reference to the Ammo library
  126271. */
  126272. this.bjsAMMO = {};
  126273. /**
  126274. * Name of the plugin
  126275. */
  126276. this.name = "AmmoJSPlugin";
  126277. this._timeStep = 1 / 60;
  126278. this._fixedTimeStep = 1 / 60;
  126279. this._maxSteps = 5;
  126280. this._tmpQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  126281. this._tmpContactCallbackResult = false;
  126282. this._tmpVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  126283. this._tmpMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  126284. if (typeof ammoInjection === "function") {
  126285. ammoInjection(this.bjsAMMO);
  126286. }
  126287. else {
  126288. this.bjsAMMO = ammoInjection;
  126289. }
  126290. if (!this.isSupported()) {
  126291. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  126292. return;
  126293. }
  126294. // Initialize the physics world
  126295. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  126296. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  126297. this._overlappingPairCache = overlappingPairCache || new this.bjsAMMO.btDbvtBroadphase();
  126298. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  126299. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  126300. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  126301. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  126302. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  126303. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__["PhysicsRaycastResult"]();
  126304. // Create temp ammo variables
  126305. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  126306. this._tmpAmmoTransform.setIdentity();
  126307. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  126308. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  126309. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  126310. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  126311. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  126312. }
  126313. /**
  126314. * Sets the gravity of the physics world (m/(s^2))
  126315. * @param gravity Gravity to set
  126316. */
  126317. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  126318. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  126319. this.world.setGravity(this._tmpAmmoVectorA);
  126320. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  126321. };
  126322. /**
  126323. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  126324. * @param timeStep timestep to use in seconds
  126325. */
  126326. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  126327. this._timeStep = timeStep;
  126328. };
  126329. /**
  126330. * 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)
  126331. * @param fixedTimeStep fixedTimeStep to use in seconds
  126332. */
  126333. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  126334. this._fixedTimeStep = fixedTimeStep;
  126335. };
  126336. /**
  126337. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  126338. * @param maxSteps the maximum number of steps by the physics engine per frame
  126339. */
  126340. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  126341. this._maxSteps = maxSteps;
  126342. };
  126343. /**
  126344. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  126345. * @returns the current timestep in seconds
  126346. */
  126347. AmmoJSPlugin.prototype.getTimeStep = function () {
  126348. return this._timeStep;
  126349. };
  126350. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  126351. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  126352. this._tmpContactCallbackResult = false;
  126353. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  126354. return this._tmpContactCallbackResult;
  126355. };
  126356. // Ammo's collision events have some weird quirks
  126357. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  126358. // so only fire event if both contactTest and contactPairTest have a hit
  126359. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  126360. this._tmpContactCallbackResult = false;
  126361. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  126362. return this._tmpContactCallbackResult;
  126363. };
  126364. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  126365. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  126366. //
  126367. // When maxSteps is 0 do the entire simulation in one step
  126368. // 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)
  126369. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  126370. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  126371. if (timeStep === void 0) { timeStep = 1 / 60; }
  126372. if (maxSteps === void 0) { maxSteps = 10; }
  126373. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  126374. if (maxSteps == 0) {
  126375. this.world.stepSimulation(timeStep, 0);
  126376. }
  126377. else {
  126378. while (maxSteps > 0 && timeStep > 0) {
  126379. if (timeStep - fixedTimeStep < fixedTimeStep) {
  126380. this.world.stepSimulation(timeStep, 0);
  126381. timeStep = 0;
  126382. }
  126383. else {
  126384. timeStep -= fixedTimeStep;
  126385. this.world.stepSimulation(fixedTimeStep, 0);
  126386. }
  126387. maxSteps--;
  126388. }
  126389. }
  126390. };
  126391. /**
  126392. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  126393. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  126394. * After the step the babylon meshes are set to the position of the physics imposters
  126395. * @param delta amount of time to step forward
  126396. * @param impostors array of imposters to update before/after the step
  126397. */
  126398. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  126399. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  126400. var impostor = impostors_1[_i];
  126401. // Update physics world objects to match babylon world
  126402. if (!impostor.soft) {
  126403. impostor.beforeStep();
  126404. }
  126405. }
  126406. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  126407. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  126408. var mainImpostor = impostors_2[_a];
  126409. // After physics update make babylon world objects match physics world objects
  126410. if (mainImpostor.soft) {
  126411. this._afterSoftStep(mainImpostor);
  126412. }
  126413. else {
  126414. mainImpostor.afterStep();
  126415. }
  126416. // Handle collision event
  126417. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  126418. if (this._isImpostorInContact(mainImpostor)) {
  126419. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  126420. var collideCallback = _c[_b];
  126421. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  126422. var otherImpostor = _e[_d];
  126423. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  126424. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  126425. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  126426. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  126427. }
  126428. }
  126429. }
  126430. }
  126431. }
  126432. }
  126433. }
  126434. };
  126435. /**
  126436. * Update babylon mesh to match physics world object
  126437. * @param impostor imposter to match
  126438. */
  126439. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  126440. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  126441. this._ropeStep(impostor);
  126442. }
  126443. else {
  126444. this._softbodyOrClothStep(impostor);
  126445. }
  126446. };
  126447. /**
  126448. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  126449. * @param impostor imposter to match
  126450. */
  126451. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  126452. var bodyVertices = impostor.physicsBody.get_m_nodes();
  126453. var nbVertices = bodyVertices.size();
  126454. var node;
  126455. var nodePositions;
  126456. var x, y, z;
  126457. var path = new Array();
  126458. for (var n = 0; n < nbVertices; n++) {
  126459. node = bodyVertices.at(n);
  126460. nodePositions = node.get_m_x();
  126461. x = nodePositions.x();
  126462. y = nodePositions.y();
  126463. z = nodePositions.z();
  126464. path.push(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  126465. }
  126466. var object = impostor.object;
  126467. var shape = impostor.getParam("shape");
  126468. if (impostor._isFromLine) {
  126469. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  126470. }
  126471. else {
  126472. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  126473. }
  126474. };
  126475. /**
  126476. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  126477. * @param impostor imposter to match
  126478. */
  126479. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  126480. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  126481. var object = impostor.object;
  126482. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  126483. if (!vertexPositions) {
  126484. vertexPositions = [];
  126485. }
  126486. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  126487. if (!vertexNormals) {
  126488. vertexNormals = [];
  126489. }
  126490. var nbVertices = vertexPositions.length / 3;
  126491. var bodyVertices = impostor.physicsBody.get_m_nodes();
  126492. var node;
  126493. var nodePositions;
  126494. var nodeNormals;
  126495. var x, y, z;
  126496. var nx, ny, nz;
  126497. for (var n = 0; n < nbVertices; n++) {
  126498. node = bodyVertices.at(n);
  126499. nodePositions = node.get_m_x();
  126500. x = nodePositions.x();
  126501. y = nodePositions.y();
  126502. z = nodePositions.z() * normalDirection;
  126503. var nodeNormals = node.get_m_n();
  126504. nx = nodeNormals.x();
  126505. ny = nodeNormals.y();
  126506. nz = nodeNormals.z() * normalDirection;
  126507. vertexPositions[3 * n] = x;
  126508. vertexPositions[3 * n + 1] = y;
  126509. vertexPositions[3 * n + 2] = z;
  126510. vertexNormals[3 * n] = nx;
  126511. vertexNormals[3 * n + 1] = ny;
  126512. vertexNormals[3 * n + 2] = nz;
  126513. }
  126514. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  126515. vertex_data.positions = vertexPositions;
  126516. vertex_data.normals = vertexNormals;
  126517. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  126518. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  126519. if (object && object.getIndices) {
  126520. vertex_data.indices = object.getIndices();
  126521. }
  126522. vertex_data.applyToMesh(object);
  126523. };
  126524. /**
  126525. * Applies an impulse on the imposter
  126526. * @param impostor imposter to apply impulse to
  126527. * @param force amount of force to be applied to the imposter
  126528. * @param contactPoint the location to apply the impulse on the imposter
  126529. */
  126530. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  126531. if (!impostor.soft) {
  126532. impostor.physicsBody.activate();
  126533. var worldPoint = this._tmpAmmoVectorA;
  126534. var impulse = this._tmpAmmoVectorB;
  126535. // Convert contactPoint into world space
  126536. if (impostor.object && impostor.object.getWorldMatrix) {
  126537. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  126538. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  126539. contactPoint = this._tmpVector;
  126540. }
  126541. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  126542. impulse.setValue(force.x, force.y, force.z);
  126543. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  126544. }
  126545. else {
  126546. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  126547. }
  126548. };
  126549. /**
  126550. * Applies a force on the imposter
  126551. * @param impostor imposter to apply force
  126552. * @param force amount of force to be applied to the imposter
  126553. * @param contactPoint the location to apply the force on the imposter
  126554. */
  126555. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  126556. if (!impostor.soft) {
  126557. impostor.physicsBody.activate();
  126558. var worldPoint = this._tmpAmmoVectorA;
  126559. var impulse = this._tmpAmmoVectorB;
  126560. // Convert contactPoint into world space
  126561. if (impostor.object && impostor.object.getWorldMatrix) {
  126562. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  126563. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  126564. contactPoint = this._tmpVector;
  126565. }
  126566. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  126567. impulse.setValue(force.x, force.y, force.z);
  126568. impostor.physicsBody.applyForce(impulse, worldPoint);
  126569. }
  126570. else {
  126571. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  126572. }
  126573. };
  126574. /**
  126575. * Creates a physics body using the plugin
  126576. * @param impostor the imposter to create the physics body on
  126577. */
  126578. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  126579. // Note: this method will not be called on child imposotrs for compound impostors
  126580. impostor._pluginData.toDispose = [];
  126581. //parent-child relationship
  126582. if (impostor.parent) {
  126583. if (impostor.physicsBody) {
  126584. this.removePhysicsBody(impostor);
  126585. impostor.forceUpdate();
  126586. }
  126587. return;
  126588. }
  126589. if (impostor.isBodyInitRequired()) {
  126590. var colShape = this._createShape(impostor);
  126591. var mass = impostor.getParam("mass");
  126592. impostor._pluginData.mass = mass;
  126593. if (impostor.soft) {
  126594. colShape.get_m_cfg().set_collisions(0x11);
  126595. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  126596. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  126597. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  126598. this.world.addSoftBody(colShape, 1, -1);
  126599. impostor.physicsBody = colShape;
  126600. impostor._pluginData.toDispose.push(colShape);
  126601. this.setBodyPressure(impostor, 0);
  126602. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  126603. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  126604. }
  126605. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  126606. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  126607. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  126608. }
  126609. else {
  126610. var localInertia = new Ammo.btVector3(0, 0, 0);
  126611. var startTransform = new Ammo.btTransform();
  126612. startTransform.setIdentity();
  126613. if (mass !== 0) {
  126614. colShape.calculateLocalInertia(mass, localInertia);
  126615. }
  126616. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  126617. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  126618. startTransform.setOrigin(this._tmpAmmoVectorA);
  126619. startTransform.setRotation(this._tmpAmmoQuaternion);
  126620. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  126621. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  126622. var body = new Ammo.btRigidBody(rbInfo);
  126623. // Make objects kinematic if it's mass is 0
  126624. if (mass === 0) {
  126625. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  126626. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  126627. }
  126628. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  126629. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  126630. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  126631. }
  126632. this.world.addRigidBody(body);
  126633. impostor.physicsBody = body;
  126634. impostor._pluginData.toDispose = impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  126635. }
  126636. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  126637. this.setBodyFriction(impostor, impostor.getParam("friction"));
  126638. }
  126639. };
  126640. /**
  126641. * Removes the physics body from the imposter and disposes of the body's memory
  126642. * @param impostor imposter to remove the physics body from
  126643. */
  126644. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  126645. var _this = this;
  126646. if (this.world) {
  126647. if (impostor.soft) {
  126648. this.world.removeSoftBody(impostor.physicsBody);
  126649. }
  126650. else {
  126651. this.world.removeRigidBody(impostor.physicsBody);
  126652. }
  126653. if (impostor._pluginData) {
  126654. impostor._pluginData.toDispose.forEach(function (d) {
  126655. _this.bjsAMMO.destroy(d);
  126656. });
  126657. impostor._pluginData.toDispose = [];
  126658. }
  126659. }
  126660. };
  126661. /**
  126662. * Generates a joint
  126663. * @param impostorJoint the imposter joint to create the joint with
  126664. */
  126665. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  126666. var mainBody = impostorJoint.mainImpostor.physicsBody;
  126667. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  126668. if (!mainBody || !connectedBody) {
  126669. return;
  126670. }
  126671. var jointData = impostorJoint.joint.jointData;
  126672. if (!jointData.mainPivot) {
  126673. jointData.mainPivot = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  126674. }
  126675. if (!jointData.connectedPivot) {
  126676. jointData.connectedPivot = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  126677. }
  126678. var joint;
  126679. switch (impostorJoint.joint.type) {
  126680. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  126681. var distance = jointData.maxDistance;
  126682. if (distance) {
  126683. jointData.mainPivot = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  126684. jointData.connectedPivot = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  126685. }
  126686. 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));
  126687. break;
  126688. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  126689. if (!jointData.mainAxis) {
  126690. jointData.mainAxis = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  126691. }
  126692. if (!jointData.connectedAxis) {
  126693. jointData.connectedAxis = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  126694. }
  126695. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  126696. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  126697. 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);
  126698. break;
  126699. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  126700. 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));
  126701. break;
  126702. default:
  126703. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  126704. 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));
  126705. break;
  126706. }
  126707. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  126708. impostorJoint.joint.physicsJoint = joint;
  126709. };
  126710. /**
  126711. * Removes a joint
  126712. * @param impostorJoint the imposter joint to remove the joint from
  126713. */
  126714. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  126715. if (this.world) {
  126716. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  126717. }
  126718. };
  126719. // adds all verticies (including child verticies) to the triangle mesh
  126720. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  126721. var _this = this;
  126722. var triangleCount = 0;
  126723. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  126724. var indices = object.getIndices();
  126725. if (!indices) {
  126726. indices = [];
  126727. }
  126728. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  126729. if (!vertexPositions) {
  126730. vertexPositions = [];
  126731. }
  126732. object.computeWorldMatrix(false);
  126733. var faceCount = indices.length / 3;
  126734. for (var i = 0; i < faceCount; i++) {
  126735. var triPoints = [];
  126736. for (var point = 0; point < 3; point++) {
  126737. var v = new _Maths_math_vector__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]);
  126738. // Adjust for initial scaling
  126739. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  126740. v = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  126741. var vec;
  126742. if (point == 0) {
  126743. vec = this._tmpAmmoVectorA;
  126744. }
  126745. else if (point == 1) {
  126746. vec = this._tmpAmmoVectorB;
  126747. }
  126748. else {
  126749. vec = this._tmpAmmoVectorC;
  126750. }
  126751. vec.setValue(v.x, v.y, v.z);
  126752. triPoints.push(vec);
  126753. }
  126754. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  126755. triangleCount++;
  126756. }
  126757. object.getChildMeshes().forEach(function (m) {
  126758. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  126759. });
  126760. }
  126761. return triangleCount;
  126762. };
  126763. /**
  126764. * Initialise the soft body vertices to match its object's (mesh) vertices
  126765. * Softbody vertices (nodes) are in world space and to match this
  126766. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  126767. * @param impostor to create the softbody for
  126768. */
  126769. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  126770. var object = impostor.object;
  126771. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  126772. var indices = object.getIndices();
  126773. if (!indices) {
  126774. indices = [];
  126775. }
  126776. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  126777. if (!vertexPositions) {
  126778. vertexPositions = [];
  126779. }
  126780. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  126781. if (!vertexNormals) {
  126782. vertexNormals = [];
  126783. }
  126784. object.computeWorldMatrix(false);
  126785. var newPoints = [];
  126786. var newNorms = [];
  126787. for (var i = 0; i < vertexPositions.length; i += 3) {
  126788. var v = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  126789. var n = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  126790. v = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  126791. n = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  126792. newPoints.push(v.x, v.y, v.z);
  126793. newNorms.push(n.x, n.y, n.z);
  126794. }
  126795. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  126796. vertex_data.positions = newPoints;
  126797. vertex_data.normals = newNorms;
  126798. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  126799. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  126800. if (object && object.getIndices) {
  126801. vertex_data.indices = object.getIndices();
  126802. }
  126803. vertex_data.applyToMesh(object);
  126804. object.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  126805. object.rotationQuaternion = null;
  126806. object.rotation = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  126807. object.computeWorldMatrix(true);
  126808. return vertex_data;
  126809. }
  126810. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  126811. };
  126812. /**
  126813. * Create an impostor's soft body
  126814. * @param impostor to create the softbody for
  126815. */
  126816. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  126817. var object = impostor.object;
  126818. if (object && object.getIndices) {
  126819. var indices = object.getIndices();
  126820. if (!indices) {
  126821. indices = [];
  126822. }
  126823. var vertex_data = this._softVertexData(impostor);
  126824. var vertexPositions = vertex_data.positions;
  126825. var vertexNormals = vertex_data.normals;
  126826. if (vertexPositions === null || vertexNormals === null) {
  126827. return new Ammo.btCompoundShape();
  126828. }
  126829. else {
  126830. var triPoints = [];
  126831. var triNorms = [];
  126832. for (var i = 0; i < vertexPositions.length; i += 3) {
  126833. var v = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  126834. var n = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  126835. triPoints.push(v.x, v.y, -v.z);
  126836. triNorms.push(n.x, n.y, -n.z);
  126837. }
  126838. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  126839. var nbVertices = vertexPositions.length / 3;
  126840. var bodyVertices = softBody.get_m_nodes();
  126841. var node;
  126842. var nodeNormals;
  126843. for (var i = 0; i < nbVertices; i++) {
  126844. node = bodyVertices.at(i);
  126845. var nodeNormals = node.get_m_n();
  126846. nodeNormals.setX(triNorms[3 * i]);
  126847. nodeNormals.setY(triNorms[3 * i + 1]);
  126848. nodeNormals.setZ(triNorms[3 * i + 2]);
  126849. }
  126850. return softBody;
  126851. }
  126852. }
  126853. };
  126854. /**
  126855. * Create cloth for an impostor
  126856. * @param impostor to create the softbody for
  126857. */
  126858. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  126859. var object = impostor.object;
  126860. if (object && object.getIndices) {
  126861. var indices = object.getIndices();
  126862. if (!indices) {
  126863. indices = [];
  126864. }
  126865. var vertex_data = this._softVertexData(impostor);
  126866. var vertexPositions = vertex_data.positions;
  126867. var vertexNormals = vertex_data.normals;
  126868. if (vertexPositions === null || vertexNormals === null) {
  126869. return new Ammo.btCompoundShape();
  126870. }
  126871. else {
  126872. var len = vertexPositions.length;
  126873. var segments = Math.sqrt(len / 3);
  126874. impostor.segments = segments;
  126875. var segs = segments - 1;
  126876. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  126877. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  126878. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  126879. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  126880. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  126881. return clothBody;
  126882. }
  126883. }
  126884. };
  126885. /**
  126886. * Create rope for an impostor
  126887. * @param impostor to create the softbody for
  126888. */
  126889. AmmoJSPlugin.prototype._createRope = function (impostor) {
  126890. var len;
  126891. var segments;
  126892. var vertex_data = this._softVertexData(impostor);
  126893. var vertexPositions = vertex_data.positions;
  126894. var vertexNormals = vertex_data.normals;
  126895. if (vertexPositions === null || vertexNormals === null) {
  126896. return new Ammo.btCompoundShape();
  126897. }
  126898. //force the mesh to be updatable
  126899. vertex_data.applyToMesh(impostor.object, true);
  126900. impostor._isFromLine = true;
  126901. // If in lines mesh all normals will be zero
  126902. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  126903. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  126904. var reduced = vertexSquared.reduce(reducer);
  126905. if (reduced === 0) { // line mesh
  126906. len = vertexPositions.length;
  126907. segments = len / 3 - 1;
  126908. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  126909. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  126910. }
  126911. else { //extruded mesh
  126912. impostor._isFromLine = false;
  126913. var pathVectors = impostor.getParam("path");
  126914. var shape = impostor.getParam("shape");
  126915. if (shape === null) {
  126916. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  126917. return new Ammo.btCompoundShape();
  126918. }
  126919. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  126920. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  126921. return new Ammo.btCompoundShape();
  126922. }
  126923. len = pathVectors.length;
  126924. segments = len - 1;
  126925. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  126926. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  126927. }
  126928. impostor.segments = segments;
  126929. var fixedPoints = impostor.getParam("fixedPoints");
  126930. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  126931. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  126932. ropeBody.get_m_cfg().set_collisions(0x11);
  126933. return ropeBody;
  126934. };
  126935. // adds all verticies (including child verticies) to the convex hull shape
  126936. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  126937. var _this = this;
  126938. var triangleCount = 0;
  126939. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  126940. var indices = object.getIndices();
  126941. if (!indices) {
  126942. indices = [];
  126943. }
  126944. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  126945. if (!vertexPositions) {
  126946. vertexPositions = [];
  126947. }
  126948. object.computeWorldMatrix(false);
  126949. var faceCount = indices.length / 3;
  126950. for (var i = 0; i < faceCount; i++) {
  126951. var triPoints = [];
  126952. for (var point = 0; point < 3; point++) {
  126953. var v = new _Maths_math_vector__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]);
  126954. // Adjust for initial scaling
  126955. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  126956. v = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  126957. var vec;
  126958. if (point == 0) {
  126959. vec = this._tmpAmmoVectorA;
  126960. }
  126961. else if (point == 1) {
  126962. vec = this._tmpAmmoVectorB;
  126963. }
  126964. else {
  126965. vec = this._tmpAmmoVectorC;
  126966. }
  126967. vec.setValue(v.x, v.y, v.z);
  126968. triPoints.push(vec);
  126969. }
  126970. btConvexHullShape.addPoint(triPoints[0], true);
  126971. btConvexHullShape.addPoint(triPoints[1], true);
  126972. btConvexHullShape.addPoint(triPoints[2], true);
  126973. triangleCount++;
  126974. }
  126975. object.getChildMeshes().forEach(function (m) {
  126976. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  126977. });
  126978. }
  126979. return triangleCount;
  126980. };
  126981. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  126982. var _this = this;
  126983. if (ignoreChildren === void 0) { ignoreChildren = false; }
  126984. var object = impostor.object;
  126985. var returnValue;
  126986. var extendSize = impostor.getObjectExtendSize();
  126987. if (!ignoreChildren) {
  126988. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  126989. returnValue = new Ammo.btCompoundShape();
  126990. // Add shape of all children to the compound shape
  126991. var childrenAdded = 0;
  126992. meshChildren.forEach(function (childMesh) {
  126993. var childImpostor = childMesh.getPhysicsImpostor();
  126994. if (childImpostor) {
  126995. if (childImpostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor) {
  126996. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  126997. }
  126998. var shape = _this._createShape(childImpostor);
  126999. // Position needs to be scaled based on parent's scaling
  127000. var parentMat = childMesh.parent.getWorldMatrix().clone();
  127001. var s = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  127002. parentMat.decompose(s);
  127003. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  127004. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  127005. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  127006. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  127007. childImpostor.dispose();
  127008. childrenAdded++;
  127009. }
  127010. });
  127011. if (childrenAdded > 0) {
  127012. // Add parents shape as a child if present
  127013. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  127014. var shape = this._createShape(impostor, true);
  127015. if (shape) {
  127016. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  127017. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  127018. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  127019. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  127020. }
  127021. }
  127022. return returnValue;
  127023. }
  127024. else {
  127025. // If no children with impostors create the actual shape below instead
  127026. Ammo.destroy(returnValue);
  127027. returnValue = null;
  127028. }
  127029. }
  127030. switch (impostor.type) {
  127031. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  127032. // Is there a better way to compare floats number? With an epsylon or with a Math function
  127033. if (_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_9__["Scalar"].WithinEpsilon(extendSize.x, extendSize.y, 0.0001) && _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_9__["Scalar"].WithinEpsilon(extendSize.x, extendSize.z, 0.0001)) {
  127034. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  127035. }
  127036. else {
  127037. // create a btMultiSphereShape because it's not possible to set a local scaling on a btSphereShape
  127038. var positions = [new Ammo.btVector3(0, 0, 0)];
  127039. var radii = [1];
  127040. returnValue = new Ammo.btMultiSphereShape(positions, radii, 1);
  127041. returnValue.setLocalScaling(new Ammo.btVector3(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2));
  127042. }
  127043. break;
  127044. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CapsuleImpostor:
  127045. returnValue = new Ammo.btCapsuleShape(extendSize.x / 2, extendSize.y / 2);
  127046. break;
  127047. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  127048. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  127049. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  127050. break;
  127051. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  127052. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  127053. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  127054. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  127055. break;
  127056. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  127057. if (impostor.getParam("mass") == 0) {
  127058. // Only create btBvhTriangleMeshShape impostor is static
  127059. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  127060. var tetraMesh = new Ammo.btTriangleMesh();
  127061. impostor._pluginData.toDispose.push(tetraMesh);
  127062. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  127063. if (triangeCount == 0) {
  127064. returnValue = new Ammo.btCompoundShape();
  127065. }
  127066. else {
  127067. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  127068. }
  127069. break;
  127070. }
  127071. // Otherwise create convexHullImpostor
  127072. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  127073. var convexMesh = new Ammo.btConvexHullShape();
  127074. var triangeCount = this._addHullVerts(convexMesh, object, object);
  127075. if (triangeCount == 0) {
  127076. // Cleanup Unused Convex Hull Shape
  127077. impostor._pluginData.toDispose.push(convexMesh);
  127078. returnValue = new Ammo.btCompoundShape();
  127079. }
  127080. else {
  127081. returnValue = convexMesh;
  127082. }
  127083. break;
  127084. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  127085. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  127086. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  127087. break;
  127088. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  127089. // Only usable with a mesh that has sufficient and shared vertices
  127090. returnValue = this._createSoftbody(impostor);
  127091. break;
  127092. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  127093. // Only usable with a ground mesh that has sufficient and shared vertices
  127094. returnValue = this._createCloth(impostor);
  127095. break;
  127096. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  127097. // Only usable with a line mesh or an extruded mesh that is updatable
  127098. returnValue = this._createRope(impostor);
  127099. break;
  127100. default:
  127101. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  127102. break;
  127103. }
  127104. return returnValue;
  127105. };
  127106. /**
  127107. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  127108. * @param impostor imposter containing the physics body and babylon object
  127109. */
  127110. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  127111. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  127112. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  127113. if (!impostor.object.rotationQuaternion) {
  127114. if (impostor.object.rotation) {
  127115. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  127116. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  127117. }
  127118. }
  127119. else {
  127120. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  127121. }
  127122. };
  127123. /**
  127124. * Sets the babylon object's position/rotation from the physics body's position/rotation
  127125. * @param impostor imposter containing the physics body and babylon object
  127126. * @param newPosition new position
  127127. * @param newRotation new rotation
  127128. */
  127129. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  127130. var trans = impostor.physicsBody.getWorldTransform();
  127131. // If rotation/position has changed update and activate riged body
  127132. if (trans.getOrigin().x() != newPosition.x ||
  127133. trans.getOrigin().y() != newPosition.y ||
  127134. trans.getOrigin().z() != newPosition.z ||
  127135. trans.getRotation().x() != newRotation.x ||
  127136. trans.getRotation().y() != newRotation.y ||
  127137. trans.getRotation().z() != newRotation.z ||
  127138. trans.getRotation().w() != newRotation.w) {
  127139. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  127140. trans.setOrigin(this._tmpAmmoVectorA);
  127141. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  127142. trans.setRotation(this._tmpAmmoQuaternion);
  127143. impostor.physicsBody.setWorldTransform(trans);
  127144. if (impostor.mass == 0) {
  127145. // Kinematic objects must be updated using motion state
  127146. var motionState = impostor.physicsBody.getMotionState();
  127147. if (motionState) {
  127148. motionState.setWorldTransform(trans);
  127149. }
  127150. }
  127151. else {
  127152. impostor.physicsBody.activate();
  127153. }
  127154. }
  127155. };
  127156. /**
  127157. * If this plugin is supported
  127158. * @returns true if its supported
  127159. */
  127160. AmmoJSPlugin.prototype.isSupported = function () {
  127161. return this.bjsAMMO !== undefined;
  127162. };
  127163. /**
  127164. * Sets the linear velocity of the physics body
  127165. * @param impostor imposter to set the velocity on
  127166. * @param velocity velocity to set
  127167. */
  127168. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  127169. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  127170. if (impostor.soft) {
  127171. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  127172. }
  127173. else {
  127174. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  127175. }
  127176. };
  127177. /**
  127178. * Sets the angular velocity of the physics body
  127179. * @param impostor imposter to set the velocity on
  127180. * @param velocity velocity to set
  127181. */
  127182. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  127183. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  127184. if (impostor.soft) {
  127185. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  127186. }
  127187. else {
  127188. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  127189. }
  127190. };
  127191. /**
  127192. * gets the linear velocity
  127193. * @param impostor imposter to get linear velocity from
  127194. * @returns linear velocity
  127195. */
  127196. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  127197. if (impostor.soft) {
  127198. var v = impostor.physicsBody.linearVelocity();
  127199. }
  127200. else {
  127201. var v = impostor.physicsBody.getLinearVelocity();
  127202. }
  127203. if (!v) {
  127204. return null;
  127205. }
  127206. var result = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  127207. Ammo.destroy(v);
  127208. return result;
  127209. };
  127210. /**
  127211. * gets the angular velocity
  127212. * @param impostor imposter to get angular velocity from
  127213. * @returns angular velocity
  127214. */
  127215. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  127216. if (impostor.soft) {
  127217. var v = impostor.physicsBody.angularVelocity();
  127218. }
  127219. else {
  127220. var v = impostor.physicsBody.getAngularVelocity();
  127221. }
  127222. if (!v) {
  127223. return null;
  127224. }
  127225. var result = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  127226. Ammo.destroy(v);
  127227. return result;
  127228. };
  127229. /**
  127230. * Sets the mass of physics body
  127231. * @param impostor imposter to set the mass on
  127232. * @param mass mass to set
  127233. */
  127234. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  127235. if (impostor.soft) {
  127236. impostor.physicsBody.setTotalMass(mass, false);
  127237. }
  127238. else {
  127239. impostor.physicsBody.setMassProps(mass);
  127240. }
  127241. impostor._pluginData.mass = mass;
  127242. };
  127243. /**
  127244. * Gets the mass of the physics body
  127245. * @param impostor imposter to get the mass from
  127246. * @returns mass
  127247. */
  127248. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  127249. return impostor._pluginData.mass || 0;
  127250. };
  127251. /**
  127252. * Gets friction of the impostor
  127253. * @param impostor impostor to get friction from
  127254. * @returns friction value
  127255. */
  127256. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  127257. return impostor._pluginData.friction || 0;
  127258. };
  127259. /**
  127260. * Sets friction of the impostor
  127261. * @param impostor impostor to set friction on
  127262. * @param friction friction value
  127263. */
  127264. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  127265. if (impostor.soft) {
  127266. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  127267. }
  127268. else {
  127269. impostor.physicsBody.setFriction(friction);
  127270. }
  127271. impostor._pluginData.friction = friction;
  127272. };
  127273. /**
  127274. * Gets restitution of the impostor
  127275. * @param impostor impostor to get restitution from
  127276. * @returns restitution value
  127277. */
  127278. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  127279. return impostor._pluginData.restitution || 0;
  127280. };
  127281. /**
  127282. * Sets resitution of the impostor
  127283. * @param impostor impostor to set resitution on
  127284. * @param restitution resitution value
  127285. */
  127286. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  127287. impostor.physicsBody.setRestitution(restitution);
  127288. impostor._pluginData.restitution = restitution;
  127289. };
  127290. /**
  127291. * Gets pressure inside the impostor
  127292. * @param impostor impostor to get pressure from
  127293. * @returns pressure value
  127294. */
  127295. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  127296. if (!impostor.soft) {
  127297. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  127298. return 0;
  127299. }
  127300. return impostor._pluginData.pressure || 0;
  127301. };
  127302. /**
  127303. * Sets pressure inside a soft body impostor
  127304. * Cloth and rope must remain 0 pressure
  127305. * @param impostor impostor to set pressure on
  127306. * @param pressure pressure value
  127307. */
  127308. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  127309. if (impostor.soft) {
  127310. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  127311. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  127312. impostor._pluginData.pressure = pressure;
  127313. }
  127314. else {
  127315. impostor.physicsBody.get_m_cfg().set_kPR(0);
  127316. impostor._pluginData.pressure = 0;
  127317. }
  127318. }
  127319. else {
  127320. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  127321. }
  127322. };
  127323. /**
  127324. * Gets stiffness of the impostor
  127325. * @param impostor impostor to get stiffness from
  127326. * @returns pressure value
  127327. */
  127328. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  127329. if (!impostor.soft) {
  127330. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  127331. return 0;
  127332. }
  127333. return impostor._pluginData.stiffness || 0;
  127334. };
  127335. /**
  127336. * Sets stiffness of the impostor
  127337. * @param impostor impostor to set stiffness on
  127338. * @param stiffness stiffness value from 0 to 1
  127339. */
  127340. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  127341. if (impostor.soft) {
  127342. stiffness = stiffness < 0 ? 0 : stiffness;
  127343. stiffness = stiffness > 1 ? 1 : stiffness;
  127344. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  127345. impostor._pluginData.stiffness = stiffness;
  127346. }
  127347. else {
  127348. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  127349. }
  127350. };
  127351. /**
  127352. * Gets velocityIterations of the impostor
  127353. * @param impostor impostor to get velocity iterations from
  127354. * @returns velocityIterations value
  127355. */
  127356. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  127357. if (!impostor.soft) {
  127358. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  127359. return 0;
  127360. }
  127361. return impostor._pluginData.velocityIterations || 0;
  127362. };
  127363. /**
  127364. * Sets velocityIterations of the impostor
  127365. * @param impostor impostor to set velocity iterations on
  127366. * @param velocityIterations velocityIterations value
  127367. */
  127368. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  127369. if (impostor.soft) {
  127370. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  127371. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  127372. impostor._pluginData.velocityIterations = velocityIterations;
  127373. }
  127374. else {
  127375. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  127376. }
  127377. };
  127378. /**
  127379. * Gets positionIterations of the impostor
  127380. * @param impostor impostor to get position iterations from
  127381. * @returns positionIterations value
  127382. */
  127383. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  127384. if (!impostor.soft) {
  127385. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  127386. return 0;
  127387. }
  127388. return impostor._pluginData.positionIterations || 0;
  127389. };
  127390. /**
  127391. * Sets positionIterations of the impostor
  127392. * @param impostor impostor to set position on
  127393. * @param positionIterations positionIterations value
  127394. */
  127395. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  127396. if (impostor.soft) {
  127397. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  127398. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  127399. impostor._pluginData.positionIterations = positionIterations;
  127400. }
  127401. else {
  127402. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  127403. }
  127404. };
  127405. /**
  127406. * Append an anchor to a cloth object
  127407. * @param impostor is the cloth impostor to add anchor to
  127408. * @param otherImpostor is the rigid impostor to anchor to
  127409. * @param width ratio across width from 0 to 1
  127410. * @param height ratio up height from 0 to 1
  127411. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  127412. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  127413. */
  127414. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  127415. if (influence === void 0) { influence = 1; }
  127416. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  127417. var segs = impostor.segments;
  127418. var nbAcross = Math.round((segs - 1) * width);
  127419. var nbUp = Math.round((segs - 1) * height);
  127420. var nbDown = segs - 1 - nbUp;
  127421. var node = nbAcross + segs * nbDown;
  127422. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  127423. };
  127424. /**
  127425. * Append an hook to a rope object
  127426. * @param impostor is the rope impostor to add hook to
  127427. * @param otherImpostor is the rigid impostor to hook to
  127428. * @param length ratio along the rope from 0 to 1
  127429. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  127430. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  127431. */
  127432. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  127433. if (influence === void 0) { influence = 1; }
  127434. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  127435. var node = Math.round(impostor.segments * length);
  127436. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  127437. };
  127438. /**
  127439. * Sleeps the physics body and stops it from being active
  127440. * @param impostor impostor to sleep
  127441. */
  127442. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  127443. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  127444. };
  127445. /**
  127446. * Activates the physics body
  127447. * @param impostor impostor to activate
  127448. */
  127449. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  127450. impostor.physicsBody.activate();
  127451. };
  127452. /**
  127453. * Updates the distance parameters of the joint
  127454. * @param joint joint to update
  127455. * @param maxDistance maximum distance of the joint
  127456. * @param minDistance minimum distance of the joint
  127457. */
  127458. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  127459. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  127460. };
  127461. /**
  127462. * Sets a motor on the joint
  127463. * @param joint joint to set motor on
  127464. * @param speed speed of the motor
  127465. * @param maxForce maximum force of the motor
  127466. * @param motorIndex index of the motor
  127467. */
  127468. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  127469. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  127470. };
  127471. /**
  127472. * Sets the motors limit
  127473. * @param joint joint to set limit on
  127474. * @param upperLimit upper limit
  127475. * @param lowerLimit lower limit
  127476. */
  127477. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  127478. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  127479. };
  127480. /**
  127481. * Syncs the position and rotation of a mesh with the impostor
  127482. * @param mesh mesh to sync
  127483. * @param impostor impostor to update the mesh with
  127484. */
  127485. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  127486. var body = impostor.physicsBody;
  127487. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  127488. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  127489. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  127490. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  127491. if (mesh.rotationQuaternion) {
  127492. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  127493. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  127494. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  127495. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  127496. }
  127497. };
  127498. /**
  127499. * Gets the radius of the impostor
  127500. * @param impostor impostor to get radius from
  127501. * @returns the radius
  127502. */
  127503. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  127504. var exntend = impostor.getObjectExtendSize();
  127505. return exntend.x / 2;
  127506. };
  127507. /**
  127508. * Gets the box size of the impostor
  127509. * @param impostor impostor to get box size from
  127510. * @param result the resulting box size
  127511. */
  127512. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  127513. var exntend = impostor.getObjectExtendSize();
  127514. result.x = exntend.x;
  127515. result.y = exntend.y;
  127516. result.z = exntend.z;
  127517. };
  127518. /**
  127519. * Disposes of the impostor
  127520. */
  127521. AmmoJSPlugin.prototype.dispose = function () {
  127522. // Dispose of world
  127523. Ammo.destroy(this.world);
  127524. Ammo.destroy(this._solver);
  127525. Ammo.destroy(this._overlappingPairCache);
  127526. Ammo.destroy(this._dispatcher);
  127527. Ammo.destroy(this._collisionConfiguration);
  127528. // Dispose of tmp variables
  127529. Ammo.destroy(this._tmpAmmoVectorA);
  127530. Ammo.destroy(this._tmpAmmoVectorB);
  127531. Ammo.destroy(this._tmpAmmoVectorC);
  127532. Ammo.destroy(this._tmpAmmoTransform);
  127533. Ammo.destroy(this._tmpAmmoQuaternion);
  127534. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  127535. this.world = null;
  127536. };
  127537. /**
  127538. * Does a raycast in the physics world
  127539. * @param from when should the ray start?
  127540. * @param to when should the ray end?
  127541. * @returns PhysicsRaycastResult
  127542. */
  127543. AmmoJSPlugin.prototype.raycast = function (from, to) {
  127544. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  127545. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  127546. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  127547. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  127548. this._raycastResult.reset(from, to);
  127549. if (rayCallback.hasHit()) {
  127550. // TODO: do we want/need the body? If so, set all the data
  127551. /*
  127552. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  127553. rayCallback.get_m_collisionObject()
  127554. );
  127555. var body = {};
  127556. */
  127557. this._raycastResult.setHitData({
  127558. x: rayCallback.get_m_hitNormalWorld().x(),
  127559. y: rayCallback.get_m_hitNormalWorld().y(),
  127560. z: rayCallback.get_m_hitNormalWorld().z(),
  127561. }, {
  127562. x: rayCallback.get_m_hitPointWorld().x(),
  127563. y: rayCallback.get_m_hitPointWorld().y(),
  127564. z: rayCallback.get_m_hitPointWorld().z(),
  127565. });
  127566. this._raycastResult.calculateHitDistance();
  127567. }
  127568. Ammo.destroy(rayCallback);
  127569. Ammo.destroy(this._tmpAmmoVectorRCA);
  127570. Ammo.destroy(this._tmpAmmoVectorRCB);
  127571. return this._raycastResult;
  127572. };
  127573. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  127574. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  127575. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  127576. return AmmoJSPlugin;
  127577. }());
  127578. /***/ }),
  127579. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  127580. /*!*******************************************!*\
  127581. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  127582. \*******************************************/
  127583. /*! exports provided: CannonJSPlugin */
  127584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127585. "use strict";
  127586. __webpack_require__.r(__webpack_exports__);
  127587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  127588. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  127589. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  127590. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  127591. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  127592. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  127593. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  127594. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  127595. /** @hidden */
  127596. var CannonJSPlugin = /** @class */ (function () {
  127597. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  127598. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  127599. if (iterations === void 0) { iterations = 10; }
  127600. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  127601. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  127602. this.name = "CannonJSPlugin";
  127603. this._physicsMaterials = new Array();
  127604. this._fixedTimeStep = 1 / 60;
  127605. this._physicsBodysToRemoveAfterStep = new Array();
  127606. this._minus90X = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  127607. this._plus90X = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  127608. this._tmpPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  127609. this._tmpDeltaPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  127610. this._tmpUnityRotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  127611. this.BJSCANNON = cannonInjection;
  127612. if (!this.isSupported()) {
  127613. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  127614. return;
  127615. }
  127616. this._extendNamespace();
  127617. this.world = new this.BJSCANNON.World();
  127618. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  127619. this.world.solver.iterations = iterations;
  127620. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  127621. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  127622. }
  127623. CannonJSPlugin.prototype.setGravity = function (gravity) {
  127624. this.world.gravity.copy(gravity);
  127625. };
  127626. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  127627. this._fixedTimeStep = timeStep;
  127628. };
  127629. CannonJSPlugin.prototype.getTimeStep = function () {
  127630. return this._fixedTimeStep;
  127631. };
  127632. CannonJSPlugin.prototype.executeStep = function (delta) {
  127633. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  127634. this._removeMarkedPhysicsBodiesFromWorld();
  127635. };
  127636. CannonJSPlugin.prototype._removeMarkedPhysicsBodiesFromWorld = function () {
  127637. var _this = this;
  127638. if (this._physicsBodysToRemoveAfterStep.length > 0) {
  127639. this._physicsBodysToRemoveAfterStep.forEach(function (physicsBody) {
  127640. _this.world.remove(physicsBody);
  127641. });
  127642. this._physicsBodysToRemoveAfterStep = [];
  127643. }
  127644. };
  127645. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  127646. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  127647. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  127648. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  127649. };
  127650. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  127651. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  127652. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  127653. impostor.physicsBody.applyForce(impulse, worldPoint);
  127654. };
  127655. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  127656. // When calling forceUpdate generatePhysicsBody is called again, ensure that the updated body does not instantly collide with removed body
  127657. this._removeMarkedPhysicsBodiesFromWorld();
  127658. //parent-child relationship. Does this impostor has a parent impostor?
  127659. if (impostor.parent) {
  127660. if (impostor.physicsBody) {
  127661. this.removePhysicsBody(impostor);
  127662. //TODO is that needed?
  127663. impostor.forceUpdate();
  127664. }
  127665. return;
  127666. }
  127667. //should a new body be created for this impostor?
  127668. if (impostor.isBodyInitRequired()) {
  127669. var shape = this._createShape(impostor);
  127670. //unregister events, if body is being changed
  127671. var oldBody = impostor.physicsBody;
  127672. if (oldBody) {
  127673. this.removePhysicsBody(impostor);
  127674. }
  127675. //create the body and material
  127676. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  127677. var bodyCreationObject = {
  127678. mass: impostor.getParam("mass"),
  127679. material: material
  127680. };
  127681. // A simple extend, in case native options were used.
  127682. var nativeOptions = impostor.getParam("nativeOptions");
  127683. for (var key in nativeOptions) {
  127684. if (nativeOptions.hasOwnProperty(key)) {
  127685. bodyCreationObject[key] = nativeOptions[key];
  127686. }
  127687. }
  127688. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  127689. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  127690. this.world.addEventListener("preStep", impostor.beforeStep);
  127691. this.world.addEventListener("postStep", impostor.afterStep);
  127692. impostor.physicsBody.addShape(shape);
  127693. this.world.add(impostor.physicsBody);
  127694. //try to keep the body moving in the right direction by taking old properties.
  127695. //Should be tested!
  127696. if (oldBody) {
  127697. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  127698. impostor.physicsBody[param].copy(oldBody[param]);
  127699. });
  127700. }
  127701. this._processChildMeshes(impostor);
  127702. }
  127703. //now update the body's transformation
  127704. this._updatePhysicsBodyTransformation(impostor);
  127705. };
  127706. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  127707. var _this = this;
  127708. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  127709. var currentRotation = mainImpostor.object.rotationQuaternion;
  127710. if (meshChildren.length) {
  127711. var processMesh = function (localPosition, mesh) {
  127712. if (!currentRotation || !mesh.rotationQuaternion) {
  127713. return;
  127714. }
  127715. var childImpostor = mesh.getPhysicsImpostor();
  127716. if (childImpostor) {
  127717. var parent = childImpostor.parent;
  127718. if (parent !== mainImpostor) {
  127719. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  127720. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  127721. if (childImpostor.physicsBody) {
  127722. _this.removePhysicsBody(childImpostor);
  127723. childImpostor.physicsBody = null;
  127724. }
  127725. childImpostor.parent = mainImpostor;
  127726. childImpostor.resetUpdateFlags();
  127727. 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));
  127728. //Add the mass of the children.
  127729. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  127730. }
  127731. }
  127732. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  127733. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  127734. };
  127735. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  127736. }
  127737. };
  127738. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  127739. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  127740. this.world.removeEventListener("preStep", impostor.beforeStep);
  127741. this.world.removeEventListener("postStep", impostor.afterStep);
  127742. // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
  127743. if (this._physicsBodysToRemoveAfterStep.indexOf(impostor.physicsBody) === -1) {
  127744. this._physicsBodysToRemoveAfterStep.push(impostor.physicsBody);
  127745. }
  127746. };
  127747. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  127748. var mainBody = impostorJoint.mainImpostor.physicsBody;
  127749. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  127750. if (!mainBody || !connectedBody) {
  127751. return;
  127752. }
  127753. var constraint;
  127754. var jointData = impostorJoint.joint.jointData;
  127755. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  127756. var constraintData = {
  127757. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  127758. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  127759. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  127760. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  127761. maxForce: jointData.nativeParams.maxForce,
  127762. collideConnected: !!jointData.collision
  127763. };
  127764. switch (impostorJoint.joint.type) {
  127765. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  127766. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  127767. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  127768. break;
  127769. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  127770. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  127771. break;
  127772. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  127773. var springData = jointData;
  127774. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  127775. restLength: springData.length,
  127776. stiffness: springData.stiffness,
  127777. damping: springData.damping,
  127778. localAnchorA: constraintData.pivotA,
  127779. localAnchorB: constraintData.pivotB
  127780. });
  127781. break;
  127782. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  127783. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  127784. break;
  127785. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  127786. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  127787. default:
  127788. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  127789. break;
  127790. }
  127791. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  127792. constraint.collideConnected = !!jointData.collision;
  127793. impostorJoint.joint.physicsJoint = constraint;
  127794. //don't add spring as constraint, as it is not one.
  127795. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  127796. this.world.addConstraint(constraint);
  127797. }
  127798. else {
  127799. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  127800. constraint.applyForce();
  127801. };
  127802. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  127803. }
  127804. };
  127805. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  127806. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  127807. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  127808. }
  127809. else {
  127810. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  127811. }
  127812. };
  127813. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  127814. var index;
  127815. var mat;
  127816. for (index = 0; index < this._physicsMaterials.length; index++) {
  127817. mat = this._physicsMaterials[index];
  127818. if (mat.friction === friction && mat.restitution === restitution) {
  127819. return mat;
  127820. }
  127821. }
  127822. var currentMat = new this.BJSCANNON.Material(name);
  127823. currentMat.friction = friction;
  127824. currentMat.restitution = restitution;
  127825. this._physicsMaterials.push(currentMat);
  127826. return currentMat;
  127827. };
  127828. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  127829. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  127830. };
  127831. CannonJSPlugin.prototype._createShape = function (impostor) {
  127832. var object = impostor.object;
  127833. var returnValue;
  127834. var extendSize = impostor.getObjectExtendSize();
  127835. switch (impostor.type) {
  127836. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  127837. var radiusX = extendSize.x;
  127838. var radiusY = extendSize.y;
  127839. var radiusZ = extendSize.z;
  127840. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  127841. break;
  127842. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  127843. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  127844. var nativeParams = impostor.getParam("nativeOptions");
  127845. if (!nativeParams) {
  127846. nativeParams = {};
  127847. }
  127848. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  127849. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  127850. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  127851. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  127852. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  127853. // Rotate 90 degrees as this shape is horizontal in cannon
  127854. var quat = new this.BJSCANNON.Quaternion();
  127855. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  127856. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  127857. returnValue.transformAllPoints(translation, quat);
  127858. break;
  127859. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  127860. var box = extendSize.scale(0.5);
  127861. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  127862. break;
  127863. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  127864. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  127865. returnValue = new this.BJSCANNON.Plane();
  127866. break;
  127867. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  127868. // should transform the vertex data to world coordinates!!
  127869. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  127870. var rawFaces = object.getIndices ? object.getIndices() : [];
  127871. if (!rawVerts) {
  127872. return;
  127873. }
  127874. // get only scale! so the object could transform correctly.
  127875. var oldPosition = object.position.clone();
  127876. var oldRotation = object.rotation && object.rotation.clone();
  127877. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  127878. object.position.copyFromFloats(0, 0, 0);
  127879. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  127880. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  127881. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  127882. var transform = object.computeWorldMatrix(true);
  127883. // convert rawVerts to object space
  127884. var temp = new Array();
  127885. var index;
  127886. for (index = 0; index < rawVerts.length; index += 3) {
  127887. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  127888. }
  127889. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  127890. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  127891. //now set back the transformation!
  127892. object.position.copyFrom(oldPosition);
  127893. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  127894. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  127895. break;
  127896. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  127897. var oldPosition2 = object.position.clone();
  127898. var oldRotation2 = object.rotation && object.rotation.clone();
  127899. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  127900. object.position.copyFromFloats(0, 0, 0);
  127901. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  127902. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  127903. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  127904. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  127905. returnValue = this._createHeightmap(object);
  127906. object.position.copyFrom(oldPosition2);
  127907. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  127908. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  127909. object.computeWorldMatrix(true);
  127910. break;
  127911. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  127912. returnValue = new this.BJSCANNON.Particle();
  127913. break;
  127914. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  127915. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  127916. break;
  127917. }
  127918. return returnValue;
  127919. };
  127920. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  127921. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  127922. var transform = object.computeWorldMatrix(true);
  127923. // convert rawVerts to object space
  127924. var temp = new Array();
  127925. var index;
  127926. for (index = 0; index < pos.length; index += 3) {
  127927. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  127928. }
  127929. pos = temp;
  127930. var matrix = new Array();
  127931. //For now pointDepth will not be used and will be automatically calculated.
  127932. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  127933. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  127934. var boundingInfo = object.getBoundingInfo();
  127935. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  127936. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  127937. var elementSize = dim * 2 / arraySize;
  127938. for (var i = 0; i < pos.length; i = i + 3) {
  127939. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  127940. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  127941. var y = -pos[i + 2] + minY;
  127942. if (!matrix[x]) {
  127943. matrix[x] = [];
  127944. }
  127945. if (!matrix[x][z]) {
  127946. matrix[x][z] = y;
  127947. }
  127948. matrix[x][z] = Math.max(y, matrix[x][z]);
  127949. }
  127950. for (var x = 0; x <= arraySize; ++x) {
  127951. if (!matrix[x]) {
  127952. var loc = 1;
  127953. while (!matrix[(x + loc) % arraySize]) {
  127954. loc++;
  127955. }
  127956. matrix[x] = matrix[(x + loc) % arraySize].slice();
  127957. //console.log("missing x", x);
  127958. }
  127959. for (var z = 0; z <= arraySize; ++z) {
  127960. if (!matrix[x][z]) {
  127961. var loc = 1;
  127962. var newValue;
  127963. while (newValue === undefined) {
  127964. newValue = matrix[x][(z + loc++) % arraySize];
  127965. }
  127966. matrix[x][z] = newValue;
  127967. }
  127968. }
  127969. }
  127970. var shape = new this.BJSCANNON.Heightfield(matrix, {
  127971. elementSize: elementSize
  127972. });
  127973. //For future reference, needed for body transformation
  127974. shape.minY = minY;
  127975. return shape;
  127976. };
  127977. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  127978. var object = impostor.object;
  127979. //make sure it is updated...
  127980. object.computeWorldMatrix && object.computeWorldMatrix(true);
  127981. // The delta between the mesh position and the mesh bounding box center
  127982. var bInfo = object.getBoundingInfo();
  127983. if (!bInfo) {
  127984. return;
  127985. }
  127986. var center = impostor.getObjectCenter();
  127987. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  127988. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  127989. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  127990. this._tmpPosition.copyFrom(center);
  127991. var quaternion = object.rotationQuaternion;
  127992. if (!quaternion) {
  127993. return;
  127994. }
  127995. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  127996. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  127997. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  127998. //-90 DEG in X, precalculated
  127999. quaternion = quaternion.multiply(this._minus90X);
  128000. //Invert! (Precalculated, 90 deg in X)
  128001. //No need to clone. this will never change.
  128002. impostor.setDeltaRotation(this._plus90X);
  128003. }
  128004. //If it is a heightfield, if should be centered.
  128005. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  128006. var mesh = object;
  128007. var boundingInfo = mesh.getBoundingInfo();
  128008. //calculate the correct body position:
  128009. var rotationQuaternion = mesh.rotationQuaternion;
  128010. mesh.rotationQuaternion = this._tmpUnityRotation;
  128011. mesh.computeWorldMatrix(true);
  128012. //get original center with no rotation
  128013. var c = center.clone();
  128014. var oldPivot = mesh.getPivotMatrix();
  128015. if (oldPivot) {
  128016. // create a copy the pivot Matrix as it is modified in place
  128017. oldPivot = oldPivot.clone();
  128018. }
  128019. else {
  128020. oldPivot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  128021. }
  128022. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  128023. var p = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  128024. mesh.setPreTransformMatrix(p);
  128025. mesh.computeWorldMatrix(true);
  128026. //calculate the translation
  128027. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  128028. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  128029. //add it inverted to the delta
  128030. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  128031. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  128032. //rotation is back
  128033. mesh.rotationQuaternion = rotationQuaternion;
  128034. mesh.setPreTransformMatrix(oldPivot);
  128035. mesh.computeWorldMatrix(true);
  128036. }
  128037. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  128038. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  128039. //this._tmpPosition.copyFrom(object.position);
  128040. }
  128041. impostor.setDeltaPosition(this._tmpDeltaPosition);
  128042. //Now update the impostor object
  128043. impostor.physicsBody.position.copy(this._tmpPosition);
  128044. impostor.physicsBody.quaternion.copy(quaternion);
  128045. };
  128046. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  128047. impostor.object.position.copyFrom(impostor.physicsBody.position);
  128048. if (impostor.object.rotationQuaternion) {
  128049. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  128050. }
  128051. };
  128052. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  128053. impostor.physicsBody.position.copy(newPosition);
  128054. impostor.physicsBody.quaternion.copy(newRotation);
  128055. };
  128056. CannonJSPlugin.prototype.isSupported = function () {
  128057. return this.BJSCANNON !== undefined;
  128058. };
  128059. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  128060. impostor.physicsBody.velocity.copy(velocity);
  128061. };
  128062. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  128063. impostor.physicsBody.angularVelocity.copy(velocity);
  128064. };
  128065. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  128066. var v = impostor.physicsBody.velocity;
  128067. if (!v) {
  128068. return null;
  128069. }
  128070. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  128071. };
  128072. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  128073. var v = impostor.physicsBody.angularVelocity;
  128074. if (!v) {
  128075. return null;
  128076. }
  128077. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  128078. };
  128079. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  128080. impostor.physicsBody.mass = mass;
  128081. impostor.physicsBody.updateMassProperties();
  128082. };
  128083. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  128084. return impostor.physicsBody.mass;
  128085. };
  128086. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  128087. return impostor.physicsBody.material.friction;
  128088. };
  128089. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  128090. impostor.physicsBody.material.friction = friction;
  128091. };
  128092. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  128093. return impostor.physicsBody.material.restitution;
  128094. };
  128095. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  128096. impostor.physicsBody.material.restitution = restitution;
  128097. };
  128098. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  128099. impostor.physicsBody.sleep();
  128100. };
  128101. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  128102. impostor.physicsBody.wakeUp();
  128103. };
  128104. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  128105. joint.physicsJoint.distance = maxDistance;
  128106. };
  128107. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  128108. // if (!motorIndex) {
  128109. // joint.physicsJoint.enableMotor();
  128110. // }
  128111. // }
  128112. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  128113. // if (!motorIndex) {
  128114. // joint.physicsJoint.disableMotor();
  128115. // }
  128116. // }
  128117. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  128118. if (!motorIndex) {
  128119. joint.physicsJoint.enableMotor();
  128120. joint.physicsJoint.setMotorSpeed(speed);
  128121. if (maxForce) {
  128122. this.setLimit(joint, maxForce);
  128123. }
  128124. }
  128125. };
  128126. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  128127. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  128128. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  128129. };
  128130. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  128131. var body = impostor.physicsBody;
  128132. mesh.position.x = body.position.x;
  128133. mesh.position.y = body.position.y;
  128134. mesh.position.z = body.position.z;
  128135. if (mesh.rotationQuaternion) {
  128136. mesh.rotationQuaternion.x = body.quaternion.x;
  128137. mesh.rotationQuaternion.y = body.quaternion.y;
  128138. mesh.rotationQuaternion.z = body.quaternion.z;
  128139. mesh.rotationQuaternion.w = body.quaternion.w;
  128140. }
  128141. };
  128142. CannonJSPlugin.prototype.getRadius = function (impostor) {
  128143. var shape = impostor.physicsBody.shapes[0];
  128144. return shape.boundingSphereRadius;
  128145. };
  128146. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  128147. var shape = impostor.physicsBody.shapes[0];
  128148. result.x = shape.halfExtents.x * 2;
  128149. result.y = shape.halfExtents.y * 2;
  128150. result.z = shape.halfExtents.z * 2;
  128151. };
  128152. CannonJSPlugin.prototype.dispose = function () {
  128153. };
  128154. CannonJSPlugin.prototype._extendNamespace = function () {
  128155. //this will force cannon to execute at least one step when using interpolation
  128156. var step_tmp1 = new this.BJSCANNON.Vec3();
  128157. var Engine = this.BJSCANNON;
  128158. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  128159. maxSubSteps = maxSubSteps || 10;
  128160. timeSinceLastCalled = timeSinceLastCalled || 0;
  128161. if (timeSinceLastCalled === 0) {
  128162. this.internalStep(dt);
  128163. this.time += dt;
  128164. }
  128165. else {
  128166. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  128167. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  128168. var t0 = performance.now();
  128169. for (var i = 0; i !== internalSteps; i++) {
  128170. this.internalStep(dt);
  128171. if (performance.now() - t0 > dt * 1000) {
  128172. break;
  128173. }
  128174. }
  128175. this.time += timeSinceLastCalled;
  128176. var h = this.time % dt;
  128177. var h_div_dt = h / dt;
  128178. var interpvelo = step_tmp1;
  128179. var bodies = this.bodies;
  128180. for (var j = 0; j !== bodies.length; j++) {
  128181. var b = bodies[j];
  128182. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  128183. b.position.vsub(b.previousPosition, interpvelo);
  128184. interpvelo.scale(h_div_dt, interpvelo);
  128185. b.position.vadd(interpvelo, b.interpolatedPosition);
  128186. }
  128187. else {
  128188. b.interpolatedPosition.copy(b.position);
  128189. b.interpolatedQuaternion.copy(b.quaternion);
  128190. }
  128191. }
  128192. }
  128193. };
  128194. };
  128195. /**
  128196. * Does a raycast in the physics world
  128197. * @param from when should the ray start?
  128198. * @param to when should the ray end?
  128199. * @returns PhysicsRaycastResult
  128200. */
  128201. CannonJSPlugin.prototype.raycast = function (from, to) {
  128202. this._cannonRaycastResult.reset();
  128203. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  128204. this._raycastResult.reset(from, to);
  128205. if (this._cannonRaycastResult.hasHit) {
  128206. // TODO: do we also want to get the body it hit?
  128207. this._raycastResult.setHitData({
  128208. x: this._cannonRaycastResult.hitNormalWorld.x,
  128209. y: this._cannonRaycastResult.hitNormalWorld.y,
  128210. z: this._cannonRaycastResult.hitNormalWorld.z,
  128211. }, {
  128212. x: this._cannonRaycastResult.hitPointWorld.x,
  128213. y: this._cannonRaycastResult.hitPointWorld.y,
  128214. z: this._cannonRaycastResult.hitPointWorld.z,
  128215. });
  128216. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  128217. }
  128218. return this._raycastResult;
  128219. };
  128220. return CannonJSPlugin;
  128221. }());
  128222. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  128223. /***/ }),
  128224. /***/ "./Physics/Plugins/index.ts":
  128225. /*!**********************************!*\
  128226. !*** ./Physics/Plugins/index.ts ***!
  128227. \**********************************/
  128228. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  128229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128230. "use strict";
  128231. __webpack_require__.r(__webpack_exports__);
  128232. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  128233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  128234. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  128235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  128236. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  128237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  128238. /***/ }),
  128239. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  128240. /*!*****************************************!*\
  128241. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  128242. \*****************************************/
  128243. /*! exports provided: OimoJSPlugin */
  128244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128245. "use strict";
  128246. __webpack_require__.r(__webpack_exports__);
  128247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  128248. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  128249. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  128250. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  128251. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math.vector */ "./Maths/math.vector.ts");
  128252. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  128253. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  128254. /** @hidden */
  128255. var OimoJSPlugin = /** @class */ (function () {
  128256. function OimoJSPlugin(iterations, oimoInjection) {
  128257. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  128258. this.name = "OimoJSPlugin";
  128259. this._tmpImpostorsArray = [];
  128260. this._tmpPositionVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  128261. this.BJSOIMO = oimoInjection;
  128262. this.world = new this.BJSOIMO.World({
  128263. iterations: iterations
  128264. });
  128265. this.world.clear();
  128266. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  128267. }
  128268. OimoJSPlugin.prototype.setGravity = function (gravity) {
  128269. this.world.gravity.copy(gravity);
  128270. };
  128271. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  128272. this.world.timeStep = timeStep;
  128273. };
  128274. OimoJSPlugin.prototype.getTimeStep = function () {
  128275. return this.world.timeStep;
  128276. };
  128277. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  128278. var _this = this;
  128279. impostors.forEach(function (impostor) {
  128280. impostor.beforeStep();
  128281. });
  128282. this.world.step();
  128283. impostors.forEach(function (impostor) {
  128284. impostor.afterStep();
  128285. //update the ordered impostors array
  128286. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  128287. });
  128288. //check for collisions
  128289. var contact = this.world.contacts;
  128290. while (contact !== null) {
  128291. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  128292. contact = contact.next;
  128293. continue;
  128294. }
  128295. //is this body colliding with any other? get the impostor
  128296. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  128297. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  128298. if (!mainImpostor || !collidingImpostor) {
  128299. contact = contact.next;
  128300. continue;
  128301. }
  128302. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  128303. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  128304. contact = contact.next;
  128305. }
  128306. };
  128307. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  128308. var mass = impostor.physicsBody.mass;
  128309. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  128310. };
  128311. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  128312. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  128313. this.applyImpulse(impostor, force, contactPoint);
  128314. };
  128315. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  128316. var _this = this;
  128317. //parent-child relationship. Does this impostor has a parent impostor?
  128318. if (impostor.parent) {
  128319. if (impostor.physicsBody) {
  128320. this.removePhysicsBody(impostor);
  128321. //TODO is that needed?
  128322. impostor.forceUpdate();
  128323. }
  128324. return;
  128325. }
  128326. if (impostor.isBodyInitRequired()) {
  128327. var bodyConfig = {
  128328. name: impostor.uniqueId,
  128329. //Oimo must have mass, also for static objects.
  128330. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  128331. size: [],
  128332. type: [],
  128333. pos: [],
  128334. posShape: [],
  128335. rot: [],
  128336. rotShape: [],
  128337. move: impostor.getParam("mass") !== 0,
  128338. density: impostor.getParam("mass"),
  128339. friction: impostor.getParam("friction"),
  128340. restitution: impostor.getParam("restitution"),
  128341. //Supporting older versions of Oimo
  128342. world: this.world
  128343. };
  128344. var impostors = [impostor];
  128345. var addToArray = function (parent) {
  128346. if (!parent.getChildMeshes) {
  128347. return;
  128348. }
  128349. parent.getChildMeshes().forEach(function (m) {
  128350. if (m.physicsImpostor) {
  128351. impostors.push(m.physicsImpostor);
  128352. //m.physicsImpostor._init();
  128353. }
  128354. });
  128355. };
  128356. addToArray(impostor.object);
  128357. var checkWithEpsilon_1 = function (value) {
  128358. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  128359. };
  128360. var globalQuaternion_1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  128361. impostors.forEach(function (i) {
  128362. if (!i.object.rotationQuaternion) {
  128363. return;
  128364. }
  128365. //get the correct bounding box
  128366. var oldQuaternion = i.object.rotationQuaternion;
  128367. globalQuaternion_1 = oldQuaternion.clone();
  128368. var rot = oldQuaternion.toEulerAngles();
  128369. var extendSize = i.getObjectExtendSize();
  128370. var radToDeg = 57.295779513082320876;
  128371. if (i === impostor) {
  128372. var center = impostor.getObjectCenter();
  128373. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  128374. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  128375. //Can also use Array.prototype.push.apply
  128376. bodyConfig.pos.push(center.x);
  128377. bodyConfig.pos.push(center.y);
  128378. bodyConfig.pos.push(center.z);
  128379. bodyConfig.posShape.push(0, 0, 0);
  128380. bodyConfig.rotShape.push(0, 0, 0);
  128381. }
  128382. else {
  128383. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  128384. bodyConfig.posShape.push(localPosition.x);
  128385. bodyConfig.posShape.push(localPosition.y);
  128386. bodyConfig.posShape.push(localPosition.z);
  128387. bodyConfig.pos.push(0, 0, 0);
  128388. bodyConfig.rotShape.push(rot.x * radToDeg);
  128389. bodyConfig.rotShape.push(rot.y * radToDeg);
  128390. bodyConfig.rotShape.push(rot.z * radToDeg);
  128391. }
  128392. // register mesh
  128393. switch (i.type) {
  128394. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  128395. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  128396. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  128397. var radiusX = extendSize.x;
  128398. var radiusY = extendSize.y;
  128399. var radiusZ = extendSize.z;
  128400. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  128401. bodyConfig.type.push('sphere');
  128402. //due to the way oimo works with compounds, add 3 times
  128403. bodyConfig.size.push(size);
  128404. bodyConfig.size.push(size);
  128405. bodyConfig.size.push(size);
  128406. break;
  128407. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  128408. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  128409. var sizeY = checkWithEpsilon_1(extendSize.y);
  128410. bodyConfig.type.push('cylinder');
  128411. bodyConfig.size.push(sizeX);
  128412. bodyConfig.size.push(sizeY);
  128413. //due to the way oimo works with compounds, add one more value.
  128414. bodyConfig.size.push(sizeY);
  128415. break;
  128416. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  128417. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  128418. default:
  128419. var sizeX = checkWithEpsilon_1(extendSize.x);
  128420. var sizeY = checkWithEpsilon_1(extendSize.y);
  128421. var sizeZ = checkWithEpsilon_1(extendSize.z);
  128422. bodyConfig.type.push('box');
  128423. //if (i === impostor) {
  128424. bodyConfig.size.push(sizeX);
  128425. bodyConfig.size.push(sizeY);
  128426. bodyConfig.size.push(sizeZ);
  128427. //} else {
  128428. // bodyConfig.size.push(0,0,0);
  128429. //}
  128430. break;
  128431. }
  128432. //actually not needed, but hey...
  128433. i.object.rotationQuaternion = oldQuaternion;
  128434. });
  128435. impostor.physicsBody = this.world.add(bodyConfig);
  128436. // set the quaternion, ignoring the previously defined (euler) rotation
  128437. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  128438. // update with delta 0, so the body will reveive the new rotation.
  128439. impostor.physicsBody.updatePosition(0);
  128440. }
  128441. else {
  128442. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  128443. }
  128444. impostor.setDeltaPosition(this._tmpPositionVector);
  128445. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  128446. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  128447. };
  128448. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  128449. //impostor.physicsBody.dispose();
  128450. //Same as : (older oimo versions)
  128451. this.world.removeRigidBody(impostor.physicsBody);
  128452. };
  128453. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  128454. var mainBody = impostorJoint.mainImpostor.physicsBody;
  128455. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  128456. if (!mainBody || !connectedBody) {
  128457. return;
  128458. }
  128459. var jointData = impostorJoint.joint.jointData;
  128460. var options = jointData.nativeParams || {};
  128461. var type;
  128462. var nativeJointData = {
  128463. body1: mainBody,
  128464. body2: connectedBody,
  128465. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  128466. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  128467. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  128468. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  128469. min: options.min,
  128470. max: options.max,
  128471. collision: options.collision || jointData.collision,
  128472. spring: options.spring,
  128473. //supporting older version of Oimo
  128474. world: this.world
  128475. };
  128476. switch (impostorJoint.joint.type) {
  128477. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  128478. type = "jointBall";
  128479. break;
  128480. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  128481. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  128482. var springData = jointData;
  128483. nativeJointData.min = springData.length || nativeJointData.min;
  128484. //Max should also be set, just make sure it is at least min
  128485. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  128486. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  128487. type = "jointDistance";
  128488. nativeJointData.max = jointData.maxDistance;
  128489. break;
  128490. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  128491. type = "jointPrisme";
  128492. break;
  128493. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  128494. type = "jointSlide";
  128495. break;
  128496. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  128497. type = "jointWheel";
  128498. break;
  128499. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  128500. default:
  128501. type = "jointHinge";
  128502. break;
  128503. }
  128504. nativeJointData.type = type;
  128505. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  128506. };
  128507. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  128508. //Bug in Oimo prevents us from disposing a joint in the playground
  128509. //joint.joint.physicsJoint.dispose();
  128510. //So we will bruteforce it!
  128511. try {
  128512. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  128513. }
  128514. catch (e) {
  128515. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  128516. }
  128517. };
  128518. OimoJSPlugin.prototype.isSupported = function () {
  128519. return this.BJSOIMO !== undefined;
  128520. };
  128521. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  128522. if (!impostor.physicsBody.sleeping) {
  128523. //TODO check that
  128524. /*if (impostor.physicsBody.shapes.next) {
  128525. var parentShape = this._getLastShape(impostor.physicsBody);
  128526. impostor.object.position.copyFrom(parentShape.position);
  128527. console.log(parentShape.position);
  128528. } else {*/
  128529. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  128530. //}
  128531. if (impostor.object.rotationQuaternion) {
  128532. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  128533. }
  128534. }
  128535. };
  128536. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  128537. var body = impostor.physicsBody;
  128538. body.position.copy(newPosition);
  128539. body.orientation.copy(newRotation);
  128540. body.syncShapes();
  128541. body.awake();
  128542. };
  128543. /*private _getLastShape(body: any): any {
  128544. var lastShape = body.shapes;
  128545. while (lastShape.next) {
  128546. lastShape = lastShape.next;
  128547. }
  128548. return lastShape;
  128549. }*/
  128550. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  128551. impostor.physicsBody.linearVelocity.copy(velocity);
  128552. };
  128553. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  128554. impostor.physicsBody.angularVelocity.copy(velocity);
  128555. };
  128556. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  128557. var v = impostor.physicsBody.linearVelocity;
  128558. if (!v) {
  128559. return null;
  128560. }
  128561. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  128562. };
  128563. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  128564. var v = impostor.physicsBody.angularVelocity;
  128565. if (!v) {
  128566. return null;
  128567. }
  128568. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  128569. };
  128570. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  128571. var staticBody = mass === 0;
  128572. //this will actually set the body's density and not its mass.
  128573. //But this is how oimo treats the mass variable.
  128574. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  128575. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  128576. };
  128577. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  128578. return impostor.physicsBody.shapes.density;
  128579. };
  128580. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  128581. return impostor.physicsBody.shapes.friction;
  128582. };
  128583. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  128584. impostor.physicsBody.shapes.friction = friction;
  128585. };
  128586. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  128587. return impostor.physicsBody.shapes.restitution;
  128588. };
  128589. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  128590. impostor.physicsBody.shapes.restitution = restitution;
  128591. };
  128592. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  128593. impostor.physicsBody.sleep();
  128594. };
  128595. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  128596. impostor.physicsBody.awake();
  128597. };
  128598. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  128599. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  128600. if (minDistance !== void 0) {
  128601. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  128602. }
  128603. };
  128604. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  128605. if (force !== undefined) {
  128606. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  128607. }
  128608. else {
  128609. force = 1e6;
  128610. }
  128611. speed *= -1;
  128612. //TODO separate rotational and transational motors.
  128613. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  128614. if (motor) {
  128615. motor.setMotor(speed, force);
  128616. }
  128617. };
  128618. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  128619. //TODO separate rotational and transational motors.
  128620. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  128621. if (motor) {
  128622. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  128623. }
  128624. };
  128625. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  128626. var body = impostor.physicsBody;
  128627. mesh.position.x = body.position.x;
  128628. mesh.position.y = body.position.y;
  128629. mesh.position.z = body.position.z;
  128630. if (mesh.rotationQuaternion) {
  128631. mesh.rotationQuaternion.x = body.orientation.x;
  128632. mesh.rotationQuaternion.y = body.orientation.y;
  128633. mesh.rotationQuaternion.z = body.orientation.z;
  128634. mesh.rotationQuaternion.w = body.orientation.s;
  128635. }
  128636. };
  128637. OimoJSPlugin.prototype.getRadius = function (impostor) {
  128638. return impostor.physicsBody.shapes.radius;
  128639. };
  128640. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  128641. var shape = impostor.physicsBody.shapes;
  128642. result.x = shape.halfWidth * 2;
  128643. result.y = shape.halfHeight * 2;
  128644. result.z = shape.halfDepth * 2;
  128645. };
  128646. OimoJSPlugin.prototype.dispose = function () {
  128647. this.world.clear();
  128648. };
  128649. /**
  128650. * Does a raycast in the physics world
  128651. * @param from when should the ray start?
  128652. * @param to when should the ray end?
  128653. * @returns PhysicsRaycastResult
  128654. */
  128655. OimoJSPlugin.prototype.raycast = function (from, to) {
  128656. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  128657. this._raycastResult.reset(from, to);
  128658. return this._raycastResult;
  128659. };
  128660. return OimoJSPlugin;
  128661. }());
  128662. /***/ }),
  128663. /***/ "./Physics/index.ts":
  128664. /*!**************************!*\
  128665. !*** ./Physics/index.ts ***!
  128666. \**************************/
  128667. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  128668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128669. "use strict";
  128670. __webpack_require__.r(__webpack_exports__);
  128671. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  128672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  128673. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  128674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  128675. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  128676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  128677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  128678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  128679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  128680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  128681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  128682. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  128683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  128684. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  128685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  128686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  128687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  128688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  128689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  128690. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  128691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  128692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  128693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  128694. /***/ }),
  128695. /***/ "./Physics/physicsEngine.ts":
  128696. /*!**********************************!*\
  128697. !*** ./Physics/physicsEngine.ts ***!
  128698. \**********************************/
  128699. /*! exports provided: PhysicsEngine */
  128700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128701. "use strict";
  128702. __webpack_require__.r(__webpack_exports__);
  128703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  128704. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  128705. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  128706. /**
  128707. * Class used to control physics engine
  128708. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128709. */
  128710. var PhysicsEngine = /** @class */ (function () {
  128711. /**
  128712. * Creates a new Physics Engine
  128713. * @param gravity defines the gravity vector used by the simulation
  128714. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128715. */
  128716. function PhysicsEngine(gravity, _physicsPlugin) {
  128717. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  128718. this._physicsPlugin = _physicsPlugin;
  128719. this._impostors = [];
  128720. this._joints = [];
  128721. if (!this._physicsPlugin.isSupported()) {
  128722. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  128723. + "Please make sure it is included.");
  128724. }
  128725. gravity = gravity || new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  128726. this.setGravity(gravity);
  128727. this.setTimeStep();
  128728. }
  128729. /**
  128730. * Factory used to create the default physics plugin.
  128731. * @returns The default physics plugin
  128732. */
  128733. PhysicsEngine.DefaultPluginFactory = function () {
  128734. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  128735. };
  128736. /**
  128737. * Sets the gravity vector used by the simulation
  128738. * @param gravity defines the gravity vector to use
  128739. */
  128740. PhysicsEngine.prototype.setGravity = function (gravity) {
  128741. this.gravity = gravity;
  128742. this._physicsPlugin.setGravity(this.gravity);
  128743. };
  128744. /**
  128745. * Set the time step of the physics engine.
  128746. * Default is 1/60.
  128747. * To slow it down, enter 1/600 for example.
  128748. * To speed it up, 1/30
  128749. * @param newTimeStep defines the new timestep to apply to this world.
  128750. */
  128751. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  128752. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  128753. this._physicsPlugin.setTimeStep(newTimeStep);
  128754. };
  128755. /**
  128756. * Get the time step of the physics engine.
  128757. * @returns the current time step
  128758. */
  128759. PhysicsEngine.prototype.getTimeStep = function () {
  128760. return this._physicsPlugin.getTimeStep();
  128761. };
  128762. /**
  128763. * Release all resources
  128764. */
  128765. PhysicsEngine.prototype.dispose = function () {
  128766. this._impostors.forEach(function (impostor) {
  128767. impostor.dispose();
  128768. });
  128769. this._physicsPlugin.dispose();
  128770. };
  128771. /**
  128772. * Gets the name of the current physics plugin
  128773. * @returns the name of the plugin
  128774. */
  128775. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  128776. return this._physicsPlugin.name;
  128777. };
  128778. /**
  128779. * Adding a new impostor for the impostor tracking.
  128780. * This will be done by the impostor itself.
  128781. * @param impostor the impostor to add
  128782. */
  128783. PhysicsEngine.prototype.addImpostor = function (impostor) {
  128784. impostor.uniqueId = this._impostors.push(impostor);
  128785. //if no parent, generate the body
  128786. if (!impostor.parent) {
  128787. this._physicsPlugin.generatePhysicsBody(impostor);
  128788. }
  128789. };
  128790. /**
  128791. * Remove an impostor from the engine.
  128792. * This impostor and its mesh will not longer be updated by the physics engine.
  128793. * @param impostor the impostor to remove
  128794. */
  128795. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  128796. var index = this._impostors.indexOf(impostor);
  128797. if (index > -1) {
  128798. var removed = this._impostors.splice(index, 1);
  128799. //Is it needed?
  128800. if (removed.length) {
  128801. this.getPhysicsPlugin().removePhysicsBody(impostor);
  128802. }
  128803. }
  128804. };
  128805. /**
  128806. * Add a joint to the physics engine
  128807. * @param mainImpostor defines the main impostor to which the joint is added.
  128808. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128809. * @param joint defines the joint that will connect both impostors.
  128810. */
  128811. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  128812. var impostorJoint = {
  128813. mainImpostor: mainImpostor,
  128814. connectedImpostor: connectedImpostor,
  128815. joint: joint
  128816. };
  128817. joint.physicsPlugin = this._physicsPlugin;
  128818. this._joints.push(impostorJoint);
  128819. this._physicsPlugin.generateJoint(impostorJoint);
  128820. };
  128821. /**
  128822. * Removes a joint from the simulation
  128823. * @param mainImpostor defines the impostor used with the joint
  128824. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128825. * @param joint defines the joint to remove
  128826. */
  128827. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  128828. var matchingJoints = this._joints.filter(function (impostorJoint) {
  128829. return (impostorJoint.connectedImpostor === connectedImpostor
  128830. && impostorJoint.joint === joint
  128831. && impostorJoint.mainImpostor === mainImpostor);
  128832. });
  128833. if (matchingJoints.length) {
  128834. this._physicsPlugin.removeJoint(matchingJoints[0]);
  128835. //TODO remove it from the list as well
  128836. }
  128837. };
  128838. /**
  128839. * Called by the scene. No need to call it.
  128840. * @param delta defines the timespam between frames
  128841. */
  128842. PhysicsEngine.prototype._step = function (delta) {
  128843. var _this = this;
  128844. //check if any mesh has no body / requires an update
  128845. this._impostors.forEach(function (impostor) {
  128846. if (impostor.isBodyInitRequired()) {
  128847. _this._physicsPlugin.generatePhysicsBody(impostor);
  128848. }
  128849. });
  128850. if (delta > 0.1) {
  128851. delta = 0.1;
  128852. }
  128853. else if (delta <= 0) {
  128854. delta = 1.0 / 60.0;
  128855. }
  128856. this._physicsPlugin.executeStep(delta, this._impostors);
  128857. };
  128858. /**
  128859. * Gets the current plugin used to run the simulation
  128860. * @returns current plugin
  128861. */
  128862. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  128863. return this._physicsPlugin;
  128864. };
  128865. /**
  128866. * Gets the list of physic impostors
  128867. * @returns an array of PhysicsImpostor
  128868. */
  128869. PhysicsEngine.prototype.getImpostors = function () {
  128870. return this._impostors;
  128871. };
  128872. /**
  128873. * Gets the impostor for a physics enabled object
  128874. * @param object defines the object impersonated by the impostor
  128875. * @returns the PhysicsImpostor or null if not found
  128876. */
  128877. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  128878. for (var i = 0; i < this._impostors.length; ++i) {
  128879. if (this._impostors[i].object === object) {
  128880. return this._impostors[i];
  128881. }
  128882. }
  128883. return null;
  128884. };
  128885. /**
  128886. * Gets the impostor for a physics body object
  128887. * @param body defines physics body used by the impostor
  128888. * @returns the PhysicsImpostor or null if not found
  128889. */
  128890. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  128891. for (var i = 0; i < this._impostors.length; ++i) {
  128892. if (this._impostors[i].physicsBody === body) {
  128893. return this._impostors[i];
  128894. }
  128895. }
  128896. return null;
  128897. };
  128898. /**
  128899. * Does a raycast in the physics world
  128900. * @param from when should the ray start?
  128901. * @param to when should the ray end?
  128902. * @returns PhysicsRaycastResult
  128903. */
  128904. PhysicsEngine.prototype.raycast = function (from, to) {
  128905. return this._physicsPlugin.raycast(from, to);
  128906. };
  128907. /**
  128908. * Global value used to control the smallest number supported by the simulation
  128909. */
  128910. PhysicsEngine.Epsilon = 0.001;
  128911. return PhysicsEngine;
  128912. }());
  128913. /***/ }),
  128914. /***/ "./Physics/physicsEngineComponent.ts":
  128915. /*!*******************************************!*\
  128916. !*** ./Physics/physicsEngineComponent.ts ***!
  128917. \*******************************************/
  128918. /*! exports provided: PhysicsEngineSceneComponent */
  128919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128920. "use strict";
  128921. __webpack_require__.r(__webpack_exports__);
  128922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  128923. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  128924. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  128925. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  128926. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  128927. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128928. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  128929. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  128930. /**
  128931. * Gets the current physics engine
  128932. * @returns a IPhysicsEngine or null if none attached
  128933. */
  128934. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  128935. return this._physicsEngine;
  128936. };
  128937. /**
  128938. * Enables physics to the current scene
  128939. * @param gravity defines the scene's gravity for the physics engine
  128940. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  128941. * @return a boolean indicating if the physics engine was initialized
  128942. */
  128943. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  128944. if (gravity === void 0) { gravity = null; }
  128945. if (this._physicsEngine) {
  128946. return true;
  128947. }
  128948. // Register the component to the scene
  128949. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  128950. if (!component) {
  128951. component = new PhysicsEngineSceneComponent(this);
  128952. this._addComponent(component);
  128953. }
  128954. try {
  128955. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  128956. return true;
  128957. }
  128958. catch (e) {
  128959. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  128960. return false;
  128961. }
  128962. };
  128963. /**
  128964. * Disables and disposes the physics engine associated with the scene
  128965. */
  128966. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  128967. if (!this._physicsEngine) {
  128968. return;
  128969. }
  128970. this._physicsEngine.dispose();
  128971. this._physicsEngine = null;
  128972. };
  128973. /**
  128974. * Gets a boolean indicating if there is an active physics engine
  128975. * @returns a boolean indicating if there is an active physics engine
  128976. */
  128977. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  128978. return this._physicsEngine !== undefined;
  128979. };
  128980. /**
  128981. * Deletes a physics compound impostor
  128982. * @param compound defines the compound to delete
  128983. */
  128984. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  128985. var mesh = compound.parts[0].mesh;
  128986. if (mesh.physicsImpostor) {
  128987. mesh.physicsImpostor.dispose( /*true*/);
  128988. mesh.physicsImpostor = null;
  128989. }
  128990. };
  128991. /** @hidden */
  128992. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  128993. if (this._physicsEngine) {
  128994. this.onBeforePhysicsObservable.notifyObservers(this);
  128995. this._physicsEngine._step(step / 1000);
  128996. this.onAfterPhysicsObservable.notifyObservers(this);
  128997. }
  128998. };
  128999. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  129000. get: function () {
  129001. return this._physicsImpostor;
  129002. },
  129003. set: function (value) {
  129004. var _this = this;
  129005. if (this._physicsImpostor === value) {
  129006. return;
  129007. }
  129008. if (this._disposePhysicsObserver) {
  129009. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  129010. }
  129011. this._physicsImpostor = value;
  129012. if (value) {
  129013. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  129014. // Physics
  129015. if (_this.physicsImpostor) {
  129016. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  129017. _this.physicsImpostor = null;
  129018. }
  129019. });
  129020. }
  129021. },
  129022. enumerable: true,
  129023. configurable: true
  129024. });
  129025. /**
  129026. * Gets the current physics impostor
  129027. * @see http://doc.babylonjs.com/features/physics_engine
  129028. * @returns a physics impostor or null
  129029. */
  129030. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  129031. return this.physicsImpostor;
  129032. };
  129033. /**
  129034. * Apply a physic impulse to the mesh
  129035. * @param force defines the force to apply
  129036. * @param contactPoint defines where to apply the force
  129037. * @returns the current mesh
  129038. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129039. */
  129040. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  129041. if (!this.physicsImpostor) {
  129042. return this;
  129043. }
  129044. this.physicsImpostor.applyImpulse(force, contactPoint);
  129045. return this;
  129046. };
  129047. /**
  129048. * Creates a physic joint between two meshes
  129049. * @param otherMesh defines the other mesh to use
  129050. * @param pivot1 defines the pivot to use on this mesh
  129051. * @param pivot2 defines the pivot to use on the other mesh
  129052. * @param options defines additional options (can be plugin dependent)
  129053. * @returns the current mesh
  129054. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129055. */
  129056. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  129057. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  129058. return this;
  129059. }
  129060. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  129061. mainPivot: pivot1,
  129062. connectedPivot: pivot2,
  129063. nativeParams: options
  129064. });
  129065. return this;
  129066. };
  129067. /**
  129068. * Defines the physics engine scene component responsible to manage a physics engine
  129069. */
  129070. var PhysicsEngineSceneComponent = /** @class */ (function () {
  129071. /**
  129072. * Creates a new instance of the component for the given scene
  129073. * @param scene Defines the scene to register the component in
  129074. */
  129075. function PhysicsEngineSceneComponent(scene) {
  129076. var _this = this;
  129077. /**
  129078. * The component name helpful to identify the component in the list of scene components.
  129079. */
  129080. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  129081. this.scene = scene;
  129082. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  129083. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  129084. // Replace the function used to get the deterministic frame time
  129085. this.scene.getDeterministicFrameTime = function () {
  129086. if (_this.scene._physicsEngine) {
  129087. return _this.scene._physicsEngine.getTimeStep() * 1000;
  129088. }
  129089. return 1000.0 / 60.0;
  129090. };
  129091. }
  129092. /**
  129093. * Registers the component in a given scene
  129094. */
  129095. PhysicsEngineSceneComponent.prototype.register = function () {
  129096. };
  129097. /**
  129098. * Rebuilds the elements related to this component in case of
  129099. * context lost for instance.
  129100. */
  129101. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  129102. // Nothing to do for this component
  129103. };
  129104. /**
  129105. * Disposes the component and the associated ressources
  129106. */
  129107. PhysicsEngineSceneComponent.prototype.dispose = function () {
  129108. this.scene.onBeforePhysicsObservable.clear();
  129109. this.scene.onAfterPhysicsObservable.clear();
  129110. if (this.scene._physicsEngine) {
  129111. this.scene.disablePhysicsEngine();
  129112. }
  129113. };
  129114. return PhysicsEngineSceneComponent;
  129115. }());
  129116. /***/ }),
  129117. /***/ "./Physics/physicsHelper.ts":
  129118. /*!**********************************!*\
  129119. !*** ./Physics/physicsHelper.ts ***!
  129120. \**********************************/
  129121. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  129122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129123. "use strict";
  129124. __webpack_require__.r(__webpack_exports__);
  129125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  129126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  129127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  129128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  129129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  129130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  129131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  129132. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  129133. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  129134. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  129135. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  129136. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  129137. /**
  129138. * A helper for physics simulations
  129139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129140. */
  129141. var PhysicsHelper = /** @class */ (function () {
  129142. /**
  129143. * Initializes the Physics helper
  129144. * @param scene Babylon.js scene
  129145. */
  129146. function PhysicsHelper(scene) {
  129147. this._scene = scene;
  129148. this._physicsEngine = this._scene.getPhysicsEngine();
  129149. if (!this._physicsEngine) {
  129150. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  129151. return;
  129152. }
  129153. }
  129154. /**
  129155. * Applies a radial explosion impulse
  129156. * @param origin the origin of the explosion
  129157. * @param radiusOrEventOptions the radius or the options of radial explosion
  129158. * @param strength the explosion strength
  129159. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129160. * @returns A physics radial explosion event, or null
  129161. */
  129162. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  129163. if (!this._physicsEngine) {
  129164. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  129165. return null;
  129166. }
  129167. var impostors = this._physicsEngine.getImpostors();
  129168. if (impostors.length === 0) {
  129169. return null;
  129170. }
  129171. if (typeof radiusOrEventOptions === 'number') {
  129172. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  129173. radiusOrEventOptions.radius = radiusOrEventOptions;
  129174. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  129175. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  129176. }
  129177. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  129178. var affectedImpostorsWithData = Array();
  129179. impostors.forEach(function (impostor) {
  129180. var impostorHitData = event.getImpostorHitData(impostor, origin);
  129181. if (!impostorHitData) {
  129182. return;
  129183. }
  129184. impostor.applyImpulse(impostorHitData.force, impostorHitData.contactPoint);
  129185. affectedImpostorsWithData.push({
  129186. impostor: impostor,
  129187. hitData: impostorHitData,
  129188. });
  129189. });
  129190. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  129191. event.dispose(false);
  129192. return event;
  129193. };
  129194. /**
  129195. * Applies a radial explosion force
  129196. * @param origin the origin of the explosion
  129197. * @param radiusOrEventOptions the radius or the options of radial explosion
  129198. * @param strength the explosion strength
  129199. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129200. * @returns A physics radial explosion event, or null
  129201. */
  129202. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  129203. if (!this._physicsEngine) {
  129204. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  129205. return null;
  129206. }
  129207. var impostors = this._physicsEngine.getImpostors();
  129208. if (impostors.length === 0) {
  129209. return null;
  129210. }
  129211. if (typeof radiusOrEventOptions === 'number') {
  129212. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  129213. radiusOrEventOptions.radius = radiusOrEventOptions;
  129214. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  129215. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  129216. }
  129217. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  129218. var affectedImpostorsWithData = Array();
  129219. impostors.forEach(function (impostor) {
  129220. var impostorHitData = event.getImpostorHitData(impostor, origin);
  129221. if (!impostorHitData) {
  129222. return;
  129223. }
  129224. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  129225. affectedImpostorsWithData.push({
  129226. impostor: impostor,
  129227. hitData: impostorHitData,
  129228. });
  129229. });
  129230. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  129231. event.dispose(false);
  129232. return event;
  129233. };
  129234. /**
  129235. * Creates a gravitational field
  129236. * @param origin the origin of the explosion
  129237. * @param radiusOrEventOptions the radius or the options of radial explosion
  129238. * @param strength the explosion strength
  129239. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129240. * @returns A physics gravitational field event, or null
  129241. */
  129242. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  129243. if (!this._physicsEngine) {
  129244. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  129245. return null;
  129246. }
  129247. var impostors = this._physicsEngine.getImpostors();
  129248. if (impostors.length === 0) {
  129249. return null;
  129250. }
  129251. if (typeof radiusOrEventOptions === 'number') {
  129252. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  129253. radiusOrEventOptions.radius = radiusOrEventOptions;
  129254. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  129255. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  129256. }
  129257. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  129258. event.dispose(false);
  129259. return event;
  129260. };
  129261. /**
  129262. * Creates a physics updraft event
  129263. * @param origin the origin of the updraft
  129264. * @param radiusOrEventOptions the radius or the options of the updraft
  129265. * @param strength the strength of the updraft
  129266. * @param height the height of the updraft
  129267. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129268. * @returns A physics updraft event, or null
  129269. */
  129270. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  129271. if (!this._physicsEngine) {
  129272. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  129273. return null;
  129274. }
  129275. if (this._physicsEngine.getImpostors().length === 0) {
  129276. return null;
  129277. }
  129278. if (typeof radiusOrEventOptions === 'number') {
  129279. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  129280. radiusOrEventOptions.radius = radiusOrEventOptions;
  129281. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  129282. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  129283. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  129284. }
  129285. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  129286. event.dispose(false);
  129287. return event;
  129288. };
  129289. /**
  129290. * Creates a physics vortex event
  129291. * @param origin the of the vortex
  129292. * @param radiusOrEventOptions the radius or the options of the vortex
  129293. * @param strength the strength of the vortex
  129294. * @param height the height of the vortex
  129295. * @returns a Physics vortex event, or null
  129296. * A physics vortex event or null
  129297. */
  129298. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  129299. if (!this._physicsEngine) {
  129300. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  129301. return null;
  129302. }
  129303. if (this._physicsEngine.getImpostors().length === 0) {
  129304. return null;
  129305. }
  129306. if (typeof radiusOrEventOptions === 'number') {
  129307. radiusOrEventOptions = new PhysicsVortexEventOptions();
  129308. radiusOrEventOptions.radius = radiusOrEventOptions;
  129309. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  129310. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  129311. }
  129312. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  129313. event.dispose(false);
  129314. return event;
  129315. };
  129316. return PhysicsHelper;
  129317. }());
  129318. /**
  129319. * Represents a physics radial explosion event
  129320. */
  129321. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  129322. /**
  129323. * Initializes a radial explosioin event
  129324. * @param _scene BabylonJS scene
  129325. * @param _options The options for the vortex event
  129326. */
  129327. function PhysicsRadialExplosionEvent(_scene, _options) {
  129328. this._scene = _scene;
  129329. this._options = _options;
  129330. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  129331. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  129332. }
  129333. /**
  129334. * Returns the data related to the radial explosion event (sphere).
  129335. * @returns The radial explosion event data
  129336. */
  129337. PhysicsRadialExplosionEvent.prototype.getData = function () {
  129338. this._dataFetched = true;
  129339. return {
  129340. sphere: this._sphere,
  129341. };
  129342. };
  129343. /**
  129344. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129345. * @param impostor A physics imposter
  129346. * @param origin the origin of the explosion
  129347. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129348. */
  129349. PhysicsRadialExplosionEvent.prototype.getImpostorHitData = function (impostor, origin) {
  129350. if (impostor.mass === 0) {
  129351. return null;
  129352. }
  129353. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  129354. return null;
  129355. }
  129356. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  129357. return null;
  129358. }
  129359. var impostorObjectCenter = impostor.getObjectCenter();
  129360. var direction = impostorObjectCenter.subtract(origin);
  129361. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  129362. var hit = ray.intersectsMesh(impostor.object);
  129363. var contactPoint = hit.pickedPoint;
  129364. if (!contactPoint) {
  129365. return null;
  129366. }
  129367. var distanceFromOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  129368. if (distanceFromOrigin > this._options.radius) {
  129369. return null;
  129370. }
  129371. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  129372. ? this._options.strength
  129373. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  129374. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  129375. return { force: force, contactPoint: contactPoint, distanceFromOrigin: distanceFromOrigin };
  129376. };
  129377. /**
  129378. * Triggers affecterd impostors callbacks
  129379. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129380. */
  129381. PhysicsRadialExplosionEvent.prototype.triggerAffectedImpostorsCallback = function (affectedImpostorsWithData) {
  129382. if (this._options.affectedImpostorsCallback) {
  129383. this._options.affectedImpostorsCallback(affectedImpostorsWithData);
  129384. }
  129385. };
  129386. /**
  129387. * Disposes the sphere.
  129388. * @param force Specifies if the sphere should be disposed by force
  129389. */
  129390. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  129391. var _this = this;
  129392. if (force === void 0) { force = true; }
  129393. if (force) {
  129394. this._sphere.dispose();
  129395. }
  129396. else {
  129397. setTimeout(function () {
  129398. if (!_this._dataFetched) {
  129399. _this._sphere.dispose();
  129400. }
  129401. }, 0);
  129402. }
  129403. };
  129404. /*** Helpers ***/
  129405. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  129406. if (!this._sphere) {
  129407. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  129408. this._sphere.isVisible = false;
  129409. }
  129410. };
  129411. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  129412. var impostorObject = impostor.object;
  129413. this._prepareSphere();
  129414. this._sphere.position = origin;
  129415. this._sphere.scaling = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  129416. this._sphere._updateBoundingInfo();
  129417. this._sphere.computeWorldMatrix(true);
  129418. return this._sphere.intersectsMesh(impostorObject, true);
  129419. };
  129420. return PhysicsRadialExplosionEvent;
  129421. }());
  129422. /**
  129423. * Represents a gravitational field event
  129424. */
  129425. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  129426. /**
  129427. * Initializes the physics gravitational field event
  129428. * @param _physicsHelper A physics helper
  129429. * @param _scene BabylonJS scene
  129430. * @param _origin The origin position of the gravitational field event
  129431. * @param _options The options for the vortex event
  129432. */
  129433. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  129434. this._physicsHelper = _physicsHelper;
  129435. this._scene = _scene;
  129436. this._origin = _origin;
  129437. this._options = _options;
  129438. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  129439. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  129440. this._tickCallback = this._tick.bind(this);
  129441. this._options.strength = this._options.strength * -1;
  129442. }
  129443. /**
  129444. * Returns the data related to the gravitational field event (sphere).
  129445. * @returns A gravitational field event
  129446. */
  129447. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  129448. this._dataFetched = true;
  129449. return {
  129450. sphere: this._sphere,
  129451. };
  129452. };
  129453. /**
  129454. * Enables the gravitational field.
  129455. */
  129456. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  129457. this._tickCallback.call(this);
  129458. this._scene.registerBeforeRender(this._tickCallback);
  129459. };
  129460. /**
  129461. * Disables the gravitational field.
  129462. */
  129463. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  129464. this._scene.unregisterBeforeRender(this._tickCallback);
  129465. };
  129466. /**
  129467. * Disposes the sphere.
  129468. * @param force The force to dispose from the gravitational field event
  129469. */
  129470. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  129471. var _this = this;
  129472. if (force === void 0) { force = true; }
  129473. if (force) {
  129474. this._sphere.dispose();
  129475. }
  129476. else {
  129477. setTimeout(function () {
  129478. if (!_this._dataFetched) {
  129479. _this._sphere.dispose();
  129480. }
  129481. }, 0);
  129482. }
  129483. };
  129484. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  129485. // Since the params won't change, we fetch the event only once
  129486. if (this._sphere) {
  129487. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  129488. }
  129489. else {
  129490. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  129491. if (radialExplosionEvent) {
  129492. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  129493. }
  129494. }
  129495. };
  129496. return PhysicsGravitationalFieldEvent;
  129497. }());
  129498. /**
  129499. * Represents a physics updraft event
  129500. */
  129501. var PhysicsUpdraftEvent = /** @class */ (function () {
  129502. /**
  129503. * Initializes the physics updraft event
  129504. * @param _scene BabylonJS scene
  129505. * @param _origin The origin position of the updraft
  129506. * @param _options The options for the updraft event
  129507. */
  129508. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  129509. this._scene = _scene;
  129510. this._origin = _origin;
  129511. this._options = _options;
  129512. this._originTop = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  129513. this._originDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  129514. this._cylinderPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  129515. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  129516. this._physicsEngine = this._scene.getPhysicsEngine();
  129517. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  129518. this._origin.addToRef(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  129519. this._origin.addToRef(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  129520. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  129521. this._originDirection = this._origin.subtract(this._originTop).normalize();
  129522. }
  129523. this._tickCallback = this._tick.bind(this);
  129524. this._prepareCylinder();
  129525. }
  129526. /**
  129527. * Returns the data related to the updraft event (cylinder).
  129528. * @returns A physics updraft event
  129529. */
  129530. PhysicsUpdraftEvent.prototype.getData = function () {
  129531. this._dataFetched = true;
  129532. return {
  129533. cylinder: this._cylinder,
  129534. };
  129535. };
  129536. /**
  129537. * Enables the updraft.
  129538. */
  129539. PhysicsUpdraftEvent.prototype.enable = function () {
  129540. this._tickCallback.call(this);
  129541. this._scene.registerBeforeRender(this._tickCallback);
  129542. };
  129543. /**
  129544. * Disables the updraft.
  129545. */
  129546. PhysicsUpdraftEvent.prototype.disable = function () {
  129547. this._scene.unregisterBeforeRender(this._tickCallback);
  129548. };
  129549. /**
  129550. * Disposes the cylinder.
  129551. * @param force Specifies if the updraft should be disposed by force
  129552. */
  129553. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  129554. var _this = this;
  129555. if (force === void 0) { force = true; }
  129556. if (!this._cylinder) {
  129557. return;
  129558. }
  129559. if (force) {
  129560. this._cylinder.dispose();
  129561. }
  129562. else {
  129563. setTimeout(function () {
  129564. if (!_this._dataFetched) {
  129565. _this._cylinder.dispose();
  129566. }
  129567. }, 0);
  129568. }
  129569. };
  129570. PhysicsUpdraftEvent.prototype.getImpostorHitData = function (impostor) {
  129571. if (impostor.mass === 0) {
  129572. return null;
  129573. }
  129574. if (!this._intersectsWithCylinder(impostor)) {
  129575. return null;
  129576. }
  129577. var impostorObjectCenter = impostor.getObjectCenter();
  129578. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  129579. var direction = this._originDirection;
  129580. }
  129581. else {
  129582. var direction = impostorObjectCenter.subtract(this._originTop);
  129583. }
  129584. var distanceFromOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(this._origin, impostorObjectCenter);
  129585. var multiplier = this._options.strength * -1;
  129586. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  129587. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: distanceFromOrigin };
  129588. };
  129589. PhysicsUpdraftEvent.prototype._tick = function () {
  129590. var _this = this;
  129591. this._physicsEngine.getImpostors().forEach(function (impostor) {
  129592. var impostorHitData = _this.getImpostorHitData(impostor);
  129593. if (!impostorHitData) {
  129594. return;
  129595. }
  129596. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  129597. });
  129598. };
  129599. /*** Helpers ***/
  129600. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  129601. if (!this._cylinder) {
  129602. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  129603. height: this._options.height,
  129604. diameter: this._options.radius * 2,
  129605. }, this._scene);
  129606. this._cylinder.isVisible = false;
  129607. }
  129608. };
  129609. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  129610. var impostorObject = impostor.object;
  129611. this._cylinder.position = this._cylinderPosition;
  129612. return this._cylinder.intersectsMesh(impostorObject, true);
  129613. };
  129614. return PhysicsUpdraftEvent;
  129615. }());
  129616. /**
  129617. * Represents a physics vortex event
  129618. */
  129619. var PhysicsVortexEvent = /** @class */ (function () {
  129620. /**
  129621. * Initializes the physics vortex event
  129622. * @param _scene The BabylonJS scene
  129623. * @param _origin The origin position of the vortex
  129624. * @param _options The options for the vortex event
  129625. */
  129626. function PhysicsVortexEvent(_scene, _origin, _options) {
  129627. this._scene = _scene;
  129628. this._origin = _origin;
  129629. this._options = _options;
  129630. this._originTop = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  129631. this._cylinderPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  129632. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  129633. this._physicsEngine = this._scene.getPhysicsEngine();
  129634. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  129635. this._origin.addToRef(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  129636. this._origin.addToRef(new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  129637. this._tickCallback = this._tick.bind(this);
  129638. this._prepareCylinder();
  129639. }
  129640. /**
  129641. * Returns the data related to the vortex event (cylinder).
  129642. * @returns The physics vortex event data
  129643. */
  129644. PhysicsVortexEvent.prototype.getData = function () {
  129645. this._dataFetched = true;
  129646. return {
  129647. cylinder: this._cylinder,
  129648. };
  129649. };
  129650. /**
  129651. * Enables the vortex.
  129652. */
  129653. PhysicsVortexEvent.prototype.enable = function () {
  129654. this._tickCallback.call(this);
  129655. this._scene.registerBeforeRender(this._tickCallback);
  129656. };
  129657. /**
  129658. * Disables the cortex.
  129659. */
  129660. PhysicsVortexEvent.prototype.disable = function () {
  129661. this._scene.unregisterBeforeRender(this._tickCallback);
  129662. };
  129663. /**
  129664. * Disposes the sphere.
  129665. * @param force
  129666. */
  129667. PhysicsVortexEvent.prototype.dispose = function (force) {
  129668. var _this = this;
  129669. if (force === void 0) { force = true; }
  129670. if (force) {
  129671. this._cylinder.dispose();
  129672. }
  129673. else {
  129674. setTimeout(function () {
  129675. if (!_this._dataFetched) {
  129676. _this._cylinder.dispose();
  129677. }
  129678. }, 0);
  129679. }
  129680. };
  129681. PhysicsVortexEvent.prototype.getImpostorHitData = function (impostor) {
  129682. if (impostor.mass === 0) {
  129683. return null;
  129684. }
  129685. if (!this._intersectsWithCylinder(impostor)) {
  129686. return null;
  129687. }
  129688. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  129689. return null;
  129690. }
  129691. var impostorObjectCenter = impostor.getObjectCenter();
  129692. var originOnPlane = new _Maths_math_vector__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)
  129693. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  129694. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  129695. var hit = ray.intersectsMesh(impostor.object);
  129696. var contactPoint = hit.pickedPoint;
  129697. if (!contactPoint) {
  129698. return null;
  129699. }
  129700. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  129701. var directionToOrigin = contactPoint.normalize();
  129702. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  129703. directionToOrigin = directionToOrigin.negate();
  129704. }
  129705. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  129706. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  129707. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  129708. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  129709. }
  129710. else {
  129711. var perpendicularDirection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  129712. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  129713. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  129714. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  129715. }
  129716. var force = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  129717. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  129718. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: absoluteDistanceFromOrigin };
  129719. };
  129720. PhysicsVortexEvent.prototype._tick = function () {
  129721. var _this = this;
  129722. this._physicsEngine.getImpostors().forEach(function (impostor) {
  129723. var impostorHitData = _this.getImpostorHitData(impostor);
  129724. if (!impostorHitData) {
  129725. return;
  129726. }
  129727. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  129728. });
  129729. };
  129730. /*** Helpers ***/
  129731. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  129732. if (!this._cylinder) {
  129733. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  129734. height: this._options.height,
  129735. diameter: this._options.radius * 2,
  129736. }, this._scene);
  129737. this._cylinder.isVisible = false;
  129738. }
  129739. };
  129740. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  129741. var impostorObject = impostor.object;
  129742. this._cylinder.position = this._cylinderPosition;
  129743. return this._cylinder.intersectsMesh(impostorObject, true);
  129744. };
  129745. return PhysicsVortexEvent;
  129746. }());
  129747. /**
  129748. * Options fot the radial explosion event
  129749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129750. */
  129751. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  129752. function PhysicsRadialExplosionEventOptions() {
  129753. /**
  129754. * The radius of the sphere for the radial explosion.
  129755. */
  129756. this.radius = 5;
  129757. /**
  129758. * The strenth of the explosion.
  129759. */
  129760. this.strength = 10;
  129761. /**
  129762. * The strenght of the force in correspondence to the distance of the affected object
  129763. */
  129764. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  129765. /**
  129766. * Sphere options for the radial explosion.
  129767. */
  129768. this.sphere = { segments: 32, diameter: 1 };
  129769. }
  129770. return PhysicsRadialExplosionEventOptions;
  129771. }());
  129772. /**
  129773. * Options fot the updraft event
  129774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129775. */
  129776. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  129777. function PhysicsUpdraftEventOptions() {
  129778. /**
  129779. * The radius of the cylinder for the vortex
  129780. */
  129781. this.radius = 5;
  129782. /**
  129783. * The strenth of the updraft.
  129784. */
  129785. this.strength = 10;
  129786. /**
  129787. * The height of the cylinder for the updraft.
  129788. */
  129789. this.height = 10;
  129790. /**
  129791. * The mode for the the updraft.
  129792. */
  129793. this.updraftMode = PhysicsUpdraftMode.Center;
  129794. }
  129795. return PhysicsUpdraftEventOptions;
  129796. }());
  129797. /**
  129798. * Options fot the vortex event
  129799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129800. */
  129801. var PhysicsVortexEventOptions = /** @class */ (function () {
  129802. function PhysicsVortexEventOptions() {
  129803. /**
  129804. * The radius of the cylinder for the vortex
  129805. */
  129806. this.radius = 5;
  129807. /**
  129808. * The strenth of the vortex.
  129809. */
  129810. this.strength = 10;
  129811. /**
  129812. * The height of the cylinder for the vortex.
  129813. */
  129814. this.height = 10;
  129815. /**
  129816. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129817. */
  129818. this.centripetalForceThreshold = 0.7;
  129819. /**
  129820. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129821. */
  129822. this.centripetalForceMultiplier = 5;
  129823. /**
  129824. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129825. */
  129826. this.centrifugalForceMultiplier = 0.5;
  129827. /**
  129828. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129829. */
  129830. this.updraftForceMultiplier = 0.02;
  129831. }
  129832. return PhysicsVortexEventOptions;
  129833. }());
  129834. /**
  129835. * The strenght of the force in correspondence to the distance of the affected object
  129836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129837. */
  129838. var PhysicsRadialImpulseFalloff;
  129839. (function (PhysicsRadialImpulseFalloff) {
  129840. /** Defines that impulse is constant in strength across it's whole radius */
  129841. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  129842. /** Defines that impulse gets weaker if it's further from the origin */
  129843. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  129844. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  129845. /**
  129846. * The strength of the force in correspondence to the distance of the affected object
  129847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129848. */
  129849. var PhysicsUpdraftMode;
  129850. (function (PhysicsUpdraftMode) {
  129851. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129852. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  129853. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129854. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  129855. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  129856. /***/ }),
  129857. /***/ "./Physics/physicsImpostor.ts":
  129858. /*!************************************!*\
  129859. !*** ./Physics/physicsImpostor.ts ***!
  129860. \************************************/
  129861. /*! exports provided: PhysicsImpostor */
  129862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129863. "use strict";
  129864. __webpack_require__.r(__webpack_exports__);
  129865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  129866. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  129867. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  129868. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  129869. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  129870. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  129871. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  129872. /* harmony import */ var _Maths_math_axis__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math.axis */ "./Maths/math.axis.ts");
  129873. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  129874. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  129875. mass: jsonObject.physicsMass,
  129876. friction: jsonObject.physicsFriction,
  129877. restitution: jsonObject.physicsRestitution
  129878. }, scene);
  129879. };
  129880. /**
  129881. * Represents a physics imposter
  129882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129883. */
  129884. var PhysicsImpostor = /** @class */ (function () {
  129885. /**
  129886. * Initializes the physics imposter
  129887. * @param object The physics-enabled object used as the physics imposter
  129888. * @param type The type of the physics imposter
  129889. * @param _options The options for the physics imposter
  129890. * @param _scene The Babylon scene
  129891. */
  129892. function PhysicsImpostor(
  129893. /**
  129894. * The physics-enabled object used as the physics imposter
  129895. */
  129896. object,
  129897. /**
  129898. * The type of the physics imposter
  129899. */
  129900. type, _options, _scene) {
  129901. var _this = this;
  129902. if (_options === void 0) { _options = { mass: 0 }; }
  129903. this.object = object;
  129904. this.type = type;
  129905. this._options = _options;
  129906. this._scene = _scene;
  129907. /** @hidden */
  129908. this._pluginData = {};
  129909. this._bodyUpdateRequired = false;
  129910. this._onBeforePhysicsStepCallbacks = new Array();
  129911. this._onAfterPhysicsStepCallbacks = new Array();
  129912. /** @hidden */
  129913. this._onPhysicsCollideCallbacks = [];
  129914. this._deltaPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  129915. this._isDisposed = false;
  129916. /**
  129917. * @hidden
  129918. */
  129919. this.soft = false;
  129920. /**
  129921. * @hidden
  129922. */
  129923. this.segments = 0;
  129924. //temp variables for parent rotation calculations
  129925. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  129926. this._tmpQuat = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  129927. this._tmpQuat2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  129928. /**
  129929. * this function is executed by the physics engine.
  129930. */
  129931. this.beforeStep = function () {
  129932. if (!_this._physicsEngine) {
  129933. return;
  129934. }
  129935. _this.object.translate(_this._deltaPosition, -1);
  129936. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  129937. _this.object.computeWorldMatrix(false);
  129938. if (_this.object.parent && _this.object.rotationQuaternion) {
  129939. _this.getParentsRotation();
  129940. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  129941. }
  129942. else {
  129943. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  129944. }
  129945. if (!_this._options.disableBidirectionalTransformation) {
  129946. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  129947. }
  129948. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  129949. func(_this);
  129950. });
  129951. };
  129952. /**
  129953. * this function is executed by the physics engine
  129954. */
  129955. this.afterStep = function () {
  129956. if (!_this._physicsEngine) {
  129957. return;
  129958. }
  129959. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  129960. func(_this);
  129961. });
  129962. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  129963. // object has now its world rotation. needs to be converted to local.
  129964. if (_this.object.parent && _this.object.rotationQuaternion) {
  129965. _this.getParentsRotation();
  129966. _this._tmpQuat.conjugateInPlace();
  129967. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  129968. }
  129969. // take the position set and make it the absolute position of this object.
  129970. _this.object.setAbsolutePosition(_this.object.position);
  129971. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  129972. _this.object.translate(_this._deltaPosition, 1);
  129973. };
  129974. /**
  129975. * Legacy collision detection event support
  129976. */
  129977. this.onCollideEvent = null;
  129978. /**
  129979. * event and body object due to cannon's event-based architecture.
  129980. */
  129981. this.onCollide = function (e) {
  129982. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  129983. return;
  129984. }
  129985. if (!_this._physicsEngine) {
  129986. return;
  129987. }
  129988. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  129989. if (otherImpostor) {
  129990. // Legacy collision detection event support
  129991. if (_this.onCollideEvent) {
  129992. _this.onCollideEvent(_this, otherImpostor);
  129993. }
  129994. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  129995. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  129996. }).forEach(function (obj) {
  129997. obj.callback(_this, otherImpostor);
  129998. });
  129999. }
  130000. };
  130001. //sanity check!
  130002. if (!this.object) {
  130003. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  130004. return;
  130005. }
  130006. if (this.object.parent && _options.mass !== 0) {
  130007. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur.");
  130008. }
  130009. // Legacy support for old syntax.
  130010. if (!this._scene && object.getScene) {
  130011. this._scene = object.getScene();
  130012. }
  130013. if (!this._scene) {
  130014. return;
  130015. }
  130016. if (this.type > 100) {
  130017. this.soft = true;
  130018. }
  130019. this._physicsEngine = this._scene.getPhysicsEngine();
  130020. if (!this._physicsEngine) {
  130021. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  130022. }
  130023. else {
  130024. //set the object's quaternion, if not set
  130025. if (!this.object.rotationQuaternion) {
  130026. if (this.object.rotation) {
  130027. this.object.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  130028. }
  130029. else {
  130030. this.object.rotationQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  130031. }
  130032. }
  130033. //default options params
  130034. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  130035. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  130036. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  130037. if (this.soft) {
  130038. //softbody mass must be above 0;
  130039. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  130040. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  130041. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  130042. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  130043. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  130044. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  130045. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  130046. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  130047. this._options.path = (_options.path === void 0) ? null : _options.path;
  130048. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  130049. }
  130050. this._joints = [];
  130051. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  130052. if (!this.object.parent || this._options.ignoreParent) {
  130053. this._init();
  130054. }
  130055. else if (this.object.parent.physicsImpostor) {
  130056. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  130057. }
  130058. }
  130059. }
  130060. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  130061. /**
  130062. * Specifies if the physics imposter is disposed
  130063. */
  130064. get: function () {
  130065. return this._isDisposed;
  130066. },
  130067. enumerable: true,
  130068. configurable: true
  130069. });
  130070. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  130071. /**
  130072. * Gets the mass of the physics imposter
  130073. */
  130074. get: function () {
  130075. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  130076. },
  130077. set: function (value) {
  130078. this.setMass(value);
  130079. },
  130080. enumerable: true,
  130081. configurable: true
  130082. });
  130083. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  130084. /**
  130085. * Gets the coefficient of friction
  130086. */
  130087. get: function () {
  130088. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  130089. },
  130090. /**
  130091. * Sets the coefficient of friction
  130092. */
  130093. set: function (value) {
  130094. if (!this._physicsEngine) {
  130095. return;
  130096. }
  130097. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  130098. },
  130099. enumerable: true,
  130100. configurable: true
  130101. });
  130102. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  130103. /**
  130104. * Gets the coefficient of restitution
  130105. */
  130106. get: function () {
  130107. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  130108. },
  130109. /**
  130110. * Sets the coefficient of restitution
  130111. */
  130112. set: function (value) {
  130113. if (!this._physicsEngine) {
  130114. return;
  130115. }
  130116. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  130117. },
  130118. enumerable: true,
  130119. configurable: true
  130120. });
  130121. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  130122. /**
  130123. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  130124. */
  130125. get: function () {
  130126. if (!this._physicsEngine) {
  130127. return 0;
  130128. }
  130129. var plugin = this._physicsEngine.getPhysicsPlugin();
  130130. if (!plugin.setBodyPressure) {
  130131. return 0;
  130132. }
  130133. return plugin.getBodyPressure(this);
  130134. },
  130135. /**
  130136. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  130137. */
  130138. set: function (value) {
  130139. if (!this._physicsEngine) {
  130140. return;
  130141. }
  130142. var plugin = this._physicsEngine.getPhysicsPlugin();
  130143. if (!plugin.setBodyPressure) {
  130144. return;
  130145. }
  130146. plugin.setBodyPressure(this, value);
  130147. },
  130148. enumerable: true,
  130149. configurable: true
  130150. });
  130151. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  130152. /**
  130153. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  130154. */
  130155. get: function () {
  130156. if (!this._physicsEngine) {
  130157. return 0;
  130158. }
  130159. var plugin = this._physicsEngine.getPhysicsPlugin();
  130160. if (!plugin.getBodyStiffness) {
  130161. return 0;
  130162. }
  130163. return plugin.getBodyStiffness(this);
  130164. },
  130165. /**
  130166. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  130167. */
  130168. set: function (value) {
  130169. if (!this._physicsEngine) {
  130170. return;
  130171. }
  130172. var plugin = this._physicsEngine.getPhysicsPlugin();
  130173. if (!plugin.setBodyStiffness) {
  130174. return;
  130175. }
  130176. plugin.setBodyStiffness(this, value);
  130177. },
  130178. enumerable: true,
  130179. configurable: true
  130180. });
  130181. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  130182. /**
  130183. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  130184. */
  130185. get: function () {
  130186. if (!this._physicsEngine) {
  130187. return 0;
  130188. }
  130189. var plugin = this._physicsEngine.getPhysicsPlugin();
  130190. if (!plugin.getBodyVelocityIterations) {
  130191. return 0;
  130192. }
  130193. return plugin.getBodyVelocityIterations(this);
  130194. },
  130195. /**
  130196. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  130197. */
  130198. set: function (value) {
  130199. if (!this._physicsEngine) {
  130200. return;
  130201. }
  130202. var plugin = this._physicsEngine.getPhysicsPlugin();
  130203. if (!plugin.setBodyVelocityIterations) {
  130204. return;
  130205. }
  130206. plugin.setBodyVelocityIterations(this, value);
  130207. },
  130208. enumerable: true,
  130209. configurable: true
  130210. });
  130211. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  130212. /**
  130213. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  130214. */
  130215. get: function () {
  130216. if (!this._physicsEngine) {
  130217. return 0;
  130218. }
  130219. var plugin = this._physicsEngine.getPhysicsPlugin();
  130220. if (!plugin.getBodyPositionIterations) {
  130221. return 0;
  130222. }
  130223. return plugin.getBodyPositionIterations(this);
  130224. },
  130225. /**
  130226. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  130227. */
  130228. set: function (value) {
  130229. if (!this._physicsEngine) {
  130230. return;
  130231. }
  130232. var plugin = this._physicsEngine.getPhysicsPlugin();
  130233. if (!plugin.setBodyPositionIterations) {
  130234. return;
  130235. }
  130236. plugin.setBodyPositionIterations(this, value);
  130237. },
  130238. enumerable: true,
  130239. configurable: true
  130240. });
  130241. /**
  130242. * This function will completly initialize this impostor.
  130243. * It will create a new body - but only if this mesh has no parent.
  130244. * If it has, this impostor will not be used other than to define the impostor
  130245. * of the child mesh.
  130246. * @hidden
  130247. */
  130248. PhysicsImpostor.prototype._init = function () {
  130249. if (!this._physicsEngine) {
  130250. return;
  130251. }
  130252. this._physicsEngine.removeImpostor(this);
  130253. this.physicsBody = null;
  130254. this._parent = this._parent || this._getPhysicsParent();
  130255. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  130256. this._physicsEngine.addImpostor(this);
  130257. }
  130258. };
  130259. PhysicsImpostor.prototype._getPhysicsParent = function () {
  130260. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  130261. var parentMesh = this.object.parent;
  130262. return parentMesh.physicsImpostor;
  130263. }
  130264. return null;
  130265. };
  130266. /**
  130267. * Should a new body be generated.
  130268. * @returns boolean specifying if body initialization is required
  130269. */
  130270. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  130271. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  130272. };
  130273. /**
  130274. * Sets the updated scaling
  130275. * @param updated Specifies if the scaling is updated
  130276. */
  130277. PhysicsImpostor.prototype.setScalingUpdated = function () {
  130278. this.forceUpdate();
  130279. };
  130280. /**
  130281. * Force a regeneration of this or the parent's impostor's body.
  130282. * Use under cautious - This will remove all joints already implemented.
  130283. */
  130284. PhysicsImpostor.prototype.forceUpdate = function () {
  130285. this._init();
  130286. if (this.parent && !this._options.ignoreParent) {
  130287. this.parent.forceUpdate();
  130288. }
  130289. };
  130290. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  130291. /*public get mesh(): AbstractMesh {
  130292. return this._mesh;
  130293. }*/
  130294. /**
  130295. * Gets the body that holds this impostor. Either its own, or its parent.
  130296. */
  130297. get: function () {
  130298. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  130299. },
  130300. /**
  130301. * Set the physics body. Used mainly by the physics engine/plugin
  130302. */
  130303. set: function (physicsBody) {
  130304. if (this._physicsBody && this._physicsEngine) {
  130305. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  130306. }
  130307. this._physicsBody = physicsBody;
  130308. this.resetUpdateFlags();
  130309. },
  130310. enumerable: true,
  130311. configurable: true
  130312. });
  130313. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  130314. /**
  130315. * Get the parent of the physics imposter
  130316. * @returns Physics imposter or null
  130317. */
  130318. get: function () {
  130319. return !this._options.ignoreParent && this._parent ? this._parent : null;
  130320. },
  130321. /**
  130322. * Sets the parent of the physics imposter
  130323. */
  130324. set: function (value) {
  130325. this._parent = value;
  130326. },
  130327. enumerable: true,
  130328. configurable: true
  130329. });
  130330. /**
  130331. * Resets the update flags
  130332. */
  130333. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  130334. this._bodyUpdateRequired = false;
  130335. };
  130336. /**
  130337. * Gets the object extend size
  130338. * @returns the object extend size
  130339. */
  130340. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  130341. if (this.object.getBoundingInfo) {
  130342. var q = this.object.rotationQuaternion;
  130343. //reset rotation
  130344. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  130345. //calculate the world matrix with no rotation
  130346. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  130347. var boundingInfo = this.object.getBoundingInfo();
  130348. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  130349. //bring back the rotation
  130350. this.object.rotationQuaternion = q;
  130351. //calculate the world matrix with the new rotation
  130352. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  130353. return size;
  130354. }
  130355. else {
  130356. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  130357. }
  130358. };
  130359. /**
  130360. * Gets the object center
  130361. * @returns The object center
  130362. */
  130363. PhysicsImpostor.prototype.getObjectCenter = function () {
  130364. if (this.object.getBoundingInfo) {
  130365. var boundingInfo = this.object.getBoundingInfo();
  130366. return boundingInfo.boundingBox.centerWorld;
  130367. }
  130368. else {
  130369. return this.object.position;
  130370. }
  130371. };
  130372. /**
  130373. * Get a specific parametes from the options parameter
  130374. * @param paramName The object parameter name
  130375. * @returns The object parameter
  130376. */
  130377. PhysicsImpostor.prototype.getParam = function (paramName) {
  130378. return this._options[paramName];
  130379. };
  130380. /**
  130381. * Sets a specific parameter in the options given to the physics plugin
  130382. * @param paramName The parameter name
  130383. * @param value The value of the parameter
  130384. */
  130385. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  130386. this._options[paramName] = value;
  130387. this._bodyUpdateRequired = true;
  130388. };
  130389. /**
  130390. * Specifically change the body's mass option. Won't recreate the physics body object
  130391. * @param mass The mass of the physics imposter
  130392. */
  130393. PhysicsImpostor.prototype.setMass = function (mass) {
  130394. if (this.getParam("mass") !== mass) {
  130395. this.setParam("mass", mass);
  130396. }
  130397. if (this._physicsEngine) {
  130398. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  130399. }
  130400. };
  130401. /**
  130402. * Gets the linear velocity
  130403. * @returns linear velocity or null
  130404. */
  130405. PhysicsImpostor.prototype.getLinearVelocity = function () {
  130406. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  130407. };
  130408. /**
  130409. * Sets the linear velocity
  130410. * @param velocity linear velocity or null
  130411. */
  130412. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  130413. if (this._physicsEngine) {
  130414. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  130415. }
  130416. };
  130417. /**
  130418. * Gets the angular velocity
  130419. * @returns angular velocity or null
  130420. */
  130421. PhysicsImpostor.prototype.getAngularVelocity = function () {
  130422. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  130423. };
  130424. /**
  130425. * Sets the angular velocity
  130426. * @param velocity The velocity or null
  130427. */
  130428. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  130429. if (this._physicsEngine) {
  130430. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  130431. }
  130432. };
  130433. /**
  130434. * Execute a function with the physics plugin native code
  130435. * Provide a function the will have two variables - the world object and the physics body object
  130436. * @param func The function to execute with the physics plugin native code
  130437. */
  130438. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  130439. if (this._physicsEngine) {
  130440. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  130441. }
  130442. };
  130443. /**
  130444. * Register a function that will be executed before the physics world is stepping forward
  130445. * @param func The function to execute before the physics world is stepped forward
  130446. */
  130447. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  130448. this._onBeforePhysicsStepCallbacks.push(func);
  130449. };
  130450. /**
  130451. * Unregister a function that will be executed before the physics world is stepping forward
  130452. * @param func The function to execute before the physics world is stepped forward
  130453. */
  130454. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  130455. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  130456. if (index > -1) {
  130457. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  130458. }
  130459. else {
  130460. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  130461. }
  130462. };
  130463. /**
  130464. * Register a function that will be executed after the physics step
  130465. * @param func The function to execute after physics step
  130466. */
  130467. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  130468. this._onAfterPhysicsStepCallbacks.push(func);
  130469. };
  130470. /**
  130471. * Unregisters a function that will be executed after the physics step
  130472. * @param func The function to execute after physics step
  130473. */
  130474. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  130475. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  130476. if (index > -1) {
  130477. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  130478. }
  130479. else {
  130480. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  130481. }
  130482. };
  130483. /**
  130484. * register a function that will be executed when this impostor collides against a different body
  130485. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  130486. * @param func Callback that is executed on collision
  130487. */
  130488. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  130489. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  130490. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  130491. };
  130492. /**
  130493. * Unregisters the physics imposter on contact
  130494. * @param collideAgainst The physics object to collide against
  130495. * @param func Callback to execute on collision
  130496. */
  130497. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  130498. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  130499. var index = -1;
  130500. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  130501. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  130502. // chcek the arrays match
  130503. var sameList = cbDef.otherImpostors.every(function (impostor) {
  130504. return collidedAgainstList.indexOf(impostor) > -1;
  130505. });
  130506. if (sameList) {
  130507. index = idx;
  130508. }
  130509. return sameList;
  130510. }
  130511. return false;
  130512. });
  130513. if (found) {
  130514. this._onPhysicsCollideCallbacks.splice(index, 1);
  130515. }
  130516. else {
  130517. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  130518. }
  130519. };
  130520. /**
  130521. * Get the parent rotation
  130522. * @returns The parent rotation
  130523. */
  130524. PhysicsImpostor.prototype.getParentsRotation = function () {
  130525. var parent = this.object.parent;
  130526. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  130527. while (parent) {
  130528. if (parent.rotationQuaternion) {
  130529. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  130530. }
  130531. else {
  130532. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  130533. }
  130534. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  130535. parent = parent.parent;
  130536. }
  130537. return this._tmpQuat;
  130538. };
  130539. /**
  130540. * Apply a force
  130541. * @param force The force to apply
  130542. * @param contactPoint The contact point for the force
  130543. * @returns The physics imposter
  130544. */
  130545. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  130546. if (this._physicsEngine) {
  130547. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  130548. }
  130549. return this;
  130550. };
  130551. /**
  130552. * Apply an impulse
  130553. * @param force The impulse force
  130554. * @param contactPoint The contact point for the impulse force
  130555. * @returns The physics imposter
  130556. */
  130557. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  130558. if (this._physicsEngine) {
  130559. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  130560. }
  130561. return this;
  130562. };
  130563. /**
  130564. * A help function to create a joint
  130565. * @param otherImpostor A physics imposter used to create a joint
  130566. * @param jointType The type of joint
  130567. * @param jointData The data for the joint
  130568. * @returns The physics imposter
  130569. */
  130570. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  130571. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  130572. this.addJoint(otherImpostor, joint);
  130573. return this;
  130574. };
  130575. /**
  130576. * Add a joint to this impostor with a different impostor
  130577. * @param otherImpostor A physics imposter used to add a joint
  130578. * @param joint The joint to add
  130579. * @returns The physics imposter
  130580. */
  130581. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  130582. this._joints.push({
  130583. otherImpostor: otherImpostor,
  130584. joint: joint
  130585. });
  130586. if (this._physicsEngine) {
  130587. this._physicsEngine.addJoint(this, otherImpostor, joint);
  130588. }
  130589. return this;
  130590. };
  130591. /**
  130592. * Add an anchor to a cloth impostor
  130593. * @param otherImpostor rigid impostor to anchor to
  130594. * @param width ratio across width from 0 to 1
  130595. * @param height ratio up height from 0 to 1
  130596. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130597. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  130598. * @returns impostor the soft imposter
  130599. */
  130600. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  130601. if (!this._physicsEngine) {
  130602. return this;
  130603. }
  130604. var plugin = this._physicsEngine.getPhysicsPlugin();
  130605. if (!plugin.appendAnchor) {
  130606. return this;
  130607. }
  130608. if (this._physicsEngine) {
  130609. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  130610. }
  130611. return this;
  130612. };
  130613. /**
  130614. * Add a hook to a rope impostor
  130615. * @param otherImpostor rigid impostor to anchor to
  130616. * @param length ratio across rope from 0 to 1
  130617. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  130618. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130619. * @returns impostor the rope imposter
  130620. */
  130621. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  130622. if (!this._physicsEngine) {
  130623. return this;
  130624. }
  130625. var plugin = this._physicsEngine.getPhysicsPlugin();
  130626. if (!plugin.appendAnchor) {
  130627. return this;
  130628. }
  130629. if (this._physicsEngine) {
  130630. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  130631. }
  130632. return this;
  130633. };
  130634. /**
  130635. * Will keep this body still, in a sleep mode.
  130636. * @returns the physics imposter
  130637. */
  130638. PhysicsImpostor.prototype.sleep = function () {
  130639. if (this._physicsEngine) {
  130640. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  130641. }
  130642. return this;
  130643. };
  130644. /**
  130645. * Wake the body up.
  130646. * @returns The physics imposter
  130647. */
  130648. PhysicsImpostor.prototype.wakeUp = function () {
  130649. if (this._physicsEngine) {
  130650. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  130651. }
  130652. return this;
  130653. };
  130654. /**
  130655. * Clones the physics imposter
  130656. * @param newObject The physics imposter clones to this physics-enabled object
  130657. * @returns A nullable physics imposter
  130658. */
  130659. PhysicsImpostor.prototype.clone = function (newObject) {
  130660. if (!newObject) {
  130661. return null;
  130662. }
  130663. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  130664. };
  130665. /**
  130666. * Disposes the physics imposter
  130667. */
  130668. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  130669. var _this = this;
  130670. //no dispose if no physics engine is available.
  130671. if (!this._physicsEngine) {
  130672. return;
  130673. }
  130674. this._joints.forEach(function (j) {
  130675. if (_this._physicsEngine) {
  130676. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  130677. }
  130678. });
  130679. //dispose the physics body
  130680. this._physicsEngine.removeImpostor(this);
  130681. if (this.parent) {
  130682. this.parent.forceUpdate();
  130683. }
  130684. else {
  130685. /*this._object.getChildMeshes().forEach(function(mesh) {
  130686. if (mesh.physicsImpostor) {
  130687. if (disposeChildren) {
  130688. mesh.physicsImpostor.dispose();
  130689. mesh.physicsImpostor = null;
  130690. }
  130691. }
  130692. })*/
  130693. }
  130694. this._isDisposed = true;
  130695. };
  130696. /**
  130697. * Sets the delta position
  130698. * @param position The delta position amount
  130699. */
  130700. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  130701. this._deltaPosition.copyFrom(position);
  130702. };
  130703. /**
  130704. * Sets the delta rotation
  130705. * @param rotation The delta rotation amount
  130706. */
  130707. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  130708. if (!this._deltaRotation) {
  130709. this._deltaRotation = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  130710. }
  130711. this._deltaRotation.copyFrom(rotation);
  130712. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  130713. };
  130714. /**
  130715. * Gets the box size of the physics imposter and stores the result in the input parameter
  130716. * @param result Stores the box size
  130717. * @returns The physics imposter
  130718. */
  130719. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  130720. if (this._physicsEngine) {
  130721. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  130722. }
  130723. return this;
  130724. };
  130725. /**
  130726. * Gets the radius of the physics imposter
  130727. * @returns Radius of the physics imposter
  130728. */
  130729. PhysicsImpostor.prototype.getRadius = function () {
  130730. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  130731. };
  130732. /**
  130733. * Sync a bone with this impostor
  130734. * @param bone The bone to sync to the impostor.
  130735. * @param boneMesh The mesh that the bone is influencing.
  130736. * @param jointPivot The pivot of the joint / bone in local space.
  130737. * @param distToJoint Optional distance from the impostor to the joint.
  130738. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  130739. */
  130740. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  130741. var tempVec = PhysicsImpostor._tmpVecs[0];
  130742. var mesh = this.object;
  130743. if (mesh.rotationQuaternion) {
  130744. if (adjustRotation) {
  130745. var tempQuat = PhysicsImpostor._tmpQuat;
  130746. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  130747. bone.setRotationQuaternion(tempQuat, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_6__["Space"].WORLD, boneMesh);
  130748. }
  130749. else {
  130750. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math_axis__WEBPACK_IMPORTED_MODULE_6__["Space"].WORLD, boneMesh);
  130751. }
  130752. }
  130753. tempVec.x = 0;
  130754. tempVec.y = 0;
  130755. tempVec.z = 0;
  130756. if (jointPivot) {
  130757. tempVec.x = jointPivot.x;
  130758. tempVec.y = jointPivot.y;
  130759. tempVec.z = jointPivot.z;
  130760. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  130761. if (distToJoint === undefined || distToJoint === null) {
  130762. distToJoint = jointPivot.length();
  130763. }
  130764. tempVec.x *= distToJoint;
  130765. tempVec.y *= distToJoint;
  130766. tempVec.z *= distToJoint;
  130767. }
  130768. if (bone.getParent()) {
  130769. tempVec.addInPlace(mesh.getAbsolutePosition());
  130770. bone.setAbsolutePosition(tempVec, boneMesh);
  130771. }
  130772. else {
  130773. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  130774. boneMesh.position.x -= tempVec.x;
  130775. boneMesh.position.y -= tempVec.y;
  130776. boneMesh.position.z -= tempVec.z;
  130777. }
  130778. };
  130779. /**
  130780. * Sync impostor to a bone
  130781. * @param bone The bone that the impostor will be synced to.
  130782. * @param boneMesh The mesh that the bone is influencing.
  130783. * @param jointPivot The pivot of the joint / bone in local space.
  130784. * @param distToJoint Optional distance from the impostor to the joint.
  130785. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  130786. * @param boneAxis Optional vector3 axis the bone is aligned with
  130787. */
  130788. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  130789. var mesh = this.object;
  130790. if (mesh.rotationQuaternion) {
  130791. if (adjustRotation) {
  130792. var tempQuat = PhysicsImpostor._tmpQuat;
  130793. bone.getRotationQuaternionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_6__["Space"].WORLD, boneMesh, tempQuat);
  130794. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  130795. }
  130796. else {
  130797. bone.getRotationQuaternionToRef(_Maths_math_axis__WEBPACK_IMPORTED_MODULE_6__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  130798. }
  130799. }
  130800. var pos = PhysicsImpostor._tmpVecs[0];
  130801. var boneDir = PhysicsImpostor._tmpVecs[1];
  130802. if (!boneAxis) {
  130803. boneAxis = PhysicsImpostor._tmpVecs[2];
  130804. boneAxis.x = 0;
  130805. boneAxis.y = 1;
  130806. boneAxis.z = 0;
  130807. }
  130808. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  130809. bone.getAbsolutePositionToRef(boneMesh, pos);
  130810. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  130811. distToJoint = jointPivot.length();
  130812. }
  130813. if (distToJoint !== undefined && distToJoint !== null) {
  130814. pos.x += boneDir.x * distToJoint;
  130815. pos.y += boneDir.y * distToJoint;
  130816. pos.z += boneDir.z * distToJoint;
  130817. }
  130818. mesh.setAbsolutePosition(pos);
  130819. };
  130820. /**
  130821. * The default object size of the imposter
  130822. */
  130823. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  130824. /**
  130825. * The identity quaternion of the imposter
  130826. */
  130827. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  130828. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  130829. PhysicsImpostor._tmpQuat = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  130830. //Impostor types
  130831. /**
  130832. * No-Imposter type
  130833. */
  130834. PhysicsImpostor.NoImpostor = 0;
  130835. /**
  130836. * Sphere-Imposter type
  130837. */
  130838. PhysicsImpostor.SphereImpostor = 1;
  130839. /**
  130840. * Box-Imposter type
  130841. */
  130842. PhysicsImpostor.BoxImpostor = 2;
  130843. /**
  130844. * Plane-Imposter type
  130845. */
  130846. PhysicsImpostor.PlaneImpostor = 3;
  130847. /**
  130848. * Mesh-imposter type
  130849. */
  130850. PhysicsImpostor.MeshImpostor = 4;
  130851. /**
  130852. * Capsule-Impostor type (Ammo.js plugin only)
  130853. */
  130854. PhysicsImpostor.CapsuleImpostor = 6;
  130855. /**
  130856. * Cylinder-Imposter type
  130857. */
  130858. PhysicsImpostor.CylinderImpostor = 7;
  130859. /**
  130860. * Particle-Imposter type
  130861. */
  130862. PhysicsImpostor.ParticleImpostor = 8;
  130863. /**
  130864. * Heightmap-Imposter type
  130865. */
  130866. PhysicsImpostor.HeightmapImpostor = 9;
  130867. /**
  130868. * ConvexHull-Impostor type (Ammo.js plugin only)
  130869. */
  130870. PhysicsImpostor.ConvexHullImpostor = 10;
  130871. /**
  130872. * Rope-Imposter type
  130873. */
  130874. PhysicsImpostor.RopeImpostor = 101;
  130875. /**
  130876. * Cloth-Imposter type
  130877. */
  130878. PhysicsImpostor.ClothImpostor = 102;
  130879. /**
  130880. * Softbody-Imposter type
  130881. */
  130882. PhysicsImpostor.SoftbodyImpostor = 103;
  130883. return PhysicsImpostor;
  130884. }());
  130885. /***/ }),
  130886. /***/ "./Physics/physicsJoint.ts":
  130887. /*!*********************************!*\
  130888. !*** ./Physics/physicsJoint.ts ***!
  130889. \*********************************/
  130890. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  130891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130892. "use strict";
  130893. __webpack_require__.r(__webpack_exports__);
  130894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  130895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  130896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  130897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  130898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  130899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  130900. /**
  130901. * This is a holder class for the physics joint created by the physics plugin
  130902. * It holds a set of functions to control the underlying joint
  130903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  130904. */
  130905. var PhysicsJoint = /** @class */ (function () {
  130906. /**
  130907. * Initializes the physics joint
  130908. * @param type The type of the physics joint
  130909. * @param jointData The data for the physics joint
  130910. */
  130911. function PhysicsJoint(
  130912. /**
  130913. * The type of the physics joint
  130914. */
  130915. type,
  130916. /**
  130917. * The data for the physics joint
  130918. */
  130919. jointData) {
  130920. this.type = type;
  130921. this.jointData = jointData;
  130922. jointData.nativeParams = jointData.nativeParams || {};
  130923. }
  130924. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  130925. /**
  130926. * Gets the physics joint
  130927. */
  130928. get: function () {
  130929. return this._physicsJoint;
  130930. },
  130931. /**
  130932. * Sets the physics joint
  130933. */
  130934. set: function (newJoint) {
  130935. if (this._physicsJoint) {
  130936. //remove from the wolrd
  130937. }
  130938. this._physicsJoint = newJoint;
  130939. },
  130940. enumerable: true,
  130941. configurable: true
  130942. });
  130943. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  130944. /**
  130945. * Sets the physics plugin
  130946. */
  130947. set: function (physicsPlugin) {
  130948. this._physicsPlugin = physicsPlugin;
  130949. },
  130950. enumerable: true,
  130951. configurable: true
  130952. });
  130953. /**
  130954. * Execute a function that is physics-plugin specific.
  130955. * @param {Function} func the function that will be executed.
  130956. * It accepts two parameters: the physics world and the physics joint
  130957. */
  130958. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  130959. func(this._physicsPlugin.world, this._physicsJoint);
  130960. };
  130961. //TODO check if the native joints are the same
  130962. //Joint Types
  130963. /**
  130964. * Distance-Joint type
  130965. */
  130966. PhysicsJoint.DistanceJoint = 0;
  130967. /**
  130968. * Hinge-Joint type
  130969. */
  130970. PhysicsJoint.HingeJoint = 1;
  130971. /**
  130972. * Ball-and-Socket joint type
  130973. */
  130974. PhysicsJoint.BallAndSocketJoint = 2;
  130975. /**
  130976. * Wheel-Joint type
  130977. */
  130978. PhysicsJoint.WheelJoint = 3;
  130979. /**
  130980. * Slider-Joint type
  130981. */
  130982. PhysicsJoint.SliderJoint = 4;
  130983. //OIMO
  130984. /**
  130985. * Prismatic-Joint type
  130986. */
  130987. PhysicsJoint.PrismaticJoint = 5;
  130988. //
  130989. /**
  130990. * Universal-Joint type
  130991. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  130992. */
  130993. PhysicsJoint.UniversalJoint = 6;
  130994. /**
  130995. * Hinge-Joint 2 type
  130996. */
  130997. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  130998. //Cannon
  130999. /**
  131000. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  131001. */
  131002. PhysicsJoint.PointToPointJoint = 8;
  131003. //Cannon only at the moment
  131004. /**
  131005. * Spring-Joint type
  131006. */
  131007. PhysicsJoint.SpringJoint = 9;
  131008. /**
  131009. * Lock-Joint type
  131010. */
  131011. PhysicsJoint.LockJoint = 10;
  131012. return PhysicsJoint;
  131013. }());
  131014. /**
  131015. * A class representing a physics distance joint
  131016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131017. */
  131018. var DistanceJoint = /** @class */ (function (_super) {
  131019. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  131020. /**
  131021. *
  131022. * @param jointData The data for the Distance-Joint
  131023. */
  131024. function DistanceJoint(jointData) {
  131025. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  131026. }
  131027. /**
  131028. * Update the predefined distance.
  131029. * @param maxDistance The maximum preferred distance
  131030. * @param minDistance The minimum preferred distance
  131031. */
  131032. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  131033. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  131034. };
  131035. return DistanceJoint;
  131036. }(PhysicsJoint));
  131037. /**
  131038. * Represents a Motor-Enabled Joint
  131039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131040. */
  131041. var MotorEnabledJoint = /** @class */ (function (_super) {
  131042. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  131043. /**
  131044. * Initializes the Motor-Enabled Joint
  131045. * @param type The type of the joint
  131046. * @param jointData The physica joint data for the joint
  131047. */
  131048. function MotorEnabledJoint(type, jointData) {
  131049. return _super.call(this, type, jointData) || this;
  131050. }
  131051. /**
  131052. * Set the motor values.
  131053. * Attention, this function is plugin specific. Engines won't react 100% the same.
  131054. * @param force the force to apply
  131055. * @param maxForce max force for this motor.
  131056. */
  131057. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  131058. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  131059. };
  131060. /**
  131061. * Set the motor's limits.
  131062. * Attention, this function is plugin specific. Engines won't react 100% the same.
  131063. * @param upperLimit The upper limit of the motor
  131064. * @param lowerLimit The lower limit of the motor
  131065. */
  131066. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  131067. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  131068. };
  131069. return MotorEnabledJoint;
  131070. }(PhysicsJoint));
  131071. /**
  131072. * This class represents a single physics Hinge-Joint
  131073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131074. */
  131075. var HingeJoint = /** @class */ (function (_super) {
  131076. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  131077. /**
  131078. * Initializes the Hinge-Joint
  131079. * @param jointData The joint data for the Hinge-Joint
  131080. */
  131081. function HingeJoint(jointData) {
  131082. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  131083. }
  131084. /**
  131085. * Set the motor values.
  131086. * Attention, this function is plugin specific. Engines won't react 100% the same.
  131087. * @param {number} force the force to apply
  131088. * @param {number} maxForce max force for this motor.
  131089. */
  131090. HingeJoint.prototype.setMotor = function (force, maxForce) {
  131091. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  131092. };
  131093. /**
  131094. * Set the motor's limits.
  131095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  131096. * @param upperLimit The upper limit of the motor
  131097. * @param lowerLimit The lower limit of the motor
  131098. */
  131099. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  131100. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  131101. };
  131102. return HingeJoint;
  131103. }(MotorEnabledJoint));
  131104. /**
  131105. * This class represents a dual hinge physics joint (same as wheel joint)
  131106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131107. */
  131108. var Hinge2Joint = /** @class */ (function (_super) {
  131109. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  131110. /**
  131111. * Initializes the Hinge2-Joint
  131112. * @param jointData The joint data for the Hinge2-Joint
  131113. */
  131114. function Hinge2Joint(jointData) {
  131115. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  131116. }
  131117. /**
  131118. * Set the motor values.
  131119. * Attention, this function is plugin specific. Engines won't react 100% the same.
  131120. * @param {number} targetSpeed the speed the motor is to reach
  131121. * @param {number} maxForce max force for this motor.
  131122. * @param {motorIndex} the motor's index, 0 or 1.
  131123. */
  131124. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  131125. if (motorIndex === void 0) { motorIndex = 0; }
  131126. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  131127. };
  131128. /**
  131129. * Set the motor limits.
  131130. * Attention, this function is plugin specific. Engines won't react 100% the same.
  131131. * @param {number} upperLimit the upper limit
  131132. * @param {number} lowerLimit lower limit
  131133. * @param {motorIndex} the motor's index, 0 or 1.
  131134. */
  131135. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  131136. if (motorIndex === void 0) { motorIndex = 0; }
  131137. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  131138. };
  131139. return Hinge2Joint;
  131140. }(MotorEnabledJoint));
  131141. /***/ }),
  131142. /***/ "./Physics/physicsRaycastResult.ts":
  131143. /*!*****************************************!*\
  131144. !*** ./Physics/physicsRaycastResult.ts ***!
  131145. \*****************************************/
  131146. /*! exports provided: PhysicsRaycastResult */
  131147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131148. "use strict";
  131149. __webpack_require__.r(__webpack_exports__);
  131150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  131151. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  131152. /**
  131153. * Holds the data for the raycast result
  131154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131155. */
  131156. var PhysicsRaycastResult = /** @class */ (function () {
  131157. function PhysicsRaycastResult() {
  131158. this._hasHit = false;
  131159. this._hitDistance = 0;
  131160. this._hitNormalWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131161. this._hitPointWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131162. this._rayFromWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131163. this._rayToWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131164. }
  131165. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  131166. /**
  131167. * Gets if there was a hit
  131168. */
  131169. get: function () {
  131170. return this._hasHit;
  131171. },
  131172. enumerable: true,
  131173. configurable: true
  131174. });
  131175. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  131176. /**
  131177. * Gets the distance from the hit
  131178. */
  131179. get: function () {
  131180. return this._hitDistance;
  131181. },
  131182. enumerable: true,
  131183. configurable: true
  131184. });
  131185. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  131186. /**
  131187. * Gets the hit normal/direction in the world
  131188. */
  131189. get: function () {
  131190. return this._hitNormalWorld;
  131191. },
  131192. enumerable: true,
  131193. configurable: true
  131194. });
  131195. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  131196. /**
  131197. * Gets the hit point in the world
  131198. */
  131199. get: function () {
  131200. return this._hitPointWorld;
  131201. },
  131202. enumerable: true,
  131203. configurable: true
  131204. });
  131205. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  131206. /**
  131207. * Gets the ray "start point" of the ray in the world
  131208. */
  131209. get: function () {
  131210. return this._rayFromWorld;
  131211. },
  131212. enumerable: true,
  131213. configurable: true
  131214. });
  131215. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  131216. /**
  131217. * Gets the ray "end point" of the ray in the world
  131218. */
  131219. get: function () {
  131220. return this._rayToWorld;
  131221. },
  131222. enumerable: true,
  131223. configurable: true
  131224. });
  131225. /**
  131226. * Sets the hit data (normal & point in world space)
  131227. * @param hitNormalWorld defines the normal in world space
  131228. * @param hitPointWorld defines the point in world space
  131229. */
  131230. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  131231. this._hasHit = true;
  131232. this._hitNormalWorld = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  131233. this._hitPointWorld = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  131234. };
  131235. /**
  131236. * Sets the distance from the start point to the hit point
  131237. * @param distance
  131238. */
  131239. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  131240. this._hitDistance = distance;
  131241. };
  131242. /**
  131243. * Calculates the distance manually
  131244. */
  131245. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  131246. this._hitDistance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  131247. };
  131248. /**
  131249. * Resets all the values to default
  131250. * @param from The from point on world space
  131251. * @param to The to point on world space
  131252. */
  131253. PhysicsRaycastResult.prototype.reset = function (from, to) {
  131254. if (from === void 0) { from = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  131255. if (to === void 0) { to = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  131256. this._rayFromWorld = from;
  131257. this._rayToWorld = to;
  131258. this._hasHit = false;
  131259. this._hitDistance = 0;
  131260. this._hitNormalWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131261. this._hitPointWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131262. };
  131263. return PhysicsRaycastResult;
  131264. }());
  131265. /***/ }),
  131266. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  131267. /*!****************************************************************************!*\
  131268. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  131269. \****************************************************************************/
  131270. /*! exports provided: DefaultRenderingPipeline */
  131271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131272. "use strict";
  131273. __webpack_require__.r(__webpack_exports__);
  131274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  131275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131276. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  131277. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  131278. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  131279. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  131280. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  131281. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  131282. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  131283. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  131284. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  131285. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  131286. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  131287. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  131288. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  131289. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  131290. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  131291. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  131292. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  131293. /**
  131294. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  131295. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131296. */
  131297. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  131298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  131299. /**
  131300. * @constructor
  131301. * @param name - The rendering pipeline name (default: "")
  131302. * @param hdr - If high dynamic range textures should be used (default: true)
  131303. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131304. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131305. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131306. */
  131307. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  131308. if (name === void 0) { name = ""; }
  131309. if (hdr === void 0) { hdr = true; }
  131310. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  131311. if (automaticBuild === void 0) { automaticBuild = true; }
  131312. var _this = _super.call(this, scene.getEngine(), name) || this;
  131313. _this._camerasToBeAttached = [];
  131314. /**
  131315. * ID of the sharpen post process,
  131316. */
  131317. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  131318. /**
  131319. * @ignore
  131320. * ID of the image processing post process;
  131321. */
  131322. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  131323. /**
  131324. * @ignore
  131325. * ID of the Fast Approximate Anti-Aliasing post process;
  131326. */
  131327. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  131328. /**
  131329. * ID of the chromatic aberration post process,
  131330. */
  131331. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  131332. /**
  131333. * ID of the grain post process
  131334. */
  131335. _this.GrainPostProcessId = "GrainPostProcessEffect";
  131336. /**
  131337. * Glow post process which adds a glow to emissive areas of the image
  131338. */
  131339. _this._glowLayer = null;
  131340. /**
  131341. * Animations which can be used to tweak settings over a period of time
  131342. */
  131343. _this.animations = [];
  131344. _this._imageProcessingConfigurationObserver = null;
  131345. // Values
  131346. _this._sharpenEnabled = false;
  131347. _this._bloomEnabled = false;
  131348. _this._depthOfFieldEnabled = false;
  131349. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  131350. _this._fxaaEnabled = false;
  131351. _this._imageProcessingEnabled = true;
  131352. _this._bloomScale = 0.5;
  131353. _this._chromaticAberrationEnabled = false;
  131354. _this._grainEnabled = false;
  131355. _this._buildAllowed = true;
  131356. _this._resizeObserver = null;
  131357. _this._hardwareScaleLevel = 1.0;
  131358. _this._bloomKernel = 64;
  131359. /**
  131360. * Specifies the weight of the bloom in the final rendering
  131361. */
  131362. _this._bloomWeight = 0.15;
  131363. /**
  131364. * Specifies the luma threshold for the area that will be blurred by the bloom
  131365. */
  131366. _this._bloomThreshold = 0.9;
  131367. _this._samples = 1;
  131368. _this._hasCleared = false;
  131369. _this._prevPostProcess = null;
  131370. _this._prevPrevPostProcess = null;
  131371. _this._depthOfFieldSceneObserver = null;
  131372. _this._cameras = cameras || scene.cameras;
  131373. _this._cameras = _this._cameras.slice();
  131374. _this._camerasToBeAttached = _this._cameras.slice();
  131375. _this._buildAllowed = automaticBuild;
  131376. // Initialize
  131377. _this._scene = scene;
  131378. var caps = _this._scene.getEngine().getCaps();
  131379. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  131380. // Misc
  131381. if (_this._hdr) {
  131382. if (caps.textureHalfFloatRender) {
  131383. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  131384. }
  131385. else if (caps.textureFloatRender) {
  131386. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  131387. }
  131388. }
  131389. else {
  131390. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  131391. }
  131392. // Attach
  131393. scene.postProcessRenderPipelineManager.addPipeline(_this);
  131394. var engine = _this._scene.getEngine();
  131395. // Create post processes before hand so they can be modified before enabled.
  131396. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  131397. _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);
  131398. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  131399. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  131400. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  131401. _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);
  131402. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  131403. _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);
  131404. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  131405. _this._resizeObserver = engine.onResizeObservable.add(function () {
  131406. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  131407. _this.bloomKernel = _this.bloomKernel;
  131408. });
  131409. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  131410. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  131411. });
  131412. _this._buildPipeline();
  131413. return _this;
  131414. }
  131415. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  131416. /**
  131417. * Gets active scene
  131418. */
  131419. get: function () {
  131420. return this._scene;
  131421. },
  131422. enumerable: true,
  131423. configurable: true
  131424. });
  131425. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  131426. get: function () {
  131427. return this._sharpenEnabled;
  131428. },
  131429. /**
  131430. * Enable or disable the sharpen process from the pipeline
  131431. */
  131432. set: function (enabled) {
  131433. if (this._sharpenEnabled === enabled) {
  131434. return;
  131435. }
  131436. this._sharpenEnabled = enabled;
  131437. this._buildPipeline();
  131438. },
  131439. enumerable: true,
  131440. configurable: true
  131441. });
  131442. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  131443. /**
  131444. * Specifies the size of the bloom blur kernel, relative to the final output size
  131445. */
  131446. get: function () {
  131447. return this._bloomKernel;
  131448. },
  131449. set: function (value) {
  131450. this._bloomKernel = value;
  131451. this.bloom.kernel = value / this._hardwareScaleLevel;
  131452. },
  131453. enumerable: true,
  131454. configurable: true
  131455. });
  131456. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  131457. get: function () {
  131458. return this._bloomWeight;
  131459. },
  131460. /**
  131461. * The strength of the bloom.
  131462. */
  131463. set: function (value) {
  131464. if (this._bloomWeight === value) {
  131465. return;
  131466. }
  131467. this.bloom.weight = value;
  131468. this._bloomWeight = value;
  131469. },
  131470. enumerable: true,
  131471. configurable: true
  131472. });
  131473. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  131474. get: function () {
  131475. return this._bloomThreshold;
  131476. },
  131477. /**
  131478. * The strength of the bloom.
  131479. */
  131480. set: function (value) {
  131481. if (this._bloomThreshold === value) {
  131482. return;
  131483. }
  131484. this.bloom.threshold = value;
  131485. this._bloomThreshold = value;
  131486. },
  131487. enumerable: true,
  131488. configurable: true
  131489. });
  131490. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  131491. get: function () {
  131492. return this._bloomScale;
  131493. },
  131494. /**
  131495. * The scale of the bloom, lower value will provide better performance.
  131496. */
  131497. set: function (value) {
  131498. if (this._bloomScale === value) {
  131499. return;
  131500. }
  131501. this._bloomScale = value;
  131502. // recreate bloom and dispose old as this setting is not dynamic
  131503. this._rebuildBloom();
  131504. this._buildPipeline();
  131505. },
  131506. enumerable: true,
  131507. configurable: true
  131508. });
  131509. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  131510. get: function () {
  131511. return this._bloomEnabled;
  131512. },
  131513. /**
  131514. * Enable or disable the bloom from the pipeline
  131515. */
  131516. set: function (enabled) {
  131517. if (this._bloomEnabled === enabled) {
  131518. return;
  131519. }
  131520. this._bloomEnabled = enabled;
  131521. this._buildPipeline();
  131522. },
  131523. enumerable: true,
  131524. configurable: true
  131525. });
  131526. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  131527. // recreate bloom and dispose old as this setting is not dynamic
  131528. var oldBloom = this.bloom;
  131529. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  131530. this.bloom.threshold = oldBloom.threshold;
  131531. for (var i = 0; i < this._cameras.length; i++) {
  131532. oldBloom.disposeEffects(this._cameras[i]);
  131533. }
  131534. };
  131535. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  131536. /**
  131537. * If the depth of field is enabled.
  131538. */
  131539. get: function () {
  131540. return this._depthOfFieldEnabled;
  131541. },
  131542. set: function (enabled) {
  131543. if (this._depthOfFieldEnabled === enabled) {
  131544. return;
  131545. }
  131546. this._depthOfFieldEnabled = enabled;
  131547. this._buildPipeline();
  131548. },
  131549. enumerable: true,
  131550. configurable: true
  131551. });
  131552. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  131553. /**
  131554. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131555. */
  131556. get: function () {
  131557. return this._depthOfFieldBlurLevel;
  131558. },
  131559. set: function (value) {
  131560. if (this._depthOfFieldBlurLevel === value) {
  131561. return;
  131562. }
  131563. this._depthOfFieldBlurLevel = value;
  131564. // recreate dof and dispose old as this setting is not dynamic
  131565. var oldDof = this.depthOfField;
  131566. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  131567. this.depthOfField.focalLength = oldDof.focalLength;
  131568. this.depthOfField.focusDistance = oldDof.focusDistance;
  131569. this.depthOfField.fStop = oldDof.fStop;
  131570. this.depthOfField.lensSize = oldDof.lensSize;
  131571. for (var i = 0; i < this._cameras.length; i++) {
  131572. oldDof.disposeEffects(this._cameras[i]);
  131573. }
  131574. this._buildPipeline();
  131575. },
  131576. enumerable: true,
  131577. configurable: true
  131578. });
  131579. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  131580. get: function () {
  131581. return this._fxaaEnabled;
  131582. },
  131583. /**
  131584. * If the anti aliasing is enabled.
  131585. */
  131586. set: function (enabled) {
  131587. if (this._fxaaEnabled === enabled) {
  131588. return;
  131589. }
  131590. this._fxaaEnabled = enabled;
  131591. this._buildPipeline();
  131592. },
  131593. enumerable: true,
  131594. configurable: true
  131595. });
  131596. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  131597. get: function () {
  131598. return this._samples;
  131599. },
  131600. /**
  131601. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131602. */
  131603. set: function (sampleCount) {
  131604. if (this._samples === sampleCount) {
  131605. return;
  131606. }
  131607. this._samples = sampleCount;
  131608. this._buildPipeline();
  131609. },
  131610. enumerable: true,
  131611. configurable: true
  131612. });
  131613. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  131614. get: function () {
  131615. return this._imageProcessingEnabled;
  131616. },
  131617. /**
  131618. * If image processing is enabled.
  131619. */
  131620. set: function (enabled) {
  131621. if (this._imageProcessingEnabled === enabled) {
  131622. return;
  131623. }
  131624. this._imageProcessingEnabled = enabled;
  131625. this._buildPipeline();
  131626. },
  131627. enumerable: true,
  131628. configurable: true
  131629. });
  131630. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  131631. get: function () {
  131632. return this._glowLayer != null;
  131633. },
  131634. /**
  131635. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131636. */
  131637. set: function (enabled) {
  131638. if (enabled && !this._glowLayer) {
  131639. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  131640. }
  131641. else if (!enabled && this._glowLayer) {
  131642. this._glowLayer.dispose();
  131643. this._glowLayer = null;
  131644. }
  131645. },
  131646. enumerable: true,
  131647. configurable: true
  131648. });
  131649. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayer", {
  131650. /**
  131651. * Gets the glow layer (or null if not defined)
  131652. */
  131653. get: function () {
  131654. return this._glowLayer;
  131655. },
  131656. enumerable: true,
  131657. configurable: true
  131658. });
  131659. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  131660. get: function () {
  131661. return this._chromaticAberrationEnabled;
  131662. },
  131663. /**
  131664. * Enable or disable the chromaticAberration process from the pipeline
  131665. */
  131666. set: function (enabled) {
  131667. if (this._chromaticAberrationEnabled === enabled) {
  131668. return;
  131669. }
  131670. this._chromaticAberrationEnabled = enabled;
  131671. this._buildPipeline();
  131672. },
  131673. enumerable: true,
  131674. configurable: true
  131675. });
  131676. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  131677. get: function () {
  131678. return this._grainEnabled;
  131679. },
  131680. /**
  131681. * Enable or disable the grain process from the pipeline
  131682. */
  131683. set: function (enabled) {
  131684. if (this._grainEnabled === enabled) {
  131685. return;
  131686. }
  131687. this._grainEnabled = enabled;
  131688. this._buildPipeline();
  131689. },
  131690. enumerable: true,
  131691. configurable: true
  131692. });
  131693. /**
  131694. * Get the class name
  131695. * @returns "DefaultRenderingPipeline"
  131696. */
  131697. DefaultRenderingPipeline.prototype.getClassName = function () {
  131698. return "DefaultRenderingPipeline";
  131699. };
  131700. /**
  131701. * Force the compilation of the entire pipeline.
  131702. */
  131703. DefaultRenderingPipeline.prototype.prepare = function () {
  131704. var previousState = this._buildAllowed;
  131705. this._buildAllowed = true;
  131706. this._buildPipeline();
  131707. this._buildAllowed = previousState;
  131708. };
  131709. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  131710. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  131711. if (this._hasCleared) {
  131712. postProcess.autoClear = false;
  131713. }
  131714. else {
  131715. postProcess.autoClear = true;
  131716. this._scene.autoClear = false;
  131717. this._hasCleared = true;
  131718. }
  131719. if (!skipTextureSharing) {
  131720. if (this._prevPrevPostProcess) {
  131721. postProcess.shareOutputWith(this._prevPrevPostProcess);
  131722. }
  131723. else {
  131724. postProcess.useOwnOutput();
  131725. }
  131726. if (this._prevPostProcess) {
  131727. this._prevPrevPostProcess = this._prevPostProcess;
  131728. }
  131729. this._prevPostProcess = postProcess;
  131730. }
  131731. };
  131732. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  131733. var _this = this;
  131734. if (!this._buildAllowed) {
  131735. return;
  131736. }
  131737. this._scene.autoClear = true;
  131738. var engine = this._scene.getEngine();
  131739. this._disposePostProcesses();
  131740. if (this._cameras !== null) {
  131741. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  131742. // get back cameras to be used to reattach pipeline
  131743. this._cameras = this._camerasToBeAttached.slice();
  131744. }
  131745. this._reset();
  131746. this._prevPostProcess = null;
  131747. this._prevPrevPostProcess = null;
  131748. this._hasCleared = false;
  131749. if (this.depthOfFieldEnabled) {
  131750. // Multi camera suport
  131751. if (this._cameras.length > 1) {
  131752. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  131753. var camera = _a[_i];
  131754. var depthRenderer = this._scene.enableDepthRenderer(camera);
  131755. depthRenderer.useOnlyInActiveCamera = true;
  131756. }
  131757. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  131758. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  131759. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  131760. }
  131761. });
  131762. }
  131763. else {
  131764. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  131765. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  131766. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  131767. }
  131768. if (!this.depthOfField._isReady()) {
  131769. this.depthOfField._updateEffects();
  131770. }
  131771. this.addEffect(this.depthOfField);
  131772. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  131773. }
  131774. else {
  131775. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  131776. }
  131777. if (this.bloomEnabled) {
  131778. if (!this.bloom._isReady()) {
  131779. this.bloom._updateEffects();
  131780. }
  131781. this.addEffect(this.bloom);
  131782. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  131783. }
  131784. if (this._imageProcessingEnabled) {
  131785. 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);
  131786. if (this._hdr) {
  131787. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  131788. this._setAutoClearAndTextureSharing(this.imageProcessing);
  131789. }
  131790. else {
  131791. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  131792. }
  131793. }
  131794. if (this.sharpenEnabled) {
  131795. if (!this.sharpen.isReady()) {
  131796. this.sharpen.updateEffect();
  131797. }
  131798. this.addEffect(this._sharpenEffect);
  131799. this._setAutoClearAndTextureSharing(this.sharpen);
  131800. }
  131801. if (this.grainEnabled) {
  131802. if (!this.grain.isReady()) {
  131803. this.grain.updateEffect();
  131804. }
  131805. this.addEffect(this._grainEffect);
  131806. this._setAutoClearAndTextureSharing(this.grain);
  131807. }
  131808. if (this.chromaticAberrationEnabled) {
  131809. if (!this.chromaticAberration.isReady()) {
  131810. this.chromaticAberration.updateEffect();
  131811. }
  131812. this.addEffect(this._chromaticAberrationEffect);
  131813. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  131814. }
  131815. if (this.fxaaEnabled) {
  131816. 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);
  131817. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  131818. this._setAutoClearAndTextureSharing(this.fxaa, true);
  131819. }
  131820. if (this._cameras !== null) {
  131821. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  131822. }
  131823. // In multicamera mode, the scene needs to autoclear in between cameras.
  131824. if (this._scene.activeCameras && this._scene.activeCameras.length > 1) {
  131825. this._scene.autoClear = true;
  131826. }
  131827. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  131828. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  131829. }
  131830. };
  131831. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  131832. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  131833. for (var i = 0; i < this._cameras.length; i++) {
  131834. var camera = this._cameras[i];
  131835. if (this.imageProcessing) {
  131836. this.imageProcessing.dispose(camera);
  131837. }
  131838. if (this.fxaa) {
  131839. this.fxaa.dispose(camera);
  131840. }
  131841. // These are created in the constructor and should not be disposed on every pipeline change
  131842. if (disposeNonRecreated) {
  131843. if (this.sharpen) {
  131844. this.sharpen.dispose(camera);
  131845. }
  131846. if (this.depthOfField) {
  131847. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  131848. this.depthOfField.disposeEffects(camera);
  131849. }
  131850. if (this.bloom) {
  131851. this.bloom.disposeEffects(camera);
  131852. }
  131853. if (this.chromaticAberration) {
  131854. this.chromaticAberration.dispose(camera);
  131855. }
  131856. if (this.grain) {
  131857. this.grain.dispose(camera);
  131858. }
  131859. if (this._glowLayer) {
  131860. this._glowLayer.dispose();
  131861. }
  131862. }
  131863. }
  131864. this.imageProcessing = null;
  131865. this.fxaa = null;
  131866. if (disposeNonRecreated) {
  131867. this.sharpen = null;
  131868. this._sharpenEffect = null;
  131869. this.depthOfField = null;
  131870. this.bloom = null;
  131871. this.chromaticAberration = null;
  131872. this._chromaticAberrationEffect = null;
  131873. this.grain = null;
  131874. this._grainEffect = null;
  131875. this._glowLayer = null;
  131876. }
  131877. };
  131878. /**
  131879. * Adds a camera to the pipeline
  131880. * @param camera the camera to be added
  131881. */
  131882. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  131883. this._camerasToBeAttached.push(camera);
  131884. this._buildPipeline();
  131885. };
  131886. /**
  131887. * Removes a camera from the pipeline
  131888. * @param camera the camera to remove
  131889. */
  131890. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  131891. var index = this._camerasToBeAttached.indexOf(camera);
  131892. this._camerasToBeAttached.splice(index, 1);
  131893. this._buildPipeline();
  131894. };
  131895. /**
  131896. * Dispose of the pipeline and stop all post processes
  131897. */
  131898. DefaultRenderingPipeline.prototype.dispose = function () {
  131899. this._disposePostProcesses(true);
  131900. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  131901. this._scene.autoClear = true;
  131902. if (this._resizeObserver) {
  131903. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  131904. this._resizeObserver = null;
  131905. }
  131906. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  131907. _super.prototype.dispose.call(this);
  131908. };
  131909. /**
  131910. * Serialize the rendering pipeline (Used when exporting)
  131911. * @returns the serialized object
  131912. */
  131913. DefaultRenderingPipeline.prototype.serialize = function () {
  131914. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  131915. serializationObject.customType = "DefaultRenderingPipeline";
  131916. return serializationObject;
  131917. };
  131918. /**
  131919. * Parse the serialized pipeline
  131920. * @param source Source pipeline.
  131921. * @param scene The scene to load the pipeline to.
  131922. * @param rootUrl The URL of the serialized pipeline.
  131923. * @returns An instantiated pipeline from the serialized object.
  131924. */
  131925. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  131926. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  131927. };
  131928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131930. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  131931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131933. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  131934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131936. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  131937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131939. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  131940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131942. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  131943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131945. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  131946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131948. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  131949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131951. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  131952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131954. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  131955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131957. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  131958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131960. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  131961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131963. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  131964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131966. ], DefaultRenderingPipeline.prototype, "samples", null);
  131967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131969. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  131970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131972. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  131973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131975. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  131976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  131977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  131978. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  131979. return DefaultRenderingPipeline;
  131980. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  131981. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  131982. /***/ }),
  131983. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  131984. /*!*********************************************************!*\
  131985. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  131986. \*********************************************************/
  131987. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  131988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131989. "use strict";
  131990. __webpack_require__.r(__webpack_exports__);
  131991. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  131992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  131993. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  131994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  131995. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  131996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  131997. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  131998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  131999. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  132000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  132001. /***/ }),
  132002. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  132003. /*!*************************************************************************!*\
  132004. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  132005. \*************************************************************************/
  132006. /*! exports provided: LensRenderingPipeline */
  132007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132008. "use strict";
  132009. __webpack_require__.r(__webpack_exports__);
  132010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  132011. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132012. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  132013. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  132014. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  132015. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  132016. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  132017. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  132018. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  132019. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  132020. /**
  132021. * BABYLON.JS Chromatic Aberration GLSL Shader
  132022. * Author: Olivier Guyot
  132023. * Separates very slightly R, G and B colors on the edges of the screen
  132024. * Inspired by Francois Tarlier & Martins Upitis
  132025. */
  132026. var LensRenderingPipeline = /** @class */ (function (_super) {
  132027. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  132028. /**
  132029. * @constructor
  132030. *
  132031. * Effect parameters are as follow:
  132032. * {
  132033. * chromatic_aberration: number; // from 0 to x (1 for realism)
  132034. * edge_blur: number; // from 0 to x (1 for realism)
  132035. * distortion: number; // from 0 to x (1 for realism)
  132036. * grain_amount: number; // from 0 to 1
  132037. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  132038. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  132039. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  132040. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  132041. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  132042. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  132043. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  132044. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  132045. * }
  132046. * Note: if an effect parameter is unset, effect is disabled
  132047. *
  132048. * @param name The rendering pipeline name
  132049. * @param parameters - An object containing all parameters (see above)
  132050. * @param scene The scene linked to this pipeline
  132051. * @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)
  132052. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132053. */
  132054. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  132055. if (ratio === void 0) { ratio = 1.0; }
  132056. var _this = _super.call(this, scene.getEngine(), name) || this;
  132057. // Lens effects can be of the following:
  132058. // - chromatic aberration (slight shift of RGB colors)
  132059. // - blur on the edge of the lens
  132060. // - lens distortion
  132061. // - depth-of-field blur & highlights enhancing
  132062. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  132063. // - grain effect (noise or custom texture)
  132064. // Two additional texture samplers are needed:
  132065. // - depth map (for depth-of-field)
  132066. // - grain texture
  132067. /**
  132068. * @ignore
  132069. * The chromatic aberration PostProcess id in the pipeline
  132070. */
  132071. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  132072. /**
  132073. * @ignore
  132074. * The highlights enhancing PostProcess id in the pipeline
  132075. */
  132076. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  132077. /**
  132078. * @ignore
  132079. * The depth-of-field PostProcess id in the pipeline
  132080. */
  132081. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  132082. _this._pentagonBokehIsEnabled = false;
  132083. _this._scene = scene;
  132084. // Fetch texture samplers
  132085. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  132086. if (parameters.grain_texture) {
  132087. _this._grainTexture = parameters.grain_texture;
  132088. }
  132089. else {
  132090. _this._createGrainTexture();
  132091. }
  132092. // save parameters
  132093. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  132094. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  132095. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  132096. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  132097. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  132098. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  132099. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  132100. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  132101. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  132102. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  132103. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  132104. // Create effects
  132105. _this._createChromaticAberrationPostProcess(ratio);
  132106. _this._createHighlightsPostProcess(ratio);
  132107. _this._createDepthOfFieldPostProcess(ratio / 4);
  132108. // Set up pipeline
  132109. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  132110. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  132111. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  132112. if (_this._highlightsGain === -1) {
  132113. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  132114. }
  132115. // Finish
  132116. scene.postProcessRenderPipelineManager.addPipeline(_this);
  132117. if (cameras) {
  132118. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  132119. }
  132120. return _this;
  132121. }
  132122. /**
  132123. * Get the class name
  132124. * @returns "LensRenderingPipeline"
  132125. */
  132126. LensRenderingPipeline.prototype.getClassName = function () {
  132127. return "LensRenderingPipeline";
  132128. };
  132129. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  132130. // Properties
  132131. /**
  132132. * Gets associated scene
  132133. */
  132134. get: function () {
  132135. return this._scene;
  132136. },
  132137. enumerable: true,
  132138. configurable: true
  132139. });
  132140. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  132141. /**
  132142. * Gets or sets the edge blur
  132143. */
  132144. get: function () {
  132145. return this._edgeBlur;
  132146. },
  132147. set: function (value) {
  132148. this.setEdgeBlur(value);
  132149. },
  132150. enumerable: true,
  132151. configurable: true
  132152. });
  132153. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  132154. /**
  132155. * Gets or sets the grain amount
  132156. */
  132157. get: function () {
  132158. return this._grainAmount;
  132159. },
  132160. set: function (value) {
  132161. this.setGrainAmount(value);
  132162. },
  132163. enumerable: true,
  132164. configurable: true
  132165. });
  132166. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  132167. /**
  132168. * Gets or sets the chromatic aberration amount
  132169. */
  132170. get: function () {
  132171. return this._chromaticAberration;
  132172. },
  132173. set: function (value) {
  132174. this.setChromaticAberration(value);
  132175. },
  132176. enumerable: true,
  132177. configurable: true
  132178. });
  132179. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  132180. /**
  132181. * Gets or sets the depth of field aperture
  132182. */
  132183. get: function () {
  132184. return this._dofAperture;
  132185. },
  132186. set: function (value) {
  132187. this.setAperture(value);
  132188. },
  132189. enumerable: true,
  132190. configurable: true
  132191. });
  132192. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  132193. /**
  132194. * Gets or sets the edge distortion
  132195. */
  132196. get: function () {
  132197. return this._distortion;
  132198. },
  132199. set: function (value) {
  132200. this.setEdgeDistortion(value);
  132201. },
  132202. enumerable: true,
  132203. configurable: true
  132204. });
  132205. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  132206. /**
  132207. * Gets or sets the depth of field distortion
  132208. */
  132209. get: function () {
  132210. return this._dofDistance;
  132211. },
  132212. set: function (value) {
  132213. this.setFocusDistance(value);
  132214. },
  132215. enumerable: true,
  132216. configurable: true
  132217. });
  132218. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  132219. /**
  132220. * Gets or sets the darken out of focus amount
  132221. */
  132222. get: function () {
  132223. return this._dofDarken;
  132224. },
  132225. set: function (value) {
  132226. this.setDarkenOutOfFocus(value);
  132227. },
  132228. enumerable: true,
  132229. configurable: true
  132230. });
  132231. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  132232. /**
  132233. * Gets or sets a boolean indicating if blur noise is enabled
  132234. */
  132235. get: function () {
  132236. return this._blurNoise;
  132237. },
  132238. set: function (value) {
  132239. this._blurNoise = value;
  132240. },
  132241. enumerable: true,
  132242. configurable: true
  132243. });
  132244. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  132245. /**
  132246. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  132247. */
  132248. get: function () {
  132249. return this._pentagonBokehIsEnabled;
  132250. },
  132251. set: function (value) {
  132252. if (value) {
  132253. this.enablePentagonBokeh();
  132254. }
  132255. else {
  132256. this.disablePentagonBokeh();
  132257. }
  132258. },
  132259. enumerable: true,
  132260. configurable: true
  132261. });
  132262. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  132263. /**
  132264. * Gets or sets the highlight grain amount
  132265. */
  132266. get: function () {
  132267. return this._highlightsGain;
  132268. },
  132269. set: function (value) {
  132270. this.setHighlightsGain(value);
  132271. },
  132272. enumerable: true,
  132273. configurable: true
  132274. });
  132275. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  132276. /**
  132277. * Gets or sets the highlight threshold
  132278. */
  132279. get: function () {
  132280. return this._highlightsThreshold;
  132281. },
  132282. set: function (value) {
  132283. this.setHighlightsThreshold(value);
  132284. },
  132285. enumerable: true,
  132286. configurable: true
  132287. });
  132288. // public methods (self explanatory)
  132289. /**
  132290. * Sets the amount of blur at the edges
  132291. * @param amount blur amount
  132292. */
  132293. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  132294. /**
  132295. * Sets edge blur to 0
  132296. */
  132297. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  132298. /**
  132299. * Sets the amout of grain
  132300. * @param amount Amount of grain
  132301. */
  132302. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  132303. /**
  132304. * Set grain amount to 0
  132305. */
  132306. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  132307. /**
  132308. * Sets the chromatic aberration amount
  132309. * @param amount amount of chromatic aberration
  132310. */
  132311. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  132312. /**
  132313. * Sets chromatic aberration amount to 0
  132314. */
  132315. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  132316. /**
  132317. * Sets the EdgeDistortion amount
  132318. * @param amount amount of EdgeDistortion
  132319. */
  132320. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  132321. /**
  132322. * Sets edge distortion to 0
  132323. */
  132324. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  132325. /**
  132326. * Sets the FocusDistance amount
  132327. * @param amount amount of FocusDistance
  132328. */
  132329. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  132330. /**
  132331. * Disables depth of field
  132332. */
  132333. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  132334. /**
  132335. * Sets the Aperture amount
  132336. * @param amount amount of Aperture
  132337. */
  132338. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  132339. /**
  132340. * Sets the DarkenOutOfFocus amount
  132341. * @param amount amount of DarkenOutOfFocus
  132342. */
  132343. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  132344. /**
  132345. * Creates a pentagon bokeh effect
  132346. */
  132347. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  132348. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  132349. this._pentagonBokehIsEnabled = true;
  132350. };
  132351. /**
  132352. * Disables the pentagon bokeh effect
  132353. */
  132354. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  132355. this._pentagonBokehIsEnabled = false;
  132356. this._highlightsPostProcess.updateEffect();
  132357. };
  132358. /**
  132359. * Enables noise blur
  132360. */
  132361. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  132362. /**
  132363. * Disables noise blur
  132364. */
  132365. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  132366. /**
  132367. * Sets the HighlightsGain amount
  132368. * @param amount amount of HighlightsGain
  132369. */
  132370. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  132371. this._highlightsGain = amount;
  132372. };
  132373. /**
  132374. * Sets the HighlightsThreshold amount
  132375. * @param amount amount of HighlightsThreshold
  132376. */
  132377. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  132378. if (this._highlightsGain === -1) {
  132379. this._highlightsGain = 1.0;
  132380. }
  132381. this._highlightsThreshold = amount;
  132382. };
  132383. /**
  132384. * Disables highlights
  132385. */
  132386. LensRenderingPipeline.prototype.disableHighlights = function () {
  132387. this._highlightsGain = -1;
  132388. };
  132389. /**
  132390. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  132391. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  132392. */
  132393. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  132394. if (disableDepthRender === void 0) { disableDepthRender = false; }
  132395. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  132396. this._chromaticAberrationPostProcess = null;
  132397. this._highlightsPostProcess = null;
  132398. this._depthOfFieldPostProcess = null;
  132399. this._grainTexture.dispose();
  132400. if (disableDepthRender) {
  132401. this._scene.disableDepthRenderer();
  132402. }
  132403. };
  132404. // colors shifting and distortion
  132405. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  132406. var _this = this;
  132407. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  132408. [], // samplers
  132409. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  132410. this._chromaticAberrationPostProcess.onApply = function (effect) {
  132411. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  132412. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  132413. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  132414. effect.setFloat('radialIntensity', 1);
  132415. effect.setFloat2('direction', 17, 17);
  132416. effect.setFloat2('centerPosition', 0.5, 0.5);
  132417. };
  132418. };
  132419. // highlights enhancing
  132420. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  132421. var _this = this;
  132422. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  132423. [], // samplers
  132424. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  132425. this._highlightsPostProcess.onApply = function (effect) {
  132426. effect.setFloat('gain', _this._highlightsGain);
  132427. effect.setFloat('threshold', _this._highlightsThreshold);
  132428. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  132429. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  132430. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  132431. };
  132432. };
  132433. // colors shifting and distortion
  132434. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  132435. var _this = this;
  132436. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  132437. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  132438. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  132439. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  132440. this._depthOfFieldPostProcess.onApply = function (effect) {
  132441. effect.setTexture("depthSampler", _this._depthTexture);
  132442. effect.setTexture("grainSampler", _this._grainTexture);
  132443. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  132444. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  132445. effect.setFloat('grain_amount', _this._grainAmount);
  132446. effect.setBool('blur_noise', _this._blurNoise);
  132447. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  132448. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  132449. effect.setFloat('distortion', _this._distortion);
  132450. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  132451. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  132452. effect.setFloat('aperture', _this._dofAperture);
  132453. effect.setFloat('darken', _this._dofDarken);
  132454. effect.setFloat('edge_blur', _this._edgeBlur);
  132455. effect.setBool('highlights', (_this._highlightsGain !== -1));
  132456. if (_this._scene.activeCamera) {
  132457. effect.setFloat('near', _this._scene.activeCamera.minZ);
  132458. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  132459. }
  132460. };
  132461. };
  132462. // creates a black and white random noise texture, 512x512
  132463. LensRenderingPipeline.prototype._createGrainTexture = function () {
  132464. var size = 512;
  132465. 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);
  132466. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  132467. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  132468. var context = this._grainTexture.getContext();
  132469. var rand = function (min, max) {
  132470. return Math.random() * (max - min) + min;
  132471. };
  132472. var value;
  132473. for (var x = 0; x < size; x++) {
  132474. for (var y = 0; y < size; y++) {
  132475. value = Math.floor(rand(0.42, 0.58) * 255);
  132476. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  132477. context.fillRect(x, y, 1, 1);
  132478. }
  132479. }
  132480. this._grainTexture.update(false);
  132481. };
  132482. return LensRenderingPipeline;
  132483. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  132484. /***/ }),
  132485. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  132486. /*!**************************************************************************!*\
  132487. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  132488. \**************************************************************************/
  132489. /*! exports provided: SSAO2RenderingPipeline */
  132490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132491. "use strict";
  132492. __webpack_require__.r(__webpack_exports__);
  132493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  132494. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132495. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  132496. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  132497. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math.vector */ "./Maths/math.vector.ts");
  132498. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  132499. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  132500. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  132501. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  132502. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  132503. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  132504. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  132505. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  132506. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  132507. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  132508. /**
  132509. * Render pipeline to produce ssao effect
  132510. */
  132511. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  132512. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  132513. /**
  132514. * @constructor
  132515. * @param name The rendering pipeline name
  132516. * @param scene The scene linked to this pipeline
  132517. * @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 }
  132518. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132519. */
  132520. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  132521. var _this = _super.call(this, scene.getEngine(), name) || this;
  132522. // Members
  132523. /**
  132524. * @ignore
  132525. * The PassPostProcess id in the pipeline that contains the original scene color
  132526. */
  132527. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  132528. /**
  132529. * @ignore
  132530. * The SSAO PostProcess id in the pipeline
  132531. */
  132532. _this.SSAORenderEffect = "SSAORenderEffect";
  132533. /**
  132534. * @ignore
  132535. * The horizontal blur PostProcess id in the pipeline
  132536. */
  132537. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  132538. /**
  132539. * @ignore
  132540. * The vertical blur PostProcess id in the pipeline
  132541. */
  132542. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  132543. /**
  132544. * @ignore
  132545. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  132546. */
  132547. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  132548. /**
  132549. * The output strength of the SSAO post-process. Default value is 1.0.
  132550. */
  132551. _this.totalStrength = 1.0;
  132552. /**
  132553. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  132554. */
  132555. _this.maxZ = 100.0;
  132556. /**
  132557. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  132558. */
  132559. _this.minZAspect = 0.2;
  132560. _this._samples = 8;
  132561. _this._textureSamples = 1;
  132562. _this._expensiveBlur = true;
  132563. /**
  132564. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  132565. */
  132566. _this.radius = 2.0;
  132567. /**
  132568. * The base color of the SSAO post-process
  132569. * The final result is "base + ssao" between [0, 1]
  132570. */
  132571. _this.base = 0;
  132572. _this._firstUpdate = true;
  132573. _this._bits = new Uint32Array(1);
  132574. _this._scene = scene;
  132575. _this._ratio = ratio;
  132576. if (!_this.isSupported) {
  132577. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  132578. return _this;
  132579. }
  132580. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  132581. var blurRatio = _this._ratio.blurRatio || ratio;
  132582. // Set up assets
  132583. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  132584. _this._createRandomTexture();
  132585. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  132586. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  132587. _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);
  132588. _this._originalColorPostProcess.samples = _this.textureSamples;
  132589. _this._createSSAOPostProcess(1.0);
  132590. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  132591. _this._createSSAOCombinePostProcess(blurRatio);
  132592. // Set up pipeline
  132593. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  132594. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  132595. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  132596. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  132597. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  132598. // Finish
  132599. scene.postProcessRenderPipelineManager.addPipeline(_this);
  132600. if (cameras) {
  132601. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  132602. }
  132603. return _this;
  132604. }
  132605. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  132606. get: function () {
  132607. return this._samples;
  132608. },
  132609. /**
  132610. * Number of samples used for the SSAO calculations. Default value is 8
  132611. */
  132612. set: function (n) {
  132613. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  132614. this._samples = n;
  132615. this._sampleSphere = this._generateHemisphere();
  132616. this._firstUpdate = true;
  132617. },
  132618. enumerable: true,
  132619. configurable: true
  132620. });
  132621. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  132622. get: function () {
  132623. return this._textureSamples;
  132624. },
  132625. /**
  132626. * Number of samples to use for antialiasing
  132627. */
  132628. set: function (n) {
  132629. this._textureSamples = n;
  132630. this._originalColorPostProcess.samples = n;
  132631. this._blurHPostProcess.samples = n;
  132632. this._blurVPostProcess.samples = n;
  132633. this._ssaoPostProcess.samples = n;
  132634. this._ssaoCombinePostProcess.samples = n;
  132635. },
  132636. enumerable: true,
  132637. configurable: true
  132638. });
  132639. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  132640. get: function () {
  132641. return this._expensiveBlur;
  132642. },
  132643. /**
  132644. * If bilateral blur should be used
  132645. */
  132646. set: function (b) {
  132647. 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"]);
  132648. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  132649. this._expensiveBlur = b;
  132650. this._firstUpdate = true;
  132651. },
  132652. enumerable: true,
  132653. configurable: true
  132654. });
  132655. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  132656. /**
  132657. * Support test.
  132658. */
  132659. get: function () {
  132660. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  132661. if (!engine) {
  132662. return false;
  132663. }
  132664. return engine.getCaps().drawBuffersExtension;
  132665. },
  132666. enumerable: true,
  132667. configurable: true
  132668. });
  132669. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  132670. /**
  132671. * Gets active scene
  132672. */
  132673. get: function () {
  132674. return this._scene;
  132675. },
  132676. enumerable: true,
  132677. configurable: true
  132678. });
  132679. // Public Methods
  132680. /**
  132681. * Get the class name
  132682. * @returns "SSAO2RenderingPipeline"
  132683. */
  132684. SSAO2RenderingPipeline.prototype.getClassName = function () {
  132685. return "SSAO2RenderingPipeline";
  132686. };
  132687. /**
  132688. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  132689. */
  132690. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  132691. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  132692. for (var i = 0; i < this._scene.cameras.length; i++) {
  132693. var camera = this._scene.cameras[i];
  132694. this._originalColorPostProcess.dispose(camera);
  132695. this._ssaoPostProcess.dispose(camera);
  132696. this._blurHPostProcess.dispose(camera);
  132697. this._blurVPostProcess.dispose(camera);
  132698. this._ssaoCombinePostProcess.dispose(camera);
  132699. }
  132700. this._randomTexture.dispose();
  132701. if (disableGeometryBufferRenderer) {
  132702. this._scene.disableGeometryBufferRenderer();
  132703. }
  132704. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  132705. _super.prototype.dispose.call(this);
  132706. };
  132707. // Private Methods
  132708. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  132709. var _this = this;
  132710. this._samplerOffsets = [];
  132711. var expensive = this.expensiveBlur;
  132712. for (var i = -8; i < 8; i++) {
  132713. this._samplerOffsets.push(i * 2 + 0.5);
  132714. }
  132715. 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");
  132716. this._blurHPostProcess.onApply = function (effect) {
  132717. if (!_this._scene.activeCamera) {
  132718. return;
  132719. }
  132720. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  132721. effect.setFloat("near", _this._scene.activeCamera.minZ);
  132722. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  132723. effect.setFloat("radius", _this.radius);
  132724. effect.setTexture("depthSampler", _this._depthTexture);
  132725. if (_this._firstUpdate) {
  132726. effect.setArray("samplerOffsets", _this._samplerOffsets);
  132727. }
  132728. };
  132729. 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");
  132730. this._blurVPostProcess.onApply = function (effect) {
  132731. if (!_this._scene.activeCamera) {
  132732. return;
  132733. }
  132734. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  132735. effect.setFloat("near", _this._scene.activeCamera.minZ);
  132736. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  132737. effect.setFloat("radius", _this.radius);
  132738. effect.setTexture("depthSampler", _this._depthTexture);
  132739. if (_this._firstUpdate) {
  132740. effect.setArray("samplerOffsets", _this._samplerOffsets);
  132741. _this._firstUpdate = false;
  132742. }
  132743. };
  132744. this._blurHPostProcess.samples = this.textureSamples;
  132745. this._blurVPostProcess.samples = this.textureSamples;
  132746. };
  132747. /** @hidden */
  132748. SSAO2RenderingPipeline.prototype._rebuild = function () {
  132749. this._firstUpdate = true;
  132750. _super.prototype._rebuild.call(this);
  132751. };
  132752. //Van der Corput radical inverse
  132753. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  132754. this._bits[0] = i;
  132755. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  132756. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  132757. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  132758. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  132759. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  132760. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  132761. };
  132762. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  132763. return [i / n, this._radicalInverse_VdC(i)];
  132764. };
  132765. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  132766. var phi = v * 2.0 * Math.PI;
  132767. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  132768. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  132769. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  132770. return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  132771. };
  132772. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  132773. var numSamples = this.samples;
  132774. var result = [];
  132775. var vector;
  132776. var i = 0;
  132777. while (i < numSamples) {
  132778. if (numSamples < 16) {
  132779. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  132780. }
  132781. else {
  132782. var rand = this._hammersley(i, numSamples);
  132783. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  132784. }
  132785. result.push(vector.x, vector.y, vector.z);
  132786. i++;
  132787. }
  132788. return result;
  132789. };
  132790. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  132791. var _this = this;
  132792. var numSamples = this.samples;
  132793. this._sampleSphere = this._generateHemisphere();
  132794. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  132795. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  132796. "base", "range", "projection", "near", "far", "texelSize",
  132797. "xViewport", "yViewport", "maxZ", "minZAspect"
  132798. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  132799. this._ssaoPostProcess.onApply = function (effect) {
  132800. if (_this._firstUpdate) {
  132801. effect.setArray3("sampleSphere", _this._sampleSphere);
  132802. effect.setFloat("randTextureTiles", 32.0);
  132803. }
  132804. if (!_this._scene.activeCamera) {
  132805. return;
  132806. }
  132807. effect.setFloat("samplesFactor", 1 / _this.samples);
  132808. effect.setFloat("totalStrength", _this.totalStrength);
  132809. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  132810. effect.setFloat("radius", _this.radius);
  132811. effect.setFloat("maxZ", _this.maxZ);
  132812. effect.setFloat("minZAspect", _this.minZAspect);
  132813. effect.setFloat("base", _this.base);
  132814. effect.setFloat("near", _this._scene.activeCamera.minZ);
  132815. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  132816. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  132817. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  132818. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  132819. effect.setTexture("textureSampler", _this._depthTexture);
  132820. effect.setTexture("normalSampler", _this._normalTexture);
  132821. effect.setTexture("randomSampler", _this._randomTexture);
  132822. };
  132823. this._ssaoPostProcess.samples = this.textureSamples;
  132824. };
  132825. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  132826. var _this = this;
  132827. 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);
  132828. this._ssaoCombinePostProcess.onApply = function (effect) {
  132829. var viewport = _this._scene.activeCamera.viewport;
  132830. effect.setVector4("viewport", _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  132831. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  132832. };
  132833. this._ssaoCombinePostProcess.samples = this.textureSamples;
  132834. };
  132835. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  132836. var size = 128;
  132837. 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);
  132838. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  132839. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  132840. var context = this._randomTexture.getContext();
  132841. var rand = function (min, max) {
  132842. return Math.random() * (max - min) + min;
  132843. };
  132844. var randVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  132845. for (var x = 0; x < size; x++) {
  132846. for (var y = 0; y < size; y++) {
  132847. randVector.x = rand(0.0, 1.0);
  132848. randVector.y = rand(0.0, 1.0);
  132849. randVector.z = 0.0;
  132850. randVector.normalize();
  132851. randVector.scaleInPlace(255);
  132852. randVector.x = Math.floor(randVector.x);
  132853. randVector.y = Math.floor(randVector.y);
  132854. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  132855. context.fillRect(x, y, 1, 1);
  132856. }
  132857. }
  132858. this._randomTexture.update(false);
  132859. };
  132860. /**
  132861. * Serialize the rendering pipeline (Used when exporting)
  132862. * @returns the serialized object
  132863. */
  132864. SSAO2RenderingPipeline.prototype.serialize = function () {
  132865. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  132866. serializationObject.customType = "SSAO2RenderingPipeline";
  132867. return serializationObject;
  132868. };
  132869. /**
  132870. * Parse the serialized pipeline
  132871. * @param source Source pipeline.
  132872. * @param scene The scene to load the pipeline to.
  132873. * @param rootUrl The URL of the serialized pipeline.
  132874. * @returns An instantiated pipeline from the serialized object.
  132875. */
  132876. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  132877. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  132878. };
  132879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132881. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  132882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132884. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  132885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132887. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  132888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  132890. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  132891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  132893. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  132894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132896. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  132897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  132899. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  132900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132902. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  132903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132905. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  132906. return SSAO2RenderingPipeline;
  132907. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  132908. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  132909. /***/ }),
  132910. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  132911. /*!*************************************************************************!*\
  132912. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  132913. \*************************************************************************/
  132914. /*! exports provided: SSAORenderingPipeline */
  132915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132916. "use strict";
  132917. __webpack_require__.r(__webpack_exports__);
  132918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  132919. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132920. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math.vector */ "./Maths/math.vector.ts");
  132921. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  132922. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  132923. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  132924. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  132925. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  132926. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  132927. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  132928. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  132929. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  132930. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  132931. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  132932. /**
  132933. * Render pipeline to produce ssao effect
  132934. */
  132935. var SSAORenderingPipeline = /** @class */ (function (_super) {
  132936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  132937. /**
  132938. * @constructor
  132939. * @param name - The rendering pipeline name
  132940. * @param scene - The scene linked to this pipeline
  132941. * @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 }
  132942. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  132943. */
  132944. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  132945. var _this = _super.call(this, scene.getEngine(), name) || this;
  132946. // Members
  132947. /**
  132948. * @ignore
  132949. * The PassPostProcess id in the pipeline that contains the original scene color
  132950. */
  132951. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  132952. /**
  132953. * @ignore
  132954. * The SSAO PostProcess id in the pipeline
  132955. */
  132956. _this.SSAORenderEffect = "SSAORenderEffect";
  132957. /**
  132958. * @ignore
  132959. * The horizontal blur PostProcess id in the pipeline
  132960. */
  132961. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  132962. /**
  132963. * @ignore
  132964. * The vertical blur PostProcess id in the pipeline
  132965. */
  132966. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  132967. /**
  132968. * @ignore
  132969. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  132970. */
  132971. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  132972. /**
  132973. * The output strength of the SSAO post-process. Default value is 1.0.
  132974. */
  132975. _this.totalStrength = 1.0;
  132976. /**
  132977. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  132978. */
  132979. _this.radius = 0.0001;
  132980. /**
  132981. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  132982. * Must not be equal to fallOff and superior to fallOff.
  132983. * Default value is 0.0075
  132984. */
  132985. _this.area = 0.0075;
  132986. /**
  132987. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  132988. * Must not be equal to area and inferior to area.
  132989. * Default value is 0.000001
  132990. */
  132991. _this.fallOff = 0.000001;
  132992. /**
  132993. * The base color of the SSAO post-process
  132994. * The final result is "base + ssao" between [0, 1]
  132995. */
  132996. _this.base = 0.5;
  132997. _this._firstUpdate = true;
  132998. _this._scene = scene;
  132999. // Set up assets
  133000. _this._createRandomTexture();
  133001. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  133002. var ssaoRatio = ratio.ssaoRatio || ratio;
  133003. var combineRatio = ratio.combineRatio || ratio;
  133004. _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);
  133005. _this._createSSAOPostProcess(ssaoRatio);
  133006. _this._createBlurPostProcess(ssaoRatio);
  133007. _this._createSSAOCombinePostProcess(combineRatio);
  133008. // Set up pipeline
  133009. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  133010. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  133011. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  133012. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  133013. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  133014. // Finish
  133015. scene.postProcessRenderPipelineManager.addPipeline(_this);
  133016. if (cameras) {
  133017. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  133018. }
  133019. return _this;
  133020. }
  133021. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  133022. /**
  133023. * Gets active scene
  133024. */
  133025. get: function () {
  133026. return this._scene;
  133027. },
  133028. enumerable: true,
  133029. configurable: true
  133030. });
  133031. // Public Methods
  133032. /**
  133033. * Get the class name
  133034. * @returns "SSAORenderingPipeline"
  133035. */
  133036. SSAORenderingPipeline.prototype.getClassName = function () {
  133037. return "SSAORenderingPipeline";
  133038. };
  133039. /**
  133040. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  133041. */
  133042. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  133043. if (disableDepthRender === void 0) { disableDepthRender = false; }
  133044. for (var i = 0; i < this._scene.cameras.length; i++) {
  133045. var camera = this._scene.cameras[i];
  133046. this._originalColorPostProcess.dispose(camera);
  133047. this._ssaoPostProcess.dispose(camera);
  133048. this._blurHPostProcess.dispose(camera);
  133049. this._blurVPostProcess.dispose(camera);
  133050. this._ssaoCombinePostProcess.dispose(camera);
  133051. }
  133052. this._randomTexture.dispose();
  133053. if (disableDepthRender) {
  133054. this._scene.disableDepthRenderer();
  133055. }
  133056. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  133057. _super.prototype.dispose.call(this);
  133058. };
  133059. // Private Methods
  133060. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  133061. var _this = this;
  133062. var size = 16;
  133063. this._blurHPostProcess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("BlurH", new _Maths_math_vector__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);
  133064. this._blurVPostProcess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("BlurV", new _Maths_math_vector__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);
  133065. this._blurHPostProcess.onActivateObservable.add(function () {
  133066. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  133067. _this._blurHPostProcess.kernel = size * dw;
  133068. });
  133069. this._blurVPostProcess.onActivateObservable.add(function () {
  133070. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  133071. _this._blurVPostProcess.kernel = size * dw;
  133072. });
  133073. };
  133074. /** @hidden */
  133075. SSAORenderingPipeline.prototype._rebuild = function () {
  133076. this._firstUpdate = true;
  133077. _super.prototype._rebuild.call(this);
  133078. };
  133079. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  133080. var _this = this;
  133081. var numSamples = 16;
  133082. var sampleSphere = [
  133083. 0.5381, 0.1856, -0.4319,
  133084. 0.1379, 0.2486, 0.4430,
  133085. 0.3371, 0.5679, -0.0057,
  133086. -0.6999, -0.0451, -0.0019,
  133087. 0.0689, -0.1598, -0.8547,
  133088. 0.0560, 0.0069, -0.1843,
  133089. -0.0146, 0.1402, 0.0762,
  133090. 0.0100, -0.1924, -0.0344,
  133091. -0.3577, -0.5301, -0.4358,
  133092. -0.3169, 0.1063, 0.0158,
  133093. 0.0103, -0.5869, 0.0046,
  133094. -0.0897, -0.4940, 0.3287,
  133095. 0.7119, -0.0154, -0.0918,
  133096. -0.0533, 0.0596, -0.5411,
  133097. 0.0352, -0.0631, 0.5460,
  133098. -0.4776, 0.2847, -0.0271
  133099. ];
  133100. var samplesFactor = 1.0 / numSamples;
  133101. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  133102. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  133103. "area", "fallOff", "base", "range", "viewport"
  133104. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  133105. this._ssaoPostProcess.onApply = function (effect) {
  133106. if (_this._firstUpdate) {
  133107. effect.setArray3("sampleSphere", sampleSphere);
  133108. effect.setFloat("samplesFactor", samplesFactor);
  133109. effect.setFloat("randTextureTiles", 4.0);
  133110. }
  133111. effect.setFloat("totalStrength", _this.totalStrength);
  133112. effect.setFloat("radius", _this.radius);
  133113. effect.setFloat("area", _this.area);
  133114. effect.setFloat("fallOff", _this.fallOff);
  133115. effect.setFloat("base", _this.base);
  133116. effect.setTexture("textureSampler", _this._depthTexture);
  133117. effect.setTexture("randomSampler", _this._randomTexture);
  133118. };
  133119. };
  133120. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  133121. var _this = this;
  133122. 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);
  133123. this._ssaoCombinePostProcess.onApply = function (effect) {
  133124. effect.setVector4("viewport", _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  133125. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  133126. };
  133127. };
  133128. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  133129. var size = 512;
  133130. 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);
  133131. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  133132. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  133133. var context = this._randomTexture.getContext();
  133134. var rand = function (min, max) {
  133135. return Math.random() * (max - min) + min;
  133136. };
  133137. var randVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  133138. for (var x = 0; x < size; x++) {
  133139. for (var y = 0; y < size; y++) {
  133140. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  133141. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  133142. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  133143. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  133144. context.fillRect(x, y, 1, 1);
  133145. }
  133146. }
  133147. this._randomTexture.update(false);
  133148. };
  133149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  133151. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  133152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  133154. ], SSAORenderingPipeline.prototype, "radius", void 0);
  133155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  133157. ], SSAORenderingPipeline.prototype, "area", void 0);
  133158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  133160. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  133161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  133163. ], SSAORenderingPipeline.prototype, "base", void 0);
  133164. return SSAORenderingPipeline;
  133165. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  133166. /***/ }),
  133167. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  133168. /*!*****************************************************************************!*\
  133169. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  133170. \*****************************************************************************/
  133171. /*! exports provided: StandardRenderingPipeline */
  133172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133173. "use strict";
  133174. __webpack_require__.r(__webpack_exports__);
  133175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  133176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  133177. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  133178. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  133179. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math.vector */ "./Maths/math.vector.ts");
  133180. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  133181. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  133182. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  133183. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  133184. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  133185. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  133186. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  133187. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  133188. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  133189. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  133190. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  133191. /**
  133192. * Standard rendering pipeline
  133193. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  133194. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  133195. */
  133196. var StandardRenderingPipeline = /** @class */ (function (_super) {
  133197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  133198. /**
  133199. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  133200. * @constructor
  133201. * @param name The rendering pipeline name
  133202. * @param scene The scene linked to this pipeline
  133203. * @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)
  133204. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  133205. * @param cameras The array of cameras that the rendering pipeline will be attached to
  133206. */
  133207. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  133208. if (originalPostProcess === void 0) { originalPostProcess = null; }
  133209. var _this = _super.call(this, scene.getEngine(), name) || this;
  133210. /**
  133211. * Post-process used to down scale an image x4
  133212. */
  133213. _this.downSampleX4PostProcess = null;
  133214. /**
  133215. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  133216. */
  133217. _this.brightPassPostProcess = null;
  133218. /**
  133219. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  133220. */
  133221. _this.blurHPostProcesses = [];
  133222. /**
  133223. * Post-process array storing all the vertical blur post-processes used by the pipeline
  133224. */
  133225. _this.blurVPostProcesses = [];
  133226. /**
  133227. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  133228. */
  133229. _this.textureAdderPostProcess = null;
  133230. /**
  133231. * Post-process used to create volumetric lighting effect
  133232. */
  133233. _this.volumetricLightPostProcess = null;
  133234. /**
  133235. * Post-process used to smooth the previous volumetric light post-process on the X axis
  133236. */
  133237. _this.volumetricLightSmoothXPostProcess = null;
  133238. /**
  133239. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  133240. */
  133241. _this.volumetricLightSmoothYPostProcess = null;
  133242. /**
  133243. * Post-process used to merge the volumetric light effect and the real scene color
  133244. */
  133245. _this.volumetricLightMergePostProces = null;
  133246. /**
  133247. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  133248. */
  133249. _this.volumetricLightFinalPostProcess = null;
  133250. /**
  133251. * Base post-process used to calculate the average luminance of the final image for HDR
  133252. */
  133253. _this.luminancePostProcess = null;
  133254. /**
  133255. * Post-processes used to create down sample post-processes in order to get
  133256. * the average luminance of the final image for HDR
  133257. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  133258. */
  133259. _this.luminanceDownSamplePostProcesses = [];
  133260. /**
  133261. * Post-process used to create a HDR effect (light adaptation)
  133262. */
  133263. _this.hdrPostProcess = null;
  133264. /**
  133265. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  133266. */
  133267. _this.textureAdderFinalPostProcess = null;
  133268. /**
  133269. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  133270. */
  133271. _this.lensFlareFinalPostProcess = null;
  133272. /**
  133273. * Post-process used to merge the final HDR post-process and the real scene color
  133274. */
  133275. _this.hdrFinalPostProcess = null;
  133276. /**
  133277. * Post-process used to create a lens flare effect
  133278. */
  133279. _this.lensFlarePostProcess = null;
  133280. /**
  133281. * Post-process that merges the result of the lens flare post-process and the real scene color
  133282. */
  133283. _this.lensFlareComposePostProcess = null;
  133284. /**
  133285. * Post-process used to create a motion blur effect
  133286. */
  133287. _this.motionBlurPostProcess = null;
  133288. /**
  133289. * Post-process used to create a depth of field effect
  133290. */
  133291. _this.depthOfFieldPostProcess = null;
  133292. /**
  133293. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  133294. */
  133295. _this.fxaaPostProcess = null;
  133296. // Values
  133297. /**
  133298. * Represents the brightness threshold in order to configure the illuminated surfaces
  133299. */
  133300. _this.brightThreshold = 1.0;
  133301. /**
  133302. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  133303. */
  133304. _this.blurWidth = 512.0;
  133305. /**
  133306. * Sets if the blur for highlighted surfaces must be only horizontal
  133307. */
  133308. _this.horizontalBlur = false;
  133309. /**
  133310. * Texture used typically to simulate "dirty" on camera lens
  133311. */
  133312. _this.lensTexture = null;
  133313. /**
  133314. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  133315. */
  133316. _this.volumetricLightCoefficient = 0.2;
  133317. /**
  133318. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  133319. */
  133320. _this.volumetricLightPower = 4.0;
  133321. /**
  133322. * Used the set the blur intensity to smooth the volumetric lights
  133323. */
  133324. _this.volumetricLightBlurScale = 64.0;
  133325. /**
  133326. * Light (spot or directional) used to generate the volumetric lights rays
  133327. * The source light must have a shadow generate so the pipeline can get its
  133328. * depth map
  133329. */
  133330. _this.sourceLight = null;
  133331. /**
  133332. * For eye adaptation, represents the minimum luminance the eye can see
  133333. */
  133334. _this.hdrMinimumLuminance = 1.0;
  133335. /**
  133336. * For eye adaptation, represents the decrease luminance speed
  133337. */
  133338. _this.hdrDecreaseRate = 0.5;
  133339. /**
  133340. * For eye adaptation, represents the increase luminance speed
  133341. */
  133342. _this.hdrIncreaseRate = 0.5;
  133343. /**
  133344. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  133345. */
  133346. _this.lensColorTexture = null;
  133347. /**
  133348. * The overall strengh for the lens flare effect
  133349. */
  133350. _this.lensFlareStrength = 20.0;
  133351. /**
  133352. * Dispersion coefficient for lens flare ghosts
  133353. */
  133354. _this.lensFlareGhostDispersal = 1.4;
  133355. /**
  133356. * Main lens flare halo width
  133357. */
  133358. _this.lensFlareHaloWidth = 0.7;
  133359. /**
  133360. * Based on the lens distortion effect, defines how much the lens flare result
  133361. * is distorted
  133362. */
  133363. _this.lensFlareDistortionStrength = 16.0;
  133364. /**
  133365. * Lens star texture must be used to simulate rays on the flares and is available
  133366. * in the documentation
  133367. */
  133368. _this.lensStarTexture = null;
  133369. /**
  133370. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  133371. * flare effect by taking account of the dirt texture
  133372. */
  133373. _this.lensFlareDirtTexture = null;
  133374. /**
  133375. * Represents the focal length for the depth of field effect
  133376. */
  133377. _this.depthOfFieldDistance = 10.0;
  133378. /**
  133379. * Represents the blur intensity for the blurred part of the depth of field effect
  133380. */
  133381. _this.depthOfFieldBlurWidth = 64.0;
  133382. /**
  133383. * List of animations for the pipeline (IAnimatable implementation)
  133384. */
  133385. _this.animations = [];
  133386. _this._currentDepthOfFieldSource = null;
  133387. _this._fixedExposure = 1.0;
  133388. _this._currentExposure = 1.0;
  133389. _this._hdrAutoExposure = false;
  133390. _this._hdrCurrentLuminance = 1.0;
  133391. _this._motionStrength = 1.0;
  133392. _this._isObjectBasedMotionBlur = false;
  133393. // Getters and setters
  133394. _this._bloomEnabled = false;
  133395. _this._depthOfFieldEnabled = false;
  133396. _this._vlsEnabled = false;
  133397. _this._lensFlareEnabled = false;
  133398. _this._hdrEnabled = false;
  133399. _this._motionBlurEnabled = false;
  133400. _this._fxaaEnabled = false;
  133401. _this._motionBlurSamples = 64.0;
  133402. _this._volumetricLightStepsCount = 50.0;
  133403. _this._samples = 1;
  133404. _this._cameras = cameras || [];
  133405. // Initialize
  133406. _this._scene = scene;
  133407. _this._basePostProcess = originalPostProcess;
  133408. _this._ratio = ratio;
  133409. // Misc
  133410. _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;
  133411. // Finish
  133412. scene.postProcessRenderPipelineManager.addPipeline(_this);
  133413. _this._buildPipeline();
  133414. return _this;
  133415. }
  133416. Object.defineProperty(StandardRenderingPipeline.prototype, "exposure", {
  133417. /**
  133418. * Gets the overall exposure used by the pipeline
  133419. */
  133420. get: function () {
  133421. return this._fixedExposure;
  133422. },
  133423. /**
  133424. * Sets the overall exposure used by the pipeline
  133425. */
  133426. set: function (value) {
  133427. this._fixedExposure = value;
  133428. this._currentExposure = value;
  133429. },
  133430. enumerable: true,
  133431. configurable: true
  133432. });
  133433. Object.defineProperty(StandardRenderingPipeline.prototype, "hdrAutoExposure", {
  133434. /**
  133435. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  133436. */
  133437. get: function () {
  133438. return this._hdrAutoExposure;
  133439. },
  133440. /**
  133441. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  133442. */
  133443. set: function (value) {
  133444. this._hdrAutoExposure = value;
  133445. if (this.hdrPostProcess) {
  133446. var defines = ["#define HDR"];
  133447. if (value) {
  133448. defines.push("#define AUTO_EXPOSURE");
  133449. }
  133450. this.hdrPostProcess.updateEffect(defines.join("\n"));
  133451. }
  133452. },
  133453. enumerable: true,
  133454. configurable: true
  133455. });
  133456. Object.defineProperty(StandardRenderingPipeline.prototype, "motionStrength", {
  133457. /**
  133458. * Gets how much the image is blurred by the movement while using the motion blur post-process
  133459. */
  133460. get: function () {
  133461. return this._motionStrength;
  133462. },
  133463. /**
  133464. * Sets how much the image is blurred by the movement while using the motion blur post-process
  133465. */
  133466. set: function (strength) {
  133467. this._motionStrength = strength;
  133468. if (this._isObjectBasedMotionBlur && this.motionBlurPostProcess) {
  133469. this.motionBlurPostProcess.motionStrength = strength;
  133470. }
  133471. },
  133472. enumerable: true,
  133473. configurable: true
  133474. });
  133475. Object.defineProperty(StandardRenderingPipeline.prototype, "objectBasedMotionBlur", {
  133476. /**
  133477. * Gets wether or not the motion blur post-process is object based or screen based.
  133478. */
  133479. get: function () {
  133480. return this._isObjectBasedMotionBlur;
  133481. },
  133482. /**
  133483. * Sets wether or not the motion blur post-process should be object based or screen based
  133484. */
  133485. set: function (value) {
  133486. var shouldRebuild = this._isObjectBasedMotionBlur !== value;
  133487. this._isObjectBasedMotionBlur = value;
  133488. if (shouldRebuild) {
  133489. this._buildPipeline();
  133490. }
  133491. },
  133492. enumerable: true,
  133493. configurable: true
  133494. });
  133495. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  133496. /**
  133497. * @ignore
  133498. * Specifies if the bloom pipeline is enabled
  133499. */
  133500. get: function () {
  133501. return this._bloomEnabled;
  133502. },
  133503. set: function (enabled) {
  133504. if (this._bloomEnabled === enabled) {
  133505. return;
  133506. }
  133507. this._bloomEnabled = enabled;
  133508. this._buildPipeline();
  133509. },
  133510. enumerable: true,
  133511. configurable: true
  133512. });
  133513. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  133514. /**
  133515. * @ignore
  133516. * Specifies if the depth of field pipeline is enabed
  133517. */
  133518. get: function () {
  133519. return this._depthOfFieldEnabled;
  133520. },
  133521. set: function (enabled) {
  133522. if (this._depthOfFieldEnabled === enabled) {
  133523. return;
  133524. }
  133525. this._depthOfFieldEnabled = enabled;
  133526. this._buildPipeline();
  133527. },
  133528. enumerable: true,
  133529. configurable: true
  133530. });
  133531. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  133532. /**
  133533. * @ignore
  133534. * Specifies if the lens flare pipeline is enabed
  133535. */
  133536. get: function () {
  133537. return this._lensFlareEnabled;
  133538. },
  133539. set: function (enabled) {
  133540. if (this._lensFlareEnabled === enabled) {
  133541. return;
  133542. }
  133543. this._lensFlareEnabled = enabled;
  133544. this._buildPipeline();
  133545. },
  133546. enumerable: true,
  133547. configurable: true
  133548. });
  133549. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  133550. /**
  133551. * @ignore
  133552. * Specifies if the HDR pipeline is enabled
  133553. */
  133554. get: function () {
  133555. return this._hdrEnabled;
  133556. },
  133557. set: function (enabled) {
  133558. if (this._hdrEnabled === enabled) {
  133559. return;
  133560. }
  133561. this._hdrEnabled = enabled;
  133562. this._buildPipeline();
  133563. },
  133564. enumerable: true,
  133565. configurable: true
  133566. });
  133567. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  133568. /**
  133569. * @ignore
  133570. * Specifies if the volumetric lights scattering effect is enabled
  133571. */
  133572. get: function () {
  133573. return this._vlsEnabled;
  133574. },
  133575. set: function (enabled) {
  133576. if (this._vlsEnabled === enabled) {
  133577. return;
  133578. }
  133579. if (enabled) {
  133580. var geometry = this._scene.enableGeometryBufferRenderer();
  133581. if (!geometry) {
  133582. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  133583. return;
  133584. }
  133585. }
  133586. this._vlsEnabled = enabled;
  133587. this._buildPipeline();
  133588. },
  133589. enumerable: true,
  133590. configurable: true
  133591. });
  133592. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  133593. /**
  133594. * @ignore
  133595. * Specifies if the motion blur effect is enabled
  133596. */
  133597. get: function () {
  133598. return this._motionBlurEnabled;
  133599. },
  133600. set: function (enabled) {
  133601. if (this._motionBlurEnabled === enabled) {
  133602. return;
  133603. }
  133604. this._motionBlurEnabled = enabled;
  133605. this._buildPipeline();
  133606. },
  133607. enumerable: true,
  133608. configurable: true
  133609. });
  133610. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  133611. /**
  133612. * Specifies if anti-aliasing is enabled
  133613. */
  133614. get: function () {
  133615. return this._fxaaEnabled;
  133616. },
  133617. set: function (enabled) {
  133618. if (this._fxaaEnabled === enabled) {
  133619. return;
  133620. }
  133621. this._fxaaEnabled = enabled;
  133622. this._buildPipeline();
  133623. },
  133624. enumerable: true,
  133625. configurable: true
  133626. });
  133627. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  133628. /**
  133629. * Specifies the number of steps used to calculate the volumetric lights
  133630. * Typically in interval [50, 200]
  133631. */
  133632. get: function () {
  133633. return this._volumetricLightStepsCount;
  133634. },
  133635. set: function (count) {
  133636. if (this.volumetricLightPostProcess) {
  133637. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  133638. }
  133639. this._volumetricLightStepsCount = count;
  133640. },
  133641. enumerable: true,
  133642. configurable: true
  133643. });
  133644. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  133645. /**
  133646. * Specifies the number of samples used for the motion blur effect
  133647. * Typically in interval [16, 64]
  133648. */
  133649. get: function () {
  133650. return this._motionBlurSamples;
  133651. },
  133652. set: function (samples) {
  133653. if (this.motionBlurPostProcess) {
  133654. if (this._isObjectBasedMotionBlur) {
  133655. this.motionBlurPostProcess.motionBlurSamples = samples;
  133656. }
  133657. else {
  133658. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  133659. }
  133660. }
  133661. this._motionBlurSamples = samples;
  133662. },
  133663. enumerable: true,
  133664. configurable: true
  133665. });
  133666. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  133667. /**
  133668. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  133669. */
  133670. get: function () {
  133671. return this._samples;
  133672. },
  133673. set: function (sampleCount) {
  133674. if (this._samples === sampleCount) {
  133675. return;
  133676. }
  133677. this._samples = sampleCount;
  133678. this._buildPipeline();
  133679. },
  133680. enumerable: true,
  133681. configurable: true
  133682. });
  133683. StandardRenderingPipeline.prototype._buildPipeline = function () {
  133684. var _this = this;
  133685. var ratio = this._ratio;
  133686. var scene = this._scene;
  133687. this._disposePostProcesses();
  133688. this._reset();
  133689. // Create pass post-process
  133690. if (!this._basePostProcess) {
  133691. 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);
  133692. this.originalPostProcess.onApply = function () {
  133693. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  133694. };
  133695. }
  133696. else {
  133697. this.originalPostProcess = this._basePostProcess;
  133698. }
  133699. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  133700. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  133701. }
  133702. this._currentDepthOfFieldSource = this.originalPostProcess;
  133703. if (this._bloomEnabled) {
  133704. // Create down sample X4 post-process
  133705. this._createDownSampleX4PostProcess(scene, ratio / 2);
  133706. // Create bright pass post-process
  133707. this._createBrightPassPostProcess(scene, ratio / 2);
  133708. // Create gaussian blur post-processes (down sampling blurs)
  133709. this._createBlurPostProcesses(scene, ratio / 4, 1);
  133710. // Create texture adder post-process
  133711. this._createTextureAdderPostProcess(scene, ratio);
  133712. // Create depth-of-field source post-process
  133713. 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);
  133714. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  133715. }
  133716. if (this._vlsEnabled) {
  133717. // Create volumetric light
  133718. this._createVolumetricLightPostProcess(scene, ratio);
  133719. // Create volumetric light final post-process
  133720. 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);
  133721. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  133722. }
  133723. if (this._lensFlareEnabled) {
  133724. // Create lens flare post-process
  133725. this._createLensFlarePostProcess(scene, ratio);
  133726. // Create depth-of-field source post-process post lens-flare and disable it now
  133727. 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);
  133728. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  133729. }
  133730. if (this._hdrEnabled) {
  133731. // Create luminance
  133732. this._createLuminancePostProcesses(scene, this._floatTextureType);
  133733. // Create HDR
  133734. this._createHdrPostProcess(scene, ratio);
  133735. // Create depth-of-field source post-process post hdr and disable it now
  133736. 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);
  133737. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  133738. }
  133739. if (this._depthOfFieldEnabled) {
  133740. // Create gaussian blur used by depth-of-field
  133741. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  133742. // Create depth-of-field post-process
  133743. this._createDepthOfFieldPostProcess(scene, ratio);
  133744. }
  133745. if (this._motionBlurEnabled) {
  133746. // Create motion blur post-process
  133747. this._createMotionBlurPostProcess(scene, ratio);
  133748. }
  133749. if (this._fxaaEnabled) {
  133750. // Create fxaa post-process
  133751. 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);
  133752. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  133753. }
  133754. if (this._cameras !== null) {
  133755. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  133756. }
  133757. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  133758. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  133759. }
  133760. };
  133761. // Down Sample X4 Post-Processs
  133762. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  133763. var _this = this;
  133764. var downSampleX4Offsets = new Array(32);
  133765. 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);
  133766. this.downSampleX4PostProcess.onApply = function (effect) {
  133767. var id = 0;
  133768. var width = _this.downSampleX4PostProcess.width;
  133769. var height = _this.downSampleX4PostProcess.height;
  133770. for (var i = -2; i < 2; i++) {
  133771. for (var j = -2; j < 2; j++) {
  133772. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  133773. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  133774. id += 2;
  133775. }
  133776. }
  133777. effect.setArray2("dsOffsets", downSampleX4Offsets);
  133778. };
  133779. // Add to pipeline
  133780. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  133781. };
  133782. // Brightpass Post-Process
  133783. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  133784. var _this = this;
  133785. var brightOffsets = new Array(8);
  133786. 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);
  133787. this.brightPassPostProcess.onApply = function (effect) {
  133788. var sU = (1.0 / _this.brightPassPostProcess.width);
  133789. var sV = (1.0 / _this.brightPassPostProcess.height);
  133790. brightOffsets[0] = -0.5 * sU;
  133791. brightOffsets[1] = 0.5 * sV;
  133792. brightOffsets[2] = 0.5 * sU;
  133793. brightOffsets[3] = 0.5 * sV;
  133794. brightOffsets[4] = -0.5 * sU;
  133795. brightOffsets[5] = -0.5 * sV;
  133796. brightOffsets[6] = 0.5 * sU;
  133797. brightOffsets[7] = -0.5 * sV;
  133798. effect.setArray2("dsOffsets", brightOffsets);
  133799. effect.setFloat("brightThreshold", _this.brightThreshold);
  133800. };
  133801. // Add to pipeline
  133802. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  133803. };
  133804. // Create blur H&V post-processes
  133805. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  133806. var _this = this;
  133807. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  133808. var engine = scene.getEngine();
  133809. var blurX = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"]("HDRBlurH" + "_" + indice, new _Maths_math_vector__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);
  133810. var blurY = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"]("HDRBlurV" + "_" + indice, new _Maths_math_vector__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);
  133811. blurX.onActivateObservable.add(function () {
  133812. var dw = blurX.width / engine.getRenderWidth();
  133813. blurX.kernel = _this[blurWidthKey] * dw;
  133814. });
  133815. blurY.onActivateObservable.add(function () {
  133816. var dw = blurY.height / engine.getRenderHeight();
  133817. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  133818. });
  133819. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  133820. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  133821. this.blurHPostProcesses.push(blurX);
  133822. this.blurVPostProcesses.push(blurY);
  133823. };
  133824. // Create texture adder post-process
  133825. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  133826. var _this = this;
  133827. 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);
  133828. this.textureAdderPostProcess.onApply = function (effect) {
  133829. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  133830. effect.setTexture("lensSampler", _this.lensTexture);
  133831. effect.setFloat("exposure", _this._currentExposure);
  133832. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  133833. };
  133834. // Add to pipeline
  133835. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  133836. };
  133837. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  133838. var _this = this;
  133839. var geometryRenderer = scene.enableGeometryBufferRenderer();
  133840. geometryRenderer.enablePosition = true;
  133841. var geometry = geometryRenderer.getGBuffer();
  133842. // Base post-process
  133843. 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));
  133844. var depthValues = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  133845. this.volumetricLightPostProcess.onApply = function (effect) {
  133846. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  133847. var generator = _this.sourceLight.getShadowGenerator();
  133848. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  133849. effect.setTexture("positionSampler", geometry.textures[2]);
  133850. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  133851. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  133852. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  133853. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  133854. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  133855. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  133856. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  133857. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  133858. effect.setVector2("depthValues", depthValues);
  133859. }
  133860. };
  133861. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  133862. // Smooth
  133863. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  133864. // Merge
  133865. 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");
  133866. this.volumetricLightMergePostProces.onApply = function (effect) {
  133867. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  133868. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  133869. };
  133870. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  133871. };
  133872. // Create luminance
  133873. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  133874. var _this = this;
  133875. // Create luminance
  133876. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  133877. 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);
  133878. var offsets = [];
  133879. this.luminancePostProcess.onApply = function (effect) {
  133880. var sU = (1.0 / _this.luminancePostProcess.width);
  133881. var sV = (1.0 / _this.luminancePostProcess.height);
  133882. offsets[0] = -0.5 * sU;
  133883. offsets[1] = 0.5 * sV;
  133884. offsets[2] = 0.5 * sU;
  133885. offsets[3] = 0.5 * sV;
  133886. offsets[4] = -0.5 * sU;
  133887. offsets[5] = -0.5 * sV;
  133888. offsets[6] = 0.5 * sU;
  133889. offsets[7] = -0.5 * sV;
  133890. effect.setArray2("lumOffsets", offsets);
  133891. };
  133892. // Add to pipeline
  133893. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  133894. // Create down sample luminance
  133895. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  133896. var size = Math.pow(3, i);
  133897. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  133898. if (i === 0) {
  133899. defines += "#define FINAL_DOWN_SAMPLER";
  133900. }
  133901. 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);
  133902. this.luminanceDownSamplePostProcesses.push(postProcess);
  133903. }
  133904. // Create callbacks and add effects
  133905. var lastLuminance = this.luminancePostProcess;
  133906. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  133907. var downSampleOffsets = new Array(18);
  133908. pp.onApply = function (effect) {
  133909. if (!lastLuminance) {
  133910. return;
  133911. }
  133912. var id = 0;
  133913. for (var x = -1; x < 2; x++) {
  133914. for (var y = -1; y < 2; y++) {
  133915. downSampleOffsets[id] = x / lastLuminance.width;
  133916. downSampleOffsets[id + 1] = y / lastLuminance.height;
  133917. id += 2;
  133918. }
  133919. }
  133920. effect.setArray2("dsOffsets", downSampleOffsets);
  133921. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  133922. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  133923. lastLuminance = _this.luminancePostProcess;
  133924. }
  133925. else {
  133926. lastLuminance = pp;
  133927. }
  133928. };
  133929. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  133930. pp.onAfterRender = function () {
  133931. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  133932. var bit_shift = new _Maths_math_vector__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);
  133933. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  133934. };
  133935. }
  133936. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  133937. });
  133938. };
  133939. // Create HDR post-process
  133940. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  133941. var _this = this;
  133942. var defines = ["#define HDR"];
  133943. if (this._hdrAutoExposure) {
  133944. defines.push("#define AUTO_EXPOSURE");
  133945. }
  133946. 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);
  133947. var outputLiminance = 1;
  133948. var time = 0;
  133949. var lastTime = 0;
  133950. this.hdrPostProcess.onApply = function (effect) {
  133951. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  133952. time += scene.getEngine().getDeltaTime();
  133953. if (outputLiminance < 0) {
  133954. outputLiminance = _this._hdrCurrentLuminance;
  133955. }
  133956. else {
  133957. var dt = (lastTime - time) / 1000.0;
  133958. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  133959. outputLiminance += _this.hdrDecreaseRate * dt;
  133960. }
  133961. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  133962. outputLiminance -= _this.hdrIncreaseRate * dt;
  133963. }
  133964. else {
  133965. outputLiminance = _this._hdrCurrentLuminance;
  133966. }
  133967. }
  133968. if (_this.hdrAutoExposure) {
  133969. _this._currentExposure = _this._fixedExposure / outputLiminance;
  133970. }
  133971. else {
  133972. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  133973. effect.setFloat("averageLuminance", outputLiminance);
  133974. }
  133975. lastTime = time;
  133976. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  133977. };
  133978. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  133979. };
  133980. // Create lens flare post-process
  133981. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  133982. var _this = this;
  133983. 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);
  133984. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  133985. this._createBlurPostProcesses(scene, ratio / 4, 2);
  133986. 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);
  133987. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  133988. var resolution = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  133989. // Lens flare
  133990. this.lensFlarePostProcess.onApply = function (effect) {
  133991. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  133992. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  133993. effect.setFloat("strength", _this.lensFlareStrength);
  133994. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  133995. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  133996. // Shift
  133997. resolution.x = _this.lensFlarePostProcess.width;
  133998. resolution.y = _this.lensFlarePostProcess.height;
  133999. effect.setVector2("resolution", resolution);
  134000. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  134001. };
  134002. // Compose
  134003. var scaleBias1 = _Maths_math_vector__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);
  134004. var scaleBias2 = _Maths_math_vector__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);
  134005. this.lensFlareComposePostProcess.onApply = function (effect) {
  134006. if (!_this._scene.activeCamera) {
  134007. return;
  134008. }
  134009. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  134010. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  134011. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  134012. // Lens start rotation matrix
  134013. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  134014. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  134015. var camRot = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(camerax.toVector3(), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1.0, 0.0, 0.0)) + _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(cameraz.toVector3(), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.0, 0.0, 1.0));
  134016. camRot *= 4.0;
  134017. var starRotation = _Maths_math_vector__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);
  134018. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  134019. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  134020. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  134021. };
  134022. };
  134023. // Create depth-of-field post-process
  134024. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  134025. var _this = this;
  134026. 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);
  134027. this.depthOfFieldPostProcess.onApply = function (effect) {
  134028. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  134029. effect.setTexture("depthSampler", _this._getDepthTexture());
  134030. effect.setFloat("distance", _this.depthOfFieldDistance);
  134031. };
  134032. // Add to pipeline
  134033. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  134034. };
  134035. // Create motion blur post-process
  134036. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  134037. var _this = this;
  134038. if (this._isObjectBasedMotionBlur) {
  134039. var mb = new _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_13__["MotionBlurPostProcess"]("HDRMotionBlur", scene, 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);
  134040. mb.motionStrength = this.motionStrength;
  134041. mb.motionBlurSamples = this.motionBlurSamples;
  134042. this.motionBlurPostProcess = mb;
  134043. }
  134044. else {
  134045. 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);
  134046. var motionScale = 0;
  134047. var prevViewProjection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  134048. var invViewProjection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  134049. var viewProjection = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  134050. var screenSize = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  134051. this.motionBlurPostProcess.onApply = function (effect) {
  134052. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  134053. viewProjection.invertToRef(invViewProjection);
  134054. effect.setMatrix("inverseViewProjection", invViewProjection);
  134055. effect.setMatrix("prevViewProjection", prevViewProjection);
  134056. prevViewProjection = viewProjection;
  134057. screenSize.x = _this.motionBlurPostProcess.width;
  134058. screenSize.y = _this.motionBlurPostProcess.height;
  134059. effect.setVector2("screenSize", screenSize);
  134060. motionScale = scene.getEngine().getFps() / 60.0;
  134061. effect.setFloat("motionScale", motionScale);
  134062. effect.setFloat("motionStrength", _this.motionStrength);
  134063. effect.setTexture("depthSampler", _this._getDepthTexture());
  134064. };
  134065. }
  134066. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  134067. };
  134068. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  134069. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  134070. var renderer = this._scene.enableGeometryBufferRenderer();
  134071. return renderer.getGBuffer().textures[0];
  134072. }
  134073. return this._scene.enableDepthRenderer().getDepthMap();
  134074. };
  134075. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  134076. for (var i = 0; i < this._cameras.length; i++) {
  134077. var camera = this._cameras[i];
  134078. if (this.originalPostProcess) {
  134079. this.originalPostProcess.dispose(camera);
  134080. }
  134081. if (this.downSampleX4PostProcess) {
  134082. this.downSampleX4PostProcess.dispose(camera);
  134083. }
  134084. if (this.brightPassPostProcess) {
  134085. this.brightPassPostProcess.dispose(camera);
  134086. }
  134087. if (this.textureAdderPostProcess) {
  134088. this.textureAdderPostProcess.dispose(camera);
  134089. }
  134090. if (this.textureAdderFinalPostProcess) {
  134091. this.textureAdderFinalPostProcess.dispose(camera);
  134092. }
  134093. if (this.volumetricLightPostProcess) {
  134094. this.volumetricLightPostProcess.dispose(camera);
  134095. }
  134096. if (this.volumetricLightSmoothXPostProcess) {
  134097. this.volumetricLightSmoothXPostProcess.dispose(camera);
  134098. }
  134099. if (this.volumetricLightSmoothYPostProcess) {
  134100. this.volumetricLightSmoothYPostProcess.dispose(camera);
  134101. }
  134102. if (this.volumetricLightMergePostProces) {
  134103. this.volumetricLightMergePostProces.dispose(camera);
  134104. }
  134105. if (this.volumetricLightFinalPostProcess) {
  134106. this.volumetricLightFinalPostProcess.dispose(camera);
  134107. }
  134108. if (this.lensFlarePostProcess) {
  134109. this.lensFlarePostProcess.dispose(camera);
  134110. }
  134111. if (this.lensFlareComposePostProcess) {
  134112. this.lensFlareComposePostProcess.dispose(camera);
  134113. }
  134114. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  134115. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  134116. }
  134117. if (this.luminancePostProcess) {
  134118. this.luminancePostProcess.dispose(camera);
  134119. }
  134120. if (this.hdrPostProcess) {
  134121. this.hdrPostProcess.dispose(camera);
  134122. }
  134123. if (this.hdrFinalPostProcess) {
  134124. this.hdrFinalPostProcess.dispose(camera);
  134125. }
  134126. if (this.depthOfFieldPostProcess) {
  134127. this.depthOfFieldPostProcess.dispose(camera);
  134128. }
  134129. if (this.motionBlurPostProcess) {
  134130. this.motionBlurPostProcess.dispose(camera);
  134131. }
  134132. if (this.fxaaPostProcess) {
  134133. this.fxaaPostProcess.dispose(camera);
  134134. }
  134135. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  134136. this.blurHPostProcesses[j].dispose(camera);
  134137. }
  134138. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  134139. this.blurVPostProcesses[j].dispose(camera);
  134140. }
  134141. }
  134142. this.originalPostProcess = null;
  134143. this.downSampleX4PostProcess = null;
  134144. this.brightPassPostProcess = null;
  134145. this.textureAdderPostProcess = null;
  134146. this.textureAdderFinalPostProcess = null;
  134147. this.volumetricLightPostProcess = null;
  134148. this.volumetricLightSmoothXPostProcess = null;
  134149. this.volumetricLightSmoothYPostProcess = null;
  134150. this.volumetricLightMergePostProces = null;
  134151. this.volumetricLightFinalPostProcess = null;
  134152. this.lensFlarePostProcess = null;
  134153. this.lensFlareComposePostProcess = null;
  134154. this.luminancePostProcess = null;
  134155. this.hdrPostProcess = null;
  134156. this.hdrFinalPostProcess = null;
  134157. this.depthOfFieldPostProcess = null;
  134158. this.motionBlurPostProcess = null;
  134159. this.fxaaPostProcess = null;
  134160. this.luminanceDownSamplePostProcesses = [];
  134161. this.blurHPostProcesses = [];
  134162. this.blurVPostProcesses = [];
  134163. };
  134164. /**
  134165. * Dispose of the pipeline and stop all post processes
  134166. */
  134167. StandardRenderingPipeline.prototype.dispose = function () {
  134168. this._disposePostProcesses();
  134169. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  134170. _super.prototype.dispose.call(this);
  134171. };
  134172. /**
  134173. * Serialize the rendering pipeline (Used when exporting)
  134174. * @returns the serialized object
  134175. */
  134176. StandardRenderingPipeline.prototype.serialize = function () {
  134177. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  134178. if (this.sourceLight) {
  134179. serializationObject.sourceLightId = this.sourceLight.id;
  134180. }
  134181. serializationObject.customType = "StandardRenderingPipeline";
  134182. return serializationObject;
  134183. };
  134184. /**
  134185. * Parse the serialized pipeline
  134186. * @param source Source pipeline.
  134187. * @param scene The scene to load the pipeline to.
  134188. * @param rootUrl The URL of the serialized pipeline.
  134189. * @returns An instantiated pipeline from the serialized object.
  134190. */
  134191. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  134192. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  134193. if (source.sourceLightId) {
  134194. p.sourceLight = scene.getLightByID(source.sourceLightId);
  134195. }
  134196. return p;
  134197. };
  134198. /**
  134199. * Luminance steps
  134200. */
  134201. StandardRenderingPipeline.LuminanceSteps = 6;
  134202. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134203. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134204. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  134205. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134206. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134207. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  134208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134210. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  134211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134213. ], StandardRenderingPipeline.prototype, "exposure", null);
  134214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  134216. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  134217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134219. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  134220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134222. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  134223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134225. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  134226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134228. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  134229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134231. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  134232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134234. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  134235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134237. ], StandardRenderingPipeline.prototype, "hdrAutoExposure", null);
  134238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  134240. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  134241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134243. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  134244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134246. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  134247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134249. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  134250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134252. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  134253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  134255. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  134256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  134258. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  134259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134261. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  134262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134264. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  134265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134267. ], StandardRenderingPipeline.prototype, "motionStrength", null);
  134268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134270. ], StandardRenderingPipeline.prototype, "objectBasedMotionBlur", null);
  134271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134273. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  134274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134276. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  134277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134279. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  134280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134282. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  134283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134285. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  134286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134288. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  134289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134291. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  134292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134294. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  134295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134297. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  134298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134300. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  134301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  134303. ], StandardRenderingPipeline.prototype, "samples", null);
  134304. return StandardRenderingPipeline;
  134305. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  134306. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  134307. /***/ }),
  134308. /***/ "./PostProcesses/RenderPipeline/index.ts":
  134309. /*!***********************************************!*\
  134310. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  134311. \***********************************************/
  134312. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  134313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134314. "use strict";
  134315. __webpack_require__.r(__webpack_exports__);
  134316. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  134317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  134318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  134319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  134320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  134321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  134322. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  134323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  134324. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  134325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  134326. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  134327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  134328. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  134329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  134330. /***/ }),
  134331. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  134332. /*!*****************************************************************!*\
  134333. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  134334. \*****************************************************************/
  134335. /*! exports provided: PostProcessRenderEffect */
  134336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134337. "use strict";
  134338. __webpack_require__.r(__webpack_exports__);
  134339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  134340. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  134341. /**
  134342. * This represents a set of one or more post processes in Babylon.
  134343. * A post process can be used to apply a shader to a texture after it is rendered.
  134344. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134345. */
  134346. var PostProcessRenderEffect = /** @class */ (function () {
  134347. /**
  134348. * Instantiates a post process render effect.
  134349. * A post process can be used to apply a shader to a texture after it is rendered.
  134350. * @param engine The engine the effect is tied to
  134351. * @param name The name of the effect
  134352. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  134353. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  134354. */
  134355. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  134356. this._name = name;
  134357. this._singleInstance = singleInstance || true;
  134358. this._getPostProcesses = getPostProcesses;
  134359. this._cameras = {};
  134360. this._indicesForCamera = {};
  134361. this._postProcesses = {};
  134362. }
  134363. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  134364. /**
  134365. * Checks if all the post processes in the effect are supported.
  134366. */
  134367. get: function () {
  134368. for (var index in this._postProcesses) {
  134369. if (this._postProcesses.hasOwnProperty(index)) {
  134370. var pps = this._postProcesses[index];
  134371. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  134372. if (!pps[ppIndex].isSupported) {
  134373. return false;
  134374. }
  134375. }
  134376. }
  134377. }
  134378. return true;
  134379. },
  134380. enumerable: true,
  134381. configurable: true
  134382. });
  134383. /**
  134384. * Updates the current state of the effect
  134385. * @hidden
  134386. */
  134387. PostProcessRenderEffect.prototype._update = function () {
  134388. };
  134389. /**
  134390. * Attaches the effect on cameras
  134391. * @param cameras The camera to attach to.
  134392. * @hidden
  134393. */
  134394. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  134395. var _this = this;
  134396. var cameraKey;
  134397. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  134398. if (!cams) {
  134399. return;
  134400. }
  134401. for (var i = 0; i < cams.length; i++) {
  134402. var camera = cams[i];
  134403. var cameraName = camera.name;
  134404. if (this._singleInstance) {
  134405. cameraKey = 0;
  134406. }
  134407. else {
  134408. cameraKey = cameraName;
  134409. }
  134410. if (!this._postProcesses[cameraKey]) {
  134411. var postProcess = this._getPostProcesses();
  134412. if (postProcess) {
  134413. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  134414. }
  134415. }
  134416. if (!this._indicesForCamera[cameraName]) {
  134417. this._indicesForCamera[cameraName] = [];
  134418. }
  134419. this._postProcesses[cameraKey].forEach(function (postProcess) {
  134420. var index = camera.attachPostProcess(postProcess);
  134421. _this._indicesForCamera[cameraName].push(index);
  134422. });
  134423. if (!this._cameras[cameraName]) {
  134424. this._cameras[cameraName] = camera;
  134425. }
  134426. }
  134427. };
  134428. /**
  134429. * Detatches the effect on cameras
  134430. * @param cameras The camera to detatch from.
  134431. * @hidden
  134432. */
  134433. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  134434. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  134435. if (!cams) {
  134436. return;
  134437. }
  134438. for (var i = 0; i < cams.length; i++) {
  134439. var camera = cams[i];
  134440. var cameraName = camera.name;
  134441. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  134442. if (postProcesses) {
  134443. postProcesses.forEach(function (postProcess) {
  134444. camera.detachPostProcess(postProcess);
  134445. });
  134446. }
  134447. if (this._cameras[cameraName]) {
  134448. this._cameras[cameraName] = null;
  134449. }
  134450. }
  134451. };
  134452. /**
  134453. * Enables the effect on given cameras
  134454. * @param cameras The camera to enable.
  134455. * @hidden
  134456. */
  134457. PostProcessRenderEffect.prototype._enable = function (cameras) {
  134458. var _this = this;
  134459. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  134460. if (!cams) {
  134461. return;
  134462. }
  134463. for (var i = 0; i < cams.length; i++) {
  134464. var camera = cams[i];
  134465. var cameraName = camera.name;
  134466. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  134467. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  134468. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  134469. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  134470. });
  134471. }
  134472. }
  134473. }
  134474. };
  134475. /**
  134476. * Disables the effect on the given cameras
  134477. * @param cameras The camera to disable.
  134478. * @hidden
  134479. */
  134480. PostProcessRenderEffect.prototype._disable = function (cameras) {
  134481. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  134482. if (!cams) {
  134483. return;
  134484. }
  134485. for (var i = 0; i < cams.length; i++) {
  134486. var camera = cams[i];
  134487. var cameraName = camera.name;
  134488. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  134489. camera.detachPostProcess(postProcess);
  134490. });
  134491. }
  134492. };
  134493. /**
  134494. * Gets a list of the post processes contained in the effect.
  134495. * @param camera The camera to get the post processes on.
  134496. * @returns The list of the post processes in the effect.
  134497. */
  134498. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  134499. if (this._singleInstance) {
  134500. return this._postProcesses[0];
  134501. }
  134502. else {
  134503. if (!camera) {
  134504. return null;
  134505. }
  134506. return this._postProcesses[camera.name];
  134507. }
  134508. };
  134509. return PostProcessRenderEffect;
  134510. }());
  134511. /***/ }),
  134512. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  134513. /*!*******************************************************************!*\
  134514. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  134515. \*******************************************************************/
  134516. /*! exports provided: PostProcessRenderPipeline */
  134517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134518. "use strict";
  134519. __webpack_require__.r(__webpack_exports__);
  134520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  134521. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134522. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  134523. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  134524. /**
  134525. * PostProcessRenderPipeline
  134526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134527. */
  134528. var PostProcessRenderPipeline = /** @class */ (function () {
  134529. /**
  134530. * Initializes a PostProcessRenderPipeline
  134531. * @param engine engine to add the pipeline to
  134532. * @param name name of the pipeline
  134533. */
  134534. function PostProcessRenderPipeline(engine, name) {
  134535. this.engine = engine;
  134536. this._name = name;
  134537. this._renderEffects = {};
  134538. this._renderEffectsForIsolatedPass = new Array();
  134539. this._cameras = [];
  134540. }
  134541. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  134542. /**
  134543. * Gets pipeline name
  134544. */
  134545. get: function () {
  134546. return this._name;
  134547. },
  134548. enumerable: true,
  134549. configurable: true
  134550. });
  134551. /**
  134552. * Gets the class name
  134553. * @returns "PostProcessRenderPipeline"
  134554. */
  134555. PostProcessRenderPipeline.prototype.getClassName = function () {
  134556. return "PostProcessRenderPipeline";
  134557. };
  134558. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  134559. /**
  134560. * If all the render effects in the pipeline are supported
  134561. */
  134562. get: function () {
  134563. for (var renderEffectName in this._renderEffects) {
  134564. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  134565. if (!this._renderEffects[renderEffectName].isSupported) {
  134566. return false;
  134567. }
  134568. }
  134569. }
  134570. return true;
  134571. },
  134572. enumerable: true,
  134573. configurable: true
  134574. });
  134575. /**
  134576. * Adds an effect to the pipeline
  134577. * @param renderEffect the effect to add
  134578. */
  134579. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  134580. this._renderEffects[renderEffect._name] = renderEffect;
  134581. };
  134582. // private
  134583. /** @hidden */
  134584. PostProcessRenderPipeline.prototype._rebuild = function () {
  134585. };
  134586. /** @hidden */
  134587. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  134588. var renderEffects = this._renderEffects[renderEffectName];
  134589. if (!renderEffects) {
  134590. return;
  134591. }
  134592. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  134593. };
  134594. /** @hidden */
  134595. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  134596. var renderEffects = this._renderEffects[renderEffectName];
  134597. if (!renderEffects) {
  134598. return;
  134599. }
  134600. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  134601. };
  134602. /** @hidden */
  134603. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  134604. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  134605. if (!cams) {
  134606. return;
  134607. }
  134608. var indicesToDelete = [];
  134609. var i;
  134610. for (i = 0; i < cams.length; i++) {
  134611. var camera = cams[i];
  134612. var cameraName = camera.name;
  134613. if (this._cameras.indexOf(camera) === -1) {
  134614. this._cameras[cameraName] = camera;
  134615. }
  134616. else if (unique) {
  134617. indicesToDelete.push(i);
  134618. }
  134619. }
  134620. for (i = 0; i < indicesToDelete.length; i++) {
  134621. cameras.splice(indicesToDelete[i], 1);
  134622. }
  134623. for (var renderEffectName in this._renderEffects) {
  134624. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  134625. this._renderEffects[renderEffectName]._attachCameras(cams);
  134626. }
  134627. }
  134628. };
  134629. /** @hidden */
  134630. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  134631. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  134632. if (!cams) {
  134633. return;
  134634. }
  134635. for (var renderEffectName in this._renderEffects) {
  134636. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  134637. this._renderEffects[renderEffectName]._detachCameras(cams);
  134638. }
  134639. }
  134640. for (var i = 0; i < cams.length; i++) {
  134641. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  134642. }
  134643. };
  134644. /** @hidden */
  134645. PostProcessRenderPipeline.prototype._update = function () {
  134646. for (var renderEffectName in this._renderEffects) {
  134647. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  134648. this._renderEffects[renderEffectName]._update();
  134649. }
  134650. }
  134651. for (var i = 0; i < this._cameras.length; i++) {
  134652. var cameraName = this._cameras[i].name;
  134653. if (this._renderEffectsForIsolatedPass[cameraName]) {
  134654. this._renderEffectsForIsolatedPass[cameraName]._update();
  134655. }
  134656. }
  134657. };
  134658. /** @hidden */
  134659. PostProcessRenderPipeline.prototype._reset = function () {
  134660. this._renderEffects = {};
  134661. this._renderEffectsForIsolatedPass = new Array();
  134662. };
  134663. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  134664. // 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)
  134665. var effectKeys = Object.keys(this._renderEffects);
  134666. if (this.engine.webGLVersion === 1) {
  134667. return false;
  134668. }
  134669. if (effectKeys.length > 0) {
  134670. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  134671. if (postProcesses) {
  134672. postProcesses[0].samples = sampleCount;
  134673. }
  134674. }
  134675. return true;
  134676. };
  134677. /**
  134678. * Disposes of the pipeline
  134679. */
  134680. PostProcessRenderPipeline.prototype.dispose = function () {
  134681. // Must be implemented by children
  134682. };
  134683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134685. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  134686. return PostProcessRenderPipeline;
  134687. }());
  134688. /***/ }),
  134689. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  134690. /*!**************************************************************************!*\
  134691. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  134692. \**************************************************************************/
  134693. /*! exports provided: PostProcessRenderPipelineManager */
  134694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134695. "use strict";
  134696. __webpack_require__.r(__webpack_exports__);
  134697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  134698. /**
  134699. * PostProcessRenderPipelineManager class
  134700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134701. */
  134702. var PostProcessRenderPipelineManager = /** @class */ (function () {
  134703. /**
  134704. * Initializes a PostProcessRenderPipelineManager
  134705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134706. */
  134707. function PostProcessRenderPipelineManager() {
  134708. this._renderPipelines = {};
  134709. }
  134710. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  134711. /**
  134712. * Gets the list of supported render pipelines
  134713. */
  134714. get: function () {
  134715. var result = [];
  134716. for (var renderPipelineName in this._renderPipelines) {
  134717. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  134718. var pipeline = this._renderPipelines[renderPipelineName];
  134719. if (pipeline.isSupported) {
  134720. result.push(pipeline);
  134721. }
  134722. }
  134723. }
  134724. return result;
  134725. },
  134726. enumerable: true,
  134727. configurable: true
  134728. });
  134729. /**
  134730. * Adds a pipeline to the manager
  134731. * @param renderPipeline The pipeline to add
  134732. */
  134733. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  134734. this._renderPipelines[renderPipeline._name] = renderPipeline;
  134735. };
  134736. /**
  134737. * Attaches a camera to the pipeline
  134738. * @param renderPipelineName The name of the pipeline to attach to
  134739. * @param cameras the camera to attach
  134740. * @param unique if the camera can be attached multiple times to the pipeline
  134741. */
  134742. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  134743. if (unique === void 0) { unique = false; }
  134744. var renderPipeline = this._renderPipelines[renderPipelineName];
  134745. if (!renderPipeline) {
  134746. return;
  134747. }
  134748. renderPipeline._attachCameras(cameras, unique);
  134749. };
  134750. /**
  134751. * Detaches a camera from the pipeline
  134752. * @param renderPipelineName The name of the pipeline to detach from
  134753. * @param cameras the camera to detach
  134754. */
  134755. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  134756. var renderPipeline = this._renderPipelines[renderPipelineName];
  134757. if (!renderPipeline) {
  134758. return;
  134759. }
  134760. renderPipeline._detachCameras(cameras);
  134761. };
  134762. /**
  134763. * Enables an effect by name on a pipeline
  134764. * @param renderPipelineName the name of the pipeline to enable the effect in
  134765. * @param renderEffectName the name of the effect to enable
  134766. * @param cameras the cameras that the effect should be enabled on
  134767. */
  134768. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  134769. var renderPipeline = this._renderPipelines[renderPipelineName];
  134770. if (!renderPipeline) {
  134771. return;
  134772. }
  134773. renderPipeline._enableEffect(renderEffectName, cameras);
  134774. };
  134775. /**
  134776. * Disables an effect by name on a pipeline
  134777. * @param renderPipelineName the name of the pipeline to disable the effect in
  134778. * @param renderEffectName the name of the effect to disable
  134779. * @param cameras the cameras that the effect should be disabled on
  134780. */
  134781. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  134782. var renderPipeline = this._renderPipelines[renderPipelineName];
  134783. if (!renderPipeline) {
  134784. return;
  134785. }
  134786. renderPipeline._disableEffect(renderEffectName, cameras);
  134787. };
  134788. /**
  134789. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  134790. */
  134791. PostProcessRenderPipelineManager.prototype.update = function () {
  134792. for (var renderPipelineName in this._renderPipelines) {
  134793. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  134794. var pipeline = this._renderPipelines[renderPipelineName];
  134795. if (!pipeline.isSupported) {
  134796. pipeline.dispose();
  134797. delete this._renderPipelines[renderPipelineName];
  134798. }
  134799. else {
  134800. pipeline._update();
  134801. }
  134802. }
  134803. }
  134804. };
  134805. /** @hidden */
  134806. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  134807. for (var renderPipelineName in this._renderPipelines) {
  134808. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  134809. var pipeline = this._renderPipelines[renderPipelineName];
  134810. pipeline._rebuild();
  134811. }
  134812. }
  134813. };
  134814. /**
  134815. * Disposes of the manager and pipelines
  134816. */
  134817. PostProcessRenderPipelineManager.prototype.dispose = function () {
  134818. for (var renderPipelineName in this._renderPipelines) {
  134819. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  134820. var pipeline = this._renderPipelines[renderPipelineName];
  134821. pipeline.dispose();
  134822. }
  134823. }
  134824. };
  134825. return PostProcessRenderPipelineManager;
  134826. }());
  134827. /***/ }),
  134828. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  134829. /*!****************************************************************************************!*\
  134830. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  134831. \****************************************************************************************/
  134832. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  134833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134834. "use strict";
  134835. __webpack_require__.r(__webpack_exports__);
  134836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  134837. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  134838. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  134839. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  134840. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  134841. get: function () {
  134842. if (!this._postProcessRenderPipelineManager) {
  134843. // Register the G Buffer component to the scene.
  134844. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  134845. if (!component) {
  134846. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  134847. this._addComponent(component);
  134848. }
  134849. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  134850. }
  134851. return this._postProcessRenderPipelineManager;
  134852. },
  134853. enumerable: true,
  134854. configurable: true
  134855. });
  134856. /**
  134857. * Defines the Render Pipeline scene component responsible to rendering pipelines
  134858. */
  134859. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  134860. /**
  134861. * Creates a new instance of the component for the given scene
  134862. * @param scene Defines the scene to register the component in
  134863. */
  134864. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  134865. /**
  134866. * The component name helpfull to identify the component in the list of scene components.
  134867. */
  134868. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  134869. this.scene = scene;
  134870. }
  134871. /**
  134872. * Registers the component in a given scene
  134873. */
  134874. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  134875. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  134876. };
  134877. /**
  134878. * Rebuilds the elements related to this component in case of
  134879. * context lost for instance.
  134880. */
  134881. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  134882. if (this.scene._postProcessRenderPipelineManager) {
  134883. this.scene._postProcessRenderPipelineManager._rebuild();
  134884. }
  134885. };
  134886. /**
  134887. * Disposes the component and the associated ressources
  134888. */
  134889. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  134890. if (this.scene._postProcessRenderPipelineManager) {
  134891. this.scene._postProcessRenderPipelineManager.dispose();
  134892. }
  134893. };
  134894. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  134895. if (this.scene._postProcessRenderPipelineManager) {
  134896. this.scene._postProcessRenderPipelineManager.update();
  134897. }
  134898. };
  134899. return PostProcessRenderPipelineManagerSceneComponent;
  134900. }());
  134901. /***/ }),
  134902. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  134903. /*!**********************************************!*\
  134904. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  134905. \**********************************************/
  134906. /*! exports provided: AnaglyphPostProcess */
  134907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134908. "use strict";
  134909. __webpack_require__.r(__webpack_exports__);
  134910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  134911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134912. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  134913. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  134914. /**
  134915. * Postprocess used to generate anaglyphic rendering
  134916. */
  134917. var AnaglyphPostProcess = /** @class */ (function (_super) {
  134918. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  134919. /**
  134920. * Creates a new AnaglyphPostProcess
  134921. * @param name defines postprocess name
  134922. * @param options defines creation options or target ratio scale
  134923. * @param rigCameras defines cameras using this postprocess
  134924. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  134925. * @param engine defines hosting engine
  134926. * @param reusable defines if the postprocess will be reused multiple times per frame
  134927. */
  134928. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  134929. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  134930. _this._passedProcess = rigCameras[0]._rigPostProcess;
  134931. _this.onApplyObservable.add(function (effect) {
  134932. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  134933. });
  134934. return _this;
  134935. }
  134936. return AnaglyphPostProcess;
  134937. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  134938. /***/ }),
  134939. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  134940. /*!***************************************************!*\
  134941. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  134942. \***************************************************/
  134943. /*! exports provided: BlackAndWhitePostProcess */
  134944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134945. "use strict";
  134946. __webpack_require__.r(__webpack_exports__);
  134947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  134948. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134949. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  134950. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  134951. /**
  134952. * Post process used to render in black and white
  134953. */
  134954. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  134955. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  134956. /**
  134957. * Creates a black and white post process
  134958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  134959. * @param name The name of the effect.
  134960. * @param options The required width/height ratio to downsize to before computing the render pass.
  134961. * @param camera The camera to apply the render pass to.
  134962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134963. * @param engine The engine which the post process will be applied. (default: current engine)
  134964. * @param reusable If the post process can be reused on the same frame. (default: false)
  134965. */
  134966. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  134967. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  134968. /**
  134969. * Linear about to convert he result to black and white (default: 1)
  134970. */
  134971. _this.degree = 1;
  134972. _this.onApplyObservable.add(function (effect) {
  134973. effect.setFloat("degree", _this.degree);
  134974. });
  134975. return _this;
  134976. }
  134977. return BlackAndWhitePostProcess;
  134978. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  134979. /***/ }),
  134980. /***/ "./PostProcesses/bloomEffect.ts":
  134981. /*!**************************************!*\
  134982. !*** ./PostProcesses/bloomEffect.ts ***!
  134983. \**************************************/
  134984. /*! exports provided: BloomEffect */
  134985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134986. "use strict";
  134987. __webpack_require__.r(__webpack_exports__);
  134988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  134989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134990. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  134991. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  134992. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  134993. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  134994. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  134995. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  134996. /**
  134997. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  134998. */
  134999. var BloomEffect = /** @class */ (function (_super) {
  135000. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  135001. /**
  135002. * Creates a new instance of @see BloomEffect
  135003. * @param scene The scene the effect belongs to.
  135004. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  135005. * @param bloomKernel The size of the kernel to be used when applying the blur.
  135006. * @param bloomWeight The the strength of bloom.
  135007. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  135008. * @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)
  135009. */
  135010. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  135011. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  135012. if (blockCompilation === void 0) { blockCompilation = false; }
  135013. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  135014. return _this._effects;
  135015. }, true) || this;
  135016. _this.bloomScale = bloomScale;
  135017. /**
  135018. * @hidden Internal
  135019. */
  135020. _this._effects = [];
  135021. _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);
  135022. _this._blurX = new _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__["BlurPostProcess"]("horizontal blur", new _Maths_math_vector__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);
  135023. _this._blurX.alwaysForcePOT = true;
  135024. _this._blurX.autoClear = false;
  135025. _this._blurY = new _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__["BlurPostProcess"]("vertical blur", new _Maths_math_vector__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);
  135026. _this._blurY.alwaysForcePOT = true;
  135027. _this._blurY.autoClear = false;
  135028. _this.kernel = bloomKernel;
  135029. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  135030. _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);
  135031. _this._merge.autoClear = false;
  135032. _this._effects.push(_this._merge);
  135033. return _this;
  135034. }
  135035. Object.defineProperty(BloomEffect.prototype, "threshold", {
  135036. /**
  135037. * The luminance threshold to find bright areas of the image to bloom.
  135038. */
  135039. get: function () {
  135040. return this._downscale.threshold;
  135041. },
  135042. set: function (value) {
  135043. this._downscale.threshold = value;
  135044. },
  135045. enumerable: true,
  135046. configurable: true
  135047. });
  135048. Object.defineProperty(BloomEffect.prototype, "weight", {
  135049. /**
  135050. * The strength of the bloom.
  135051. */
  135052. get: function () {
  135053. return this._merge.weight;
  135054. },
  135055. set: function (value) {
  135056. this._merge.weight = value;
  135057. },
  135058. enumerable: true,
  135059. configurable: true
  135060. });
  135061. Object.defineProperty(BloomEffect.prototype, "kernel", {
  135062. /**
  135063. * Specifies the size of the bloom blur kernel, relative to the final output size
  135064. */
  135065. get: function () {
  135066. return this._blurX.kernel / this.bloomScale;
  135067. },
  135068. set: function (value) {
  135069. this._blurX.kernel = value * this.bloomScale;
  135070. this._blurY.kernel = value * this.bloomScale;
  135071. },
  135072. enumerable: true,
  135073. configurable: true
  135074. });
  135075. /**
  135076. * Disposes each of the internal effects for a given camera.
  135077. * @param camera The camera to dispose the effect on.
  135078. */
  135079. BloomEffect.prototype.disposeEffects = function (camera) {
  135080. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  135081. this._effects[effectIndex].dispose(camera);
  135082. }
  135083. };
  135084. /**
  135085. * @hidden Internal
  135086. */
  135087. BloomEffect.prototype._updateEffects = function () {
  135088. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  135089. this._effects[effectIndex].updateEffect();
  135090. }
  135091. };
  135092. /**
  135093. * Internal
  135094. * @returns if all the contained post processes are ready.
  135095. * @hidden
  135096. */
  135097. BloomEffect.prototype._isReady = function () {
  135098. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  135099. if (!this._effects[effectIndex].isReady()) {
  135100. return false;
  135101. }
  135102. }
  135103. return true;
  135104. };
  135105. return BloomEffect;
  135106. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  135107. /***/ }),
  135108. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  135109. /*!************************************************!*\
  135110. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  135111. \************************************************/
  135112. /*! exports provided: BloomMergePostProcess */
  135113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135114. "use strict";
  135115. __webpack_require__.r(__webpack_exports__);
  135116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  135117. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135118. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135119. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135120. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  135121. /**
  135122. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  135123. */
  135124. var BloomMergePostProcess = /** @class */ (function (_super) {
  135125. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  135126. /**
  135127. * Creates a new instance of @see BloomMergePostProcess
  135128. * @param name The name of the effect.
  135129. * @param originalFromInput Post process which's input will be used for the merge.
  135130. * @param blurred Blurred highlights post process which's output will be used.
  135131. * @param weight Weight of the bloom to be added to the original input.
  135132. * @param options The required width/height ratio to downsize to before computing the render pass.
  135133. * @param camera The camera to apply the render pass to.
  135134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135135. * @param engine The engine which the post process will be applied. (default: current engine)
  135136. * @param reusable If the post process can be reused on the same frame. (default: false)
  135137. * @param textureType Type of textures used when performing the post process. (default: 0)
  135138. * @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)
  135139. */
  135140. function BloomMergePostProcess(name, originalFromInput, blurred,
  135141. /** Weight of the bloom to be added to the original input. */
  135142. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  135143. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135144. if (blockCompilation === void 0) { blockCompilation = false; }
  135145. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  135146. _this.weight = weight;
  135147. _this.onApplyObservable.add(function (effect) {
  135148. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  135149. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  135150. effect.setFloat("bloomWeight", _this.weight);
  135151. });
  135152. if (!blockCompilation) {
  135153. _this.updateEffect();
  135154. }
  135155. return _this;
  135156. }
  135157. return BloomMergePostProcess;
  135158. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  135159. /***/ }),
  135160. /***/ "./PostProcesses/blurPostProcess.ts":
  135161. /*!******************************************!*\
  135162. !*** ./PostProcesses/blurPostProcess.ts ***!
  135163. \******************************************/
  135164. /*! exports provided: BlurPostProcess */
  135165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135166. "use strict";
  135167. __webpack_require__.r(__webpack_exports__);
  135168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  135169. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135170. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135171. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  135172. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135173. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  135174. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  135175. /**
  135176. * The Blur Post Process which blurs an image based on a kernel and direction.
  135177. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  135178. */
  135179. var BlurPostProcess = /** @class */ (function (_super) {
  135180. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  135181. /**
  135182. * Creates a new instance BlurPostProcess
  135183. * @param name The name of the effect.
  135184. * @param direction The direction in which to blur the image.
  135185. * @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.
  135186. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  135187. * @param camera The camera to apply the render pass to.
  135188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135189. * @param engine The engine which the post process will be applied. (default: current engine)
  135190. * @param reusable If the post process can be reused on the same frame. (default: false)
  135191. * @param textureType Type of textures used when performing the post process. (default: 0)
  135192. * @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)
  135193. */
  135194. function BlurPostProcess(name,
  135195. /** The direction in which to blur the image. */
  135196. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  135197. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  135198. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135199. if (defines === void 0) { defines = ""; }
  135200. if (blockCompilation === void 0) { blockCompilation = false; }
  135201. 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;
  135202. _this.direction = direction;
  135203. _this.blockCompilation = blockCompilation;
  135204. _this._packedFloat = false;
  135205. _this._staticDefines = "";
  135206. _this._staticDefines = defines;
  135207. _this.onApplyObservable.add(function (effect) {
  135208. if (_this._outputTexture) {
  135209. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  135210. }
  135211. else {
  135212. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  135213. }
  135214. });
  135215. _this.kernel = kernel;
  135216. return _this;
  135217. }
  135218. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  135219. /**
  135220. * Gets the length in pixels of the blur sample region
  135221. */
  135222. get: function () {
  135223. return this._idealKernel;
  135224. },
  135225. /**
  135226. * Sets the length in pixels of the blur sample region
  135227. */
  135228. set: function (v) {
  135229. if (this._idealKernel === v) {
  135230. return;
  135231. }
  135232. v = Math.max(v, 1);
  135233. this._idealKernel = v;
  135234. this._kernel = this._nearestBestKernel(v);
  135235. if (!this.blockCompilation) {
  135236. this._updateParameters();
  135237. }
  135238. },
  135239. enumerable: true,
  135240. configurable: true
  135241. });
  135242. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  135243. /**
  135244. * Gets wether or not the blur is unpacking/repacking floats
  135245. */
  135246. get: function () {
  135247. return this._packedFloat;
  135248. },
  135249. /**
  135250. * Sets wether or not the blur needs to unpack/repack floats
  135251. */
  135252. set: function (v) {
  135253. if (this._packedFloat === v) {
  135254. return;
  135255. }
  135256. this._packedFloat = v;
  135257. if (!this.blockCompilation) {
  135258. this._updateParameters();
  135259. }
  135260. },
  135261. enumerable: true,
  135262. configurable: true
  135263. });
  135264. /**
  135265. * Updates the effect with the current post process compile time values and recompiles the shader.
  135266. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  135267. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  135268. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  135269. * @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
  135270. * @param onCompiled Called when the shader has been compiled.
  135271. * @param onError Called if there is an error when compiling a shader.
  135272. */
  135273. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  135274. if (defines === void 0) { defines = null; }
  135275. if (uniforms === void 0) { uniforms = null; }
  135276. if (samplers === void 0) { samplers = null; }
  135277. this._updateParameters(onCompiled, onError);
  135278. };
  135279. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  135280. // Generate sampling offsets and weights
  135281. var N = this._kernel;
  135282. var centerIndex = (N - 1) / 2;
  135283. // Generate Gaussian sampling weights over kernel
  135284. var offsets = [];
  135285. var weights = [];
  135286. var totalWeight = 0;
  135287. for (var i = 0; i < N; i++) {
  135288. var u = i / (N - 1);
  135289. var w = this._gaussianWeight(u * 2.0 - 1);
  135290. offsets[i] = (i - centerIndex);
  135291. weights[i] = w;
  135292. totalWeight += w;
  135293. }
  135294. // Normalize weights
  135295. for (var i = 0; i < weights.length; i++) {
  135296. weights[i] /= totalWeight;
  135297. }
  135298. // Optimize: combine samples to take advantage of hardware linear sampling
  135299. // Walk from left to center, combining pairs (symmetrically)
  135300. var linearSamplingWeights = [];
  135301. var linearSamplingOffsets = [];
  135302. var linearSamplingMap = [];
  135303. for (var i = 0; i <= centerIndex; i += 2) {
  135304. var j = Math.min(i + 1, Math.floor(centerIndex));
  135305. var singleCenterSample = i === j;
  135306. if (singleCenterSample) {
  135307. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  135308. }
  135309. else {
  135310. var sharedCell = j === centerIndex;
  135311. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  135312. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  135313. if (offsetLinear === 0) {
  135314. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  135315. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  135316. }
  135317. else {
  135318. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  135319. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  135320. }
  135321. }
  135322. }
  135323. for (var i = 0; i < linearSamplingMap.length; i++) {
  135324. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  135325. linearSamplingWeights[i] = linearSamplingMap[i].w;
  135326. }
  135327. // Replace with optimized
  135328. offsets = linearSamplingOffsets;
  135329. weights = linearSamplingWeights;
  135330. // Generate shaders
  135331. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  135332. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  135333. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  135334. var defines = "";
  135335. defines += this._staticDefines;
  135336. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  135337. if (this._staticDefines.indexOf("DOF") != -1) {
  135338. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  135339. varyingCount--;
  135340. }
  135341. for (var i = 0; i < varyingCount; i++) {
  135342. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  135343. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  135344. }
  135345. var depCount = 0;
  135346. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  135347. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  135348. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  135349. depCount++;
  135350. }
  135351. if (this.packedFloat) {
  135352. defines += "#define PACKEDFLOAT 1";
  135353. }
  135354. this.blockCompilation = false;
  135355. _super.prototype.updateEffect.call(this, defines, null, null, {
  135356. varyingCount: varyingCount,
  135357. depCount: depCount
  135358. }, onCompiled, onError);
  135359. };
  135360. /**
  135361. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  135362. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  135363. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  135364. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  135365. * The gaps between physical kernels are compensated for in the weighting of the samples
  135366. * @param idealKernel Ideal blur kernel.
  135367. * @return Nearest best kernel.
  135368. */
  135369. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  135370. var v = Math.round(idealKernel);
  135371. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  135372. var k = _a[_i];
  135373. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  135374. return Math.max(k, 3);
  135375. }
  135376. }
  135377. return Math.max(v, 3);
  135378. };
  135379. /**
  135380. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  135381. * @param x The point on the Gaussian distribution to sample.
  135382. * @return the value of the Gaussian function at x.
  135383. */
  135384. BlurPostProcess.prototype._gaussianWeight = function (x) {
  135385. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  135386. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  135387. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  135388. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  135389. // truncated at around 1.3% of peak strength.
  135390. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  135391. var sigma = (1 / 3);
  135392. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  135393. var exponent = -((x * x) / (2.0 * sigma * sigma));
  135394. var weight = (1.0 / denominator) * Math.exp(exponent);
  135395. return weight;
  135396. };
  135397. /**
  135398. * Generates a string that can be used as a floating point number in GLSL.
  135399. * @param x Value to print.
  135400. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  135401. * @return GLSL float string.
  135402. */
  135403. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  135404. if (decimalFigures === void 0) { decimalFigures = 8; }
  135405. return x.toFixed(decimalFigures).replace(/0+$/, '');
  135406. };
  135407. return BlurPostProcess;
  135408. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  135409. /***/ }),
  135410. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  135411. /*!*********************************************************!*\
  135412. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  135413. \*********************************************************/
  135414. /*! exports provided: ChromaticAberrationPostProcess */
  135415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135416. "use strict";
  135417. __webpack_require__.r(__webpack_exports__);
  135418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  135419. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135420. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  135421. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135422. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135423. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  135424. /**
  135425. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  135426. */
  135427. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  135428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  135429. /**
  135430. * Creates a new instance ChromaticAberrationPostProcess
  135431. * @param name The name of the effect.
  135432. * @param screenWidth The width of the screen to apply the effect on.
  135433. * @param screenHeight The height of the screen to apply the effect on.
  135434. * @param options The required width/height ratio to downsize to before computing the render pass.
  135435. * @param camera The camera to apply the render pass to.
  135436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135437. * @param engine The engine which the post process will be applied. (default: current engine)
  135438. * @param reusable If the post process can be reused on the same frame. (default: false)
  135439. * @param textureType Type of textures used when performing the post process. (default: 0)
  135440. * @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)
  135441. */
  135442. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  135443. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135444. if (blockCompilation === void 0) { blockCompilation = false; }
  135445. 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;
  135446. /**
  135447. * The amount of seperation of rgb channels (default: 30)
  135448. */
  135449. _this.aberrationAmount = 30;
  135450. /**
  135451. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  135452. */
  135453. _this.radialIntensity = 0;
  135454. /**
  135455. * 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))
  135456. */
  135457. _this.direction = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  135458. /**
  135459. * 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))
  135460. */
  135461. _this.centerPosition = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  135462. _this.onApplyObservable.add(function (effect) {
  135463. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  135464. effect.setFloat('screen_width', screenWidth);
  135465. effect.setFloat('screen_height', screenHeight);
  135466. effect.setFloat('radialIntensity', _this.radialIntensity);
  135467. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  135468. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  135469. });
  135470. return _this;
  135471. }
  135472. return ChromaticAberrationPostProcess;
  135473. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  135474. /***/ }),
  135475. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  135476. /*!*******************************************************!*\
  135477. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  135478. \*******************************************************/
  135479. /*! exports provided: CircleOfConfusionPostProcess */
  135480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135481. "use strict";
  135482. __webpack_require__.r(__webpack_exports__);
  135483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  135484. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135485. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135486. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  135487. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135488. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  135489. /**
  135490. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  135491. */
  135492. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  135493. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  135494. /**
  135495. * Creates a new instance CircleOfConfusionPostProcess
  135496. * @param name The name of the effect.
  135497. * @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.
  135498. * @param options The required width/height ratio to downsize to before computing the render pass.
  135499. * @param camera The camera to apply the render pass to.
  135500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135501. * @param engine The engine which the post process will be applied. (default: current engine)
  135502. * @param reusable If the post process can be reused on the same frame. (default: false)
  135503. * @param textureType Type of textures used when performing the post process. (default: 0)
  135504. * @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)
  135505. */
  135506. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  135507. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135508. if (blockCompilation === void 0) { blockCompilation = false; }
  135509. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  135510. /**
  135511. * 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.
  135512. */
  135513. _this.lensSize = 50;
  135514. /**
  135515. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  135516. */
  135517. _this.fStop = 1.4;
  135518. /**
  135519. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  135520. */
  135521. _this.focusDistance = 2000;
  135522. /**
  135523. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  135524. */
  135525. _this.focalLength = 50;
  135526. _this._depthTexture = null;
  135527. _this._depthTexture = depthTexture;
  135528. _this.onApplyObservable.add(function (effect) {
  135529. if (!_this._depthTexture) {
  135530. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  135531. return;
  135532. }
  135533. effect.setTexture("depthSampler", _this._depthTexture);
  135534. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  135535. var aperture = _this.lensSize / _this.fStop;
  135536. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  135537. effect.setFloat('focusDistance', _this.focusDistance);
  135538. effect.setFloat('cocPrecalculation', cocPrecalculation);
  135539. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  135540. });
  135541. return _this;
  135542. }
  135543. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  135544. /**
  135545. * 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.
  135546. */
  135547. set: function (value) {
  135548. this._depthTexture = value;
  135549. },
  135550. enumerable: true,
  135551. configurable: true
  135552. });
  135553. return CircleOfConfusionPostProcess;
  135554. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  135555. /***/ }),
  135556. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  135557. /*!*****************************************************!*\
  135558. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  135559. \*****************************************************/
  135560. /*! exports provided: ColorCorrectionPostProcess */
  135561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135562. "use strict";
  135563. __webpack_require__.r(__webpack_exports__);
  135564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  135565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135566. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135567. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  135568. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  135569. /**
  135570. *
  135571. * This post-process allows the modification of rendered colors by using
  135572. * a 'look-up table' (LUT). This effect is also called Color Grading.
  135573. *
  135574. * The object needs to be provided an url to a texture containing the color
  135575. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  135576. * Use an image editing software to tweak the LUT to match your needs.
  135577. *
  135578. * For an example of a color LUT, see here:
  135579. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  135580. * For explanations on color grading, see here:
  135581. * @see http://udn.epicgames.com/Three/ColorGrading.html
  135582. *
  135583. */
  135584. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  135585. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  135586. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  135587. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  135588. _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);
  135589. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  135590. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  135591. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  135592. _this.onApply = function (effect) {
  135593. effect.setTexture("colorTable", _this._colorTableTexture);
  135594. };
  135595. return _this;
  135596. }
  135597. return ColorCorrectionPostProcess;
  135598. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  135599. /***/ }),
  135600. /***/ "./PostProcesses/convolutionPostProcess.ts":
  135601. /*!*************************************************!*\
  135602. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  135603. \*************************************************/
  135604. /*! exports provided: ConvolutionPostProcess */
  135605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135606. "use strict";
  135607. __webpack_require__.r(__webpack_exports__);
  135608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  135609. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135610. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135611. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135612. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  135613. /**
  135614. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  135615. * input texture to perform effects such as edge detection or sharpening
  135616. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  135617. */
  135618. var ConvolutionPostProcess = /** @class */ (function (_super) {
  135619. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  135620. /**
  135621. * Creates a new instance ConvolutionPostProcess
  135622. * @param name The name of the effect.
  135623. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  135624. * @param options The required width/height ratio to downsize to before computing the render pass.
  135625. * @param camera The camera to apply the render pass to.
  135626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135627. * @param engine The engine which the post process will be applied. (default: current engine)
  135628. * @param reusable If the post process can be reused on the same frame. (default: false)
  135629. * @param textureType Type of textures used when performing the post process. (default: 0)
  135630. */
  135631. function ConvolutionPostProcess(name,
  135632. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  135633. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  135634. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135635. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  135636. _this.kernel = kernel;
  135637. _this.onApply = function (effect) {
  135638. effect.setFloat2("screenSize", _this.width, _this.height);
  135639. effect.setArray("kernel", _this.kernel);
  135640. };
  135641. return _this;
  135642. }
  135643. // Statics
  135644. /**
  135645. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  135646. */
  135647. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  135648. /**
  135649. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  135650. */
  135651. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  135652. /**
  135653. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  135654. */
  135655. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  135656. /**
  135657. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  135658. */
  135659. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  135660. /**
  135661. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  135662. */
  135663. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  135664. /**
  135665. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  135666. */
  135667. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  135668. return ConvolutionPostProcess;
  135669. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  135670. /***/ }),
  135671. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  135672. /*!******************************************************!*\
  135673. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  135674. \******************************************************/
  135675. /*! exports provided: DepthOfFieldBlurPostProcess */
  135676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135677. "use strict";
  135678. __webpack_require__.r(__webpack_exports__);
  135679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  135680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135681. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  135682. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  135683. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135684. /**
  135685. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  135686. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  135687. * based on samples that have a large difference in distance than the center pixel.
  135688. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  135689. */
  135690. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  135691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  135692. /**
  135693. * Creates a new instance CircleOfConfusionPostProcess
  135694. * @param name The name of the effect.
  135695. * @param scene The scene the effect belongs to.
  135696. * @param direction The direction the blur should be applied.
  135697. * @param kernel The size of the kernel used to blur.
  135698. * @param options The required width/height ratio to downsize to before computing the render pass.
  135699. * @param camera The camera to apply the render pass to.
  135700. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  135701. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  135702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135703. * @param engine The engine which the post process will be applied. (default: current engine)
  135704. * @param reusable If the post process can be reused on the same frame. (default: false)
  135705. * @param textureType Type of textures used when performing the post process. (default: 0)
  135706. * @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)
  135707. */
  135708. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  135709. if (imageToBlur === void 0) { imageToBlur = null; }
  135710. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  135711. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135712. if (blockCompilation === void 0) { blockCompilation = false; }
  135713. 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;
  135714. _this.direction = direction;
  135715. _this.onApplyObservable.add(function (effect) {
  135716. if (imageToBlur != null) {
  135717. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  135718. }
  135719. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  135720. if (scene.activeCamera) {
  135721. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  135722. }
  135723. });
  135724. return _this;
  135725. }
  135726. return DepthOfFieldBlurPostProcess;
  135727. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  135728. /***/ }),
  135729. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  135730. /*!*********************************************!*\
  135731. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  135732. \*********************************************/
  135733. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  135734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135735. "use strict";
  135736. __webpack_require__.r(__webpack_exports__);
  135737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  135738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  135739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135740. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  135741. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  135742. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  135743. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  135744. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  135745. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  135746. /**
  135747. * Specifies the level of max blur that should be applied when using the depth of field effect
  135748. */
  135749. var DepthOfFieldEffectBlurLevel;
  135750. (function (DepthOfFieldEffectBlurLevel) {
  135751. /**
  135752. * Subtle blur
  135753. */
  135754. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  135755. /**
  135756. * Medium blur
  135757. */
  135758. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  135759. /**
  135760. * Large blur
  135761. */
  135762. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  135763. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  135764. /**
  135765. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  135766. */
  135767. var DepthOfFieldEffect = /** @class */ (function (_super) {
  135768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  135769. /**
  135770. * Creates a new instance DepthOfFieldEffect
  135771. * @param scene The scene the effect belongs to.
  135772. * @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.
  135773. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  135774. * @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)
  135775. */
  135776. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  135777. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  135778. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  135779. if (blockCompilation === void 0) { blockCompilation = false; }
  135780. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  135781. return _this._effects;
  135782. }, true) || this;
  135783. /**
  135784. * @hidden Internal post processes in depth of field effect
  135785. */
  135786. _this._effects = [];
  135787. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  135788. _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);
  135789. // 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)
  135790. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  135791. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  135792. _this._depthOfFieldBlurY = [];
  135793. _this._depthOfFieldBlurX = [];
  135794. var blurCount = 1;
  135795. var kernelSize = 15;
  135796. switch (blurLevel) {
  135797. case DepthOfFieldEffectBlurLevel.High: {
  135798. blurCount = 3;
  135799. kernelSize = 51;
  135800. break;
  135801. }
  135802. case DepthOfFieldEffectBlurLevel.Medium: {
  135803. blurCount = 2;
  135804. kernelSize = 31;
  135805. break;
  135806. }
  135807. default: {
  135808. kernelSize = 15;
  135809. blurCount = 1;
  135810. break;
  135811. }
  135812. }
  135813. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  135814. var ratio = 1.0;
  135815. for (var i = 0; i < blurCount; i++) {
  135816. var blurY = new _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__["DepthOfFieldBlurPostProcess"]("verticle blur", scene, new _Maths_math_vector__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);
  135817. blurY.autoClear = false;
  135818. ratio = 0.75 / Math.pow(2, i);
  135819. var blurX = new _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__["DepthOfFieldBlurPostProcess"]("horizontal blur", scene, new _Maths_math_vector__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);
  135820. blurX.autoClear = false;
  135821. _this._depthOfFieldBlurY.push(blurY);
  135822. _this._depthOfFieldBlurX.push(blurX);
  135823. }
  135824. // Set all post processes on the effect.
  135825. _this._effects = [_this._circleOfConfusion];
  135826. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  135827. _this._effects.push(_this._depthOfFieldBlurY[i]);
  135828. _this._effects.push(_this._depthOfFieldBlurX[i]);
  135829. }
  135830. // Merge blurred images with original image based on circleOfConfusion
  135831. _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);
  135832. _this._dofMerge.autoClear = false;
  135833. _this._effects.push(_this._dofMerge);
  135834. return _this;
  135835. }
  135836. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  135837. get: function () {
  135838. return this._circleOfConfusion.focalLength;
  135839. },
  135840. /**
  135841. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  135842. */
  135843. set: function (value) {
  135844. this._circleOfConfusion.focalLength = value;
  135845. },
  135846. enumerable: true,
  135847. configurable: true
  135848. });
  135849. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  135850. get: function () {
  135851. return this._circleOfConfusion.fStop;
  135852. },
  135853. /**
  135854. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  135855. */
  135856. set: function (value) {
  135857. this._circleOfConfusion.fStop = value;
  135858. },
  135859. enumerable: true,
  135860. configurable: true
  135861. });
  135862. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  135863. get: function () {
  135864. return this._circleOfConfusion.focusDistance;
  135865. },
  135866. /**
  135867. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  135868. */
  135869. set: function (value) {
  135870. this._circleOfConfusion.focusDistance = value;
  135871. },
  135872. enumerable: true,
  135873. configurable: true
  135874. });
  135875. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  135876. get: function () {
  135877. return this._circleOfConfusion.lensSize;
  135878. },
  135879. /**
  135880. * 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.
  135881. */
  135882. set: function (value) {
  135883. this._circleOfConfusion.lensSize = value;
  135884. },
  135885. enumerable: true,
  135886. configurable: true
  135887. });
  135888. /**
  135889. * Get the current class name of the current effet
  135890. * @returns "DepthOfFieldEffect"
  135891. */
  135892. DepthOfFieldEffect.prototype.getClassName = function () {
  135893. return "DepthOfFieldEffect";
  135894. };
  135895. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  135896. /**
  135897. * 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.
  135898. */
  135899. set: function (value) {
  135900. this._circleOfConfusion.depthTexture = value;
  135901. },
  135902. enumerable: true,
  135903. configurable: true
  135904. });
  135905. /**
  135906. * Disposes each of the internal effects for a given camera.
  135907. * @param camera The camera to dispose the effect on.
  135908. */
  135909. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  135910. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  135911. this._effects[effectIndex].dispose(camera);
  135912. }
  135913. };
  135914. /**
  135915. * @hidden Internal
  135916. */
  135917. DepthOfFieldEffect.prototype._updateEffects = function () {
  135918. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  135919. this._effects[effectIndex].updateEffect();
  135920. }
  135921. };
  135922. /**
  135923. * Internal
  135924. * @returns if all the contained post processes are ready.
  135925. * @hidden
  135926. */
  135927. DepthOfFieldEffect.prototype._isReady = function () {
  135928. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  135929. if (!this._effects[effectIndex].isReady()) {
  135930. return false;
  135931. }
  135932. }
  135933. return true;
  135934. };
  135935. return DepthOfFieldEffect;
  135936. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  135937. /***/ }),
  135938. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  135939. /*!*******************************************************!*\
  135940. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  135941. \*******************************************************/
  135942. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  135943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135944. "use strict";
  135945. __webpack_require__.r(__webpack_exports__);
  135946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  135947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  135948. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135949. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  135950. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  135951. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  135952. /**
  135953. * Options to be set when merging outputs from the default pipeline.
  135954. */
  135955. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  135956. function DepthOfFieldMergePostProcessOptions() {
  135957. }
  135958. return DepthOfFieldMergePostProcessOptions;
  135959. }());
  135960. /**
  135961. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  135962. */
  135963. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  135964. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  135965. /**
  135966. * Creates a new instance of DepthOfFieldMergePostProcess
  135967. * @param name The name of the effect.
  135968. * @param originalFromInput Post process which's input will be used for the merge.
  135969. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  135970. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  135971. * @param options The required width/height ratio to downsize to before computing the render pass.
  135972. * @param camera The camera to apply the render pass to.
  135973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135974. * @param engine The engine which the post process will be applied. (default: current engine)
  135975. * @param reusable If the post process can be reused on the same frame. (default: false)
  135976. * @param textureType Type of textures used when performing the post process. (default: 0)
  135977. * @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)
  135978. */
  135979. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  135980. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  135981. if (blockCompilation === void 0) { blockCompilation = false; }
  135982. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  135983. _this.blurSteps = blurSteps;
  135984. _this.onApplyObservable.add(function (effect) {
  135985. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  135986. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  135987. blurSteps.forEach(function (step, index) {
  135988. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  135989. });
  135990. });
  135991. if (!blockCompilation) {
  135992. _this.updateEffect();
  135993. }
  135994. return _this;
  135995. }
  135996. /**
  135997. * Updates the effect with the current post process compile time values and recompiles the shader.
  135998. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  135999. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  136000. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  136001. * @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
  136002. * @param onCompiled Called when the shader has been compiled.
  136003. * @param onError Called if there is an error when compiling a shader.
  136004. */
  136005. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  136006. if (defines === void 0) { defines = null; }
  136007. if (uniforms === void 0) { uniforms = null; }
  136008. if (samplers === void 0) { samplers = null; }
  136009. if (!defines) {
  136010. defines = "";
  136011. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  136012. }
  136013. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  136014. };
  136015. return DepthOfFieldMergePostProcess;
  136016. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  136017. /***/ }),
  136018. /***/ "./PostProcesses/displayPassPostProcess.ts":
  136019. /*!*************************************************!*\
  136020. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  136021. \*************************************************/
  136022. /*! exports provided: DisplayPassPostProcess */
  136023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136024. "use strict";
  136025. __webpack_require__.r(__webpack_exports__);
  136026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  136027. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136028. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136029. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  136030. /**
  136031. * DisplayPassPostProcess which produces an output the same as it's input
  136032. */
  136033. var DisplayPassPostProcess = /** @class */ (function (_super) {
  136034. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  136035. /**
  136036. * Creates the DisplayPassPostProcess
  136037. * @param name The name of the effect.
  136038. * @param options The required width/height ratio to downsize to before computing the render pass.
  136039. * @param camera The camera to apply the render pass to.
  136040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136041. * @param engine The engine which the post process will be applied. (default: current engine)
  136042. * @param reusable If the post process can be reused on the same frame. (default: false)
  136043. */
  136044. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  136045. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  136046. }
  136047. return DisplayPassPostProcess;
  136048. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  136049. /***/ }),
  136050. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  136051. /*!*******************************************************!*\
  136052. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  136053. \*******************************************************/
  136054. /*! exports provided: ExtractHighlightsPostProcess */
  136055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136056. "use strict";
  136057. __webpack_require__.r(__webpack_exports__);
  136058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  136059. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136060. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136061. /* harmony import */ var _Maths_math_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.constants */ "./Maths/math.constants.ts");
  136062. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136063. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  136064. /**
  136065. * 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.
  136066. */
  136067. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  136068. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  136069. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  136070. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136071. if (blockCompilation === void 0) { blockCompilation = false; }
  136072. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  136073. /**
  136074. * The luminance threshold, pixels below this value will be set to black.
  136075. */
  136076. _this.threshold = 0.9;
  136077. /** @hidden */
  136078. _this._exposure = 1;
  136079. /**
  136080. * Post process which has the input texture to be used when performing highlight extraction
  136081. * @hidden
  136082. */
  136083. _this._inputPostProcess = null;
  136084. _this.onApplyObservable.add(function (effect) {
  136085. if (_this._inputPostProcess) {
  136086. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  136087. }
  136088. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math_constants__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  136089. effect.setFloat('exposure', _this._exposure);
  136090. });
  136091. return _this;
  136092. }
  136093. return ExtractHighlightsPostProcess;
  136094. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  136095. /***/ }),
  136096. /***/ "./PostProcesses/filterPostProcess.ts":
  136097. /*!********************************************!*\
  136098. !*** ./PostProcesses/filterPostProcess.ts ***!
  136099. \********************************************/
  136100. /*! exports provided: FilterPostProcess */
  136101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136102. "use strict";
  136103. __webpack_require__.r(__webpack_exports__);
  136104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  136105. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136106. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136107. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  136108. /**
  136109. * Applies a kernel filter to the image
  136110. */
  136111. var FilterPostProcess = /** @class */ (function (_super) {
  136112. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  136113. /**
  136114. *
  136115. * @param name The name of the effect.
  136116. * @param kernelMatrix The matrix to be applied to the image
  136117. * @param options The required width/height ratio to downsize to before computing the render pass.
  136118. * @param camera The camera to apply the render pass to.
  136119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136120. * @param engine The engine which the post process will be applied. (default: current engine)
  136121. * @param reusable If the post process can be reused on the same frame. (default: false)
  136122. */
  136123. function FilterPostProcess(name,
  136124. /** The matrix to be applied to the image */
  136125. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  136126. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  136127. _this.kernelMatrix = kernelMatrix;
  136128. _this.onApply = function (effect) {
  136129. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  136130. };
  136131. return _this;
  136132. }
  136133. return FilterPostProcess;
  136134. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  136135. /***/ }),
  136136. /***/ "./PostProcesses/fxaaPostProcess.ts":
  136137. /*!******************************************!*\
  136138. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  136139. \******************************************/
  136140. /*! exports provided: FxaaPostProcess */
  136141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136142. "use strict";
  136143. __webpack_require__.r(__webpack_exports__);
  136144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  136145. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136146. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  136147. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136148. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136149. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  136150. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  136151. /**
  136152. * Fxaa post process
  136153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  136154. */
  136155. var FxaaPostProcess = /** @class */ (function (_super) {
  136156. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  136157. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  136158. if (camera === void 0) { camera = null; }
  136159. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136160. 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;
  136161. var defines = _this._getDefines();
  136162. _this.updateEffect(defines);
  136163. _this.onApplyObservable.add(function (effect) {
  136164. var texelSize = _this.texelSize;
  136165. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  136166. });
  136167. return _this;
  136168. }
  136169. FxaaPostProcess.prototype._getDefines = function () {
  136170. var engine = this.getEngine();
  136171. if (!engine) {
  136172. return null;
  136173. }
  136174. var glInfo = engine.getGlInfo();
  136175. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  136176. return "#define MALI 1\n";
  136177. }
  136178. return null;
  136179. };
  136180. return FxaaPostProcess;
  136181. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  136182. /***/ }),
  136183. /***/ "./PostProcesses/grainPostProcess.ts":
  136184. /*!*******************************************!*\
  136185. !*** ./PostProcesses/grainPostProcess.ts ***!
  136186. \*******************************************/
  136187. /*! exports provided: GrainPostProcess */
  136188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136189. "use strict";
  136190. __webpack_require__.r(__webpack_exports__);
  136191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  136192. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136193. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136194. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136195. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  136196. /**
  136197. * The GrainPostProcess adds noise to the image at mid luminance levels
  136198. */
  136199. var GrainPostProcess = /** @class */ (function (_super) {
  136200. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  136201. /**
  136202. * Creates a new instance of @see GrainPostProcess
  136203. * @param name The name of the effect.
  136204. * @param options The required width/height ratio to downsize to before computing the render pass.
  136205. * @param camera The camera to apply the render pass to.
  136206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136207. * @param engine The engine which the post process will be applied. (default: current engine)
  136208. * @param reusable If the post process can be reused on the same frame. (default: false)
  136209. * @param textureType Type of textures used when performing the post process. (default: 0)
  136210. * @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)
  136211. */
  136212. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  136213. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136214. if (blockCompilation === void 0) { blockCompilation = false; }
  136215. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  136216. /**
  136217. * The intensity of the grain added (default: 30)
  136218. */
  136219. _this.intensity = 30;
  136220. /**
  136221. * If the grain should be randomized on every frame
  136222. */
  136223. _this.animated = false;
  136224. _this.onApplyObservable.add(function (effect) {
  136225. effect.setFloat('intensity', _this.intensity);
  136226. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  136227. });
  136228. return _this;
  136229. }
  136230. return GrainPostProcess;
  136231. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  136232. /***/ }),
  136233. /***/ "./PostProcesses/highlightsPostProcess.ts":
  136234. /*!************************************************!*\
  136235. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  136236. \************************************************/
  136237. /*! exports provided: HighlightsPostProcess */
  136238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136239. "use strict";
  136240. __webpack_require__.r(__webpack_exports__);
  136241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  136242. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136243. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136244. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136245. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  136246. /**
  136247. * Extracts highlights from the image
  136248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136249. */
  136250. var HighlightsPostProcess = /** @class */ (function (_super) {
  136251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  136252. /**
  136253. * Extracts highlights from the image
  136254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136255. * @param name The name of the effect.
  136256. * @param options The required width/height ratio to downsize to before computing the render pass.
  136257. * @param camera The camera to apply the render pass to.
  136258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136259. * @param engine The engine which the post process will be applied. (default: current engine)
  136260. * @param reusable If the post process can be reused on the same frame. (default: false)
  136261. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  136262. */
  136263. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  136264. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136265. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  136266. }
  136267. return HighlightsPostProcess;
  136268. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  136269. /***/ }),
  136270. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  136271. /*!*****************************************************!*\
  136272. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  136273. \*****************************************************/
  136274. /*! exports provided: ImageProcessingPostProcess */
  136275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136276. "use strict";
  136277. __webpack_require__.r(__webpack_exports__);
  136278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  136279. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136280. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  136281. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  136282. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136283. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  136284. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136285. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  136286. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  136287. /**
  136288. * ImageProcessingPostProcess
  136289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  136290. */
  136291. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  136292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  136293. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  136294. if (camera === void 0) { camera = null; }
  136295. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136296. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  136297. _this._fromLinearSpace = true;
  136298. /**
  136299. * Defines cache preventing GC.
  136300. */
  136301. _this._defines = {
  136302. IMAGEPROCESSING: false,
  136303. VIGNETTE: false,
  136304. VIGNETTEBLENDMODEMULTIPLY: false,
  136305. VIGNETTEBLENDMODEOPAQUE: false,
  136306. TONEMAPPING: false,
  136307. TONEMAPPING_ACES: false,
  136308. CONTRAST: false,
  136309. COLORCURVES: false,
  136310. COLORGRADING: false,
  136311. COLORGRADING3D: false,
  136312. FROMLINEARSPACE: false,
  136313. SAMPLER3DGREENDEPTH: false,
  136314. SAMPLER3DBGRMAP: false,
  136315. IMAGEPROCESSINGPOSTPROCESS: false,
  136316. EXPOSURE: false,
  136317. };
  136318. // Setup the configuration as forced by the constructor. This would then not force the
  136319. // scene materials output in linear space and let untouched the default forward pass.
  136320. if (imageProcessingConfiguration) {
  136321. imageProcessingConfiguration.applyByPostProcess = true;
  136322. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  136323. // This will cause the shader to be compiled
  136324. _this.fromLinearSpace = false;
  136325. }
  136326. // Setup the default processing configuration to the scene.
  136327. else {
  136328. _this._attachImageProcessingConfiguration(null, true);
  136329. _this.imageProcessingConfiguration.applyByPostProcess = true;
  136330. }
  136331. _this.onApply = function (effect) {
  136332. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  136333. };
  136334. return _this;
  136335. }
  136336. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  136337. /**
  136338. * Gets the image processing configuration used either in this material.
  136339. */
  136340. get: function () {
  136341. return this._imageProcessingConfiguration;
  136342. },
  136343. /**
  136344. * Sets the Default image processing configuration used either in the this material.
  136345. *
  136346. * If sets to null, the scene one is in use.
  136347. */
  136348. set: function (value) {
  136349. // We are almost sure it is applied by post process as
  136350. // We are in the post process :-)
  136351. value.applyByPostProcess = true;
  136352. this._attachImageProcessingConfiguration(value);
  136353. },
  136354. enumerable: true,
  136355. configurable: true
  136356. });
  136357. /**
  136358. * Attaches a new image processing configuration to the PBR Material.
  136359. * @param configuration
  136360. */
  136361. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  136362. var _this = this;
  136363. if (doNotBuild === void 0) { doNotBuild = false; }
  136364. if (configuration === this._imageProcessingConfiguration) {
  136365. return;
  136366. }
  136367. // Detaches observer.
  136368. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  136369. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  136370. }
  136371. // Pick the scene configuration if needed.
  136372. if (!configuration) {
  136373. var scene = null;
  136374. var engine = this.getEngine();
  136375. var camera = this.getCamera();
  136376. if (camera) {
  136377. scene = camera.getScene();
  136378. }
  136379. else if (engine && engine.scenes) {
  136380. var scenes = engine.scenes;
  136381. scene = scenes[scenes.length - 1];
  136382. }
  136383. else {
  136384. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  136385. }
  136386. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  136387. }
  136388. else {
  136389. this._imageProcessingConfiguration = configuration;
  136390. }
  136391. // Attaches observer.
  136392. if (this._imageProcessingConfiguration) {
  136393. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  136394. _this._updateParameters();
  136395. });
  136396. }
  136397. // Ensure the effect will be rebuilt.
  136398. if (!doNotBuild) {
  136399. this._updateParameters();
  136400. }
  136401. };
  136402. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  136403. /**
  136404. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  136405. */
  136406. get: function () {
  136407. return this.imageProcessingConfiguration.colorCurves;
  136408. },
  136409. /**
  136410. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  136411. */
  136412. set: function (value) {
  136413. this.imageProcessingConfiguration.colorCurves = value;
  136414. },
  136415. enumerable: true,
  136416. configurable: true
  136417. });
  136418. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  136419. /**
  136420. * Gets wether the color curves effect is enabled.
  136421. */
  136422. get: function () {
  136423. return this.imageProcessingConfiguration.colorCurvesEnabled;
  136424. },
  136425. /**
  136426. * Sets wether the color curves effect is enabled.
  136427. */
  136428. set: function (value) {
  136429. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  136430. },
  136431. enumerable: true,
  136432. configurable: true
  136433. });
  136434. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  136435. /**
  136436. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  136437. */
  136438. get: function () {
  136439. return this.imageProcessingConfiguration.colorGradingTexture;
  136440. },
  136441. /**
  136442. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  136443. */
  136444. set: function (value) {
  136445. this.imageProcessingConfiguration.colorGradingTexture = value;
  136446. },
  136447. enumerable: true,
  136448. configurable: true
  136449. });
  136450. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  136451. /**
  136452. * Gets wether the color grading effect is enabled.
  136453. */
  136454. get: function () {
  136455. return this.imageProcessingConfiguration.colorGradingEnabled;
  136456. },
  136457. /**
  136458. * Gets wether the color grading effect is enabled.
  136459. */
  136460. set: function (value) {
  136461. this.imageProcessingConfiguration.colorGradingEnabled = value;
  136462. },
  136463. enumerable: true,
  136464. configurable: true
  136465. });
  136466. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  136467. /**
  136468. * Gets exposure used in the effect.
  136469. */
  136470. get: function () {
  136471. return this.imageProcessingConfiguration.exposure;
  136472. },
  136473. /**
  136474. * Sets exposure used in the effect.
  136475. */
  136476. set: function (value) {
  136477. this.imageProcessingConfiguration.exposure = value;
  136478. },
  136479. enumerable: true,
  136480. configurable: true
  136481. });
  136482. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  136483. /**
  136484. * Gets wether tonemapping is enabled or not.
  136485. */
  136486. get: function () {
  136487. return this._imageProcessingConfiguration.toneMappingEnabled;
  136488. },
  136489. /**
  136490. * Sets wether tonemapping is enabled or not
  136491. */
  136492. set: function (value) {
  136493. this._imageProcessingConfiguration.toneMappingEnabled = value;
  136494. },
  136495. enumerable: true,
  136496. configurable: true
  136497. });
  136498. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  136499. /**
  136500. * Gets the type of tone mapping effect.
  136501. */
  136502. get: function () {
  136503. return this._imageProcessingConfiguration.toneMappingType;
  136504. },
  136505. /**
  136506. * Sets the type of tone mapping effect.
  136507. */
  136508. set: function (value) {
  136509. this._imageProcessingConfiguration.toneMappingType = value;
  136510. },
  136511. enumerable: true,
  136512. configurable: true
  136513. });
  136514. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  136515. /**
  136516. * Gets contrast used in the effect.
  136517. */
  136518. get: function () {
  136519. return this.imageProcessingConfiguration.contrast;
  136520. },
  136521. /**
  136522. * Sets contrast used in the effect.
  136523. */
  136524. set: function (value) {
  136525. this.imageProcessingConfiguration.contrast = value;
  136526. },
  136527. enumerable: true,
  136528. configurable: true
  136529. });
  136530. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  136531. /**
  136532. * Gets Vignette stretch size.
  136533. */
  136534. get: function () {
  136535. return this.imageProcessingConfiguration.vignetteStretch;
  136536. },
  136537. /**
  136538. * Sets Vignette stretch size.
  136539. */
  136540. set: function (value) {
  136541. this.imageProcessingConfiguration.vignetteStretch = value;
  136542. },
  136543. enumerable: true,
  136544. configurable: true
  136545. });
  136546. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  136547. /**
  136548. * Gets Vignette centre X Offset.
  136549. */
  136550. get: function () {
  136551. return this.imageProcessingConfiguration.vignetteCentreX;
  136552. },
  136553. /**
  136554. * Sets Vignette centre X Offset.
  136555. */
  136556. set: function (value) {
  136557. this.imageProcessingConfiguration.vignetteCentreX = value;
  136558. },
  136559. enumerable: true,
  136560. configurable: true
  136561. });
  136562. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  136563. /**
  136564. * Gets Vignette centre Y Offset.
  136565. */
  136566. get: function () {
  136567. return this.imageProcessingConfiguration.vignetteCentreY;
  136568. },
  136569. /**
  136570. * Sets Vignette centre Y Offset.
  136571. */
  136572. set: function (value) {
  136573. this.imageProcessingConfiguration.vignetteCentreY = value;
  136574. },
  136575. enumerable: true,
  136576. configurable: true
  136577. });
  136578. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  136579. /**
  136580. * Gets Vignette weight or intensity of the vignette effect.
  136581. */
  136582. get: function () {
  136583. return this.imageProcessingConfiguration.vignetteWeight;
  136584. },
  136585. /**
  136586. * Sets Vignette weight or intensity of the vignette effect.
  136587. */
  136588. set: function (value) {
  136589. this.imageProcessingConfiguration.vignetteWeight = value;
  136590. },
  136591. enumerable: true,
  136592. configurable: true
  136593. });
  136594. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  136595. /**
  136596. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  136597. * if vignetteEnabled is set to true.
  136598. */
  136599. get: function () {
  136600. return this.imageProcessingConfiguration.vignetteColor;
  136601. },
  136602. /**
  136603. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  136604. * if vignetteEnabled is set to true.
  136605. */
  136606. set: function (value) {
  136607. this.imageProcessingConfiguration.vignetteColor = value;
  136608. },
  136609. enumerable: true,
  136610. configurable: true
  136611. });
  136612. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  136613. /**
  136614. * Gets Camera field of view used by the Vignette effect.
  136615. */
  136616. get: function () {
  136617. return this.imageProcessingConfiguration.vignetteCameraFov;
  136618. },
  136619. /**
  136620. * Sets Camera field of view used by the Vignette effect.
  136621. */
  136622. set: function (value) {
  136623. this.imageProcessingConfiguration.vignetteCameraFov = value;
  136624. },
  136625. enumerable: true,
  136626. configurable: true
  136627. });
  136628. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  136629. /**
  136630. * Gets the vignette blend mode allowing different kind of effect.
  136631. */
  136632. get: function () {
  136633. return this.imageProcessingConfiguration.vignetteBlendMode;
  136634. },
  136635. /**
  136636. * Sets the vignette blend mode allowing different kind of effect.
  136637. */
  136638. set: function (value) {
  136639. this.imageProcessingConfiguration.vignetteBlendMode = value;
  136640. },
  136641. enumerable: true,
  136642. configurable: true
  136643. });
  136644. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  136645. /**
  136646. * Gets wether the vignette effect is enabled.
  136647. */
  136648. get: function () {
  136649. return this.imageProcessingConfiguration.vignetteEnabled;
  136650. },
  136651. /**
  136652. * Sets wether the vignette effect is enabled.
  136653. */
  136654. set: function (value) {
  136655. this.imageProcessingConfiguration.vignetteEnabled = value;
  136656. },
  136657. enumerable: true,
  136658. configurable: true
  136659. });
  136660. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  136661. /**
  136662. * Gets wether the input of the processing is in Gamma or Linear Space.
  136663. */
  136664. get: function () {
  136665. return this._fromLinearSpace;
  136666. },
  136667. /**
  136668. * Sets wether the input of the processing is in Gamma or Linear Space.
  136669. */
  136670. set: function (value) {
  136671. if (this._fromLinearSpace === value) {
  136672. return;
  136673. }
  136674. this._fromLinearSpace = value;
  136675. this._updateParameters();
  136676. },
  136677. enumerable: true,
  136678. configurable: true
  136679. });
  136680. /**
  136681. * "ImageProcessingPostProcess"
  136682. * @returns "ImageProcessingPostProcess"
  136683. */
  136684. ImageProcessingPostProcess.prototype.getClassName = function () {
  136685. return "ImageProcessingPostProcess";
  136686. };
  136687. ImageProcessingPostProcess.prototype._updateParameters = function () {
  136688. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  136689. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  136690. var defines = "";
  136691. for (var define in this._defines) {
  136692. if (this._defines[define]) {
  136693. defines += "#define " + define + ";\r\n";
  136694. }
  136695. }
  136696. var samplers = ["textureSampler"];
  136697. var uniforms = ["scale"];
  136698. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  136699. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  136700. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  136701. }
  136702. this.updateEffect(defines, uniforms, samplers);
  136703. };
  136704. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  136705. _super.prototype.dispose.call(this, camera);
  136706. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  136707. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  136708. }
  136709. if (this._imageProcessingConfiguration) {
  136710. this.imageProcessingConfiguration.applyByPostProcess = false;
  136711. }
  136712. };
  136713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  136714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  136715. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  136716. return ImageProcessingPostProcess;
  136717. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  136718. /***/ }),
  136719. /***/ "./PostProcesses/index.ts":
  136720. /*!********************************!*\
  136721. !*** ./PostProcesses/index.ts ***!
  136722. \********************************/
  136723. /*! 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 */
  136724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136725. "use strict";
  136726. __webpack_require__.r(__webpack_exports__);
  136727. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  136728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  136729. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  136730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  136731. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  136732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  136733. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  136734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  136735. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  136736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  136737. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  136738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  136739. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  136740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  136741. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  136742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  136743. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  136744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  136745. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  136746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  136747. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  136748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  136749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  136750. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  136751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  136752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  136753. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  136754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  136755. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  136756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  136757. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  136758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  136759. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  136760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  136761. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  136762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  136763. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  136764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  136765. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  136766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  136767. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  136768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  136769. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  136770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  136771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  136772. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  136774. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  136775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  136776. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  136777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  136778. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  136779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  136780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  136781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  136782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  136783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  136784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  136785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  136786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  136787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  136788. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  136789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  136790. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  136791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  136792. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  136793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  136794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  136795. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  136796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  136797. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  136798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  136799. /* harmony import */ var _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  136800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  136801. /***/ }),
  136802. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  136803. /*!************************************************!*\
  136804. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  136805. \************************************************/
  136806. /*! exports provided: MotionBlurPostProcess */
  136807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136808. "use strict";
  136809. __webpack_require__.r(__webpack_exports__);
  136810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  136811. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136812. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  136813. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  136814. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136815. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136816. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  136817. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  136818. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  136819. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  136820. /**
  136821. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  136822. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  136823. * As an example, all you have to do is to create the post-process:
  136824. * var mb = new BABYLON.MotionBlurPostProcess(
  136825. * 'mb', // The name of the effect.
  136826. * scene, // The scene containing the objects to blur according to their velocity.
  136827. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  136828. * camera // The camera to apply the render pass to.
  136829. * );
  136830. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  136831. */
  136832. var MotionBlurPostProcess = /** @class */ (function (_super) {
  136833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  136834. /**
  136835. * Creates a new instance MotionBlurPostProcess
  136836. * @param name The name of the effect.
  136837. * @param scene The scene containing the objects to blur according to their velocity.
  136838. * @param options The required width/height ratio to downsize to before computing the render pass.
  136839. * @param camera The camera to apply the render pass to.
  136840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136841. * @param engine The engine which the post process will be applied. (default: current engine)
  136842. * @param reusable If the post process can be reused on the same frame. (default: false)
  136843. * @param textureType Type of textures used when performing the post process. (default: 0)
  136844. * @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)
  136845. */
  136846. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  136847. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136848. if (blockCompilation === void 0) { blockCompilation = false; }
  136849. 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;
  136850. /**
  136851. * Defines how much the image is blurred by the movement. Default value is equal to 1
  136852. */
  136853. _this.motionStrength = 1;
  136854. _this._motionBlurSamples = 32;
  136855. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  136856. if (!_this._geometryBufferRenderer) {
  136857. // Geometry buffer renderer is not supported. So, work as a passthrough.
  136858. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  136859. _this.updateEffect();
  136860. }
  136861. else {
  136862. // Geometry buffer renderer is supported.
  136863. _this._geometryBufferRenderer.enableVelocity = true;
  136864. _this.onApply = function (effect) {
  136865. effect.setVector2("screenSize", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  136866. effect.setFloat("motionScale", scene.getAnimationRatio());
  136867. effect.setFloat("motionStrength", _this.motionStrength);
  136868. if (_this._geometryBufferRenderer) {
  136869. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  136870. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  136871. }
  136872. };
  136873. }
  136874. return _this;
  136875. }
  136876. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  136877. /**
  136878. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  136879. */
  136880. get: function () {
  136881. return this._motionBlurSamples;
  136882. },
  136883. /**
  136884. * Sets the number of iterations to be used for motion blur quality
  136885. */
  136886. set: function (samples) {
  136887. this._motionBlurSamples = samples;
  136888. if (this._geometryBufferRenderer) {
  136889. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  136890. }
  136891. },
  136892. enumerable: true,
  136893. configurable: true
  136894. });
  136895. /**
  136896. * Excludes the given skinned mesh from computing bones velocities.
  136897. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  136898. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  136899. */
  136900. MotionBlurPostProcess.prototype.excludeSkinnedMesh = function (skinnedMesh) {
  136901. if (this._geometryBufferRenderer && skinnedMesh.skeleton) {
  136902. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity.push(skinnedMesh);
  136903. }
  136904. };
  136905. /**
  136906. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  136907. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  136908. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  136909. */
  136910. MotionBlurPostProcess.prototype.removeExcludedSkinnedMesh = function (skinnedMesh) {
  136911. if (this._geometryBufferRenderer && skinnedMesh.skeleton) {
  136912. var index = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity.indexOf(skinnedMesh);
  136913. if (index !== -1) {
  136914. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity.splice(index, 1);
  136915. }
  136916. }
  136917. };
  136918. /**
  136919. * Disposes the post process.
  136920. * @param camera The camera to dispose the post process on.
  136921. */
  136922. MotionBlurPostProcess.prototype.dispose = function (camera) {
  136923. if (this._geometryBufferRenderer) {
  136924. // Clear previous transformation matrices dictionary used to compute objects velocities
  136925. this._geometryBufferRenderer._previousTransformationMatrices = {};
  136926. this._geometryBufferRenderer._previousBonesTransformationMatrices = {};
  136927. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = [];
  136928. }
  136929. _super.prototype.dispose.call(this, camera);
  136930. };
  136931. return MotionBlurPostProcess;
  136932. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  136933. /***/ }),
  136934. /***/ "./PostProcesses/passPostProcess.ts":
  136935. /*!******************************************!*\
  136936. !*** ./PostProcesses/passPostProcess.ts ***!
  136937. \******************************************/
  136938. /*! exports provided: PassPostProcess, PassCubePostProcess */
  136939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136940. "use strict";
  136941. __webpack_require__.r(__webpack_exports__);
  136942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  136943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  136944. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136945. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  136946. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  136947. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  136948. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  136949. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  136950. /**
  136951. * PassPostProcess which produces an output the same as it's input
  136952. */
  136953. var PassPostProcess = /** @class */ (function (_super) {
  136954. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  136955. /**
  136956. * Creates the PassPostProcess
  136957. * @param name The name of the effect.
  136958. * @param options The required width/height ratio to downsize to before computing the render pass.
  136959. * @param camera The camera to apply the render pass to.
  136960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136961. * @param engine The engine which the post process will be applied. (default: current engine)
  136962. * @param reusable If the post process can be reused on the same frame. (default: false)
  136963. * @param textureType The type of texture to be used when performing the post processing.
  136964. * @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)
  136965. */
  136966. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  136967. if (camera === void 0) { camera = null; }
  136968. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136969. if (blockCompilation === void 0) { blockCompilation = false; }
  136970. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  136971. }
  136972. return PassPostProcess;
  136973. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  136974. /**
  136975. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  136976. */
  136977. var PassCubePostProcess = /** @class */ (function (_super) {
  136978. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  136979. /**
  136980. * Creates the PassCubePostProcess
  136981. * @param name The name of the effect.
  136982. * @param options The required width/height ratio to downsize to before computing the render pass.
  136983. * @param camera The camera to apply the render pass to.
  136984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136985. * @param engine The engine which the post process will be applied. (default: current engine)
  136986. * @param reusable If the post process can be reused on the same frame. (default: false)
  136987. * @param textureType The type of texture to be used when performing the post processing.
  136988. * @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)
  136989. */
  136990. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  136991. if (camera === void 0) { camera = null; }
  136992. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  136993. if (blockCompilation === void 0) { blockCompilation = false; }
  136994. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  136995. _this._face = 0;
  136996. return _this;
  136997. }
  136998. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  136999. /**
  137000. * Gets or sets the cube face to display.
  137001. * * 0 is +X
  137002. * * 1 is -X
  137003. * * 2 is +Y
  137004. * * 3 is -Y
  137005. * * 4 is +Z
  137006. * * 5 is -Z
  137007. */
  137008. get: function () {
  137009. return this._face;
  137010. },
  137011. set: function (value) {
  137012. if (value < 0 || value > 5) {
  137013. return;
  137014. }
  137015. this._face = value;
  137016. switch (this._face) {
  137017. case 0:
  137018. this.updateEffect("#define POSITIVEX");
  137019. break;
  137020. case 1:
  137021. this.updateEffect("#define NEGATIVEX");
  137022. break;
  137023. case 2:
  137024. this.updateEffect("#define POSITIVEY");
  137025. break;
  137026. case 3:
  137027. this.updateEffect("#define NEGATIVEY");
  137028. break;
  137029. case 4:
  137030. this.updateEffect("#define POSITIVEZ");
  137031. break;
  137032. case 5:
  137033. this.updateEffect("#define NEGATIVEZ");
  137034. break;
  137035. }
  137036. },
  137037. enumerable: true,
  137038. configurable: true
  137039. });
  137040. return PassCubePostProcess;
  137041. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  137042. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  137043. 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);
  137044. };
  137045. /***/ }),
  137046. /***/ "./PostProcesses/postProcess.ts":
  137047. /*!**************************************!*\
  137048. !*** ./PostProcesses/postProcess.ts ***!
  137049. \**************************************/
  137050. /*! exports provided: PostProcess */
  137051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  137052. "use strict";
  137053. __webpack_require__.r(__webpack_exports__);
  137054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  137055. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  137056. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  137057. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  137058. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  137059. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  137060. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  137061. /**
  137062. * PostProcess can be used to apply a shader to a texture after it has been rendered
  137063. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137064. */
  137065. var PostProcess = /** @class */ (function () {
  137066. /**
  137067. * Creates a new instance PostProcess
  137068. * @param name The name of the PostProcess.
  137069. * @param fragmentUrl The url of the fragment shader to be used.
  137070. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  137071. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  137072. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  137073. * @param camera The camera to apply the render pass to.
  137074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137075. * @param engine The engine which the post process will be applied. (default: current engine)
  137076. * @param reusable If the post process can be reused on the same frame. (default: false)
  137077. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  137078. * @param textureType Type of textures used when performing the post process. (default: 0)
  137079. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  137080. * @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
  137081. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  137082. */
  137083. function PostProcess(
  137084. /** Name of the PostProcess. */
  137085. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  137086. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  137087. if (defines === void 0) { defines = null; }
  137088. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  137089. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  137090. if (blockCompilation === void 0) { blockCompilation = false; }
  137091. this.name = name;
  137092. /**
  137093. * Width of the texture to apply the post process on
  137094. */
  137095. this.width = -1;
  137096. /**
  137097. * Height of the texture to apply the post process on
  137098. */
  137099. this.height = -1;
  137100. /**
  137101. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  137102. * @hidden
  137103. */
  137104. this._outputTexture = null;
  137105. /**
  137106. * If the buffer needs to be cleared before applying the post process. (default: true)
  137107. * Should be set to false if shader will overwrite all previous pixels.
  137108. */
  137109. this.autoClear = true;
  137110. /**
  137111. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  137112. */
  137113. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_DISABLE;
  137114. /**
  137115. * Animations to be used for the post processing
  137116. */
  137117. this.animations = new Array();
  137118. /**
  137119. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  137120. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  137121. */
  137122. this.enablePixelPerfectMode = false;
  137123. /**
  137124. * Force the postprocess to be applied without taking in account viewport
  137125. */
  137126. this.forceFullscreenViewport = true;
  137127. /**
  137128. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  137129. *
  137130. * | Value | Type | Description |
  137131. * | ----- | ----------------------------------- | ----------- |
  137132. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  137133. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  137134. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  137135. *
  137136. */
  137137. this.scaleMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].SCALEMODE_FLOOR;
  137138. /**
  137139. * Force textures to be a power of two (default: false)
  137140. */
  137141. this.alwaysForcePOT = false;
  137142. this._samples = 1;
  137143. /**
  137144. * Modify the scale of the post process to be the same as the viewport (default: false)
  137145. */
  137146. this.adaptScaleToCurrentViewport = false;
  137147. this._reusable = false;
  137148. /**
  137149. * Smart array of input and output textures for the post process.
  137150. * @hidden
  137151. */
  137152. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](2);
  137153. /**
  137154. * The index in _textures that corresponds to the output texture.
  137155. * @hidden
  137156. */
  137157. this._currentRenderTextureInd = 0;
  137158. this._scaleRatio = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"](1, 1);
  137159. this._texelSize = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector2"].Zero();
  137160. // Events
  137161. /**
  137162. * An event triggered when the postprocess is activated.
  137163. */
  137164. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  137165. /**
  137166. * An event triggered when the postprocess changes its size.
  137167. */
  137168. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  137169. /**
  137170. * An event triggered when the postprocess applies its effect.
  137171. */
  137172. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  137173. /**
  137174. * An event triggered before rendering the postprocess
  137175. */
  137176. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  137177. /**
  137178. * An event triggered after rendering the postprocess
  137179. */
  137180. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  137181. if (camera != null) {
  137182. this._camera = camera;
  137183. this._scene = camera.getScene();
  137184. camera.attachPostProcess(this);
  137185. this._engine = this._scene.getEngine();
  137186. this._scene.postProcesses.push(this);
  137187. this.uniqueId = this._scene.getUniqueId();
  137188. }
  137189. else if (engine) {
  137190. this._engine = engine;
  137191. this._engine.postProcesses.push(this);
  137192. }
  137193. this._options = options;
  137194. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  137195. this._reusable = reusable || false;
  137196. this._textureType = textureType;
  137197. this._samplers = samplers || [];
  137198. this._samplers.push("textureSampler");
  137199. this._fragmentUrl = fragmentUrl;
  137200. this._vertexUrl = vertexUrl;
  137201. this._parameters = parameters || [];
  137202. this._parameters.push("scale");
  137203. this._indexParameters = indexParameters;
  137204. if (!blockCompilation) {
  137205. this.updateEffect(defines);
  137206. }
  137207. }
  137208. Object.defineProperty(PostProcess.prototype, "samples", {
  137209. /**
  137210. * Number of sample textures (default: 1)
  137211. */
  137212. get: function () {
  137213. return this._samples;
  137214. },
  137215. set: function (n) {
  137216. var _this = this;
  137217. this._samples = n;
  137218. this._textures.forEach(function (texture) {
  137219. if (texture.samples !== _this._samples) {
  137220. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  137221. }
  137222. });
  137223. },
  137224. enumerable: true,
  137225. configurable: true
  137226. });
  137227. /**
  137228. * Returns the fragment url or shader name used in the post process.
  137229. * @returns the fragment url or name in the shader store.
  137230. */
  137231. PostProcess.prototype.getEffectName = function () {
  137232. return this._fragmentUrl;
  137233. };
  137234. Object.defineProperty(PostProcess.prototype, "onActivate", {
  137235. /**
  137236. * A function that is added to the onActivateObservable
  137237. */
  137238. set: function (callback) {
  137239. if (this._onActivateObserver) {
  137240. this.onActivateObservable.remove(this._onActivateObserver);
  137241. }
  137242. if (callback) {
  137243. this._onActivateObserver = this.onActivateObservable.add(callback);
  137244. }
  137245. },
  137246. enumerable: true,
  137247. configurable: true
  137248. });
  137249. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  137250. /**
  137251. * A function that is added to the onSizeChangedObservable
  137252. */
  137253. set: function (callback) {
  137254. if (this._onSizeChangedObserver) {
  137255. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  137256. }
  137257. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  137258. },
  137259. enumerable: true,
  137260. configurable: true
  137261. });
  137262. Object.defineProperty(PostProcess.prototype, "onApply", {
  137263. /**
  137264. * A function that is added to the onApplyObservable
  137265. */
  137266. set: function (callback) {
  137267. if (this._onApplyObserver) {
  137268. this.onApplyObservable.remove(this._onApplyObserver);
  137269. }
  137270. this._onApplyObserver = this.onApplyObservable.add(callback);
  137271. },
  137272. enumerable: true,
  137273. configurable: true
  137274. });
  137275. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  137276. /**
  137277. * A function that is added to the onBeforeRenderObservable
  137278. */
  137279. set: function (callback) {
  137280. if (this._onBeforeRenderObserver) {
  137281. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  137282. }
  137283. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  137284. },
  137285. enumerable: true,
  137286. configurable: true
  137287. });
  137288. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  137289. /**
  137290. * A function that is added to the onAfterRenderObservable
  137291. */
  137292. set: function (callback) {
  137293. if (this._onAfterRenderObserver) {
  137294. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  137295. }
  137296. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  137297. },
  137298. enumerable: true,
  137299. configurable: true
  137300. });
  137301. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  137302. /**
  137303. * 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
  137304. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  137305. */
  137306. get: function () {
  137307. return this._textures.data[this._currentRenderTextureInd];
  137308. },
  137309. set: function (value) {
  137310. this._forcedOutputTexture = value;
  137311. },
  137312. enumerable: true,
  137313. configurable: true
  137314. });
  137315. /**
  137316. * Gets the camera which post process is applied to.
  137317. * @returns The camera the post process is applied to.
  137318. */
  137319. PostProcess.prototype.getCamera = function () {
  137320. return this._camera;
  137321. };
  137322. Object.defineProperty(PostProcess.prototype, "texelSize", {
  137323. /**
  137324. * Gets the texel size of the postprocess.
  137325. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  137326. */
  137327. get: function () {
  137328. if (this._shareOutputWithPostProcess) {
  137329. return this._shareOutputWithPostProcess.texelSize;
  137330. }
  137331. if (this._forcedOutputTexture) {
  137332. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  137333. }
  137334. return this._texelSize;
  137335. },
  137336. enumerable: true,
  137337. configurable: true
  137338. });
  137339. /**
  137340. * Gets a string idenfifying the name of the class
  137341. * @returns "PostProcess" string
  137342. */
  137343. PostProcess.prototype.getClassName = function () {
  137344. return "PostProcess";
  137345. };
  137346. /**
  137347. * Gets the engine which this post process belongs to.
  137348. * @returns The engine the post process was enabled with.
  137349. */
  137350. PostProcess.prototype.getEngine = function () {
  137351. return this._engine;
  137352. };
  137353. /**
  137354. * The effect that is created when initializing the post process.
  137355. * @returns The created effect corresponding the the postprocess.
  137356. */
  137357. PostProcess.prototype.getEffect = function () {
  137358. return this._effect;
  137359. };
  137360. /**
  137361. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  137362. * @param postProcess The post process to share the output with.
  137363. * @returns This post process.
  137364. */
  137365. PostProcess.prototype.shareOutputWith = function (postProcess) {
  137366. this._disposeTextures();
  137367. this._shareOutputWithPostProcess = postProcess;
  137368. return this;
  137369. };
  137370. /**
  137371. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  137372. * This should be called if the post process that shares output with this post process is disabled/disposed.
  137373. */
  137374. PostProcess.prototype.useOwnOutput = function () {
  137375. if (this._textures.length == 0) {
  137376. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](2);
  137377. }
  137378. this._shareOutputWithPostProcess = null;
  137379. };
  137380. /**
  137381. * Updates the effect with the current post process compile time values and recompiles the shader.
  137382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137385. * @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
  137386. * @param onCompiled Called when the shader has been compiled.
  137387. * @param onError Called if there is an error when compiling a shader.
  137388. */
  137389. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  137390. if (defines === void 0) { defines = null; }
  137391. if (uniforms === void 0) { uniforms = null; }
  137392. if (samplers === void 0) { samplers = null; }
  137393. 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);
  137394. };
  137395. /**
  137396. * The post process is reusable if it can be used multiple times within one frame.
  137397. * @returns If the post process is reusable
  137398. */
  137399. PostProcess.prototype.isReusable = function () {
  137400. return this._reusable;
  137401. };
  137402. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  137403. PostProcess.prototype.markTextureDirty = function () {
  137404. this.width = -1;
  137405. };
  137406. /**
  137407. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  137408. * 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.
  137409. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  137410. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  137411. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  137412. * @returns The target texture that was bound to be written to.
  137413. */
  137414. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  137415. var _this = this;
  137416. if (sourceTexture === void 0) { sourceTexture = null; }
  137417. camera = camera || this._camera;
  137418. var scene = camera.getScene();
  137419. var engine = scene.getEngine();
  137420. var maxSize = engine.getCaps().maxTextureSize;
  137421. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  137422. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  137423. // 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
  137424. var webVRCamera = camera.parent;
  137425. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  137426. requiredWidth /= 2;
  137427. }
  137428. var desiredWidth = (this._options.width || requiredWidth);
  137429. var desiredHeight = this._options.height || requiredHeight;
  137430. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  137431. if (this.adaptScaleToCurrentViewport) {
  137432. var currentViewport = engine.currentViewport;
  137433. if (currentViewport) {
  137434. desiredWidth *= currentViewport.width;
  137435. desiredHeight *= currentViewport.height;
  137436. }
  137437. }
  137438. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  137439. if (!this._options.width) {
  137440. desiredWidth = engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  137441. }
  137442. if (!this._options.height) {
  137443. desiredHeight = engine.needPOTTextures ? _Engines_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  137444. }
  137445. }
  137446. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  137447. if (this._textures.length > 0) {
  137448. for (var i = 0; i < this._textures.length; i++) {
  137449. this._engine._releaseTexture(this._textures.data[i]);
  137450. }
  137451. this._textures.reset();
  137452. }
  137453. this.width = desiredWidth;
  137454. this.height = desiredHeight;
  137455. var textureSize = { width: this.width, height: this.height };
  137456. var textureOptions = {
  137457. generateMipMaps: false,
  137458. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  137459. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  137460. samplingMode: this.renderTargetSamplingMode,
  137461. type: this._textureType
  137462. };
  137463. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  137464. if (this._reusable) {
  137465. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  137466. }
  137467. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  137468. this.onSizeChangedObservable.notifyObservers(this);
  137469. }
  137470. this._textures.forEach(function (texture) {
  137471. if (texture.samples !== _this.samples) {
  137472. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  137473. }
  137474. });
  137475. }
  137476. var target;
  137477. if (this._shareOutputWithPostProcess) {
  137478. target = this._shareOutputWithPostProcess.inputTexture;
  137479. }
  137480. else if (this._forcedOutputTexture) {
  137481. target = this._forcedOutputTexture;
  137482. this.width = this._forcedOutputTexture.width;
  137483. this.height = this._forcedOutputTexture.height;
  137484. }
  137485. else {
  137486. target = this.inputTexture;
  137487. }
  137488. // Bind the input of this post process to be used as the output of the previous post process.
  137489. if (this.enablePixelPerfectMode) {
  137490. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  137491. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  137492. }
  137493. else {
  137494. this._scaleRatio.copyFromFloats(1, 1);
  137495. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  137496. }
  137497. this.onActivateObservable.notifyObservers(camera);
  137498. // Clear
  137499. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_DISABLE) {
  137500. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  137501. }
  137502. if (this._reusable) {
  137503. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  137504. }
  137505. return target;
  137506. };
  137507. Object.defineProperty(PostProcess.prototype, "isSupported", {
  137508. /**
  137509. * If the post process is supported.
  137510. */
  137511. get: function () {
  137512. return this._effect.isSupported;
  137513. },
  137514. enumerable: true,
  137515. configurable: true
  137516. });
  137517. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  137518. /**
  137519. * The aspect ratio of the output texture.
  137520. */
  137521. get: function () {
  137522. if (this._shareOutputWithPostProcess) {
  137523. return this._shareOutputWithPostProcess.aspectRatio;
  137524. }
  137525. if (this._forcedOutputTexture) {
  137526. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  137527. }
  137528. return this.width / this.height;
  137529. },
  137530. enumerable: true,
  137531. configurable: true
  137532. });
  137533. /**
  137534. * Get a value indicating if the post-process is ready to be used
  137535. * @returns true if the post-process is ready (shader is compiled)
  137536. */
  137537. PostProcess.prototype.isReady = function () {
  137538. return this._effect && this._effect.isReady();
  137539. };
  137540. /**
  137541. * Binds all textures and uniforms to the shader, this will be run on every pass.
  137542. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  137543. */
  137544. PostProcess.prototype.apply = function () {
  137545. // Check
  137546. if (!this._effect || !this._effect.isReady()) {
  137547. return null;
  137548. }
  137549. // States
  137550. this._engine.enableEffect(this._effect);
  137551. this._engine.setState(false);
  137552. this._engine.setDepthBuffer(false);
  137553. this._engine.setDepthWrite(false);
  137554. // Alpha
  137555. this._engine.setAlphaMode(this.alphaMode);
  137556. if (this.alphaConstants) {
  137557. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  137558. }
  137559. // Bind the output texture of the preivous post process as the input to this post process.
  137560. var source;
  137561. if (this._shareOutputWithPostProcess) {
  137562. source = this._shareOutputWithPostProcess.inputTexture;
  137563. }
  137564. else if (this._forcedOutputTexture) {
  137565. source = this._forcedOutputTexture;
  137566. }
  137567. else {
  137568. source = this.inputTexture;
  137569. }
  137570. this._effect._bindTexture("textureSampler", source);
  137571. // Parameters
  137572. this._effect.setVector2("scale", this._scaleRatio);
  137573. this.onApplyObservable.notifyObservers(this._effect);
  137574. return this._effect;
  137575. };
  137576. PostProcess.prototype._disposeTextures = function () {
  137577. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  137578. return;
  137579. }
  137580. if (this._textures.length > 0) {
  137581. for (var i = 0; i < this._textures.length; i++) {
  137582. this._engine._releaseTexture(this._textures.data[i]);
  137583. }
  137584. }
  137585. this._textures.dispose();
  137586. };
  137587. /**
  137588. * Disposes the post process.
  137589. * @param camera The camera to dispose the post process on.
  137590. */
  137591. PostProcess.prototype.dispose = function (camera) {
  137592. camera = camera || this._camera;
  137593. this._disposeTextures();
  137594. if (this._scene) {
  137595. var index_1 = this._scene.postProcesses.indexOf(this);
  137596. if (index_1 !== -1) {
  137597. this._scene.postProcesses.splice(index_1, 1);
  137598. }
  137599. }
  137600. else {
  137601. var index_2 = this._engine.postProcesses.indexOf(this);
  137602. if (index_2 !== -1) {
  137603. this._engine.postProcesses.splice(index_2, 1);
  137604. }
  137605. }
  137606. if (!camera) {
  137607. return;
  137608. }
  137609. camera.detachPostProcess(this);
  137610. var index = camera._postProcesses.indexOf(this);
  137611. if (index === 0 && camera._postProcesses.length > 0) {
  137612. var firstPostProcess = this._camera._getFirstPostProcess();
  137613. if (firstPostProcess) {
  137614. firstPostProcess.markTextureDirty();
  137615. }
  137616. }
  137617. this.onActivateObservable.clear();
  137618. this.onAfterRenderObservable.clear();
  137619. this.onApplyObservable.clear();
  137620. this.onBeforeRenderObservable.clear();
  137621. this.onSizeChangedObservable.clear();
  137622. };
  137623. return PostProcess;
  137624. }());
  137625. /***/ }),
  137626. /***/ "./PostProcesses/postProcessManager.ts":
  137627. /*!*********************************************!*\
  137628. !*** ./PostProcesses/postProcessManager.ts ***!
  137629. \*********************************************/
  137630. /*! exports provided: PostProcessManager */
  137631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  137632. "use strict";
  137633. __webpack_require__.r(__webpack_exports__);
  137634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  137635. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  137636. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  137637. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  137638. /**
  137639. * PostProcessManager is used to manage one or more post processes or post process pipelines
  137640. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137641. */
  137642. var PostProcessManager = /** @class */ (function () {
  137643. /**
  137644. * Creates a new instance PostProcess
  137645. * @param scene The scene that the post process is associated with.
  137646. */
  137647. function PostProcessManager(scene) {
  137648. this._vertexBuffers = {};
  137649. this._scene = scene;
  137650. }
  137651. PostProcessManager.prototype._prepareBuffers = function () {
  137652. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  137653. return;
  137654. }
  137655. // VBO
  137656. var vertices = [];
  137657. vertices.push(1, 1);
  137658. vertices.push(-1, 1);
  137659. vertices.push(-1, -1);
  137660. vertices.push(1, -1);
  137661. 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);
  137662. this._buildIndexBuffer();
  137663. };
  137664. PostProcessManager.prototype._buildIndexBuffer = function () {
  137665. // Indices
  137666. var indices = [];
  137667. indices.push(0);
  137668. indices.push(1);
  137669. indices.push(2);
  137670. indices.push(0);
  137671. indices.push(2);
  137672. indices.push(3);
  137673. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  137674. };
  137675. /**
  137676. * Rebuilds the vertex buffers of the manager.
  137677. * @hidden
  137678. */
  137679. PostProcessManager.prototype._rebuild = function () {
  137680. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  137681. if (!vb) {
  137682. return;
  137683. }
  137684. vb._rebuild();
  137685. this._buildIndexBuffer();
  137686. };
  137687. // Methods
  137688. /**
  137689. * Prepares a frame to be run through a post process.
  137690. * @param sourceTexture The input texture to the post procesess. (default: null)
  137691. * @param postProcesses An array of post processes to be run. (default: null)
  137692. * @returns True if the post processes were able to be run.
  137693. * @hidden
  137694. */
  137695. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  137696. if (sourceTexture === void 0) { sourceTexture = null; }
  137697. if (postProcesses === void 0) { postProcesses = null; }
  137698. var camera = this._scene.activeCamera;
  137699. if (!camera) {
  137700. return false;
  137701. }
  137702. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  137703. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  137704. return false;
  137705. }
  137706. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  137707. return true;
  137708. };
  137709. /**
  137710. * Manually render a set of post processes to a texture.
  137711. * @param postProcesses An array of post processes to be run.
  137712. * @param targetTexture The target texture to render to.
  137713. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  137714. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  137715. * @param lodLevel defines which lod of the texture to render to
  137716. */
  137717. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  137718. if (targetTexture === void 0) { targetTexture = null; }
  137719. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  137720. if (faceIndex === void 0) { faceIndex = 0; }
  137721. if (lodLevel === void 0) { lodLevel = 0; }
  137722. var engine = this._scene.getEngine();
  137723. for (var index = 0; index < postProcesses.length; index++) {
  137724. if (index < postProcesses.length - 1) {
  137725. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  137726. }
  137727. else {
  137728. if (targetTexture) {
  137729. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  137730. }
  137731. else {
  137732. engine.restoreDefaultFramebuffer();
  137733. }
  137734. }
  137735. var pp = postProcesses[index];
  137736. var effect = pp.apply();
  137737. if (effect) {
  137738. pp.onBeforeRenderObservable.notifyObservers(effect);
  137739. // VBOs
  137740. this._prepareBuffers();
  137741. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  137742. // Draw order
  137743. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  137744. pp.onAfterRenderObservable.notifyObservers(effect);
  137745. }
  137746. }
  137747. // Restore depth buffer
  137748. engine.setDepthBuffer(true);
  137749. engine.setDepthWrite(true);
  137750. };
  137751. /**
  137752. * Finalize the result of the output of the postprocesses.
  137753. * @param doNotPresent If true the result will not be displayed to the screen.
  137754. * @param targetTexture The target texture to render to.
  137755. * @param faceIndex The index of the face to bind the target texture to.
  137756. * @param postProcesses The array of post processes to render.
  137757. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  137758. * @hidden
  137759. */
  137760. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  137761. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  137762. var camera = this._scene.activeCamera;
  137763. if (!camera) {
  137764. return;
  137765. }
  137766. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  137767. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  137768. return;
  137769. }
  137770. var engine = this._scene.getEngine();
  137771. for (var index = 0, len = postProcesses.length; index < len; index++) {
  137772. var pp = postProcesses[index];
  137773. if (index < len - 1) {
  137774. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  137775. }
  137776. else {
  137777. if (targetTexture) {
  137778. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  137779. pp._outputTexture = targetTexture;
  137780. }
  137781. else {
  137782. engine.restoreDefaultFramebuffer();
  137783. pp._outputTexture = null;
  137784. }
  137785. }
  137786. if (doNotPresent) {
  137787. break;
  137788. }
  137789. var effect = pp.apply();
  137790. if (effect) {
  137791. pp.onBeforeRenderObservable.notifyObservers(effect);
  137792. // VBOs
  137793. this._prepareBuffers();
  137794. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  137795. // Draw order
  137796. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  137797. pp.onAfterRenderObservable.notifyObservers(effect);
  137798. }
  137799. }
  137800. // Restore states
  137801. engine.setDepthBuffer(true);
  137802. engine.setDepthWrite(true);
  137803. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  137804. };
  137805. /**
  137806. * Disposes of the post process manager.
  137807. */
  137808. PostProcessManager.prototype.dispose = function () {
  137809. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  137810. if (buffer) {
  137811. buffer.dispose();
  137812. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  137813. }
  137814. if (this._indexBuffer) {
  137815. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  137816. this._indexBuffer = null;
  137817. }
  137818. };
  137819. return PostProcessManager;
  137820. }());
  137821. /***/ }),
  137822. /***/ "./PostProcesses/refractionPostProcess.ts":
  137823. /*!************************************************!*\
  137824. !*** ./PostProcesses/refractionPostProcess.ts ***!
  137825. \************************************************/
  137826. /*! exports provided: RefractionPostProcess */
  137827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  137828. "use strict";
  137829. __webpack_require__.r(__webpack_exports__);
  137830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  137831. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  137832. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  137833. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  137834. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  137835. /**
  137836. * Post process which applies a refractin texture
  137837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137838. */
  137839. var RefractionPostProcess = /** @class */ (function (_super) {
  137840. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  137841. /**
  137842. * Initializes the RefractionPostProcess
  137843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137844. * @param name The name of the effect.
  137845. * @param refractionTextureUrl Url of the refraction texture to use
  137846. * @param color the base color of the refraction (used to taint the rendering)
  137847. * @param depth simulated refraction depth
  137848. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137849. * @param camera The camera to apply the render pass to.
  137850. * @param options The required width/height ratio to downsize to before computing the render pass.
  137851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137852. * @param engine The engine which the post process will be applied. (default: current engine)
  137853. * @param reusable If the post process can be reused on the same frame. (default: false)
  137854. */
  137855. function RefractionPostProcess(name, refractionTextureUrl,
  137856. /** the base color of the refraction (used to taint the rendering) */
  137857. color,
  137858. /** simulated refraction depth */
  137859. depth,
  137860. /** the coefficient of the base color (0 to remove base color tainting) */
  137861. colorLevel, options, camera, samplingMode, engine, reusable) {
  137862. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  137863. _this.color = color;
  137864. _this.depth = depth;
  137865. _this.colorLevel = colorLevel;
  137866. _this._ownRefractionTexture = true;
  137867. _this.onActivateObservable.add(function (cam) {
  137868. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  137869. });
  137870. _this.onApplyObservable.add(function (effect) {
  137871. effect.setColor3("baseColor", _this.color);
  137872. effect.setFloat("depth", _this.depth);
  137873. effect.setFloat("colorLevel", _this.colorLevel);
  137874. effect.setTexture("refractionSampler", _this._refTexture);
  137875. });
  137876. return _this;
  137877. }
  137878. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  137879. /**
  137880. * Gets or sets the refraction texture
  137881. * Please note that you are responsible for disposing the texture if you set it manually
  137882. */
  137883. get: function () {
  137884. return this._refTexture;
  137885. },
  137886. set: function (value) {
  137887. if (this._refTexture && this._ownRefractionTexture) {
  137888. this._refTexture.dispose();
  137889. }
  137890. this._refTexture = value;
  137891. this._ownRefractionTexture = false;
  137892. },
  137893. enumerable: true,
  137894. configurable: true
  137895. });
  137896. // Methods
  137897. /**
  137898. * Disposes of the post process
  137899. * @param camera Camera to dispose post process on
  137900. */
  137901. RefractionPostProcess.prototype.dispose = function (camera) {
  137902. if (this._refTexture && this._ownRefractionTexture) {
  137903. this._refTexture.dispose();
  137904. this._refTexture = null;
  137905. }
  137906. _super.prototype.dispose.call(this, camera);
  137907. };
  137908. return RefractionPostProcess;
  137909. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  137910. /***/ }),
  137911. /***/ "./PostProcesses/sharpenPostProcess.ts":
  137912. /*!*********************************************!*\
  137913. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  137914. \*********************************************/
  137915. /*! exports provided: SharpenPostProcess */
  137916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  137917. "use strict";
  137918. __webpack_require__.r(__webpack_exports__);
  137919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  137920. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  137921. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  137922. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  137923. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  137924. /**
  137925. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137926. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137927. */
  137928. var SharpenPostProcess = /** @class */ (function (_super) {
  137929. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  137930. /**
  137931. * Creates a new instance ConvolutionPostProcess
  137932. * @param name The name of the effect.
  137933. * @param options The required width/height ratio to downsize to before computing the render pass.
  137934. * @param camera The camera to apply the render pass to.
  137935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137936. * @param engine The engine which the post process will be applied. (default: current engine)
  137937. * @param reusable If the post process can be reused on the same frame. (default: false)
  137938. * @param textureType Type of textures used when performing the post process. (default: 0)
  137939. * @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)
  137940. */
  137941. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  137942. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  137943. if (blockCompilation === void 0) { blockCompilation = false; }
  137944. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  137945. /**
  137946. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137947. */
  137948. _this.colorAmount = 1.0;
  137949. /**
  137950. * How much sharpness should be applied (default: 0.3)
  137951. */
  137952. _this.edgeAmount = 0.3;
  137953. _this.onApply = function (effect) {
  137954. effect.setFloat2("screenSize", _this.width, _this.height);
  137955. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  137956. };
  137957. return _this;
  137958. }
  137959. return SharpenPostProcess;
  137960. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  137961. /***/ }),
  137962. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  137963. /*!***********************************************************!*\
  137964. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  137965. \***********************************************************/
  137966. /*! exports provided: StereoscopicInterlacePostProcess */
  137967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  137968. "use strict";
  137969. __webpack_require__.r(__webpack_exports__);
  137970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  137971. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  137972. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  137973. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  137974. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  137975. /**
  137976. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  137977. */
  137978. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  137979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  137980. /**
  137981. * Initializes a StereoscopicInterlacePostProcess
  137982. * @param name The name of the effect.
  137983. * @param rigCameras The rig cameras to be appled to the post process
  137984. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  137985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137986. * @param engine The engine which the post process will be applied. (default: current engine)
  137987. * @param reusable If the post process can be reused on the same frame. (default: false)
  137988. */
  137989. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  137990. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  137991. _this._passedProcess = rigCameras[0]._rigPostProcess;
  137992. _this._stepSize = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  137993. _this.onSizeChangedObservable.add(function () {
  137994. _this._stepSize = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  137995. });
  137996. _this.onApplyObservable.add(function (effect) {
  137997. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  137998. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  137999. });
  138000. return _this;
  138001. }
  138002. return StereoscopicInterlacePostProcess;
  138003. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  138004. /***/ }),
  138005. /***/ "./PostProcesses/tonemapPostProcess.ts":
  138006. /*!*********************************************!*\
  138007. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  138008. \*********************************************/
  138009. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  138010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138011. "use strict";
  138012. __webpack_require__.r(__webpack_exports__);
  138013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  138014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  138015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138016. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  138017. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  138018. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  138019. /** Defines operator used for tonemapping */
  138020. var TonemappingOperator;
  138021. (function (TonemappingOperator) {
  138022. /** Hable */
  138023. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  138024. /** Reinhard */
  138025. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  138026. /** HejiDawson */
  138027. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  138028. /** Photographic */
  138029. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  138030. })(TonemappingOperator || (TonemappingOperator = {}));
  138031. /**
  138032. * Defines a post process to apply tone mapping
  138033. */
  138034. var TonemapPostProcess = /** @class */ (function (_super) {
  138035. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  138036. /**
  138037. * Creates a new TonemapPostProcess
  138038. * @param name defines the name of the postprocess
  138039. * @param _operator defines the operator to use
  138040. * @param exposureAdjustment defines the required exposure adjustement
  138041. * @param camera defines the camera to use (can be null)
  138042. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  138043. * @param engine defines the hosting engine (can be ignore if camera is set)
  138044. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138045. */
  138046. function TonemapPostProcess(name, _operator,
  138047. /** Defines the required exposure adjustement */
  138048. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  138049. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  138050. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  138051. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  138052. _this._operator = _operator;
  138053. _this.exposureAdjustment = exposureAdjustment;
  138054. var defines = "#define ";
  138055. if (_this._operator === TonemappingOperator.Hable) {
  138056. defines += "HABLE_TONEMAPPING";
  138057. }
  138058. else if (_this._operator === TonemappingOperator.Reinhard) {
  138059. defines += "REINHARD_TONEMAPPING";
  138060. }
  138061. else if (_this._operator === TonemappingOperator.HejiDawson) {
  138062. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  138063. }
  138064. else if (_this._operator === TonemappingOperator.Photographic) {
  138065. defines += "PHOTOGRAPHIC_TONEMAPPING";
  138066. }
  138067. //sadly a second call to create the effect.
  138068. _this.updateEffect(defines);
  138069. _this.onApply = function (effect) {
  138070. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  138071. };
  138072. return _this;
  138073. }
  138074. return TonemapPostProcess;
  138075. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  138076. /***/ }),
  138077. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  138078. /*!***************************************************************!*\
  138079. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  138080. \***************************************************************/
  138081. /*! exports provided: VolumetricLightScatteringPostProcess */
  138082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138083. "use strict";
  138084. __webpack_require__.r(__webpack_exports__);
  138085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  138086. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138087. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  138088. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  138089. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  138090. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  138091. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  138092. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  138093. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  138094. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  138095. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  138096. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  138097. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  138098. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  138099. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  138100. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  138101. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  138102. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  138103. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  138104. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  138105. /* harmony import */ var _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Maths/math.viewport */ "./Maths/math.viewport.ts");
  138106. /**
  138107. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  138108. */
  138109. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  138110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  138111. /**
  138112. * @constructor
  138113. * @param name The post-process name
  138114. * @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)
  138115. * @param camera The camera that the post-process will be attached to
  138116. * @param mesh The mesh used to create the light scattering
  138117. * @param samples The post-process quality, default 100
  138118. * @param samplingModeThe post-process filtering mode
  138119. * @param engine The babylon engine
  138120. * @param reusable If the post-process is reusable
  138121. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  138122. */
  138123. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  138124. if (samples === void 0) { samples = 100; }
  138125. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"].BILINEAR_SAMPLINGMODE; }
  138126. 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;
  138127. _this._screenCoordinates = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  138128. /**
  138129. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  138130. */
  138131. _this.customMeshPosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  138132. /**
  138133. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  138134. */
  138135. _this.useCustomMeshPosition = false;
  138136. /**
  138137. * If the post-process should inverse the light scattering direction
  138138. */
  138139. _this.invert = true;
  138140. /**
  138141. * Array containing the excluded meshes not rendered in the internal pass
  138142. */
  138143. _this.excludedMeshes = new Array();
  138144. /**
  138145. * Controls the overall intensity of the post-process
  138146. */
  138147. _this.exposure = 0.3;
  138148. /**
  138149. * Dissipates each sample's contribution in range [0, 1]
  138150. */
  138151. _this.decay = 0.96815;
  138152. /**
  138153. * Controls the overall intensity of each sample
  138154. */
  138155. _this.weight = 0.58767;
  138156. /**
  138157. * Controls the density of each sample
  138158. */
  138159. _this.density = 0.926;
  138160. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  138161. engine = scene.getEngine();
  138162. _this._viewPort = new _Maths_math_viewport__WEBPACK_IMPORTED_MODULE_19__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  138163. // Configure mesh
  138164. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  138165. // Configure
  138166. _this._createPass(scene, ratio.passRatio || ratio);
  138167. _this.onActivate = function (camera) {
  138168. if (!_this.isSupported) {
  138169. _this.dispose(camera);
  138170. }
  138171. _this.onActivate = null;
  138172. };
  138173. _this.onApplyObservable.add(function (effect) {
  138174. _this._updateMeshScreenCoordinates(scene);
  138175. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  138176. effect.setFloat("exposure", _this.exposure);
  138177. effect.setFloat("decay", _this.decay);
  138178. effect.setFloat("weight", _this.weight);
  138179. effect.setFloat("density", _this.density);
  138180. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  138181. });
  138182. return _this;
  138183. }
  138184. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  138185. /**
  138186. * @hidden
  138187. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  138188. */
  138189. get: function () {
  138190. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  138191. return false;
  138192. },
  138193. set: function (useDiffuseColor) {
  138194. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  138195. },
  138196. enumerable: true,
  138197. configurable: true
  138198. });
  138199. /**
  138200. * Returns the string "VolumetricLightScatteringPostProcess"
  138201. * @returns "VolumetricLightScatteringPostProcess"
  138202. */
  138203. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  138204. return "VolumetricLightScatteringPostProcess";
  138205. };
  138206. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  138207. var mesh = subMesh.getMesh();
  138208. // Render this.mesh as default
  138209. if (mesh === this.mesh && mesh.material) {
  138210. return mesh.material.isReady(mesh);
  138211. }
  138212. var defines = [];
  138213. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  138214. var material = subMesh.getMaterial();
  138215. // Alpha test
  138216. if (material) {
  138217. if (material.needAlphaTesting()) {
  138218. defines.push("#define ALPHATEST");
  138219. }
  138220. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  138221. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  138222. defines.push("#define UV1");
  138223. }
  138224. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  138225. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  138226. defines.push("#define UV2");
  138227. }
  138228. }
  138229. // Bones
  138230. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  138231. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  138232. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  138233. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  138234. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  138235. }
  138236. else {
  138237. defines.push("#define NUM_BONE_INFLUENCERS 0");
  138238. }
  138239. // Instances
  138240. if (useInstances) {
  138241. defines.push("#define INSTANCES");
  138242. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].PushAttributesForInstances(attribs);
  138243. }
  138244. // Get correct effect
  138245. var join = defines.join("\n");
  138246. if (this._cachedDefines !== join) {
  138247. this._cachedDefines = join;
  138248. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: mesh.numBoneInfluencers });
  138249. }
  138250. return this._volumetricLightScatteringPass.isReady();
  138251. };
  138252. /**
  138253. * Sets the new light position for light scattering effect
  138254. * @param position The new custom light position
  138255. */
  138256. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  138257. this.customMeshPosition = position;
  138258. };
  138259. /**
  138260. * Returns the light position for light scattering effect
  138261. * @return Vector3 The custom light position
  138262. */
  138263. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  138264. return this.customMeshPosition;
  138265. };
  138266. /**
  138267. * Disposes the internal assets and detaches the post-process from the camera
  138268. */
  138269. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  138270. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  138271. if (rttIndex !== -1) {
  138272. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  138273. }
  138274. this._volumetricLightScatteringRTT.dispose();
  138275. _super.prototype.dispose.call(this, camera);
  138276. };
  138277. /**
  138278. * Returns the render target texture used by the post-process
  138279. * @return the render target texture used by the post-process
  138280. */
  138281. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  138282. return this._volumetricLightScatteringRTT;
  138283. };
  138284. // Private methods
  138285. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  138286. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  138287. return true;
  138288. }
  138289. return false;
  138290. };
  138291. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  138292. var _this = this;
  138293. var engine = scene.getEngine();
  138294. this._volumetricLightScatteringRTT = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_11__["RenderTargetTexture"]("volumetricLightScatteringMap", { width: engine.getRenderWidth() * ratio, height: engine.getRenderHeight() * ratio }, scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  138295. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"].CLAMP_ADDRESSMODE;
  138296. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"].CLAMP_ADDRESSMODE;
  138297. this._volumetricLightScatteringRTT.renderList = null;
  138298. this._volumetricLightScatteringRTT.renderParticles = false;
  138299. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  138300. var camera = this.getCamera();
  138301. if (camera) {
  138302. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  138303. }
  138304. else {
  138305. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  138306. }
  138307. // Custom render function for submeshes
  138308. var renderSubMesh = function (subMesh) {
  138309. var mesh = subMesh.getRenderingMesh();
  138310. if (_this._meshExcluded(mesh)) {
  138311. return;
  138312. }
  138313. var material = subMesh.getMaterial();
  138314. if (!material) {
  138315. return;
  138316. }
  138317. var scene = mesh.getScene();
  138318. var engine = scene.getEngine();
  138319. // Culling
  138320. engine.setState(material.backFaceCulling);
  138321. // Managing instances
  138322. var batch = mesh._getInstancesRenderList(subMesh._id);
  138323. if (batch.mustReturn) {
  138324. return;
  138325. }
  138326. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  138327. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  138328. var effect = _this._volumetricLightScatteringPass;
  138329. if (mesh === _this.mesh) {
  138330. if (subMesh.effect) {
  138331. effect = subMesh.effect;
  138332. }
  138333. else {
  138334. effect = material.getEffect();
  138335. }
  138336. }
  138337. engine.enableEffect(effect);
  138338. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  138339. if (mesh === _this.mesh) {
  138340. material.bind(mesh.getWorldMatrix(), mesh);
  138341. }
  138342. else {
  138343. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  138344. // Alpha test
  138345. if (material && material.needAlphaTesting()) {
  138346. var alphaTexture = material.getAlphaTestTexture();
  138347. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  138348. if (alphaTexture) {
  138349. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  138350. }
  138351. }
  138352. // Bones
  138353. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  138354. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  138355. }
  138356. }
  138357. // Draw
  138358. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  138359. }
  138360. };
  138361. // Render target texture callbacks
  138362. var savedSceneClearColor;
  138363. var sceneClearColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_18__["Color4"](0.0, 0.0, 0.0, 1.0);
  138364. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  138365. savedSceneClearColor = scene.clearColor;
  138366. scene.clearColor = sceneClearColor;
  138367. });
  138368. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  138369. scene.clearColor = savedSceneClearColor;
  138370. });
  138371. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  138372. var engine = scene.getEngine();
  138373. var index;
  138374. if (depthOnlySubMeshes.length) {
  138375. engine.setColorWrite(false);
  138376. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  138377. renderSubMesh(depthOnlySubMeshes.data[index]);
  138378. }
  138379. engine.setColorWrite(true);
  138380. }
  138381. for (index = 0; index < opaqueSubMeshes.length; index++) {
  138382. renderSubMesh(opaqueSubMeshes.data[index]);
  138383. }
  138384. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  138385. renderSubMesh(alphaTestSubMeshes.data[index]);
  138386. }
  138387. if (transparentSubMeshes.length) {
  138388. // Sort sub meshes
  138389. for (index = 0; index < transparentSubMeshes.length; index++) {
  138390. var submesh = transparentSubMeshes.data[index];
  138391. var boundingInfo = submesh.getBoundingInfo();
  138392. if (boundingInfo && scene.activeCamera) {
  138393. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  138394. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  138395. }
  138396. }
  138397. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  138398. sortedArray.sort(function (a, b) {
  138399. // Alpha index first
  138400. if (a._alphaIndex > b._alphaIndex) {
  138401. return 1;
  138402. }
  138403. if (a._alphaIndex < b._alphaIndex) {
  138404. return -1;
  138405. }
  138406. // Then distance to camera
  138407. if (a._distanceToCamera < b._distanceToCamera) {
  138408. return 1;
  138409. }
  138410. if (a._distanceToCamera > b._distanceToCamera) {
  138411. return -1;
  138412. }
  138413. return 0;
  138414. });
  138415. // Render sub meshes
  138416. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE);
  138417. for (index = 0; index < sortedArray.length; index++) {
  138418. renderSubMesh(sortedArray[index]);
  138419. }
  138420. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE);
  138421. }
  138422. };
  138423. };
  138424. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  138425. var transform = scene.getTransformMatrix();
  138426. var meshPosition;
  138427. if (this.useCustomMeshPosition) {
  138428. meshPosition = this.customMeshPosition;
  138429. }
  138430. else if (this.attachedNode) {
  138431. meshPosition = this.attachedNode.position;
  138432. }
  138433. else {
  138434. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  138435. }
  138436. var pos = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  138437. this._screenCoordinates.x = pos.x / this._viewPort.width;
  138438. this._screenCoordinates.y = pos.y / this._viewPort.height;
  138439. if (this.invert) {
  138440. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  138441. }
  138442. };
  138443. // Static methods
  138444. /**
  138445. * Creates a default mesh for the Volumeric Light Scattering post-process
  138446. * @param name The mesh name
  138447. * @param scene The scene where to create the mesh
  138448. * @return the default mesh
  138449. */
  138450. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  138451. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  138452. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  138453. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"](name + "Material", scene);
  138454. material.emissiveColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_18__["Color3"](1, 1, 1);
  138455. mesh.material = material;
  138456. return mesh;
  138457. };
  138458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  138460. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  138461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138463. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  138464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138466. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  138467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  138469. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  138470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138472. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  138473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138475. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  138476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138478. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  138479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138481. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  138482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  138484. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  138485. return VolumetricLightScatteringPostProcess;
  138486. }(_postProcess__WEBPACK_IMPORTED_MODULE_12__["PostProcess"]));
  138487. /***/ }),
  138488. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  138489. /*!************************************************************!*\
  138490. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  138491. \************************************************************/
  138492. /*! exports provided: VRDistortionCorrectionPostProcess */
  138493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138494. "use strict";
  138495. __webpack_require__.r(__webpack_exports__);
  138496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  138497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138498. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  138499. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  138500. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  138501. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  138502. /**
  138503. * VRDistortionCorrectionPostProcess used for mobile VR
  138504. */
  138505. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  138506. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  138507. /**
  138508. * Initializes the VRDistortionCorrectionPostProcess
  138509. * @param name The name of the effect.
  138510. * @param camera The camera to apply the render pass to.
  138511. * @param isRightEye If this is for the right eye distortion
  138512. * @param vrMetrics All the required metrics for the VR camera
  138513. */
  138514. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  138515. var _this = _super.call(this, name, "vrDistortionCorrection", [
  138516. 'LensCenter',
  138517. 'Scale',
  138518. 'ScaleIn',
  138519. 'HmdWarpParam'
  138520. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  138521. _this._isRightEye = isRightEye;
  138522. _this._distortionFactors = vrMetrics.distortionK;
  138523. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  138524. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  138525. _this.adaptScaleToCurrentViewport = true;
  138526. _this.onSizeChangedObservable.add(function () {
  138527. _this._scaleIn = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  138528. _this._scaleFactor = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  138529. _this._lensCenter = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"](_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);
  138530. });
  138531. _this.onApplyObservable.add(function (effect) {
  138532. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  138533. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  138534. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  138535. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  138536. });
  138537. return _this;
  138538. }
  138539. return VRDistortionCorrectionPostProcess;
  138540. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  138541. /***/ }),
  138542. /***/ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts":
  138543. /*!*************************************************************!*\
  138544. !*** ./PostProcesses/vrMultiviewToSingleviewPostProcess.ts ***!
  138545. \*************************************************************/
  138546. /*! exports provided: VRMultiviewToSingleviewPostProcess */
  138547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138548. "use strict";
  138549. __webpack_require__.r(__webpack_exports__);
  138550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return VRMultiviewToSingleviewPostProcess; });
  138551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138552. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  138553. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  138554. /* harmony import */ var _Shaders_vrMultiviewToSingleview_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/vrMultiviewToSingleview.fragment */ "./Shaders/vrMultiviewToSingleview.fragment.ts");
  138555. /* harmony import */ var _Engines_Extensions_engine_multiview__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Extensions/engine.multiview */ "./Engines/Extensions/engine.multiview.ts");
  138556. /**
  138557. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  138558. * This will not be used for webXR as it supports displaying texture arrays directly
  138559. */
  138560. var VRMultiviewToSingleviewPostProcess = /** @class */ (function (_super) {
  138561. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleviewPostProcess, _super);
  138562. /**
  138563. * Initializes a VRMultiviewToSingleview
  138564. * @param name name of the post process
  138565. * @param camera camera to be applied to
  138566. * @param scaleFactor scaling factor to the size of the output texture
  138567. */
  138568. function VRMultiviewToSingleviewPostProcess(name, camera, scaleFactor) {
  138569. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  138570. _this.onSizeChangedObservable.add(function () {
  138571. });
  138572. _this.onApplyObservable.add(function (effect) {
  138573. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  138574. effect.setInt("imageIndex", 0);
  138575. }
  138576. else {
  138577. effect.setInt("imageIndex", 1);
  138578. }
  138579. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  138580. });
  138581. return _this;
  138582. }
  138583. return VRMultiviewToSingleviewPostProcess;
  138584. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  138585. /***/ }),
  138586. /***/ "./Probes/index.ts":
  138587. /*!*************************!*\
  138588. !*** ./Probes/index.ts ***!
  138589. \*************************/
  138590. /*! exports provided: ReflectionProbe */
  138591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138592. "use strict";
  138593. __webpack_require__.r(__webpack_exports__);
  138594. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  138595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  138596. /***/ }),
  138597. /***/ "./Probes/reflectionProbe.ts":
  138598. /*!***********************************!*\
  138599. !*** ./Probes/reflectionProbe.ts ***!
  138600. \***********************************/
  138601. /*! exports provided: ReflectionProbe */
  138602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138603. "use strict";
  138604. __webpack_require__.r(__webpack_exports__);
  138605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  138606. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138607. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  138608. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  138609. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  138610. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  138611. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  138612. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  138613. if (!this.reflectionProbes) {
  138614. return -1;
  138615. }
  138616. var index = this.reflectionProbes.indexOf(toRemove);
  138617. if (index !== -1) {
  138618. this.reflectionProbes.splice(index, 1);
  138619. }
  138620. return index;
  138621. };
  138622. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  138623. if (!this.reflectionProbes) {
  138624. this.reflectionProbes = [];
  138625. }
  138626. this.reflectionProbes.push(newReflectionProbe);
  138627. };
  138628. /**
  138629. * Class used to generate realtime reflection / refraction cube textures
  138630. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138631. */
  138632. var ReflectionProbe = /** @class */ (function () {
  138633. /**
  138634. * Creates a new reflection probe
  138635. * @param name defines the name of the probe
  138636. * @param size defines the texture resolution (for each face)
  138637. * @param scene defines the hosting scene
  138638. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138639. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138640. */
  138641. function ReflectionProbe(
  138642. /** defines the name of the probe */
  138643. name, size, scene, generateMipMaps, useFloat) {
  138644. var _this = this;
  138645. if (generateMipMaps === void 0) { generateMipMaps = true; }
  138646. if (useFloat === void 0) { useFloat = false; }
  138647. this.name = name;
  138648. this._viewMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  138649. this._target = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  138650. this._add = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  138651. this._invertYAxis = false;
  138652. /** Gets or sets probe position (center of the cube map) */
  138653. this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  138654. this._scene = scene;
  138655. // Create the scene field if not exist.
  138656. if (!this._scene.reflectionProbes) {
  138657. this._scene.reflectionProbes = new Array();
  138658. }
  138659. this._scene.reflectionProbes.push(this);
  138660. 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);
  138661. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  138662. switch (faceIndex) {
  138663. case 0:
  138664. _this._add.copyFromFloats(1, 0, 0);
  138665. break;
  138666. case 1:
  138667. _this._add.copyFromFloats(-1, 0, 0);
  138668. break;
  138669. case 2:
  138670. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  138671. break;
  138672. case 3:
  138673. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  138674. break;
  138675. case 4:
  138676. _this._add.copyFromFloats(0, 0, 1);
  138677. break;
  138678. case 5:
  138679. _this._add.copyFromFloats(0, 0, -1);
  138680. break;
  138681. }
  138682. if (_this._attachedMesh) {
  138683. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  138684. }
  138685. _this.position.addToRef(_this._add, _this._target);
  138686. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  138687. if (scene.activeCamera) {
  138688. _this._projectionMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  138689. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  138690. }
  138691. scene._forcedViewPosition = _this.position;
  138692. });
  138693. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  138694. scene._forcedViewPosition = null;
  138695. scene.updateTransformMatrix(true);
  138696. });
  138697. }
  138698. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  138699. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138700. get: function () {
  138701. return this._renderTargetTexture.samples;
  138702. },
  138703. set: function (value) {
  138704. this._renderTargetTexture.samples = value;
  138705. },
  138706. enumerable: true,
  138707. configurable: true
  138708. });
  138709. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  138710. /** Gets or sets the refresh rate to use (on every frame by default) */
  138711. get: function () {
  138712. return this._renderTargetTexture.refreshRate;
  138713. },
  138714. set: function (value) {
  138715. this._renderTargetTexture.refreshRate = value;
  138716. },
  138717. enumerable: true,
  138718. configurable: true
  138719. });
  138720. /**
  138721. * Gets the hosting scene
  138722. * @returns a Scene
  138723. */
  138724. ReflectionProbe.prototype.getScene = function () {
  138725. return this._scene;
  138726. };
  138727. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  138728. /** Gets the internal CubeTexture used to render to */
  138729. get: function () {
  138730. return this._renderTargetTexture;
  138731. },
  138732. enumerable: true,
  138733. configurable: true
  138734. });
  138735. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  138736. /** Gets the list of meshes to render */
  138737. get: function () {
  138738. return this._renderTargetTexture.renderList;
  138739. },
  138740. enumerable: true,
  138741. configurable: true
  138742. });
  138743. /**
  138744. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138745. * @param mesh defines the mesh to attach to
  138746. */
  138747. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  138748. this._attachedMesh = mesh;
  138749. };
  138750. /**
  138751. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138752. * @param renderingGroupId The rendering group id corresponding to its index
  138753. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138754. */
  138755. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  138756. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  138757. };
  138758. /**
  138759. * Clean all associated resources
  138760. */
  138761. ReflectionProbe.prototype.dispose = function () {
  138762. var index = this._scene.reflectionProbes.indexOf(this);
  138763. if (index !== -1) {
  138764. // Remove from the scene if found
  138765. this._scene.reflectionProbes.splice(index, 1);
  138766. }
  138767. if (this._renderTargetTexture) {
  138768. this._renderTargetTexture.dispose();
  138769. this._renderTargetTexture = null;
  138770. }
  138771. };
  138772. /**
  138773. * Converts the reflection probe information to a readable string for debug purpose.
  138774. * @param fullDetails Supports for multiple levels of logging within scene loading
  138775. * @returns the human readable reflection probe info
  138776. */
  138777. ReflectionProbe.prototype.toString = function (fullDetails) {
  138778. var ret = "Name: " + this.name;
  138779. if (fullDetails) {
  138780. ret += ", position: " + this.position.toString();
  138781. if (this._attachedMesh) {
  138782. ret += ", attached mesh: " + this._attachedMesh.name;
  138783. }
  138784. }
  138785. return ret;
  138786. };
  138787. /**
  138788. * Get the class name of the relfection probe.
  138789. * @returns "ReflectionProbe"
  138790. */
  138791. ReflectionProbe.prototype.getClassName = function () {
  138792. return "ReflectionProbe";
  138793. };
  138794. /**
  138795. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138796. * @returns The JSON representation of the texture
  138797. */
  138798. ReflectionProbe.prototype.serialize = function () {
  138799. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  138800. serializationObject.isReflectionProbe = true;
  138801. return serializationObject;
  138802. };
  138803. /**
  138804. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138805. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138806. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138807. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138808. * @returns The parsed reflection probe if successful
  138809. */
  138810. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  138811. var reflectionProbe = null;
  138812. if (scene.reflectionProbes) {
  138813. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  138814. var rp = scene.reflectionProbes[index];
  138815. if (rp.name === parsedReflectionProbe.name) {
  138816. reflectionProbe = rp;
  138817. break;
  138818. }
  138819. }
  138820. }
  138821. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  138822. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  138823. if (parsedReflectionProbe._attachedMesh) {
  138824. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  138825. }
  138826. return reflectionProbe;
  138827. };
  138828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  138830. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  138831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  138832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  138833. ], ReflectionProbe.prototype, "position", void 0);
  138834. return ReflectionProbe;
  138835. }());
  138836. /***/ }),
  138837. /***/ "./Rendering/boundingBoxRenderer.ts":
  138838. /*!******************************************!*\
  138839. !*** ./Rendering/boundingBoxRenderer.ts ***!
  138840. \******************************************/
  138841. /*! exports provided: BoundingBoxRenderer */
  138842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138843. "use strict";
  138844. __webpack_require__.r(__webpack_exports__);
  138845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  138846. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  138847. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  138848. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  138849. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  138850. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  138851. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  138852. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  138853. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  138854. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  138855. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  138856. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  138857. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  138858. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  138859. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  138860. get: function () {
  138861. return this._forceShowBoundingBoxes || false;
  138862. },
  138863. set: function (value) {
  138864. this._forceShowBoundingBoxes = value;
  138865. // Lazyly creates a BB renderer if needed.
  138866. if (value) {
  138867. this.getBoundingBoxRenderer();
  138868. }
  138869. },
  138870. enumerable: true,
  138871. configurable: true
  138872. });
  138873. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  138874. if (!this._boundingBoxRenderer) {
  138875. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  138876. }
  138877. return this._boundingBoxRenderer;
  138878. };
  138879. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  138880. get: function () {
  138881. return this._showBoundingBox || false;
  138882. },
  138883. set: function (value) {
  138884. this._showBoundingBox = value;
  138885. // Lazyly creates a BB renderer if needed.
  138886. if (value) {
  138887. this.getScene().getBoundingBoxRenderer();
  138888. }
  138889. },
  138890. enumerable: true,
  138891. configurable: true
  138892. });
  138893. /**
  138894. * Component responsible of rendering the bounding box of the meshes in a scene.
  138895. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  138896. */
  138897. var BoundingBoxRenderer = /** @class */ (function () {
  138898. /**
  138899. * Instantiates a new bounding box renderer in a scene.
  138900. * @param scene the scene the renderer renders in
  138901. */
  138902. function BoundingBoxRenderer(scene) {
  138903. /**
  138904. * The component name helpfull to identify the component in the list of scene components.
  138905. */
  138906. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  138907. /**
  138908. * Color of the bounding box lines placed in front of an object
  138909. */
  138910. this.frontColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_12__["Color3"](1, 1, 1);
  138911. /**
  138912. * Color of the bounding box lines placed behind an object
  138913. */
  138914. this.backColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_12__["Color3"](0.1, 0.1, 0.1);
  138915. /**
  138916. * Defines if the renderer should show the back lines or not
  138917. */
  138918. this.showBackLines = true;
  138919. /**
  138920. * @hidden
  138921. */
  138922. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  138923. this._vertexBuffers = {};
  138924. this._fillIndexBuffer = null;
  138925. this._fillIndexData = null;
  138926. this.scene = scene;
  138927. scene._addComponent(this);
  138928. }
  138929. /**
  138930. * Registers the component in a given scene
  138931. */
  138932. BoundingBoxRenderer.prototype.register = function () {
  138933. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  138934. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  138935. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  138936. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  138937. };
  138938. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  138939. if (mesh.showSubMeshesBoundingBox) {
  138940. var boundingInfo = subMesh.getBoundingInfo();
  138941. if (boundingInfo !== null && boundingInfo !== undefined) {
  138942. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  138943. this.renderList.push(boundingInfo.boundingBox);
  138944. }
  138945. }
  138946. };
  138947. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  138948. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  138949. var boundingInfo = sourceMesh.getBoundingInfo();
  138950. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  138951. this.renderList.push(boundingInfo.boundingBox);
  138952. }
  138953. };
  138954. BoundingBoxRenderer.prototype._prepareRessources = function () {
  138955. if (this._colorShader) {
  138956. return;
  138957. }
  138958. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  138959. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  138960. uniforms: ["world", "viewProjection", "color"]
  138961. });
  138962. var engine = this.scene.getEngine();
  138963. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  138964. 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);
  138965. this._createIndexBuffer();
  138966. this._fillIndexData = boxdata.indices;
  138967. };
  138968. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  138969. var engine = this.scene.getEngine();
  138970. 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]);
  138971. };
  138972. /**
  138973. * Rebuilds the elements related to this component in case of
  138974. * context lost for instance.
  138975. */
  138976. BoundingBoxRenderer.prototype.rebuild = function () {
  138977. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  138978. if (vb) {
  138979. vb._rebuild();
  138980. }
  138981. this._createIndexBuffer();
  138982. };
  138983. /**
  138984. * @hidden
  138985. */
  138986. BoundingBoxRenderer.prototype.reset = function () {
  138987. this.renderList.reset();
  138988. };
  138989. /**
  138990. * Render the bounding boxes of a specific rendering group
  138991. * @param renderingGroupId defines the rendering group to render
  138992. */
  138993. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  138994. if (this.renderList.length === 0) {
  138995. return;
  138996. }
  138997. this._prepareRessources();
  138998. if (!this._colorShader.isReady()) {
  138999. return;
  139000. }
  139001. var engine = this.scene.getEngine();
  139002. engine.setDepthWrite(false);
  139003. this._colorShader._preBind();
  139004. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  139005. var boundingBox = this.renderList.data[boundingBoxIndex];
  139006. if (boundingBox._tag !== renderingGroupId) {
  139007. continue;
  139008. }
  139009. var min = boundingBox.minimum;
  139010. var max = boundingBox.maximum;
  139011. var diff = max.subtract(min);
  139012. var median = min.add(diff.scale(0.5));
  139013. var worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  139014. .multiply(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  139015. .multiply(boundingBox.getWorldMatrix());
  139016. // VBOs
  139017. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  139018. if (this.showBackLines) {
  139019. // Back
  139020. engine.setDepthFunctionToGreaterOrEqual();
  139021. this.scene.resetCachedMaterial();
  139022. this._colorShader.setColor4("color", this.backColor.toColor4());
  139023. this._colorShader.bind(worldMatrix);
  139024. // Draw order
  139025. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  139026. }
  139027. // Front
  139028. engine.setDepthFunctionToLess();
  139029. this.scene.resetCachedMaterial();
  139030. this._colorShader.setColor4("color", this.frontColor.toColor4());
  139031. this._colorShader.bind(worldMatrix);
  139032. // Draw order
  139033. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  139034. }
  139035. this._colorShader.unbind();
  139036. engine.setDepthFunctionToLessOrEqual();
  139037. engine.setDepthWrite(true);
  139038. };
  139039. /**
  139040. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139041. * @param mesh Define the mesh to render the occlusion bounding box for
  139042. */
  139043. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  139044. this._prepareRessources();
  139045. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  139046. return;
  139047. }
  139048. var engine = this.scene.getEngine();
  139049. if (!this._fillIndexBuffer) {
  139050. this._fillIndexBuffer = engine.createIndexBuffer(this._fillIndexData);
  139051. }
  139052. engine.setDepthWrite(false);
  139053. engine.setColorWrite(false);
  139054. this._colorShader._preBind();
  139055. var boundingBox = mesh._boundingInfo.boundingBox;
  139056. var min = boundingBox.minimum;
  139057. var max = boundingBox.maximum;
  139058. var diff = max.subtract(min);
  139059. var median = min.add(diff.scale(0.5));
  139060. var worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  139061. .multiply(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  139062. .multiply(boundingBox.getWorldMatrix());
  139063. engine.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, this._colorShader.getEffect());
  139064. engine.setDepthFunctionToLess();
  139065. this.scene.resetCachedMaterial();
  139066. this._colorShader.bind(worldMatrix);
  139067. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 36);
  139068. this._colorShader.unbind();
  139069. engine.setDepthFunctionToLessOrEqual();
  139070. engine.setDepthWrite(true);
  139071. engine.setColorWrite(true);
  139072. };
  139073. /**
  139074. * Dispose and release the resources attached to this renderer.
  139075. */
  139076. BoundingBoxRenderer.prototype.dispose = function () {
  139077. if (!this._colorShader) {
  139078. return;
  139079. }
  139080. this.renderList.dispose();
  139081. this._colorShader.dispose();
  139082. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  139083. if (buffer) {
  139084. buffer.dispose();
  139085. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  139086. }
  139087. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  139088. if (this._fillIndexBuffer) {
  139089. this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer);
  139090. this._fillIndexBuffer = null;
  139091. }
  139092. };
  139093. return BoundingBoxRenderer;
  139094. }());
  139095. /***/ }),
  139096. /***/ "./Rendering/depthRenderer.ts":
  139097. /*!************************************!*\
  139098. !*** ./Rendering/depthRenderer.ts ***!
  139099. \************************************/
  139100. /*! exports provided: DepthRenderer */
  139101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  139102. "use strict";
  139103. __webpack_require__.r(__webpack_exports__);
  139104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  139105. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  139106. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  139107. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  139108. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  139109. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  139110. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  139111. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  139112. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  139113. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  139114. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  139115. /**
  139116. * This represents a depth renderer in Babylon.
  139117. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139118. */
  139119. var DepthRenderer = /** @class */ (function () {
  139120. /**
  139121. * Instantiates a depth renderer
  139122. * @param scene The scene the renderer belongs to
  139123. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139124. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139125. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139126. */
  139127. function DepthRenderer(scene, type, camera, storeNonLinearDepth) {
  139128. var _this = this;
  139129. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT; }
  139130. if (camera === void 0) { camera = null; }
  139131. if (storeNonLinearDepth === void 0) { storeNonLinearDepth = false; }
  139132. /**
  139133. * Specifiess that the depth renderer will only be used within
  139134. * the camera it is created for.
  139135. * This can help forcing its rendering during the camera processing.
  139136. */
  139137. this.useOnlyInActiveCamera = false;
  139138. this._scene = scene;
  139139. this._storeNonLinearDepth = storeNonLinearDepth;
  139140. this.isPacked = type === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  139141. if (this.isPacked) {
  139142. this._clearColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  139143. }
  139144. else {
  139145. this._clearColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 0.0, 0.0, 1.0);
  139146. }
  139147. DepthRenderer._SceneComponentInitialization(this._scene);
  139148. this._camera = camera;
  139149. var engine = scene.getEngine();
  139150. // Render target
  139151. var format = (this.isPacked || engine.webGLVersion === 1) ? _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA : _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_R;
  139152. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type, false, undefined, undefined, undefined, undefined, format);
  139153. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  139154. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  139155. this._depthMap.refreshRate = 1;
  139156. this._depthMap.renderParticles = false;
  139157. this._depthMap.renderList = null;
  139158. // Camera to get depth map from to support multiple concurrent cameras
  139159. this._depthMap.activeCamera = this._camera;
  139160. this._depthMap.ignoreCameraViewport = true;
  139161. this._depthMap.useCameraPostProcesses = false;
  139162. // set default depth value to 1.0 (far away)
  139163. this._depthMap.onClearObservable.add(function (engine) {
  139164. engine.clear(_this._clearColor, true, true, true);
  139165. });
  139166. // Custom render function
  139167. var renderSubMesh = function (subMesh) {
  139168. var mesh = subMesh.getRenderingMesh();
  139169. var scene = _this._scene;
  139170. var engine = scene.getEngine();
  139171. var material = subMesh.getMaterial();
  139172. if (!material) {
  139173. return;
  139174. }
  139175. // Culling and reverse (right handed system)
  139176. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  139177. // Managing instances
  139178. var batch = mesh._getInstancesRenderList(subMesh._id);
  139179. if (batch.mustReturn) {
  139180. return;
  139181. }
  139182. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  139183. var camera = _this._camera || scene.activeCamera;
  139184. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  139185. engine.enableEffect(_this._effect);
  139186. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  139187. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  139188. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  139189. // Alpha test
  139190. if (material && material.needAlphaTesting()) {
  139191. var alphaTexture = material.getAlphaTestTexture();
  139192. if (alphaTexture) {
  139193. _this._effect.setTexture("diffuseSampler", alphaTexture);
  139194. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  139195. }
  139196. }
  139197. // Bones
  139198. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  139199. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  139200. }
  139201. // Morph targets
  139202. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, _this._effect);
  139203. // Draw
  139204. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  139205. }
  139206. };
  139207. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  139208. var index;
  139209. if (depthOnlySubMeshes.length) {
  139210. engine.setColorWrite(false);
  139211. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  139212. renderSubMesh(depthOnlySubMeshes.data[index]);
  139213. }
  139214. engine.setColorWrite(true);
  139215. }
  139216. for (index = 0; index < opaqueSubMeshes.length; index++) {
  139217. renderSubMesh(opaqueSubMeshes.data[index]);
  139218. }
  139219. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  139220. renderSubMesh(alphaTestSubMeshes.data[index]);
  139221. }
  139222. };
  139223. }
  139224. /**
  139225. * Creates the depth rendering effect and checks if the effect is ready.
  139226. * @param subMesh The submesh to be used to render the depth map of
  139227. * @param useInstances If multiple world instances should be used
  139228. * @returns if the depth renderer is ready to render the depth map
  139229. */
  139230. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  139231. var material = subMesh.getMaterial();
  139232. if (material.disableDepthWrite) {
  139233. return false;
  139234. }
  139235. var defines = [];
  139236. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  139237. var mesh = subMesh.getMesh();
  139238. // Alpha test
  139239. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  139240. defines.push("#define ALPHATEST");
  139241. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  139242. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  139243. defines.push("#define UV1");
  139244. }
  139245. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  139246. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  139247. defines.push("#define UV2");
  139248. }
  139249. }
  139250. // Bones
  139251. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  139252. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  139253. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  139254. if (mesh.numBoneInfluencers > 4) {
  139255. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  139256. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  139257. }
  139258. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  139259. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  139260. }
  139261. else {
  139262. defines.push("#define NUM_BONE_INFLUENCERS 0");
  139263. }
  139264. // Morph targets
  139265. var morphTargetManager = mesh.morphTargetManager;
  139266. var numMorphInfluencers = 0;
  139267. if (morphTargetManager) {
  139268. if (morphTargetManager.numInfluencers > 0) {
  139269. numMorphInfluencers = morphTargetManager.numInfluencers;
  139270. defines.push("#define MORPHTARGETS");
  139271. defines.push("#define NUM_MORPH_INFLUENCERS " + numMorphInfluencers);
  139272. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, numMorphInfluencers);
  139273. }
  139274. }
  139275. // Instances
  139276. if (useInstances) {
  139277. defines.push("#define INSTANCES");
  139278. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PushAttributesForInstances(attribs);
  139279. }
  139280. // None linear depth
  139281. if (this._storeNonLinearDepth) {
  139282. defines.push("#define NONLINEARDEPTH");
  139283. }
  139284. // Float Mode
  139285. if (this.isPacked) {
  139286. defines.push("#define PACKED");
  139287. }
  139288. // Get correct effect
  139289. var join = defines.join("\n");
  139290. if (this._cachedDefines !== join) {
  139291. this._cachedDefines = join;
  139292. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues", "morphTargetInfluences"], ["diffuseSampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: numMorphInfluencers });
  139293. }
  139294. return this._effect.isReady();
  139295. };
  139296. /**
  139297. * Gets the texture which the depth map will be written to.
  139298. * @returns The depth map texture
  139299. */
  139300. DepthRenderer.prototype.getDepthMap = function () {
  139301. return this._depthMap;
  139302. };
  139303. /**
  139304. * Disposes of the depth renderer.
  139305. */
  139306. DepthRenderer.prototype.dispose = function () {
  139307. this._depthMap.dispose();
  139308. };
  139309. /** @hidden */
  139310. DepthRenderer._SceneComponentInitialization = function (_) {
  139311. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  139312. };
  139313. return DepthRenderer;
  139314. }());
  139315. /***/ }),
  139316. /***/ "./Rendering/depthRendererSceneComponent.ts":
  139317. /*!**************************************************!*\
  139318. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  139319. \**************************************************/
  139320. /*! exports provided: DepthRendererSceneComponent */
  139321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  139322. "use strict";
  139323. __webpack_require__.r(__webpack_exports__);
  139324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  139325. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  139326. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  139327. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  139328. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  139329. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera, storeNonLinearDepth) {
  139330. if (storeNonLinearDepth === void 0) { storeNonLinearDepth = false; }
  139331. camera = camera || this.activeCamera;
  139332. if (!camera) {
  139333. throw "No camera available to enable depth renderer";
  139334. }
  139335. if (!this._depthRenderer) {
  139336. this._depthRenderer = {};
  139337. }
  139338. if (!this._depthRenderer[camera.id]) {
  139339. var textureType = 0;
  139340. if (this.getEngine().getCaps().textureHalfFloatRender) {
  139341. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  139342. }
  139343. else if (this.getEngine().getCaps().textureFloatRender) {
  139344. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  139345. }
  139346. else {
  139347. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  139348. }
  139349. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera, storeNonLinearDepth);
  139350. }
  139351. return this._depthRenderer[camera.id];
  139352. };
  139353. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  139354. camera = camera || this.activeCamera;
  139355. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  139356. return;
  139357. }
  139358. this._depthRenderer[camera.id].dispose();
  139359. delete this._depthRenderer[camera.id];
  139360. };
  139361. /**
  139362. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139363. * in several rendering techniques.
  139364. */
  139365. var DepthRendererSceneComponent = /** @class */ (function () {
  139366. /**
  139367. * Creates a new instance of the component for the given scene
  139368. * @param scene Defines the scene to register the component in
  139369. */
  139370. function DepthRendererSceneComponent(scene) {
  139371. /**
  139372. * The component name helpfull to identify the component in the list of scene components.
  139373. */
  139374. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  139375. this.scene = scene;
  139376. }
  139377. /**
  139378. * Registers the component in a given scene
  139379. */
  139380. DepthRendererSceneComponent.prototype.register = function () {
  139381. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  139382. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  139383. };
  139384. /**
  139385. * Rebuilds the elements related to this component in case of
  139386. * context lost for instance.
  139387. */
  139388. DepthRendererSceneComponent.prototype.rebuild = function () {
  139389. // Nothing to do for this component
  139390. };
  139391. /**
  139392. * Disposes the component and the associated ressources
  139393. */
  139394. DepthRendererSceneComponent.prototype.dispose = function () {
  139395. for (var key in this.scene._depthRenderer) {
  139396. this.scene._depthRenderer[key].dispose();
  139397. }
  139398. };
  139399. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  139400. if (this.scene._depthRenderer) {
  139401. for (var key in this.scene._depthRenderer) {
  139402. var depthRenderer = this.scene._depthRenderer[key];
  139403. if (!depthRenderer.useOnlyInActiveCamera) {
  139404. renderTargets.push(depthRenderer.getDepthMap());
  139405. }
  139406. }
  139407. }
  139408. };
  139409. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  139410. if (this.scene._depthRenderer) {
  139411. for (var key in this.scene._depthRenderer) {
  139412. var depthRenderer = this.scene._depthRenderer[key];
  139413. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  139414. renderTargets.push(depthRenderer.getDepthMap());
  139415. }
  139416. }
  139417. }
  139418. };
  139419. return DepthRendererSceneComponent;
  139420. }());
  139421. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  139422. // Register the G Buffer component to the scene.
  139423. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  139424. if (!component) {
  139425. component = new DepthRendererSceneComponent(scene);
  139426. scene._addComponent(component);
  139427. }
  139428. };
  139429. /***/ }),
  139430. /***/ "./Rendering/edgesRenderer.ts":
  139431. /*!************************************!*\
  139432. !*** ./Rendering/edgesRenderer.ts ***!
  139433. \************************************/
  139434. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  139435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  139436. "use strict";
  139437. __webpack_require__.r(__webpack_exports__);
  139438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  139439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  139440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  139441. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  139442. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  139443. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  139444. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  139445. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  139446. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  139447. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  139448. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  139449. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  139450. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  139451. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  139452. if (this._edgesRenderer) {
  139453. this._edgesRenderer.dispose();
  139454. this._edgesRenderer = null;
  139455. }
  139456. return this;
  139457. };
  139458. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  139459. if (epsilon === void 0) { epsilon = 0.95; }
  139460. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  139461. this.disableEdgesRendering();
  139462. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  139463. return this;
  139464. };
  139465. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  139466. get: function () {
  139467. return this._edgesRenderer;
  139468. },
  139469. enumerable: true,
  139470. configurable: true
  139471. });
  139472. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  139473. if (epsilon === void 0) { epsilon = 0.95; }
  139474. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  139475. this.disableEdgesRendering();
  139476. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  139477. return this;
  139478. };
  139479. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  139480. if (epsilon === void 0) { epsilon = 0.95; }
  139481. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  139482. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  139483. return this;
  139484. };
  139485. /**
  139486. * FaceAdjacencies Helper class to generate edges
  139487. */
  139488. var FaceAdjacencies = /** @class */ (function () {
  139489. function FaceAdjacencies() {
  139490. this.edges = new Array();
  139491. this.edgesConnectedCount = 0;
  139492. }
  139493. return FaceAdjacencies;
  139494. }());
  139495. /**
  139496. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  139497. */
  139498. var EdgesRenderer = /** @class */ (function () {
  139499. /**
  139500. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  139501. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  139502. * @param source Mesh used to create edges
  139503. * @param epsilon sum of angles in adjacency to check for edge
  139504. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  139505. * @param generateEdgesLines - should generate Lines or only prepare resources.
  139506. */
  139507. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  139508. var _this = this;
  139509. if (epsilon === void 0) { epsilon = 0.95; }
  139510. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  139511. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  139512. /**
  139513. * Define the size of the edges with an orthographic camera
  139514. */
  139515. this.edgesWidthScalerForOrthographic = 1000.0;
  139516. /**
  139517. * Define the size of the edges with a perspective camera
  139518. */
  139519. this.edgesWidthScalerForPerspective = 50.0;
  139520. this._linesPositions = new Array();
  139521. this._linesNormals = new Array();
  139522. this._linesIndices = new Array();
  139523. this._buffers = {};
  139524. this._checkVerticesInsteadOfIndices = false;
  139525. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  139526. this.isEnabled = true;
  139527. this._source = source;
  139528. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  139529. this._epsilon = epsilon;
  139530. this._prepareRessources();
  139531. if (generateEdgesLines) {
  139532. this._generateEdgesLines();
  139533. }
  139534. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  139535. _this._rebuild();
  139536. });
  139537. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  139538. _this.dispose();
  139539. });
  139540. }
  139541. EdgesRenderer.prototype._prepareRessources = function () {
  139542. if (this._lineShader) {
  139543. return;
  139544. }
  139545. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  139546. attributes: ["position", "normal"],
  139547. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  139548. });
  139549. this._lineShader.disableDepthWrite = true;
  139550. this._lineShader.backFaceCulling = false;
  139551. };
  139552. /** @hidden */
  139553. EdgesRenderer.prototype._rebuild = function () {
  139554. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  139555. if (buffer) {
  139556. buffer._rebuild();
  139557. }
  139558. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  139559. if (buffer) {
  139560. buffer._rebuild();
  139561. }
  139562. var scene = this._source.getScene();
  139563. var engine = scene.getEngine();
  139564. this._ib = engine.createIndexBuffer(this._linesIndices);
  139565. };
  139566. /**
  139567. * Releases the required resources for the edges renderer
  139568. */
  139569. EdgesRenderer.prototype.dispose = function () {
  139570. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  139571. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  139572. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  139573. if (buffer) {
  139574. buffer.dispose();
  139575. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  139576. }
  139577. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  139578. if (buffer) {
  139579. buffer.dispose();
  139580. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  139581. }
  139582. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  139583. this._lineShader.dispose();
  139584. };
  139585. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  139586. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  139587. return 0;
  139588. }
  139589. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  139590. return 1;
  139591. }
  139592. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  139593. return 2;
  139594. }
  139595. return -1;
  139596. };
  139597. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  139598. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  139599. return 0;
  139600. }
  139601. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  139602. return 1;
  139603. }
  139604. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  139605. return 2;
  139606. }
  139607. return -1;
  139608. };
  139609. /**
  139610. * Checks if the pair of p0 and p1 is en edge
  139611. * @param faceIndex
  139612. * @param edge
  139613. * @param faceNormals
  139614. * @param p0
  139615. * @param p1
  139616. * @private
  139617. */
  139618. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  139619. var needToCreateLine;
  139620. if (edge === undefined) {
  139621. needToCreateLine = true;
  139622. }
  139623. else {
  139624. var dotProduct = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  139625. needToCreateLine = dotProduct < this._epsilon;
  139626. }
  139627. if (needToCreateLine) {
  139628. this.createLine(p0, p1, this._linesPositions.length / 3);
  139629. }
  139630. };
  139631. /**
  139632. * push line into the position, normal and index buffer
  139633. * @protected
  139634. */
  139635. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  139636. // Positions
  139637. 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);
  139638. // Normals
  139639. 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);
  139640. // Indices
  139641. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  139642. };
  139643. /**
  139644. * Generates lines edges from adjacencjes
  139645. * @private
  139646. */
  139647. EdgesRenderer.prototype._generateEdgesLines = function () {
  139648. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  139649. var indices = this._source.getIndices();
  139650. if (!indices || !positions) {
  139651. return;
  139652. }
  139653. // First let's find adjacencies
  139654. var adjacencies = new Array();
  139655. var faceNormals = new Array();
  139656. var index;
  139657. var faceAdjacencies;
  139658. // Prepare faces
  139659. for (index = 0; index < indices.length; index += 3) {
  139660. faceAdjacencies = new FaceAdjacencies();
  139661. var p0Index = indices[index];
  139662. var p1Index = indices[index + 1];
  139663. var p2Index = indices[index + 2];
  139664. faceAdjacencies.p0 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  139665. faceAdjacencies.p1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  139666. faceAdjacencies.p2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  139667. var faceNormal = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  139668. faceNormal.normalize();
  139669. faceNormals.push(faceNormal);
  139670. adjacencies.push(faceAdjacencies);
  139671. }
  139672. // Scan
  139673. for (index = 0; index < adjacencies.length; index++) {
  139674. faceAdjacencies = adjacencies[index];
  139675. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  139676. var otherFaceAdjacencies = adjacencies[otherIndex];
  139677. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  139678. break;
  139679. }
  139680. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  139681. continue;
  139682. }
  139683. var otherP0 = indices[otherIndex * 3];
  139684. var otherP1 = indices[otherIndex * 3 + 1];
  139685. var otherP2 = indices[otherIndex * 3 + 2];
  139686. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  139687. var otherEdgeIndex = 0;
  139688. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  139689. continue;
  139690. }
  139691. switch (edgeIndex) {
  139692. case 0:
  139693. if (this._checkVerticesInsteadOfIndices) {
  139694. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  139695. }
  139696. else {
  139697. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  139698. }
  139699. break;
  139700. case 1:
  139701. if (this._checkVerticesInsteadOfIndices) {
  139702. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  139703. }
  139704. else {
  139705. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  139706. }
  139707. break;
  139708. case 2:
  139709. if (this._checkVerticesInsteadOfIndices) {
  139710. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  139711. }
  139712. else {
  139713. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  139714. }
  139715. break;
  139716. }
  139717. if (otherEdgeIndex === -1) {
  139718. continue;
  139719. }
  139720. faceAdjacencies.edges[edgeIndex] = otherIndex;
  139721. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  139722. faceAdjacencies.edgesConnectedCount++;
  139723. otherFaceAdjacencies.edgesConnectedCount++;
  139724. if (faceAdjacencies.edgesConnectedCount === 3) {
  139725. break;
  139726. }
  139727. }
  139728. }
  139729. }
  139730. // Create lines
  139731. for (index = 0; index < adjacencies.length; index++) {
  139732. // 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
  139733. var current = adjacencies[index];
  139734. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  139735. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  139736. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  139737. }
  139738. // Merge into a single mesh
  139739. var engine = this._source.getScene().getEngine();
  139740. 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);
  139741. 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);
  139742. this._ib = engine.createIndexBuffer(this._linesIndices);
  139743. this._indicesCount = this._linesIndices.length;
  139744. };
  139745. /**
  139746. * Checks wether or not the edges renderer is ready to render.
  139747. * @return true if ready, otherwise false.
  139748. */
  139749. EdgesRenderer.prototype.isReady = function () {
  139750. return this._lineShader.isReady();
  139751. };
  139752. /**
  139753. * Renders the edges of the attached mesh,
  139754. */
  139755. EdgesRenderer.prototype.render = function () {
  139756. var scene = this._source.getScene();
  139757. if (!this.isReady() || !scene.activeCamera) {
  139758. return;
  139759. }
  139760. var engine = scene.getEngine();
  139761. this._lineShader._preBind();
  139762. if (this._source.edgesColor.a !== 1) {
  139763. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  139764. }
  139765. else {
  139766. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  139767. }
  139768. // VBOs
  139769. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  139770. scene.resetCachedMaterial();
  139771. this._lineShader.setColor4("color", this._source.edgesColor);
  139772. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  139773. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  139774. }
  139775. else {
  139776. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  139777. }
  139778. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  139779. this._lineShader.bind(this._source.getWorldMatrix());
  139780. // Draw order
  139781. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  139782. this._lineShader.unbind();
  139783. };
  139784. return EdgesRenderer;
  139785. }());
  139786. /**
  139787. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  139788. */
  139789. var LineEdgesRenderer = /** @class */ (function (_super) {
  139790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  139791. /**
  139792. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  139793. * @param source LineMesh used to generate edges
  139794. * @param epsilon not important (specified angle for edge detection)
  139795. * @param checkVerticesInsteadOfIndices not important for LineMesh
  139796. */
  139797. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  139798. if (epsilon === void 0) { epsilon = 0.95; }
  139799. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  139800. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  139801. _this._generateEdgesLines();
  139802. return _this;
  139803. }
  139804. /**
  139805. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  139806. */
  139807. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  139808. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  139809. var indices = this._source.getIndices();
  139810. if (!indices || !positions) {
  139811. return;
  139812. }
  139813. var p0 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Vector3[0];
  139814. var p1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["TmpVectors"].Vector3[1];
  139815. var len = indices.length - 1;
  139816. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  139817. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  139818. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  139819. this.createLine(p0, p1, offset);
  139820. }
  139821. // Merge into a single mesh
  139822. var engine = this._source.getScene().getEngine();
  139823. 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);
  139824. 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);
  139825. this._ib = engine.createIndexBuffer(this._linesIndices);
  139826. this._indicesCount = this._linesIndices.length;
  139827. };
  139828. return LineEdgesRenderer;
  139829. }(EdgesRenderer));
  139830. /***/ }),
  139831. /***/ "./Rendering/geometryBufferRenderer.ts":
  139832. /*!*********************************************!*\
  139833. !*** ./Rendering/geometryBufferRenderer.ts ***!
  139834. \*********************************************/
  139835. /*! exports provided: GeometryBufferRenderer */
  139836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  139837. "use strict";
  139838. __webpack_require__.r(__webpack_exports__);
  139839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  139840. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  139841. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  139842. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  139843. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  139844. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  139845. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  139846. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  139847. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  139848. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  139849. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  139850. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  139851. /**
  139852. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139853. */
  139854. var GeometryBufferRenderer = /** @class */ (function () {
  139855. /**
  139856. * Creates a new G Buffer for the scene
  139857. * @param scene The scene the buffer belongs to
  139858. * @param ratio How big is the buffer related to the main canvas.
  139859. */
  139860. function GeometryBufferRenderer(scene, ratio) {
  139861. if (ratio === void 0) { ratio = 1; }
  139862. /**
  139863. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139864. * in order to compute objects velocities when enableVelocity is set to "true"
  139865. * @hidden
  139866. */
  139867. this._previousTransformationMatrices = {};
  139868. /**
  139869. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139870. * in order to compute objects velocities when enableVelocity is set to "true"
  139871. * @hidden
  139872. */
  139873. this._previousBonesTransformationMatrices = {};
  139874. /**
  139875. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139876. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139877. */
  139878. this.excludedSkinnedMeshesFromVelocity = [];
  139879. this._enablePosition = false;
  139880. this._enableVelocity = false;
  139881. this._positionIndex = -1;
  139882. this._velocityIndex = -1;
  139883. this._scene = scene;
  139884. this._ratio = ratio;
  139885. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  139886. // Render target
  139887. this._createRenderTargets();
  139888. }
  139889. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  139890. /**
  139891. * Set the render list (meshes to be rendered) used in the G buffer.
  139892. */
  139893. set: function (meshes) {
  139894. this._multiRenderTarget.renderList = meshes;
  139895. },
  139896. enumerable: true,
  139897. configurable: true
  139898. });
  139899. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  139900. /**
  139901. * Gets wether or not G buffer are supported by the running hardware.
  139902. * This requires draw buffer supports
  139903. */
  139904. get: function () {
  139905. return this._multiRenderTarget.isSupported;
  139906. },
  139907. enumerable: true,
  139908. configurable: true
  139909. });
  139910. /**
  139911. * Returns the index of the given texture type in the G-Buffer textures array
  139912. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139913. * @returns the index of the given texture type in the G-Buffer textures array
  139914. */
  139915. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  139916. switch (textureType) {
  139917. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  139918. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  139919. default: return -1;
  139920. }
  139921. };
  139922. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  139923. /**
  139924. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139925. */
  139926. get: function () {
  139927. return this._enablePosition;
  139928. },
  139929. /**
  139930. * Sets whether or not objects positions are enabled for the G buffer.
  139931. */
  139932. set: function (enable) {
  139933. this._enablePosition = enable;
  139934. this.dispose();
  139935. this._createRenderTargets();
  139936. },
  139937. enumerable: true,
  139938. configurable: true
  139939. });
  139940. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  139941. /**
  139942. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139943. */
  139944. get: function () {
  139945. return this._enableVelocity;
  139946. },
  139947. /**
  139948. * Sets wether or not objects velocities are enabled for the G buffer.
  139949. */
  139950. set: function (enable) {
  139951. this._enableVelocity = enable;
  139952. if (!enable) {
  139953. this._previousTransformationMatrices = {};
  139954. }
  139955. this.dispose();
  139956. this._createRenderTargets();
  139957. },
  139958. enumerable: true,
  139959. configurable: true
  139960. });
  139961. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  139962. /**
  139963. * Gets the scene associated with the buffer.
  139964. */
  139965. get: function () {
  139966. return this._scene;
  139967. },
  139968. enumerable: true,
  139969. configurable: true
  139970. });
  139971. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  139972. /**
  139973. * Gets the ratio used by the buffer during its creation.
  139974. * How big is the buffer related to the main canvas.
  139975. */
  139976. get: function () {
  139977. return this._ratio;
  139978. },
  139979. enumerable: true,
  139980. configurable: true
  139981. });
  139982. /**
  139983. * Checks wether everything is ready to render a submesh to the G buffer.
  139984. * @param subMesh the submesh to check readiness for
  139985. * @param useInstances is the mesh drawn using instance or not
  139986. * @returns true if ready otherwise false
  139987. */
  139988. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  139989. var material = subMesh.getMaterial();
  139990. if (material && material.disableDepthWrite) {
  139991. return false;
  139992. }
  139993. var defines = [];
  139994. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  139995. var mesh = subMesh.getMesh();
  139996. // Alpha test
  139997. if (material && material.needAlphaTesting()) {
  139998. defines.push("#define ALPHATEST");
  139999. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  140000. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  140001. defines.push("#define UV1");
  140002. }
  140003. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  140004. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  140005. defines.push("#define UV2");
  140006. }
  140007. }
  140008. // Buffers
  140009. if (this._enablePosition) {
  140010. defines.push("#define POSITION");
  140011. defines.push("#define POSITION_INDEX " + this._positionIndex);
  140012. }
  140013. if (this._enableVelocity) {
  140014. defines.push("#define VELOCITY");
  140015. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  140016. if (this.excludedSkinnedMeshesFromVelocity.indexOf(mesh) === -1) {
  140017. defines.push("#define BONES_VELOCITY_ENABLED");
  140018. }
  140019. }
  140020. // Bones
  140021. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  140022. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  140023. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  140024. if (mesh.numBoneInfluencers > 4) {
  140025. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  140026. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  140027. }
  140028. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  140029. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  140030. }
  140031. else {
  140032. defines.push("#define NUM_BONE_INFLUENCERS 0");
  140033. }
  140034. // Morph targets
  140035. var morphTargetManager = mesh.morphTargetManager;
  140036. var numMorphInfluencers = 0;
  140037. if (morphTargetManager) {
  140038. if (morphTargetManager.numInfluencers > 0) {
  140039. numMorphInfluencers = morphTargetManager.numInfluencers;
  140040. defines.push("#define MORPHTARGETS");
  140041. defines.push("#define NUM_MORPH_INFLUENCERS " + numMorphInfluencers);
  140042. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, numMorphInfluencers);
  140043. }
  140044. }
  140045. // Instances
  140046. if (useInstances) {
  140047. defines.push("#define INSTANCES");
  140048. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].PushAttributesForInstances(attribs);
  140049. }
  140050. // Setup textures count
  140051. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  140052. // Get correct effect
  140053. var join = defines.join("\n");
  140054. if (this._cachedDefines !== join) {
  140055. this._cachedDefines = join;
  140056. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones", "morphTargetInfluences"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2, maxSimultaneousMorphTargets: numMorphInfluencers });
  140057. }
  140058. return this._effect.isReady();
  140059. };
  140060. /**
  140061. * Gets the current underlying G Buffer.
  140062. * @returns the buffer
  140063. */
  140064. GeometryBufferRenderer.prototype.getGBuffer = function () {
  140065. return this._multiRenderTarget;
  140066. };
  140067. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  140068. /**
  140069. * Gets the number of samples used to render the buffer (anti aliasing).
  140070. */
  140071. get: function () {
  140072. return this._multiRenderTarget.samples;
  140073. },
  140074. /**
  140075. * Sets the number of samples used to render the buffer (anti aliasing).
  140076. */
  140077. set: function (value) {
  140078. this._multiRenderTarget.samples = value;
  140079. },
  140080. enumerable: true,
  140081. configurable: true
  140082. });
  140083. /**
  140084. * Disposes the renderer and frees up associated resources.
  140085. */
  140086. GeometryBufferRenderer.prototype.dispose = function () {
  140087. this.getGBuffer().dispose();
  140088. };
  140089. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  140090. var _this = this;
  140091. var engine = this._scene.getEngine();
  140092. var count = 2;
  140093. if (this._enablePosition) {
  140094. this._positionIndex = count;
  140095. count++;
  140096. }
  140097. if (this._enableVelocity) {
  140098. this._velocityIndex = count;
  140099. count++;
  140100. }
  140101. 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 });
  140102. if (!this.isSupported) {
  140103. return;
  140104. }
  140105. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  140106. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  140107. this._multiRenderTarget.refreshRate = 1;
  140108. this._multiRenderTarget.renderParticles = false;
  140109. this._multiRenderTarget.renderList = null;
  140110. // set default depth value to 1.0 (far away)
  140111. this._multiRenderTarget.onClearObservable.add(function (engine) {
  140112. engine.clear(new _Maths_math_color__WEBPACK_IMPORTED_MODULE_10__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  140113. });
  140114. // Custom render function
  140115. var renderSubMesh = function (subMesh) {
  140116. var mesh = subMesh.getRenderingMesh();
  140117. var scene = _this._scene;
  140118. var engine = scene.getEngine();
  140119. var material = subMesh.getMaterial();
  140120. if (!material) {
  140121. return;
  140122. }
  140123. // Velocity
  140124. if (_this._enableVelocity && !_this._previousTransformationMatrices[mesh.uniqueId]) {
  140125. _this._previousTransformationMatrices[mesh.uniqueId] = {
  140126. world: _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(),
  140127. viewProjection: scene.getTransformMatrix()
  140128. };
  140129. if (mesh.skeleton) {
  140130. var bonesTransformations = mesh.skeleton.getTransformMatrices(mesh);
  140131. _this._previousBonesTransformationMatrices[mesh.uniqueId] = _this._copyBonesTransformationMatrices(bonesTransformations, new Float32Array(bonesTransformations.length));
  140132. }
  140133. }
  140134. // Culling
  140135. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  140136. // Managing instances
  140137. var batch = mesh._getInstancesRenderList(subMesh._id);
  140138. if (batch.mustReturn) {
  140139. return;
  140140. }
  140141. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  140142. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  140143. engine.enableEffect(_this._effect);
  140144. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  140145. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  140146. _this._effect.setMatrix("view", scene.getViewMatrix());
  140147. // Alpha test
  140148. if (material && material.needAlphaTesting()) {
  140149. var alphaTexture = material.getAlphaTestTexture();
  140150. if (alphaTexture) {
  140151. _this._effect.setTexture("diffuseSampler", alphaTexture);
  140152. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  140153. }
  140154. }
  140155. // Bones
  140156. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  140157. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  140158. if (_this._enableVelocity) {
  140159. _this._effect.setMatrices("mPreviousBones", _this._previousBonesTransformationMatrices[mesh.uniqueId]);
  140160. }
  140161. }
  140162. // Morph targets
  140163. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].BindMorphTargetParameters(mesh, _this._effect);
  140164. // Velocity
  140165. if (_this._enableVelocity) {
  140166. _this._effect.setMatrix("previousWorld", _this._previousTransformationMatrices[mesh.uniqueId].world);
  140167. _this._effect.setMatrix("previousViewProjection", _this._previousTransformationMatrices[mesh.uniqueId].viewProjection);
  140168. }
  140169. // Draw
  140170. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  140171. }
  140172. // Velocity
  140173. if (_this._enableVelocity) {
  140174. _this._previousTransformationMatrices[mesh.uniqueId].world = mesh.getWorldMatrix().clone();
  140175. _this._previousTransformationMatrices[mesh.uniqueId].viewProjection = _this._scene.getTransformMatrix().clone();
  140176. if (mesh.skeleton) {
  140177. _this._copyBonesTransformationMatrices(mesh.skeleton.getTransformMatrices(mesh), _this._previousBonesTransformationMatrices[mesh.uniqueId]);
  140178. }
  140179. }
  140180. };
  140181. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  140182. var index;
  140183. if (depthOnlySubMeshes.length) {
  140184. engine.setColorWrite(false);
  140185. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  140186. renderSubMesh(depthOnlySubMeshes.data[index]);
  140187. }
  140188. engine.setColorWrite(true);
  140189. }
  140190. for (index = 0; index < opaqueSubMeshes.length; index++) {
  140191. renderSubMesh(opaqueSubMeshes.data[index]);
  140192. }
  140193. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  140194. renderSubMesh(alphaTestSubMeshes.data[index]);
  140195. }
  140196. };
  140197. };
  140198. // Copies the bones transformation matrices into the target array and returns the target's reference
  140199. GeometryBufferRenderer.prototype._copyBonesTransformationMatrices = function (source, target) {
  140200. for (var i = 0; i < source.length; i++) {
  140201. target[i] = source[i];
  140202. }
  140203. return target;
  140204. };
  140205. /**
  140206. * Constant used to retrieve the position texture index in the G-Buffer textures array
  140207. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  140208. */
  140209. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  140210. /**
  140211. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  140212. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  140213. */
  140214. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  140215. /** @hidden */
  140216. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  140217. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  140218. };
  140219. return GeometryBufferRenderer;
  140220. }());
  140221. /***/ }),
  140222. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  140223. /*!***********************************************************!*\
  140224. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  140225. \***********************************************************/
  140226. /*! exports provided: GeometryBufferRendererSceneComponent */
  140227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  140228. "use strict";
  140229. __webpack_require__.r(__webpack_exports__);
  140230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  140231. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  140232. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  140233. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  140234. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  140235. get: function () {
  140236. this._geometryBufferRenderer;
  140237. },
  140238. set: function (value) {
  140239. if (value && value.isSupported) {
  140240. this._geometryBufferRenderer = value;
  140241. }
  140242. },
  140243. enumerable: true,
  140244. configurable: true
  140245. });
  140246. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  140247. if (ratio === void 0) { ratio = 1; }
  140248. if (this._geometryBufferRenderer) {
  140249. return this._geometryBufferRenderer;
  140250. }
  140251. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  140252. if (!this._geometryBufferRenderer.isSupported) {
  140253. this._geometryBufferRenderer = null;
  140254. }
  140255. return this._geometryBufferRenderer;
  140256. };
  140257. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  140258. if (!this._geometryBufferRenderer) {
  140259. return;
  140260. }
  140261. this._geometryBufferRenderer.dispose();
  140262. this._geometryBufferRenderer = null;
  140263. };
  140264. /**
  140265. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  140266. * in several rendering techniques.
  140267. */
  140268. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  140269. /**
  140270. * Creates a new instance of the component for the given scene
  140271. * @param scene Defines the scene to register the component in
  140272. */
  140273. function GeometryBufferRendererSceneComponent(scene) {
  140274. /**
  140275. * The component name helpful to identify the component in the list of scene components.
  140276. */
  140277. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  140278. this.scene = scene;
  140279. }
  140280. /**
  140281. * Registers the component in a given scene
  140282. */
  140283. GeometryBufferRendererSceneComponent.prototype.register = function () {
  140284. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  140285. };
  140286. /**
  140287. * Rebuilds the elements related to this component in case of
  140288. * context lost for instance.
  140289. */
  140290. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  140291. // Nothing to do for this component
  140292. };
  140293. /**
  140294. * Disposes the component and the associated ressources
  140295. */
  140296. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  140297. // Nothing to do for this component
  140298. };
  140299. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  140300. if (this.scene._geometryBufferRenderer) {
  140301. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  140302. }
  140303. };
  140304. return GeometryBufferRendererSceneComponent;
  140305. }());
  140306. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  140307. // Register the G Buffer component to the scene.
  140308. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  140309. if (!component) {
  140310. component = new GeometryBufferRendererSceneComponent(scene);
  140311. scene._addComponent(component);
  140312. }
  140313. };
  140314. /***/ }),
  140315. /***/ "./Rendering/index.ts":
  140316. /*!****************************!*\
  140317. !*** ./Rendering/index.ts ***!
  140318. \****************************/
  140319. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  140320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  140321. "use strict";
  140322. __webpack_require__.r(__webpack_exports__);
  140323. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  140324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  140325. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  140326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  140327. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  140328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  140329. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  140330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  140331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  140332. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  140333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  140334. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  140335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  140336. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  140337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  140338. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  140339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  140340. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  140341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  140342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  140343. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  140344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  140345. /***/ }),
  140346. /***/ "./Rendering/outlineRenderer.ts":
  140347. /*!**************************************!*\
  140348. !*** ./Rendering/outlineRenderer.ts ***!
  140349. \**************************************/
  140350. /*! exports provided: OutlineRenderer */
  140351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  140352. "use strict";
  140353. __webpack_require__.r(__webpack_exports__);
  140354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  140355. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  140356. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  140357. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  140358. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  140359. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  140360. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  140361. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  140362. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  140363. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  140364. /**
  140365. * Gets the outline renderer associated with the scene
  140366. * @returns a OutlineRenderer
  140367. */
  140368. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  140369. if (!this._outlineRenderer) {
  140370. this._outlineRenderer = new OutlineRenderer(this);
  140371. }
  140372. return this._outlineRenderer;
  140373. };
  140374. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  140375. get: function () {
  140376. return this._renderOutline;
  140377. },
  140378. set: function (value) {
  140379. if (value) {
  140380. // Lazy Load the component.
  140381. this.getScene().getOutlineRenderer();
  140382. }
  140383. this._renderOutline = value;
  140384. },
  140385. enumerable: true,
  140386. configurable: true
  140387. });
  140388. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  140389. get: function () {
  140390. return this._renderOverlay;
  140391. },
  140392. set: function (value) {
  140393. if (value) {
  140394. // Lazy Load the component.
  140395. this.getScene().getOutlineRenderer();
  140396. }
  140397. this._renderOverlay = value;
  140398. },
  140399. enumerable: true,
  140400. configurable: true
  140401. });
  140402. /**
  140403. * This class is responsible to draw bothe outline/overlay of meshes.
  140404. * It should not be used directly but through the available method on mesh.
  140405. */
  140406. var OutlineRenderer = /** @class */ (function () {
  140407. /**
  140408. * Instantiates a new outline renderer. (There could be only one per scene).
  140409. * @param scene Defines the scene it belongs to
  140410. */
  140411. function OutlineRenderer(scene) {
  140412. /**
  140413. * The name of the component. Each component must have a unique name.
  140414. */
  140415. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  140416. /**
  140417. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140418. */
  140419. this.zOffset = 1;
  140420. this.scene = scene;
  140421. this._engine = scene.getEngine();
  140422. this.scene._addComponent(this);
  140423. }
  140424. /**
  140425. * Register the component to one instance of a scene.
  140426. */
  140427. OutlineRenderer.prototype.register = function () {
  140428. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  140429. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  140430. };
  140431. /**
  140432. * Rebuilds the elements related to this component in case of
  140433. * context lost for instance.
  140434. */
  140435. OutlineRenderer.prototype.rebuild = function () {
  140436. // Nothing to do here.
  140437. };
  140438. /**
  140439. * Disposes the component and the associated ressources.
  140440. */
  140441. OutlineRenderer.prototype.dispose = function () {
  140442. // Nothing to do here.
  140443. };
  140444. /**
  140445. * Renders the outline in the canvas.
  140446. * @param subMesh Defines the sumesh to render
  140447. * @param batch Defines the batch of meshes in case of instances
  140448. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140449. */
  140450. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  140451. var _this = this;
  140452. if (useOverlay === void 0) { useOverlay = false; }
  140453. var scene = this.scene;
  140454. var engine = scene.getEngine();
  140455. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  140456. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  140457. return;
  140458. }
  140459. var mesh = subMesh.getRenderingMesh();
  140460. var material = subMesh.getMaterial();
  140461. if (!material || !scene.activeCamera) {
  140462. return;
  140463. }
  140464. engine.enableEffect(this._effect);
  140465. // Logarithmic depth
  140466. if (material.useLogarithmicDepth) {
  140467. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  140468. }
  140469. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  140470. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  140471. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  140472. // Bones
  140473. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  140474. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  140475. }
  140476. // Morph targets
  140477. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  140478. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  140479. // Alpha test
  140480. if (material && material.needAlphaTesting()) {
  140481. var alphaTexture = material.getAlphaTestTexture();
  140482. if (alphaTexture) {
  140483. this._effect.setTexture("diffuseSampler", alphaTexture);
  140484. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  140485. }
  140486. }
  140487. engine.setZOffset(-this.zOffset);
  140488. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  140489. engine.setZOffset(0);
  140490. };
  140491. /**
  140492. * Returns whether or not the outline renderer is ready for a given submesh.
  140493. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140494. * @param subMesh Defines the submesh to check readyness for
  140495. * @param useInstances Defines wheter wee are trying to render instances or not
  140496. * @returns true if ready otherwise false
  140497. */
  140498. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  140499. var defines = [];
  140500. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  140501. var mesh = subMesh.getMesh();
  140502. var material = subMesh.getMaterial();
  140503. if (material) {
  140504. // Alpha test
  140505. if (material.needAlphaTesting()) {
  140506. defines.push("#define ALPHATEST");
  140507. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  140508. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  140509. defines.push("#define UV1");
  140510. }
  140511. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  140512. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  140513. defines.push("#define UV2");
  140514. }
  140515. }
  140516. //Logarithmic depth
  140517. if (material.useLogarithmicDepth) {
  140518. defines.push("#define LOGARITHMICDEPTH");
  140519. }
  140520. }
  140521. // Bones
  140522. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  140523. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  140524. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  140525. if (mesh.numBoneInfluencers > 4) {
  140526. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  140527. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  140528. }
  140529. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  140530. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  140531. }
  140532. else {
  140533. defines.push("#define NUM_BONE_INFLUENCERS 0");
  140534. }
  140535. // Morph targets
  140536. var morphTargetManager = mesh.morphTargetManager;
  140537. var numMorphInfluencers = 0;
  140538. if (morphTargetManager) {
  140539. if (morphTargetManager.numInfluencers > 0) {
  140540. numMorphInfluencers = morphTargetManager.numInfluencers;
  140541. defines.push("#define MORPHTARGETS");
  140542. defines.push("#define NUM_MORPH_INFLUENCERS " + numMorphInfluencers);
  140543. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, numMorphInfluencers);
  140544. }
  140545. }
  140546. // Instances
  140547. if (useInstances) {
  140548. defines.push("#define INSTANCES");
  140549. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_6__["MaterialHelper"].PushAttributesForInstances(attribs);
  140550. }
  140551. // Get correct effect
  140552. var join = defines.join("\n");
  140553. if (this._cachedDefines !== join) {
  140554. this._cachedDefines = join;
  140555. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant", "morphTargetInfluences"], ["diffuseSampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: numMorphInfluencers });
  140556. }
  140557. return this._effect.isReady();
  140558. };
  140559. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  140560. // Outline - step 1
  140561. this._savedDepthWrite = this._engine.getDepthWrite();
  140562. if (mesh.renderOutline) {
  140563. var material = subMesh.getMaterial();
  140564. if (material && material.needAlphaBlending()) {
  140565. this._engine.cacheStencilState();
  140566. // Draw only to stencil buffer for the original mesh
  140567. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  140568. this._engine.setDepthWrite(false);
  140569. this._engine.setColorWrite(false);
  140570. this._engine.setStencilBuffer(true);
  140571. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  140572. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  140573. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  140574. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  140575. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  140576. this._engine.setColorWrite(true);
  140577. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  140578. }
  140579. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  140580. this._engine.setDepthWrite(false);
  140581. this.render(subMesh, batch);
  140582. this._engine.setDepthWrite(this._savedDepthWrite);
  140583. if (material && material.needAlphaBlending()) {
  140584. this._engine.restoreStencilState();
  140585. }
  140586. }
  140587. };
  140588. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  140589. // Overlay
  140590. if (mesh.renderOverlay) {
  140591. var currentMode = this._engine.getAlphaMode();
  140592. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  140593. this.render(subMesh, batch, true);
  140594. this._engine.setAlphaMode(currentMode);
  140595. }
  140596. // Outline - step 2
  140597. if (mesh.renderOutline && this._savedDepthWrite) {
  140598. this._engine.setDepthWrite(true);
  140599. this._engine.setColorWrite(false);
  140600. this.render(subMesh, batch);
  140601. this._engine.setColorWrite(true);
  140602. }
  140603. };
  140604. /**
  140605. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140606. */
  140607. OutlineRenderer._StencilReference = 0x04;
  140608. return OutlineRenderer;
  140609. }());
  140610. /***/ }),
  140611. /***/ "./Rendering/renderingGroup.ts":
  140612. /*!*************************************!*\
  140613. !*** ./Rendering/renderingGroup.ts ***!
  140614. \*************************************/
  140615. /*! exports provided: RenderingGroup */
  140616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  140617. "use strict";
  140618. __webpack_require__.r(__webpack_exports__);
  140619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  140620. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  140621. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  140622. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  140623. /**
  140624. * This represents the object necessary to create a rendering group.
  140625. * This is exclusively used and created by the rendering manager.
  140626. * To modify the behavior, you use the available helpers in your scene or meshes.
  140627. * @hidden
  140628. */
  140629. var RenderingGroup = /** @class */ (function () {
  140630. /**
  140631. * Creates a new rendering group.
  140632. * @param index The rendering group index
  140633. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  140634. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  140635. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  140636. */
  140637. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  140638. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  140639. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  140640. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  140641. this.index = index;
  140642. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  140643. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  140644. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  140645. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  140646. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  140647. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  140648. /** @hidden */
  140649. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  140650. this._scene = scene;
  140651. this.opaqueSortCompareFn = opaqueSortCompareFn;
  140652. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  140653. this.transparentSortCompareFn = transparentSortCompareFn;
  140654. }
  140655. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  140656. /**
  140657. * Set the opaque sort comparison function.
  140658. * If null the sub meshes will be render in the order they were created
  140659. */
  140660. set: function (value) {
  140661. this._opaqueSortCompareFn = value;
  140662. if (value) {
  140663. this._renderOpaque = this.renderOpaqueSorted;
  140664. }
  140665. else {
  140666. this._renderOpaque = RenderingGroup.renderUnsorted;
  140667. }
  140668. },
  140669. enumerable: true,
  140670. configurable: true
  140671. });
  140672. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  140673. /**
  140674. * Set the alpha test sort comparison function.
  140675. * If null the sub meshes will be render in the order they were created
  140676. */
  140677. set: function (value) {
  140678. this._alphaTestSortCompareFn = value;
  140679. if (value) {
  140680. this._renderAlphaTest = this.renderAlphaTestSorted;
  140681. }
  140682. else {
  140683. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  140684. }
  140685. },
  140686. enumerable: true,
  140687. configurable: true
  140688. });
  140689. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  140690. /**
  140691. * Set the transparent sort comparison function.
  140692. * If null the sub meshes will be render in the order they were created
  140693. */
  140694. set: function (value) {
  140695. if (value) {
  140696. this._transparentSortCompareFn = value;
  140697. }
  140698. else {
  140699. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  140700. }
  140701. this._renderTransparent = this.renderTransparentSorted;
  140702. },
  140703. enumerable: true,
  140704. configurable: true
  140705. });
  140706. /**
  140707. * Render all the sub meshes contained in the group.
  140708. * @param customRenderFunction Used to override the default render behaviour of the group.
  140709. * @returns true if rendered some submeshes.
  140710. */
  140711. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  140712. if (customRenderFunction) {
  140713. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  140714. return;
  140715. }
  140716. var engine = this._scene.getEngine();
  140717. // Depth only
  140718. if (this._depthOnlySubMeshes.length !== 0) {
  140719. engine.setColorWrite(false);
  140720. this._renderAlphaTest(this._depthOnlySubMeshes);
  140721. engine.setColorWrite(true);
  140722. }
  140723. // Opaque
  140724. if (this._opaqueSubMeshes.length !== 0) {
  140725. this._renderOpaque(this._opaqueSubMeshes);
  140726. }
  140727. // Alpha test
  140728. if (this._alphaTestSubMeshes.length !== 0) {
  140729. this._renderAlphaTest(this._alphaTestSubMeshes);
  140730. }
  140731. var stencilState = engine.getStencilBuffer();
  140732. engine.setStencilBuffer(false);
  140733. // Sprites
  140734. if (renderSprites) {
  140735. this._renderSprites();
  140736. }
  140737. // Particles
  140738. if (renderParticles) {
  140739. this._renderParticles(activeMeshes);
  140740. }
  140741. if (this.onBeforeTransparentRendering) {
  140742. this.onBeforeTransparentRendering();
  140743. }
  140744. // Transparent
  140745. if (this._transparentSubMeshes.length !== 0) {
  140746. this._renderTransparent(this._transparentSubMeshes);
  140747. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  140748. }
  140749. // Set back stencil to false in case it changes before the edge renderer.
  140750. engine.setStencilBuffer(false);
  140751. // Edges
  140752. if (this._edgesRenderers.length) {
  140753. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  140754. this._edgesRenderers.data[edgesRendererIndex].render();
  140755. }
  140756. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  140757. }
  140758. // Restore Stencil state.
  140759. engine.setStencilBuffer(stencilState);
  140760. };
  140761. /**
  140762. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  140763. * @param subMeshes The submeshes to render
  140764. */
  140765. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  140766. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  140767. };
  140768. /**
  140769. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  140770. * @param subMeshes The submeshes to render
  140771. */
  140772. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  140773. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  140774. };
  140775. /**
  140776. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  140777. * @param subMeshes The submeshes to render
  140778. */
  140779. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  140780. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  140781. };
  140782. /**
  140783. * Renders the submeshes in a specified order.
  140784. * @param subMeshes The submeshes to sort before render
  140785. * @param sortCompareFn The comparison function use to sort
  140786. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  140787. * @param transparent Specifies to activate blending if true
  140788. */
  140789. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  140790. var subIndex = 0;
  140791. var subMesh;
  140792. var cameraPosition = camera ? camera.globalPosition : RenderingGroup._zeroVector;
  140793. for (; subIndex < subMeshes.length; subIndex++) {
  140794. subMesh = subMeshes.data[subIndex];
  140795. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  140796. subMesh._distanceToCamera = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(subMesh.getBoundingInfo().boundingSphere.centerWorld, cameraPosition);
  140797. }
  140798. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  140799. if (sortCompareFn) {
  140800. sortedArray.sort(sortCompareFn);
  140801. }
  140802. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  140803. subMesh = sortedArray[subIndex];
  140804. if (transparent) {
  140805. var material = subMesh.getMaterial();
  140806. if (material && material.needDepthPrePass) {
  140807. var engine = material.getScene().getEngine();
  140808. engine.setColorWrite(false);
  140809. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  140810. subMesh.render(false);
  140811. engine.setColorWrite(true);
  140812. }
  140813. }
  140814. subMesh.render(transparent);
  140815. }
  140816. };
  140817. /**
  140818. * Renders the submeshes in the order they were dispatched (no sort applied).
  140819. * @param subMeshes The submeshes to render
  140820. */
  140821. RenderingGroup.renderUnsorted = function (subMeshes) {
  140822. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  140823. var submesh = subMeshes.data[subIndex];
  140824. submesh.render(false);
  140825. }
  140826. };
  140827. /**
  140828. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  140829. * are rendered back to front if in the same alpha index.
  140830. *
  140831. * @param a The first submesh
  140832. * @param b The second submesh
  140833. * @returns The result of the comparison
  140834. */
  140835. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  140836. // Alpha index first
  140837. if (a._alphaIndex > b._alphaIndex) {
  140838. return 1;
  140839. }
  140840. if (a._alphaIndex < b._alphaIndex) {
  140841. return -1;
  140842. }
  140843. // Then distance to camera
  140844. return RenderingGroup.backToFrontSortCompare(a, b);
  140845. };
  140846. /**
  140847. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  140848. * are rendered back to front.
  140849. *
  140850. * @param a The first submesh
  140851. * @param b The second submesh
  140852. * @returns The result of the comparison
  140853. */
  140854. RenderingGroup.backToFrontSortCompare = function (a, b) {
  140855. // Then distance to camera
  140856. if (a._distanceToCamera < b._distanceToCamera) {
  140857. return 1;
  140858. }
  140859. if (a._distanceToCamera > b._distanceToCamera) {
  140860. return -1;
  140861. }
  140862. return 0;
  140863. };
  140864. /**
  140865. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  140866. * are rendered front to back (prevent overdraw).
  140867. *
  140868. * @param a The first submesh
  140869. * @param b The second submesh
  140870. * @returns The result of the comparison
  140871. */
  140872. RenderingGroup.frontToBackSortCompare = function (a, b) {
  140873. // Then distance to camera
  140874. if (a._distanceToCamera < b._distanceToCamera) {
  140875. return -1;
  140876. }
  140877. if (a._distanceToCamera > b._distanceToCamera) {
  140878. return 1;
  140879. }
  140880. return 0;
  140881. };
  140882. /**
  140883. * Resets the different lists of submeshes to prepare a new frame.
  140884. */
  140885. RenderingGroup.prototype.prepare = function () {
  140886. this._opaqueSubMeshes.reset();
  140887. this._transparentSubMeshes.reset();
  140888. this._alphaTestSubMeshes.reset();
  140889. this._depthOnlySubMeshes.reset();
  140890. this._particleSystems.reset();
  140891. this._spriteManagers.reset();
  140892. this._edgesRenderers.reset();
  140893. };
  140894. RenderingGroup.prototype.dispose = function () {
  140895. this._opaqueSubMeshes.dispose();
  140896. this._transparentSubMeshes.dispose();
  140897. this._alphaTestSubMeshes.dispose();
  140898. this._depthOnlySubMeshes.dispose();
  140899. this._particleSystems.dispose();
  140900. this._spriteManagers.dispose();
  140901. this._edgesRenderers.dispose();
  140902. };
  140903. /**
  140904. * Inserts the submesh in its correct queue depending on its material.
  140905. * @param subMesh The submesh to dispatch
  140906. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  140907. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  140908. */
  140909. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  140910. // Get mesh and materials if not provided
  140911. if (mesh === undefined) {
  140912. mesh = subMesh.getMesh();
  140913. }
  140914. if (material === undefined) {
  140915. material = subMesh.getMaterial();
  140916. }
  140917. if (material === null || material === undefined) {
  140918. return;
  140919. }
  140920. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  140921. this._transparentSubMeshes.push(subMesh);
  140922. }
  140923. else if (material.needAlphaTesting()) { // Alpha test
  140924. if (material.needDepthPrePass) {
  140925. this._depthOnlySubMeshes.push(subMesh);
  140926. }
  140927. this._alphaTestSubMeshes.push(subMesh);
  140928. }
  140929. else {
  140930. if (material.needDepthPrePass) {
  140931. this._depthOnlySubMeshes.push(subMesh);
  140932. }
  140933. this._opaqueSubMeshes.push(subMesh); // Opaque
  140934. }
  140935. mesh._renderingGroup = this;
  140936. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  140937. this._edgesRenderers.push(mesh._edgesRenderer);
  140938. }
  140939. };
  140940. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  140941. this._spriteManagers.push(spriteManager);
  140942. };
  140943. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  140944. this._particleSystems.push(particleSystem);
  140945. };
  140946. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  140947. if (this._particleSystems.length === 0) {
  140948. return;
  140949. }
  140950. // Particles
  140951. var activeCamera = this._scene.activeCamera;
  140952. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  140953. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  140954. var particleSystem = this._particleSystems.data[particleIndex];
  140955. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  140956. continue;
  140957. }
  140958. var emitter = particleSystem.emitter;
  140959. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  140960. this._scene._activeParticles.addCount(particleSystem.render(), false);
  140961. }
  140962. }
  140963. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  140964. };
  140965. RenderingGroup.prototype._renderSprites = function () {
  140966. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  140967. return;
  140968. }
  140969. // Sprites
  140970. var activeCamera = this._scene.activeCamera;
  140971. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  140972. for (var id = 0; id < this._spriteManagers.length; id++) {
  140973. var spriteManager = this._spriteManagers.data[id];
  140974. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  140975. spriteManager.render();
  140976. }
  140977. }
  140978. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  140979. };
  140980. RenderingGroup._zeroVector = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  140981. return RenderingGroup;
  140982. }());
  140983. /***/ }),
  140984. /***/ "./Rendering/renderingManager.ts":
  140985. /*!***************************************!*\
  140986. !*** ./Rendering/renderingManager.ts ***!
  140987. \***************************************/
  140988. /*! exports provided: RenderingGroupInfo, RenderingManager */
  140989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  140990. "use strict";
  140991. __webpack_require__.r(__webpack_exports__);
  140992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  140993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  140994. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  140995. /**
  140996. * This class is used by the onRenderingGroupObservable
  140997. */
  140998. var RenderingGroupInfo = /** @class */ (function () {
  140999. function RenderingGroupInfo() {
  141000. }
  141001. return RenderingGroupInfo;
  141002. }());
  141003. /**
  141004. * This is the manager responsible of all the rendering for meshes sprites and particles.
  141005. * It is enable to manage the different groups as well as the different necessary sort functions.
  141006. * This should not be used directly aside of the few static configurations
  141007. */
  141008. var RenderingManager = /** @class */ (function () {
  141009. /**
  141010. * Instantiates a new rendering group for a particular scene
  141011. * @param scene Defines the scene the groups belongs to
  141012. */
  141013. function RenderingManager(scene) {
  141014. /**
  141015. * @hidden
  141016. */
  141017. this._useSceneAutoClearSetup = false;
  141018. this._renderingGroups = new Array();
  141019. this._autoClearDepthStencil = {};
  141020. this._customOpaqueSortCompareFn = {};
  141021. this._customAlphaTestSortCompareFn = {};
  141022. this._customTransparentSortCompareFn = {};
  141023. this._renderingGroupInfo = new RenderingGroupInfo();
  141024. this._scene = scene;
  141025. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  141026. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  141027. }
  141028. }
  141029. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  141030. if (depth === void 0) { depth = true; }
  141031. if (stencil === void 0) { stencil = true; }
  141032. if (this._depthStencilBufferAlreadyCleaned) {
  141033. return;
  141034. }
  141035. this._scene.getEngine().clear(null, false, depth, stencil);
  141036. this._depthStencilBufferAlreadyCleaned = true;
  141037. };
  141038. /**
  141039. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  141040. * @hidden
  141041. */
  141042. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  141043. // Update the observable context (not null as it only goes away on dispose)
  141044. var info = this._renderingGroupInfo;
  141045. info.scene = this._scene;
  141046. info.camera = this._scene.activeCamera;
  141047. // Dispatch sprites
  141048. if (this._scene.spriteManagers && renderSprites) {
  141049. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  141050. var manager = this._scene.spriteManagers[index];
  141051. this.dispatchSprites(manager);
  141052. }
  141053. }
  141054. // Render
  141055. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  141056. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  141057. var renderingGroup = this._renderingGroups[index];
  141058. if (!renderingGroup) {
  141059. continue;
  141060. }
  141061. var renderingGroupMask = Math.pow(2, index);
  141062. info.renderingGroupId = index;
  141063. // Before Observable
  141064. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  141065. // Clear depth/stencil if needed
  141066. if (RenderingManager.AUTOCLEAR) {
  141067. var autoClear = this._useSceneAutoClearSetup ?
  141068. this._scene.getAutoClearDepthStencilSetup(index) :
  141069. this._autoClearDepthStencil[index];
  141070. if (autoClear && autoClear.autoClear) {
  141071. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  141072. }
  141073. }
  141074. // Render
  141075. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  141076. var step = _a[_i];
  141077. step.action(index);
  141078. }
  141079. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  141080. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  141081. var step = _c[_b];
  141082. step.action(index);
  141083. }
  141084. // After Observable
  141085. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  141086. }
  141087. };
  141088. /**
  141089. * Resets the different information of the group to prepare a new frame
  141090. * @hidden
  141091. */
  141092. RenderingManager.prototype.reset = function () {
  141093. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  141094. var renderingGroup = this._renderingGroups[index];
  141095. if (renderingGroup) {
  141096. renderingGroup.prepare();
  141097. }
  141098. }
  141099. };
  141100. /**
  141101. * Dispose and release the group and its associated resources.
  141102. * @hidden
  141103. */
  141104. RenderingManager.prototype.dispose = function () {
  141105. this.freeRenderingGroups();
  141106. this._renderingGroups.length = 0;
  141107. this._renderingGroupInfo = null;
  141108. };
  141109. /**
  141110. * Clear the info related to rendering groups preventing retention points during dispose.
  141111. */
  141112. RenderingManager.prototype.freeRenderingGroups = function () {
  141113. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  141114. var renderingGroup = this._renderingGroups[index];
  141115. if (renderingGroup) {
  141116. renderingGroup.dispose();
  141117. }
  141118. }
  141119. };
  141120. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  141121. if (this._renderingGroups[renderingGroupId] === undefined) {
  141122. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  141123. }
  141124. };
  141125. /**
  141126. * Add a sprite manager to the rendering manager in order to render it this frame.
  141127. * @param spriteManager Define the sprite manager to render
  141128. */
  141129. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  141130. var renderingGroupId = spriteManager.renderingGroupId || 0;
  141131. this._prepareRenderingGroup(renderingGroupId);
  141132. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  141133. };
  141134. /**
  141135. * Add a particle system to the rendering manager in order to render it this frame.
  141136. * @param particleSystem Define the particle system to render
  141137. */
  141138. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  141139. var renderingGroupId = particleSystem.renderingGroupId || 0;
  141140. this._prepareRenderingGroup(renderingGroupId);
  141141. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  141142. };
  141143. /**
  141144. * Add a submesh to the manager in order to render it this frame
  141145. * @param subMesh The submesh to dispatch
  141146. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  141147. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  141148. */
  141149. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  141150. if (mesh === undefined) {
  141151. mesh = subMesh.getMesh();
  141152. }
  141153. var renderingGroupId = mesh.renderingGroupId || 0;
  141154. this._prepareRenderingGroup(renderingGroupId);
  141155. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  141156. };
  141157. /**
  141158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  141159. * This allowed control for front to back rendering or reversly depending of the special needs.
  141160. *
  141161. * @param renderingGroupId The rendering group id corresponding to its index
  141162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  141163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  141164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  141165. */
  141166. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  141167. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  141168. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  141169. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  141170. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  141171. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  141172. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  141173. if (this._renderingGroups[renderingGroupId]) {
  141174. var group = this._renderingGroups[renderingGroupId];
  141175. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  141176. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  141177. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  141178. }
  141179. };
  141180. /**
  141181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  141182. *
  141183. * @param renderingGroupId The rendering group id corresponding to its index
  141184. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141185. * @param depth Automatically clears depth between groups if true and autoClear is true.
  141186. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  141187. */
  141188. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  141189. if (depth === void 0) { depth = true; }
  141190. if (stencil === void 0) { stencil = true; }
  141191. this._autoClearDepthStencil[renderingGroupId] = {
  141192. autoClear: autoClearDepthStencil,
  141193. depth: depth,
  141194. stencil: stencil
  141195. };
  141196. };
  141197. /**
  141198. * Gets the current auto clear configuration for one rendering group of the rendering
  141199. * manager.
  141200. * @param index the rendering group index to get the information for
  141201. * @returns The auto clear setup for the requested rendering group
  141202. */
  141203. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  141204. return this._autoClearDepthStencil[index];
  141205. };
  141206. /**
  141207. * The max id used for rendering groups (not included)
  141208. */
  141209. RenderingManager.MAX_RENDERINGGROUPS = 4;
  141210. /**
  141211. * The min id used for rendering groups (included)
  141212. */
  141213. RenderingManager.MIN_RENDERINGGROUPS = 0;
  141214. /**
  141215. * Used to globally prevent autoclearing scenes.
  141216. */
  141217. RenderingManager.AUTOCLEAR = true;
  141218. return RenderingManager;
  141219. }());
  141220. /***/ }),
  141221. /***/ "./Rendering/utilityLayerRenderer.ts":
  141222. /*!*******************************************!*\
  141223. !*** ./Rendering/utilityLayerRenderer.ts ***!
  141224. \*******************************************/
  141225. /*! exports provided: UtilityLayerRenderer */
  141226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141227. "use strict";
  141228. __webpack_require__.r(__webpack_exports__);
  141229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  141230. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  141231. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  141232. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  141233. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  141234. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  141235. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  141236. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  141237. /**
  141238. * Renders a layer on top of an existing scene
  141239. */
  141240. var UtilityLayerRenderer = /** @class */ (function () {
  141241. /**
  141242. * Instantiates a UtilityLayerRenderer
  141243. * @param originalScene the original scene that will be rendered on top of
  141244. * @param handleEvents boolean indicating if the utility layer should handle events
  141245. */
  141246. function UtilityLayerRenderer(
  141247. /** the original scene that will be rendered on top of */
  141248. originalScene, handleEvents) {
  141249. var _this = this;
  141250. if (handleEvents === void 0) { handleEvents = true; }
  141251. this.originalScene = originalScene;
  141252. this._pointerCaptures = {};
  141253. this._lastPointerEvents = {};
  141254. this._sharedGizmoLight = null;
  141255. this._renderCamera = null;
  141256. /**
  141257. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  141258. */
  141259. this.pickUtilitySceneFirst = true;
  141260. /**
  141261. * If the utility layer should automatically be rendered on top of existing scene
  141262. */
  141263. this.shouldRender = true;
  141264. /**
  141265. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  141266. */
  141267. this.onlyCheckPointerDownEvents = true;
  141268. /**
  141269. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  141270. */
  141271. this.processAllEvents = false;
  141272. /**
  141273. * Observable raised when the pointer move from the utility layer scene to the main scene
  141274. */
  141275. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  141276. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  141277. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine(), { virtual: true });
  141278. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  141279. this.utilityLayerScene._allowPostProcessClearColor = false;
  141280. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  141281. this.utilityLayerScene.detachControl();
  141282. if (handleEvents) {
  141283. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  141284. if (!_this.utilityLayerScene.activeCamera) {
  141285. return;
  141286. }
  141287. if (!_this.processAllEvents) {
  141288. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  141289. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  141290. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  141291. return;
  141292. }
  141293. }
  141294. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  141295. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  141296. var pointerEvent = (prePointerInfo.event);
  141297. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  141298. _this._pointerCaptures[pointerEvent.pointerId] = false;
  141299. return;
  141300. }
  141301. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  141302. if (!prePointerInfo.ray && utilityScenePick) {
  141303. prePointerInfo.ray = utilityScenePick.ray;
  141304. }
  141305. // always fire the prepointer oversvable
  141306. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  141307. // allow every non pointer down event to flow to the utility layer
  141308. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  141309. if (!prePointerInfo.skipOnPointerObservable) {
  141310. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  141311. }
  141312. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  141313. _this._pointerCaptures[pointerEvent.pointerId] = false;
  141314. }
  141315. return;
  141316. }
  141317. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  141318. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  141319. if (utilityScenePick && utilityScenePick.hit) {
  141320. if (!prePointerInfo.skipOnPointerObservable) {
  141321. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  141322. }
  141323. prePointerInfo.skipOnPointerObservable = true;
  141324. }
  141325. }
  141326. else {
  141327. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  141328. var pointerEvent_1 = (prePointerInfo.event);
  141329. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  141330. if (originalScenePick && utilityScenePick) {
  141331. // No pick in utility scene
  141332. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  141333. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  141334. // We touched an utility mesh present in the main scene
  141335. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  141336. prePointerInfo.skipOnPointerObservable = true;
  141337. }
  141338. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  141339. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  141340. }
  141341. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  141342. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  141343. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  141344. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  141345. }
  141346. }
  141347. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  141348. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  141349. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  141350. // If a previous utility layer set this, do not unset this
  141351. if (!prePointerInfo.skipOnPointerObservable) {
  141352. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  141353. }
  141354. }
  141355. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  141356. // We have a pick in both scenes but main is closer than utility
  141357. // We touched an utility mesh present in the main scene
  141358. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  141359. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  141360. prePointerInfo.skipOnPointerObservable = true;
  141361. }
  141362. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  141363. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  141364. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  141365. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  141366. }
  141367. }
  141368. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  141369. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  141370. }
  141371. }
  141372. }
  141373. });
  141374. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  141375. if (this._originalPointerObserver) {
  141376. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  141377. }
  141378. }
  141379. // Render directly on top of existing scene without clearing
  141380. this.utilityLayerScene.autoClear = false;
  141381. this._afterRenderObserver = this.originalScene.onAfterCameraRenderObservable.add(function (camera) {
  141382. // Only render when the render camera finishes rendering
  141383. if (_this.shouldRender && camera == _this.getRenderCamera()) {
  141384. _this.render();
  141385. }
  141386. });
  141387. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  141388. _this.dispose();
  141389. });
  141390. this._updateCamera();
  141391. }
  141392. /**
  141393. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  141394. * @returns the camera that is used when rendering the utility layer
  141395. */
  141396. UtilityLayerRenderer.prototype.getRenderCamera = function () {
  141397. if (this._renderCamera) {
  141398. return this._renderCamera;
  141399. }
  141400. else if (this.originalScene.activeCameras.length > 1) {
  141401. return this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  141402. }
  141403. else {
  141404. return this.originalScene.activeCamera;
  141405. }
  141406. };
  141407. /**
  141408. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  141409. * @param cam the camera that should be used when rendering the utility layer
  141410. */
  141411. UtilityLayerRenderer.prototype.setRenderCamera = function (cam) {
  141412. this._renderCamera = cam;
  141413. };
  141414. /**
  141415. * @hidden
  141416. * Light which used by gizmos to get light shading
  141417. */
  141418. UtilityLayerRenderer.prototype._getSharedGizmoLight = function () {
  141419. if (!this._sharedGizmoLight) {
  141420. this._sharedGizmoLight = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]("shared gizmo light", new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 1, 0), this.utilityLayerScene);
  141421. this._sharedGizmoLight.intensity = 2;
  141422. this._sharedGizmoLight.groundColor = _Maths_math_color__WEBPACK_IMPORTED_MODULE_6__["Color3"].Gray();
  141423. }
  141424. return this._sharedGizmoLight;
  141425. };
  141426. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  141427. /**
  141428. * 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)
  141429. */
  141430. get: function () {
  141431. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  141432. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  141433. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  141434. UtilityLayerRenderer._DefaultUtilityLayer = null;
  141435. });
  141436. }
  141437. return UtilityLayerRenderer._DefaultUtilityLayer;
  141438. },
  141439. enumerable: true,
  141440. configurable: true
  141441. });
  141442. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  141443. /**
  141444. * 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)
  141445. */
  141446. get: function () {
  141447. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  141448. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  141449. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  141450. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  141451. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  141452. });
  141453. }
  141454. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  141455. },
  141456. enumerable: true,
  141457. configurable: true
  141458. });
  141459. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  141460. if (!prePointerInfo.skipOnPointerObservable) {
  141461. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  141462. this._lastPointerEvents[pointerEvent.pointerId] = true;
  141463. }
  141464. };
  141465. /**
  141466. * Renders the utility layers scene on top of the original scene
  141467. */
  141468. UtilityLayerRenderer.prototype.render = function () {
  141469. this._updateCamera();
  141470. if (this.utilityLayerScene.activeCamera) {
  141471. // Set the camera's scene to utility layers scene
  141472. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  141473. var camera = this.utilityLayerScene.activeCamera;
  141474. camera._scene = this.utilityLayerScene;
  141475. if (camera.leftCamera) {
  141476. camera.leftCamera._scene = this.utilityLayerScene;
  141477. }
  141478. if (camera.rightCamera) {
  141479. camera.rightCamera._scene = this.utilityLayerScene;
  141480. }
  141481. this.utilityLayerScene.render(false);
  141482. // Reset camera's scene back to original
  141483. camera._scene = oldScene;
  141484. if (camera.leftCamera) {
  141485. camera.leftCamera._scene = oldScene;
  141486. }
  141487. if (camera.rightCamera) {
  141488. camera.rightCamera._scene = oldScene;
  141489. }
  141490. }
  141491. };
  141492. /**
  141493. * Disposes of the renderer
  141494. */
  141495. UtilityLayerRenderer.prototype.dispose = function () {
  141496. this.onPointerOutObservable.clear();
  141497. if (this._afterRenderObserver) {
  141498. this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver);
  141499. }
  141500. if (this._sceneDisposeObserver) {
  141501. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  141502. }
  141503. if (this._originalPointerObserver) {
  141504. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  141505. }
  141506. this.utilityLayerScene.dispose();
  141507. };
  141508. UtilityLayerRenderer.prototype._updateCamera = function () {
  141509. this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera();
  141510. this.utilityLayerScene.activeCamera = this.getRenderCamera();
  141511. };
  141512. UtilityLayerRenderer._DefaultUtilityLayer = null;
  141513. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  141514. return UtilityLayerRenderer;
  141515. }());
  141516. /***/ }),
  141517. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  141518. /*!*****************************************************************!*\
  141519. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  141520. \*****************************************************************/
  141521. /*! exports provided: backgroundFragmentDeclaration */
  141522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141523. "use strict";
  141524. __webpack_require__.r(__webpack_exports__);
  141525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  141526. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141527. var name = 'backgroundFragmentDeclaration';
  141528. 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";
  141529. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141530. /** @hidden */
  141531. var backgroundFragmentDeclaration = { name: name, shader: shader };
  141532. /***/ }),
  141533. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  141534. /*!************************************************************!*\
  141535. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  141536. \************************************************************/
  141537. /*! exports provided: backgroundUboDeclaration */
  141538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141539. "use strict";
  141540. __webpack_require__.r(__webpack_exports__);
  141541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  141542. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141543. var name = 'backgroundUboDeclaration';
  141544. 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};";
  141545. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141546. /** @hidden */
  141547. var backgroundUboDeclaration = { name: name, shader: shader };
  141548. /***/ }),
  141549. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  141550. /*!***************************************************************!*\
  141551. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  141552. \***************************************************************/
  141553. /*! exports provided: backgroundVertexDeclaration */
  141554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141555. "use strict";
  141556. __webpack_require__.r(__webpack_exports__);
  141557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  141558. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141559. var name = 'backgroundVertexDeclaration';
  141560. 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";
  141561. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141562. /** @hidden */
  141563. var backgroundVertexDeclaration = { name: name, shader: shader };
  141564. /***/ }),
  141565. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  141566. /*!****************************************************!*\
  141567. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  141568. \****************************************************/
  141569. /*! exports provided: bonesDeclaration */
  141570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141571. "use strict";
  141572. __webpack_require__.r(__webpack_exports__);
  141573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  141574. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141575. var name = 'bonesDeclaration';
  141576. 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";
  141577. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141578. /** @hidden */
  141579. var bonesDeclaration = { name: name, shader: shader };
  141580. /***/ }),
  141581. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  141582. /*!***********************************************!*\
  141583. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  141584. \***********************************************/
  141585. /*! exports provided: bonesVertex */
  141586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141587. "use strict";
  141588. __webpack_require__.r(__webpack_exports__);
  141589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  141590. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141591. var name = 'bonesVertex';
  141592. 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";
  141593. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141594. /** @hidden */
  141595. var bonesVertex = { name: name, shader: shader };
  141596. /***/ }),
  141597. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  141598. /*!************************************************!*\
  141599. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  141600. \************************************************/
  141601. /*! exports provided: bumpFragment */
  141602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141603. "use strict";
  141604. __webpack_require__.r(__webpack_exports__);
  141605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  141606. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141607. var name = 'bumpFragment';
  141608. 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";
  141609. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141610. /** @hidden */
  141611. var bumpFragment = { name: name, shader: shader };
  141612. /***/ }),
  141613. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  141614. /*!*********************************************************!*\
  141615. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  141616. \*********************************************************/
  141617. /*! exports provided: bumpFragmentFunctions */
  141618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141619. "use strict";
  141620. __webpack_require__.r(__webpack_exports__);
  141621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  141622. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141623. var name = 'bumpFragmentFunctions';
  141624. 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";
  141625. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141626. /** @hidden */
  141627. var bumpFragmentFunctions = { name: name, shader: shader };
  141628. /***/ }),
  141629. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  141630. /*!**********************************************!*\
  141631. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  141632. \**********************************************/
  141633. /*! exports provided: bumpVertex */
  141634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141635. "use strict";
  141636. __webpack_require__.r(__webpack_exports__);
  141637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  141638. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141639. var name = 'bumpVertex';
  141640. 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";
  141641. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141642. /** @hidden */
  141643. var bumpVertex = { name: name, shader: shader };
  141644. /***/ }),
  141645. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  141646. /*!*********************************************************!*\
  141647. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  141648. \*********************************************************/
  141649. /*! exports provided: bumpVertexDeclaration */
  141650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141651. "use strict";
  141652. __webpack_require__.r(__webpack_exports__);
  141653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  141654. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141655. var name = 'bumpVertexDeclaration';
  141656. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  141657. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141658. /** @hidden */
  141659. var bumpVertexDeclaration = { name: name, shader: shader };
  141660. /***/ }),
  141661. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  141662. /*!*****************************************************!*\
  141663. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  141664. \*****************************************************/
  141665. /*! exports provided: clipPlaneFragment */
  141666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141667. "use strict";
  141668. __webpack_require__.r(__webpack_exports__);
  141669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  141670. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141671. var name = 'clipPlaneFragment';
  141672. 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";
  141673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141674. /** @hidden */
  141675. var clipPlaneFragment = { name: name, shader: shader };
  141676. /***/ }),
  141677. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  141678. /*!****************************************************************!*\
  141679. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  141680. \****************************************************************/
  141681. /*! exports provided: clipPlaneFragmentDeclaration */
  141682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141683. "use strict";
  141684. __webpack_require__.r(__webpack_exports__);
  141685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  141686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141687. var name = 'clipPlaneFragmentDeclaration';
  141688. 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";
  141689. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141690. /** @hidden */
  141691. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  141692. /***/ }),
  141693. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  141694. /*!*****************************************************************!*\
  141695. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  141696. \*****************************************************************/
  141697. /*! exports provided: clipPlaneFragmentDeclaration2 */
  141698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141699. "use strict";
  141700. __webpack_require__.r(__webpack_exports__);
  141701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  141702. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141703. var name = 'clipPlaneFragmentDeclaration2';
  141704. 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";
  141705. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141706. /** @hidden */
  141707. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  141708. /***/ }),
  141709. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  141710. /*!***************************************************!*\
  141711. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  141712. \***************************************************/
  141713. /*! exports provided: clipPlaneVertex */
  141714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141715. "use strict";
  141716. __webpack_require__.r(__webpack_exports__);
  141717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  141718. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141719. var name = 'clipPlaneVertex';
  141720. 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";
  141721. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141722. /** @hidden */
  141723. var clipPlaneVertex = { name: name, shader: shader };
  141724. /***/ }),
  141725. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  141726. /*!**************************************************************!*\
  141727. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  141728. \**************************************************************/
  141729. /*! exports provided: clipPlaneVertexDeclaration */
  141730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141731. "use strict";
  141732. __webpack_require__.r(__webpack_exports__);
  141733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  141734. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141735. var name = 'clipPlaneVertexDeclaration';
  141736. 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";
  141737. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141738. /** @hidden */
  141739. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  141740. /***/ }),
  141741. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  141742. /*!***************************************************************!*\
  141743. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  141744. \***************************************************************/
  141745. /*! exports provided: clipPlaneVertexDeclaration2 */
  141746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141747. "use strict";
  141748. __webpack_require__.r(__webpack_exports__);
  141749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  141750. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141751. var name = 'clipPlaneVertexDeclaration2';
  141752. 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";
  141753. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141754. /** @hidden */
  141755. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  141756. /***/ }),
  141757. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  141758. /*!**************************************************************!*\
  141759. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  141760. \**************************************************************/
  141761. /*! exports provided: defaultFragmentDeclaration */
  141762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141763. "use strict";
  141764. __webpack_require__.r(__webpack_exports__);
  141765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  141766. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141767. var name = 'defaultFragmentDeclaration';
  141768. 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#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\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";
  141769. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141770. /** @hidden */
  141771. var defaultFragmentDeclaration = { name: name, shader: shader };
  141772. /***/ }),
  141773. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  141774. /*!*********************************************************!*\
  141775. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  141776. \*********************************************************/
  141777. /*! exports provided: defaultUboDeclaration */
  141778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141779. "use strict";
  141780. __webpack_require__.r(__webpack_exports__);
  141781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  141782. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141783. var name = 'defaultUboDeclaration';
  141784. 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";
  141785. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141786. /** @hidden */
  141787. var defaultUboDeclaration = { name: name, shader: shader };
  141788. /***/ }),
  141789. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  141790. /*!************************************************************!*\
  141791. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  141792. \************************************************************/
  141793. /*! exports provided: defaultVertexDeclaration */
  141794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141795. "use strict";
  141796. __webpack_require__.r(__webpack_exports__);
  141797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  141798. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141799. var name = 'defaultVertexDeclaration';
  141800. 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";
  141801. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141802. /** @hidden */
  141803. var defaultVertexDeclaration = { name: name, shader: shader };
  141804. /***/ }),
  141805. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  141806. /*!************************************************!*\
  141807. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  141808. \************************************************/
  141809. /*! exports provided: depthPrePass */
  141810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141811. "use strict";
  141812. __webpack_require__.r(__webpack_exports__);
  141813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  141814. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141815. var name = 'depthPrePass';
  141816. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  141817. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141818. /** @hidden */
  141819. var depthPrePass = { name: name, shader: shader };
  141820. /***/ }),
  141821. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  141822. /*!***********************************************!*\
  141823. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  141824. \***********************************************/
  141825. /*! exports provided: fogFragment */
  141826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141827. "use strict";
  141828. __webpack_require__.r(__webpack_exports__);
  141829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  141830. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141831. var name = 'fogFragment';
  141832. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  141833. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141834. /** @hidden */
  141835. var fogFragment = { name: name, shader: shader };
  141836. /***/ }),
  141837. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  141838. /*!**********************************************************!*\
  141839. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  141840. \**********************************************************/
  141841. /*! exports provided: fogFragmentDeclaration */
  141842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141843. "use strict";
  141844. __webpack_require__.r(__webpack_exports__);
  141845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  141846. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141847. var name = 'fogFragmentDeclaration';
  141848. 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";
  141849. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141850. /** @hidden */
  141851. var fogFragmentDeclaration = { name: name, shader: shader };
  141852. /***/ }),
  141853. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  141854. /*!*********************************************!*\
  141855. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  141856. \*********************************************/
  141857. /*! exports provided: fogVertex */
  141858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141859. "use strict";
  141860. __webpack_require__.r(__webpack_exports__);
  141861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  141862. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141863. var name = 'fogVertex';
  141864. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  141865. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141866. /** @hidden */
  141867. var fogVertex = { name: name, shader: shader };
  141868. /***/ }),
  141869. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  141870. /*!********************************************************!*\
  141871. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  141872. \********************************************************/
  141873. /*! exports provided: fogVertexDeclaration */
  141874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141875. "use strict";
  141876. __webpack_require__.r(__webpack_exports__);
  141877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  141878. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141879. var name = 'fogVertexDeclaration';
  141880. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  141881. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141882. /** @hidden */
  141883. var fogVertexDeclaration = { name: name, shader: shader };
  141884. /***/ }),
  141885. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  141886. /*!***************************************************!*\
  141887. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  141888. \***************************************************/
  141889. /*! exports provided: fresnelFunction */
  141890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141891. "use strict";
  141892. __webpack_require__.r(__webpack_exports__);
  141893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  141894. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141895. var name = 'fresnelFunction';
  141896. 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";
  141897. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141898. /** @hidden */
  141899. var fresnelFunction = { name: name, shader: shader };
  141900. /***/ }),
  141901. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  141902. /*!******************************************************!*\
  141903. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  141904. \******************************************************/
  141905. /*! exports provided: harmonicsFunctions */
  141906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141907. "use strict";
  141908. __webpack_require__.r(__webpack_exports__);
  141909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  141910. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141911. var name = 'harmonicsFunctions';
  141912. var shader = "#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n\n\n\n\n\n\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+vSphericalL1_1*(normal.y)\n+vSphericalL10*(normal.z)\n+vSphericalL11*(normal.x)\n+vSphericalL2_2*(normal.y*normal.x)\n+vSphericalL2_1*(normal.y*normal.z)\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+vSphericalL21*(normal.z*normal.x)\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\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;\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\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\n#endif";
  141913. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141914. /** @hidden */
  141915. var harmonicsFunctions = { name: name, shader: shader };
  141916. /***/ }),
  141917. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  141918. /*!***************************************************!*\
  141919. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  141920. \***************************************************/
  141921. /*! exports provided: helperFunctions */
  141922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141923. "use strict";
  141924. __webpack_require__.r(__webpack_exports__);
  141925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  141926. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141927. var name = 'helperFunctions';
  141928. 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}";
  141929. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141930. /** @hidden */
  141931. var helperFunctions = { name: name, shader: shader };
  141932. /***/ }),
  141933. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  141934. /*!**************************************************************!*\
  141935. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  141936. \**************************************************************/
  141937. /*! exports provided: imageProcessingDeclaration */
  141938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141939. "use strict";
  141940. __webpack_require__.r(__webpack_exports__);
  141941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  141942. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141943. var name = 'imageProcessingDeclaration';
  141944. 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";
  141945. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141946. /** @hidden */
  141947. var imageProcessingDeclaration = { name: name, shader: shader };
  141948. /***/ }),
  141949. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  141950. /*!************************************************************!*\
  141951. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  141952. \************************************************************/
  141953. /*! exports provided: imageProcessingFunctions */
  141954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141955. "use strict";
  141956. __webpack_require__.r(__webpack_exports__);
  141957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  141958. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141959. var name = 'imageProcessingFunctions';
  141960. 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}";
  141961. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141962. /** @hidden */
  141963. var imageProcessingFunctions = { name: name, shader: shader };
  141964. /***/ }),
  141965. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  141966. /*!********************************************************!*\
  141967. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  141968. \********************************************************/
  141969. /*! exports provided: instancesDeclaration */
  141970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141971. "use strict";
  141972. __webpack_require__.r(__webpack_exports__);
  141973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  141974. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141975. var name = 'instancesDeclaration';
  141976. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  141977. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141978. /** @hidden */
  141979. var instancesDeclaration = { name: name, shader: shader };
  141980. /***/ }),
  141981. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  141982. /*!***************************************************!*\
  141983. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  141984. \***************************************************/
  141985. /*! exports provided: instancesVertex */
  141986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141987. "use strict";
  141988. __webpack_require__.r(__webpack_exports__);
  141989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  141990. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  141991. var name = 'instancesVertex';
  141992. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  141993. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  141994. /** @hidden */
  141995. var instancesVertex = { name: name, shader: shader };
  141996. /***/ }),
  141997. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  141998. /*!******************************************************!*\
  141999. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  142000. \******************************************************/
  142001. /*! exports provided: kernelBlurFragment */
  142002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142003. "use strict";
  142004. __webpack_require__.r(__webpack_exports__);
  142005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  142006. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142007. var name = 'kernelBlurFragment';
  142008. 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";
  142009. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142010. /** @hidden */
  142011. var kernelBlurFragment = { name: name, shader: shader };
  142012. /***/ }),
  142013. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  142014. /*!*******************************************************!*\
  142015. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  142016. \*******************************************************/
  142017. /*! exports provided: kernelBlurFragment2 */
  142018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142019. "use strict";
  142020. __webpack_require__.r(__webpack_exports__);
  142021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  142022. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142023. var name = 'kernelBlurFragment2';
  142024. 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";
  142025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142026. /** @hidden */
  142027. var kernelBlurFragment2 = { name: name, shader: shader };
  142028. /***/ }),
  142029. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  142030. /*!****************************************************************!*\
  142031. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  142032. \****************************************************************/
  142033. /*! exports provided: kernelBlurVaryingDeclaration */
  142034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142035. "use strict";
  142036. __webpack_require__.r(__webpack_exports__);
  142037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  142038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142039. var name = 'kernelBlurVaryingDeclaration';
  142040. var shader = "varying vec2 sampleCoord{X};";
  142041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142042. /** @hidden */
  142043. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  142044. /***/ }),
  142045. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  142046. /*!****************************************************!*\
  142047. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  142048. \****************************************************/
  142049. /*! exports provided: kernelBlurVertex */
  142050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142051. "use strict";
  142052. __webpack_require__.r(__webpack_exports__);
  142053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  142054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142055. var name = 'kernelBlurVertex';
  142056. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  142057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142058. /** @hidden */
  142059. var kernelBlurVertex = { name: name, shader: shader };
  142060. /***/ }),
  142061. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  142062. /*!*************************************************!*\
  142063. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  142064. \*************************************************/
  142065. /*! exports provided: lightFragment */
  142066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142067. "use strict";
  142068. __webpack_require__.r(__webpack_exports__);
  142069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  142070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142071. var name = 'lightFragment';
  142072. 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";
  142073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142074. /** @hidden */
  142075. var lightFragment = { name: name, shader: shader };
  142076. /***/ }),
  142077. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  142078. /*!************************************************************!*\
  142079. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  142080. \************************************************************/
  142081. /*! exports provided: lightFragmentDeclaration */
  142082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142083. "use strict";
  142084. __webpack_require__.r(__webpack_exports__);
  142085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  142086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142087. var name = 'lightFragmentDeclaration';
  142088. 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";
  142089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142090. /** @hidden */
  142091. var lightFragmentDeclaration = { name: name, shader: shader };
  142092. /***/ }),
  142093. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  142094. /*!*******************************************************!*\
  142095. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  142096. \*******************************************************/
  142097. /*! exports provided: lightUboDeclaration */
  142098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142099. "use strict";
  142100. __webpack_require__.r(__webpack_exports__);
  142101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  142102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142103. var name = 'lightUboDeclaration';
  142104. 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";
  142105. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142106. /** @hidden */
  142107. var lightUboDeclaration = { name: name, shader: shader };
  142108. /***/ }),
  142109. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  142110. /*!***********************************************************!*\
  142111. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  142112. \***********************************************************/
  142113. /*! exports provided: lightsFragmentFunctions */
  142114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142115. "use strict";
  142116. __webpack_require__.r(__webpack_exports__);
  142117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  142118. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142119. var name = 'lightsFragmentFunctions';
  142120. 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}";
  142121. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142122. /** @hidden */
  142123. var lightsFragmentFunctions = { name: name, shader: shader };
  142124. /***/ }),
  142125. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  142126. /*!*******************************************************!*\
  142127. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  142128. \*******************************************************/
  142129. /*! exports provided: logDepthDeclaration */
  142130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142131. "use strict";
  142132. __webpack_require__.r(__webpack_exports__);
  142133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  142134. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142135. var name = 'logDepthDeclaration';
  142136. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  142137. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142138. /** @hidden */
  142139. var logDepthDeclaration = { name: name, shader: shader };
  142140. /***/ }),
  142141. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  142142. /*!****************************************************!*\
  142143. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  142144. \****************************************************/
  142145. /*! exports provided: logDepthFragment */
  142146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142147. "use strict";
  142148. __webpack_require__.r(__webpack_exports__);
  142149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  142150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142151. var name = 'logDepthFragment';
  142152. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  142153. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142154. /** @hidden */
  142155. var logDepthFragment = { name: name, shader: shader };
  142156. /***/ }),
  142157. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  142158. /*!**************************************************!*\
  142159. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  142160. \**************************************************/
  142161. /*! exports provided: logDepthVertex */
  142162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142163. "use strict";
  142164. __webpack_require__.r(__webpack_exports__);
  142165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  142166. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142167. var name = 'logDepthVertex';
  142168. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  142169. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142170. /** @hidden */
  142171. var logDepthVertex = { name: name, shader: shader };
  142172. /***/ }),
  142173. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  142174. /*!******************************************************!*\
  142175. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  142176. \******************************************************/
  142177. /*! exports provided: morphTargetsVertex */
  142178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142179. "use strict";
  142180. __webpack_require__.r(__webpack_exports__);
  142181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  142182. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142183. var name = 'morphTargetsVertex';
  142184. 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#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif";
  142185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142186. /** @hidden */
  142187. var morphTargetsVertex = { name: name, shader: shader };
  142188. /***/ }),
  142189. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  142190. /*!*****************************************************************!*\
  142191. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  142192. \*****************************************************************/
  142193. /*! exports provided: morphTargetsVertexDeclaration */
  142194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142195. "use strict";
  142196. __webpack_require__.r(__webpack_exports__);
  142197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  142198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142199. var name = 'morphTargetsVertexDeclaration';
  142200. 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#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#endif";
  142201. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142202. /** @hidden */
  142203. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  142204. /***/ }),
  142205. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  142206. /*!***********************************************************************!*\
  142207. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  142208. \***********************************************************************/
  142209. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  142210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142211. "use strict";
  142212. __webpack_require__.r(__webpack_exports__);
  142213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  142214. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142215. var name = 'morphTargetsVertexGlobalDeclaration';
  142216. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  142217. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142218. /** @hidden */
  142219. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  142220. /***/ }),
  142221. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  142222. /*!**********************************************************!*\
  142223. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  142224. \**********************************************************/
  142225. /*! exports provided: mrtFragmentDeclaration */
  142226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142227. "use strict";
  142228. __webpack_require__.r(__webpack_exports__);
  142229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  142230. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142231. var name = 'mrtFragmentDeclaration';
  142232. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  142233. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142234. /** @hidden */
  142235. var mrtFragmentDeclaration = { name: name, shader: shader };
  142236. /***/ }),
  142237. /***/ "./Shaders/ShadersInclude/packingFunctions.ts":
  142238. /*!****************************************************!*\
  142239. !*** ./Shaders/ShadersInclude/packingFunctions.ts ***!
  142240. \****************************************************/
  142241. /*! exports provided: packingFunctions */
  142242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142243. "use strict";
  142244. __webpack_require__.r(__webpack_exports__);
  142245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "packingFunctions", function() { return packingFunctions; });
  142246. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142247. var name = 'packingFunctions';
  142248. var shader = "vec4 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}";
  142249. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142250. /** @hidden */
  142251. var packingFunctions = { name: name, shader: shader };
  142252. /***/ }),
  142253. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  142254. /*!****************************************************!*\
  142255. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  142256. \****************************************************/
  142257. /*! exports provided: pbrBRDFFunctions */
  142258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142259. "use strict";
  142260. __webpack_require__.r(__webpack_exports__);
  142261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  142262. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142263. var name = 'pbrBRDFFunctions';
  142264. 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";
  142265. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142266. /** @hidden */
  142267. var pbrBRDFFunctions = { name: name, shader: shader };
  142268. /***/ }),
  142269. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  142270. /*!********************************************!*\
  142271. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  142272. \********************************************/
  142273. /*! exports provided: pbrDebug */
  142274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142275. "use strict";
  142276. __webpack_require__.r(__webpack_exports__);
  142277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  142278. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142279. var name = 'pbrDebug';
  142280. 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=vec3(clearCoatMapData.rg,0.0);\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 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=vec3(metallicRoughness.r);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 65\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 68 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=transmittance;\n#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=refractionTransmittance;\n\n#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 86 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 87\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";
  142281. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142282. /** @hidden */
  142283. var pbrDebug = { name: name, shader: shader };
  142284. /***/ }),
  142285. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  142286. /*!*********************************************************************!*\
  142287. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  142288. \*********************************************************************/
  142289. /*! exports provided: pbrDirectLightingFalloffFunctions */
  142290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142291. "use strict";
  142292. __webpack_require__.r(__webpack_exports__);
  142293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  142294. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142295. var name = 'pbrDirectLightingFalloffFunctions';
  142296. 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}";
  142297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142298. /** @hidden */
  142299. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  142300. /***/ }),
  142301. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  142302. /*!**************************************************************!*\
  142303. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  142304. \**************************************************************/
  142305. /*! exports provided: pbrDirectLightingFunctions */
  142306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142307. "use strict";
  142308. __webpack_require__.r(__webpack_exports__);
  142309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  142310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142311. var name = 'pbrDirectLightingFunctions';
  142312. 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";
  142313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142314. /** @hidden */
  142315. var pbrDirectLightingFunctions = { name: name, shader: shader };
  142316. /***/ }),
  142317. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  142318. /*!*******************************************************************!*\
  142319. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  142320. \*******************************************************************/
  142321. /*! exports provided: pbrDirectLightingSetupFunctions */
  142322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142323. "use strict";
  142324. __webpack_require__.r(__webpack_exports__);
  142325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  142326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142327. var name = 'pbrDirectLightingSetupFunctions';
  142328. 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}";
  142329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142330. /** @hidden */
  142331. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  142332. /***/ }),
  142333. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  142334. /*!**********************************************************!*\
  142335. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  142336. \**********************************************************/
  142337. /*! exports provided: pbrFragmentDeclaration */
  142338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142339. "use strict";
  142340. __webpack_require__.r(__webpack_exports__);
  142341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  142342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142343. var name = 'pbrFragmentDeclaration';
  142344. 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";
  142345. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142346. /** @hidden */
  142347. var pbrFragmentDeclaration = { name: name, shader: shader };
  142348. /***/ }),
  142349. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  142350. /*!***************************************************************!*\
  142351. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  142352. \***************************************************************/
  142353. /*! exports provided: pbrFragmentExtraDeclaration */
  142354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142355. "use strict";
  142356. __webpack_require__.r(__webpack_exports__);
  142357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  142358. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142359. var name = 'pbrFragmentExtraDeclaration';
  142360. 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";
  142361. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142362. /** @hidden */
  142363. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  142364. /***/ }),
  142365. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  142366. /*!******************************************************************!*\
  142367. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  142368. \******************************************************************/
  142369. /*! exports provided: pbrFragmentSamplersDeclaration */
  142370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142371. "use strict";
  142372. __webpack_require__.r(__webpack_exports__);
  142373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  142374. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142375. var name = 'pbrFragmentSamplersDeclaration';
  142376. 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#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\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 sampler2D reflectionSamplerLow;\nuniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\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";
  142377. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142378. /** @hidden */
  142379. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  142380. /***/ }),
  142381. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  142382. /*!******************************************************!*\
  142383. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  142384. \******************************************************/
  142385. /*! exports provided: pbrHelperFunctions */
  142386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142387. "use strict";
  142388. __webpack_require__.r(__webpack_exports__);
  142389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  142390. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142391. var name = 'pbrHelperFunctions';
  142392. 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";
  142393. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142394. /** @hidden */
  142395. var pbrHelperFunctions = { name: name, shader: shader };
  142396. /***/ }),
  142397. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  142398. /*!***************************************************!*\
  142399. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  142400. \***************************************************/
  142401. /*! exports provided: pbrIBLFunctions */
  142402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142403. "use strict";
  142404. __webpack_require__.r(__webpack_exports__);
  142405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  142406. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142407. var name = 'pbrIBLFunctions';
  142408. var shader = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\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";
  142409. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142410. /** @hidden */
  142411. var pbrIBLFunctions = { name: name, shader: shader };
  142412. /***/ }),
  142413. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  142414. /*!*****************************************************!*\
  142415. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  142416. \*****************************************************/
  142417. /*! exports provided: pbrUboDeclaration */
  142418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142419. "use strict";
  142420. __webpack_require__.r(__webpack_exports__);
  142421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  142422. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142423. var name = 'pbrUboDeclaration';
  142424. 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};";
  142425. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142426. /** @hidden */
  142427. var pbrUboDeclaration = { name: name, shader: shader };
  142428. /***/ }),
  142429. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  142430. /*!********************************************************!*\
  142431. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  142432. \********************************************************/
  142433. /*! exports provided: pbrVertexDeclaration */
  142434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142435. "use strict";
  142436. __webpack_require__.r(__webpack_exports__);
  142437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  142438. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142439. var name = 'pbrVertexDeclaration';
  142440. 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";
  142441. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142442. /** @hidden */
  142443. var pbrVertexDeclaration = { name: name, shader: shader };
  142444. /***/ }),
  142445. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  142446. /*!****************************************************!*\
  142447. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  142448. \****************************************************/
  142449. /*! exports provided: pointCloudVertex */
  142450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142451. "use strict";
  142452. __webpack_require__.r(__webpack_exports__);
  142453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  142454. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142455. var name = 'pointCloudVertex';
  142456. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  142457. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142458. /** @hidden */
  142459. var pointCloudVertex = { name: name, shader: shader };
  142460. /***/ }),
  142461. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  142462. /*!******************************************************!*\
  142463. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  142464. \******************************************************/
  142465. /*! exports provided: reflectionFunction */
  142466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142467. "use strict";
  142468. __webpack_require__.r(__webpack_exports__);
  142469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  142470. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142471. var name = 'reflectionFunction';
  142472. 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));\nr=vec3(reflectionMatrix*vec4(r,0));\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=vec3(reflectionMatrix*vec4(r,0));\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 vec3(reflectionMatrix*vec4(vPositionUVW,0));\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  142473. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142474. /** @hidden */
  142475. var reflectionFunction = { name: name, shader: shader };
  142476. /***/ }),
  142477. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  142478. /*!************************************************************!*\
  142479. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  142480. \************************************************************/
  142481. /*! exports provided: shadowsFragmentFunctions */
  142482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142483. "use strict";
  142484. __webpack_require__.r(__webpack_exports__);
  142485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  142486. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142487. var name = 'shadowsFragmentFunctions';
  142488. var shader = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\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\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";
  142489. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142490. /** @hidden */
  142491. var shadowsFragmentFunctions = { name: name, shader: shader };
  142492. /***/ }),
  142493. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  142494. /*!*************************************************!*\
  142495. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  142496. \*************************************************/
  142497. /*! exports provided: shadowsVertex */
  142498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142499. "use strict";
  142500. __webpack_require__.r(__webpack_exports__);
  142501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  142502. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  142503. var name = 'shadowsVertex';
  142504. 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";
  142505. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  142506. /** @hidden */
  142507. var shadowsVertex = { name: name, shader: shader };
  142508. /***/ }),
  142509. /***/ "./Shaders/anaglyph.fragment.ts":
  142510. /*!**************************************!*\
  142511. !*** ./Shaders/anaglyph.fragment.ts ***!
  142512. \**************************************/
  142513. /*! exports provided: anaglyphPixelShader */
  142514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142515. "use strict";
  142516. __webpack_require__.r(__webpack_exports__);
  142517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  142518. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142519. var name = 'anaglyphPixelShader';
  142520. 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}";
  142521. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142522. /** @hidden */
  142523. var anaglyphPixelShader = { name: name, shader: shader };
  142524. /***/ }),
  142525. /***/ "./Shaders/background.fragment.ts":
  142526. /*!****************************************!*\
  142527. !*** ./Shaders/background.fragment.ts ***!
  142528. \****************************************/
  142529. /*! exports provided: backgroundPixelShader */
  142530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142531. "use strict";
  142532. __webpack_require__.r(__webpack_exports__);
  142533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  142534. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142535. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  142536. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  142537. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  142538. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  142539. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  142540. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  142541. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  142542. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  142543. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  142544. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  142545. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  142546. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  142547. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  142548. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  142549. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  142550. var name = 'backgroundPixelShader';
  142551. 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";
  142552. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142553. /** @hidden */
  142554. var backgroundPixelShader = { name: name, shader: shader };
  142555. /***/ }),
  142556. /***/ "./Shaders/background.vertex.ts":
  142557. /*!**************************************!*\
  142558. !*** ./Shaders/background.vertex.ts ***!
  142559. \**************************************/
  142560. /*! exports provided: backgroundVertexShader */
  142561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142562. "use strict";
  142563. __webpack_require__.r(__webpack_exports__);
  142564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  142565. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142566. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  142567. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  142568. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  142569. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  142570. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  142571. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  142572. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  142573. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  142574. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  142575. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  142576. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  142577. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  142578. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  142579. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  142580. var name = 'backgroundVertexShader';
  142581. 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";
  142582. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142583. /** @hidden */
  142584. var backgroundVertexShader = { name: name, shader: shader };
  142585. /***/ }),
  142586. /***/ "./Shaders/blackAndWhite.fragment.ts":
  142587. /*!*******************************************!*\
  142588. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  142589. \*******************************************/
  142590. /*! exports provided: blackAndWhitePixelShader */
  142591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142592. "use strict";
  142593. __webpack_require__.r(__webpack_exports__);
  142594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  142595. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142596. var name = 'blackAndWhitePixelShader';
  142597. 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}";
  142598. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142599. /** @hidden */
  142600. var blackAndWhitePixelShader = { name: name, shader: shader };
  142601. /***/ }),
  142602. /***/ "./Shaders/bloomMerge.fragment.ts":
  142603. /*!****************************************!*\
  142604. !*** ./Shaders/bloomMerge.fragment.ts ***!
  142605. \****************************************/
  142606. /*! exports provided: bloomMergePixelShader */
  142607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142608. "use strict";
  142609. __webpack_require__.r(__webpack_exports__);
  142610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  142611. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142612. var name = 'bloomMergePixelShader';
  142613. 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";
  142614. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142615. /** @hidden */
  142616. var bloomMergePixelShader = { name: name, shader: shader };
  142617. /***/ }),
  142618. /***/ "./Shaders/chromaticAberration.fragment.ts":
  142619. /*!*************************************************!*\
  142620. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  142621. \*************************************************/
  142622. /*! exports provided: chromaticAberrationPixelShader */
  142623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142624. "use strict";
  142625. __webpack_require__.r(__webpack_exports__);
  142626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  142627. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142628. var name = 'chromaticAberrationPixelShader';
  142629. 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}";
  142630. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142631. /** @hidden */
  142632. var chromaticAberrationPixelShader = { name: name, shader: shader };
  142633. /***/ }),
  142634. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  142635. /*!***********************************************!*\
  142636. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  142637. \***********************************************/
  142638. /*! exports provided: circleOfConfusionPixelShader */
  142639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142640. "use strict";
  142641. __webpack_require__.r(__webpack_exports__);
  142642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  142643. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142644. var name = 'circleOfConfusionPixelShader';
  142645. 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";
  142646. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142647. /** @hidden */
  142648. var circleOfConfusionPixelShader = { name: name, shader: shader };
  142649. /***/ }),
  142650. /***/ "./Shaders/color.fragment.ts":
  142651. /*!***********************************!*\
  142652. !*** ./Shaders/color.fragment.ts ***!
  142653. \***********************************/
  142654. /*! exports provided: colorPixelShader */
  142655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142656. "use strict";
  142657. __webpack_require__.r(__webpack_exports__);
  142658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  142659. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142660. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  142661. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  142662. var name = 'colorPixelShader';
  142663. 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}";
  142664. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142665. /** @hidden */
  142666. var colorPixelShader = { name: name, shader: shader };
  142667. /***/ }),
  142668. /***/ "./Shaders/color.vertex.ts":
  142669. /*!*********************************!*\
  142670. !*** ./Shaders/color.vertex.ts ***!
  142671. \*********************************/
  142672. /*! exports provided: colorVertexShader */
  142673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142674. "use strict";
  142675. __webpack_require__.r(__webpack_exports__);
  142676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  142677. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142678. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  142679. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  142680. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  142681. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  142682. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  142683. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  142684. var name = 'colorVertexShader';
  142685. 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}";
  142686. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142687. /** @hidden */
  142688. var colorVertexShader = { name: name, shader: shader };
  142689. /***/ }),
  142690. /***/ "./Shaders/colorCorrection.fragment.ts":
  142691. /*!*********************************************!*\
  142692. !*** ./Shaders/colorCorrection.fragment.ts ***!
  142693. \*********************************************/
  142694. /*! exports provided: colorCorrectionPixelShader */
  142695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142696. "use strict";
  142697. __webpack_require__.r(__webpack_exports__);
  142698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  142699. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142700. var name = 'colorCorrectionPixelShader';
  142701. 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}";
  142702. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142703. /** @hidden */
  142704. var colorCorrectionPixelShader = { name: name, shader: shader };
  142705. /***/ }),
  142706. /***/ "./Shaders/convolution.fragment.ts":
  142707. /*!*****************************************!*\
  142708. !*** ./Shaders/convolution.fragment.ts ***!
  142709. \*****************************************/
  142710. /*! exports provided: convolutionPixelShader */
  142711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142712. "use strict";
  142713. __webpack_require__.r(__webpack_exports__);
  142714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  142715. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142716. var name = 'convolutionPixelShader';
  142717. 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}";
  142718. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142719. /** @hidden */
  142720. var convolutionPixelShader = { name: name, shader: shader };
  142721. /***/ }),
  142722. /***/ "./Shaders/default.fragment.ts":
  142723. /*!*************************************!*\
  142724. !*** ./Shaders/default.fragment.ts ***!
  142725. \*************************************/
  142726. /*! exports provided: defaultPixelShader */
  142727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142728. "use strict";
  142729. __webpack_require__.r(__webpack_exports__);
  142730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  142731. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142732. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  142733. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  142734. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  142735. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  142736. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  142737. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  142738. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  142739. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  142740. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  142741. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  142742. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  142743. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  142744. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  142745. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  142746. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  142747. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  142748. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  142749. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  142750. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  142751. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  142752. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  142753. var name = 'defaultPixelShader';
  142754. 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";
  142755. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142756. /** @hidden */
  142757. var defaultPixelShader = { name: name, shader: shader };
  142758. /***/ }),
  142759. /***/ "./Shaders/default.vertex.ts":
  142760. /*!***********************************!*\
  142761. !*** ./Shaders/default.vertex.ts ***!
  142762. \***********************************/
  142763. /*! exports provided: defaultVertexShader */
  142764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142765. "use strict";
  142766. __webpack_require__.r(__webpack_exports__);
  142767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  142768. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142769. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  142770. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  142771. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  142772. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  142773. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  142774. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  142775. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  142776. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  142777. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  142778. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  142779. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  142780. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  142781. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  142782. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  142783. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  142784. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  142785. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  142786. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  142787. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  142788. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  142789. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  142790. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  142791. var name = 'defaultVertexShader';
  142792. 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#ifdef UV1\nvec2 uvUpdated=uv;\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 uvUpdated=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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";
  142793. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142794. /** @hidden */
  142795. var defaultVertexShader = { name: name, shader: shader };
  142796. /***/ }),
  142797. /***/ "./Shaders/depth.fragment.ts":
  142798. /*!***********************************!*\
  142799. !*** ./Shaders/depth.fragment.ts ***!
  142800. \***********************************/
  142801. /*! exports provided: depthPixelShader */
  142802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142803. "use strict";
  142804. __webpack_require__.r(__webpack_exports__);
  142805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  142806. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142807. /* harmony import */ var _ShadersInclude_packingFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/packingFunctions */ "./Shaders/ShadersInclude/packingFunctions.ts");
  142808. var name = 'depthPixelShader';
  142809. var shader = "#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\n#ifdef PACKED\n#include<packingFunctions>\n#endif\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n}";
  142810. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142811. /** @hidden */
  142812. var depthPixelShader = { name: name, shader: shader };
  142813. /***/ }),
  142814. /***/ "./Shaders/depth.vertex.ts":
  142815. /*!*********************************!*\
  142816. !*** ./Shaders/depth.vertex.ts ***!
  142817. \*********************************/
  142818. /*! exports provided: depthVertexShader */
  142819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142820. "use strict";
  142821. __webpack_require__.r(__webpack_exports__);
  142822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  142823. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142824. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  142825. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  142826. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  142827. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  142828. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  142829. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  142830. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  142831. var name = 'depthVertexShader';
  142832. var shader = "\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\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{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";
  142833. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142834. /** @hidden */
  142835. var depthVertexShader = { name: name, shader: shader };
  142836. /***/ }),
  142837. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  142838. /*!******************************************!*\
  142839. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  142840. \******************************************/
  142841. /*! exports provided: depthBoxBlurPixelShader */
  142842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142843. "use strict";
  142844. __webpack_require__.r(__webpack_exports__);
  142845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  142846. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142847. var name = 'depthBoxBlurPixelShader';
  142848. 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}";
  142849. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142850. /** @hidden */
  142851. var depthBoxBlurPixelShader = { name: name, shader: shader };
  142852. /***/ }),
  142853. /***/ "./Shaders/depthOfField.fragment.ts":
  142854. /*!******************************************!*\
  142855. !*** ./Shaders/depthOfField.fragment.ts ***!
  142856. \******************************************/
  142857. /*! exports provided: depthOfFieldPixelShader */
  142858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142859. "use strict";
  142860. __webpack_require__.r(__webpack_exports__);
  142861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  142862. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142863. var name = 'depthOfFieldPixelShader';
  142864. 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";
  142865. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142866. /** @hidden */
  142867. var depthOfFieldPixelShader = { name: name, shader: shader };
  142868. /***/ }),
  142869. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  142870. /*!***********************************************!*\
  142871. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  142872. \***********************************************/
  142873. /*! exports provided: depthOfFieldMergePixelShader */
  142874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142875. "use strict";
  142876. __webpack_require__.r(__webpack_exports__);
  142877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  142878. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142879. var name = 'depthOfFieldMergePixelShader';
  142880. 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";
  142881. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142882. /** @hidden */
  142883. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  142884. /***/ }),
  142885. /***/ "./Shaders/displayPass.fragment.ts":
  142886. /*!*****************************************!*\
  142887. !*** ./Shaders/displayPass.fragment.ts ***!
  142888. \*****************************************/
  142889. /*! exports provided: displayPassPixelShader */
  142890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142891. "use strict";
  142892. __webpack_require__.r(__webpack_exports__);
  142893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  142894. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142895. var name = 'displayPassPixelShader';
  142896. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  142897. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142898. /** @hidden */
  142899. var displayPassPixelShader = { name: name, shader: shader };
  142900. /***/ }),
  142901. /***/ "./Shaders/extractHighlights.fragment.ts":
  142902. /*!***********************************************!*\
  142903. !*** ./Shaders/extractHighlights.fragment.ts ***!
  142904. \***********************************************/
  142905. /*! exports provided: extractHighlightsPixelShader */
  142906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142907. "use strict";
  142908. __webpack_require__.r(__webpack_exports__);
  142909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  142910. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142911. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  142912. var name = 'extractHighlightsPixelShader';
  142913. 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}";
  142914. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142915. /** @hidden */
  142916. var extractHighlightsPixelShader = { name: name, shader: shader };
  142917. /***/ }),
  142918. /***/ "./Shaders/filter.fragment.ts":
  142919. /*!************************************!*\
  142920. !*** ./Shaders/filter.fragment.ts ***!
  142921. \************************************/
  142922. /*! exports provided: filterPixelShader */
  142923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142924. "use strict";
  142925. __webpack_require__.r(__webpack_exports__);
  142926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  142927. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142928. var name = 'filterPixelShader';
  142929. 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}";
  142930. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142931. /** @hidden */
  142932. var filterPixelShader = { name: name, shader: shader };
  142933. /***/ }),
  142934. /***/ "./Shaders/fxaa.fragment.ts":
  142935. /*!**********************************!*\
  142936. !*** ./Shaders/fxaa.fragment.ts ***!
  142937. \**********************************/
  142938. /*! exports provided: fxaaPixelShader */
  142939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142940. "use strict";
  142941. __webpack_require__.r(__webpack_exports__);
  142942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  142943. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142944. var name = 'fxaaPixelShader';
  142945. 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}";
  142946. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142947. /** @hidden */
  142948. var fxaaPixelShader = { name: name, shader: shader };
  142949. /***/ }),
  142950. /***/ "./Shaders/fxaa.vertex.ts":
  142951. /*!********************************!*\
  142952. !*** ./Shaders/fxaa.vertex.ts ***!
  142953. \********************************/
  142954. /*! exports provided: fxaaVertexShader */
  142955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142956. "use strict";
  142957. __webpack_require__.r(__webpack_exports__);
  142958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  142959. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142960. var name = 'fxaaVertexShader';
  142961. 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}";
  142962. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142963. /** @hidden */
  142964. var fxaaVertexShader = { name: name, shader: shader };
  142965. /***/ }),
  142966. /***/ "./Shaders/geometry.fragment.ts":
  142967. /*!**************************************!*\
  142968. !*** ./Shaders/geometry.fragment.ts ***!
  142969. \**************************************/
  142970. /*! exports provided: geometryPixelShader */
  142971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142972. "use strict";
  142973. __webpack_require__.r(__webpack_exports__);
  142974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  142975. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142976. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  142977. var name = 'geometryPixelShader';
  142978. 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=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n}";
  142979. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  142980. /** @hidden */
  142981. var geometryPixelShader = { name: name, shader: shader };
  142982. /***/ }),
  142983. /***/ "./Shaders/geometry.vertex.ts":
  142984. /*!************************************!*\
  142985. !*** ./Shaders/geometry.vertex.ts ***!
  142986. \************************************/
  142987. /*! exports provided: geometryVertexShader */
  142988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  142989. "use strict";
  142990. __webpack_require__.r(__webpack_exports__);
  142991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  142992. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  142993. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  142994. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  142995. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  142996. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  142997. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  142998. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  142999. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  143000. var name = 'geometryVertexShader';
  143001. var shader = "precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\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 previousWorld;\nuniform mat4 previousViewProjection;\n#ifdef BONES_VELOCITY_ENABLED\n#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";
  143002. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143003. /** @hidden */
  143004. var geometryVertexShader = { name: name, shader: shader };
  143005. /***/ }),
  143006. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  143007. /*!*************************************************!*\
  143008. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  143009. \*************************************************/
  143010. /*! exports provided: glowBlurPostProcessPixelShader */
  143011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143012. "use strict";
  143013. __webpack_require__.r(__webpack_exports__);
  143014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  143015. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143016. var name = 'glowBlurPostProcessPixelShader';
  143017. 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}";
  143018. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143019. /** @hidden */
  143020. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  143021. /***/ }),
  143022. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  143023. /*!***********************************************!*\
  143024. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  143025. \***********************************************/
  143026. /*! exports provided: glowMapGenerationPixelShader */
  143027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143028. "use strict";
  143029. __webpack_require__.r(__webpack_exports__);
  143030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  143031. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143032. var name = 'glowMapGenerationPixelShader';
  143033. 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\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\nvoid main(void)\n{\nvec4 finalColor=glowColor;\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}";
  143034. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143035. /** @hidden */
  143036. var glowMapGenerationPixelShader = { name: name, shader: shader };
  143037. /***/ }),
  143038. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  143039. /*!*********************************************!*\
  143040. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  143041. \*********************************************/
  143042. /*! exports provided: glowMapGenerationVertexShader */
  143043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143044. "use strict";
  143045. __webpack_require__.r(__webpack_exports__);
  143046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  143047. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143048. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  143049. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  143050. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  143051. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  143052. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  143053. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  143054. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  143055. var name = 'glowMapGenerationVertexShader';
  143056. 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#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\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(uvUpdated,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(uvUpdated,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(uvUpdated,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}";
  143057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143058. /** @hidden */
  143059. var glowMapGenerationVertexShader = { name: name, shader: shader };
  143060. /***/ }),
  143061. /***/ "./Shaders/glowMapMerge.fragment.ts":
  143062. /*!******************************************!*\
  143063. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  143064. \******************************************/
  143065. /*! exports provided: glowMapMergePixelShader */
  143066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143067. "use strict";
  143068. __webpack_require__.r(__webpack_exports__);
  143069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  143070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143071. var name = 'glowMapMergePixelShader';
  143072. 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}";
  143073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143074. /** @hidden */
  143075. var glowMapMergePixelShader = { name: name, shader: shader };
  143076. /***/ }),
  143077. /***/ "./Shaders/glowMapMerge.vertex.ts":
  143078. /*!****************************************!*\
  143079. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  143080. \****************************************/
  143081. /*! exports provided: glowMapMergeVertexShader */
  143082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143083. "use strict";
  143084. __webpack_require__.r(__webpack_exports__);
  143085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  143086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143087. var name = 'glowMapMergeVertexShader';
  143088. 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}";
  143089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143090. /** @hidden */
  143091. var glowMapMergeVertexShader = { name: name, shader: shader };
  143092. /***/ }),
  143093. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  143094. /*!************************************************!*\
  143095. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  143096. \************************************************/
  143097. /*! exports provided: gpuRenderParticlesPixelShader */
  143098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143099. "use strict";
  143100. __webpack_require__.r(__webpack_exports__);
  143101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  143102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143103. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  143104. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  143105. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143106. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  143107. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  143108. var name = 'gpuRenderParticlesPixelShader';
  143109. 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";
  143110. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143111. /** @hidden */
  143112. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  143113. /***/ }),
  143114. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  143115. /*!**********************************************!*\
  143116. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  143117. \**********************************************/
  143118. /*! exports provided: gpuRenderParticlesVertexShader */
  143119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143120. "use strict";
  143121. __webpack_require__.r(__webpack_exports__);
  143122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  143123. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143124. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  143125. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  143126. var name = 'gpuRenderParticlesVertexShader';
  143127. 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}";
  143128. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143129. /** @hidden */
  143130. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  143131. /***/ }),
  143132. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  143133. /*!************************************************!*\
  143134. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  143135. \************************************************/
  143136. /*! exports provided: gpuUpdateParticlesPixelShader */
  143137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143138. "use strict";
  143139. __webpack_require__.r(__webpack_exports__);
  143140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  143141. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143142. var name = 'gpuUpdateParticlesPixelShader';
  143143. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  143144. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143145. /** @hidden */
  143146. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  143147. /***/ }),
  143148. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  143149. /*!**********************************************!*\
  143150. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  143151. \**********************************************/
  143152. /*! exports provided: gpuUpdateParticlesVertexShader */
  143153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143154. "use strict";
  143155. __webpack_require__.r(__webpack_exports__);
  143156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  143157. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143158. var name = 'gpuUpdateParticlesVertexShader';
  143159. 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.0001;\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=normalize(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}";
  143160. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143161. /** @hidden */
  143162. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  143163. /***/ }),
  143164. /***/ "./Shaders/grain.fragment.ts":
  143165. /*!***********************************!*\
  143166. !*** ./Shaders/grain.fragment.ts ***!
  143167. \***********************************/
  143168. /*! exports provided: grainPixelShader */
  143169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143170. "use strict";
  143171. __webpack_require__.r(__webpack_exports__);
  143172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  143173. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143174. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143175. var name = 'grainPixelShader';
  143176. 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}";
  143177. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143178. /** @hidden */
  143179. var grainPixelShader = { name: name, shader: shader };
  143180. /***/ }),
  143181. /***/ "./Shaders/highlights.fragment.ts":
  143182. /*!****************************************!*\
  143183. !*** ./Shaders/highlights.fragment.ts ***!
  143184. \****************************************/
  143185. /*! exports provided: highlightsPixelShader */
  143186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143187. "use strict";
  143188. __webpack_require__.r(__webpack_exports__);
  143189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  143190. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143191. var name = 'highlightsPixelShader';
  143192. 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}";
  143193. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143194. /** @hidden */
  143195. var highlightsPixelShader = { name: name, shader: shader };
  143196. /***/ }),
  143197. /***/ "./Shaders/imageProcessing.fragment.ts":
  143198. /*!*********************************************!*\
  143199. !*** ./Shaders/imageProcessing.fragment.ts ***!
  143200. \*********************************************/
  143201. /*! exports provided: imageProcessingPixelShader */
  143202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143203. "use strict";
  143204. __webpack_require__.r(__webpack_exports__);
  143205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  143206. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143207. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  143208. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143209. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  143210. var name = 'imageProcessingPixelShader';
  143211. 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}";
  143212. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143213. /** @hidden */
  143214. var imageProcessingPixelShader = { name: name, shader: shader };
  143215. /***/ }),
  143216. /***/ "./Shaders/kernelBlur.fragment.ts":
  143217. /*!****************************************!*\
  143218. !*** ./Shaders/kernelBlur.fragment.ts ***!
  143219. \****************************************/
  143220. /*! exports provided: kernelBlurPixelShader */
  143221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143222. "use strict";
  143223. __webpack_require__.r(__webpack_exports__);
  143224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  143225. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143226. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  143227. /* harmony import */ var _ShadersInclude_packingFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/packingFunctions */ "./Shaders/ShadersInclude/packingFunctions.ts");
  143228. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  143229. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  143230. var name = 'kernelBlurPixelShader';
  143231. 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\n#include<packingFunctions>\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}";
  143232. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143233. /** @hidden */
  143234. var kernelBlurPixelShader = { name: name, shader: shader };
  143235. /***/ }),
  143236. /***/ "./Shaders/kernelBlur.vertex.ts":
  143237. /*!**************************************!*\
  143238. !*** ./Shaders/kernelBlur.vertex.ts ***!
  143239. \**************************************/
  143240. /*! exports provided: kernelBlurVertexShader */
  143241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143242. "use strict";
  143243. __webpack_require__.r(__webpack_exports__);
  143244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  143245. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143246. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  143247. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  143248. var name = 'kernelBlurVertexShader';
  143249. 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}";
  143250. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143251. /** @hidden */
  143252. var kernelBlurVertexShader = { name: name, shader: shader };
  143253. /***/ }),
  143254. /***/ "./Shaders/layer.fragment.ts":
  143255. /*!***********************************!*\
  143256. !*** ./Shaders/layer.fragment.ts ***!
  143257. \***********************************/
  143258. /*! exports provided: layerPixelShader */
  143259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143260. "use strict";
  143261. __webpack_require__.r(__webpack_exports__);
  143262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  143263. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143264. var name = 'layerPixelShader';
  143265. 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}";
  143266. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143267. /** @hidden */
  143268. var layerPixelShader = { name: name, shader: shader };
  143269. /***/ }),
  143270. /***/ "./Shaders/layer.vertex.ts":
  143271. /*!*********************************!*\
  143272. !*** ./Shaders/layer.vertex.ts ***!
  143273. \*********************************/
  143274. /*! exports provided: layerVertexShader */
  143275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143276. "use strict";
  143277. __webpack_require__.r(__webpack_exports__);
  143278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  143279. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143280. var name = 'layerVertexShader';
  143281. 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}";
  143282. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143283. /** @hidden */
  143284. var layerVertexShader = { name: name, shader: shader };
  143285. /***/ }),
  143286. /***/ "./Shaders/lensFlare.fragment.ts":
  143287. /*!***************************************!*\
  143288. !*** ./Shaders/lensFlare.fragment.ts ***!
  143289. \***************************************/
  143290. /*! exports provided: lensFlarePixelShader */
  143291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143292. "use strict";
  143293. __webpack_require__.r(__webpack_exports__);
  143294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  143295. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143296. var name = 'lensFlarePixelShader';
  143297. 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}";
  143298. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143299. /** @hidden */
  143300. var lensFlarePixelShader = { name: name, shader: shader };
  143301. /***/ }),
  143302. /***/ "./Shaders/lensFlare.vertex.ts":
  143303. /*!*************************************!*\
  143304. !*** ./Shaders/lensFlare.vertex.ts ***!
  143305. \*************************************/
  143306. /*! exports provided: lensFlareVertexShader */
  143307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143308. "use strict";
  143309. __webpack_require__.r(__webpack_exports__);
  143310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  143311. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143312. var name = 'lensFlareVertexShader';
  143313. 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}";
  143314. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143315. /** @hidden */
  143316. var lensFlareVertexShader = { name: name, shader: shader };
  143317. /***/ }),
  143318. /***/ "./Shaders/lensHighlights.fragment.ts":
  143319. /*!********************************************!*\
  143320. !*** ./Shaders/lensHighlights.fragment.ts ***!
  143321. \********************************************/
  143322. /*! exports provided: lensHighlightsPixelShader */
  143323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143324. "use strict";
  143325. __webpack_require__.r(__webpack_exports__);
  143326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  143327. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143328. var name = 'lensHighlightsPixelShader';
  143329. 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}";
  143330. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143331. /** @hidden */
  143332. var lensHighlightsPixelShader = { name: name, shader: shader };
  143333. /***/ }),
  143334. /***/ "./Shaders/line.fragment.ts":
  143335. /*!**********************************!*\
  143336. !*** ./Shaders/line.fragment.ts ***!
  143337. \**********************************/
  143338. /*! exports provided: linePixelShader */
  143339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143340. "use strict";
  143341. __webpack_require__.r(__webpack_exports__);
  143342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  143343. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143344. var name = 'linePixelShader';
  143345. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  143346. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143347. /** @hidden */
  143348. var linePixelShader = { name: name, shader: shader };
  143349. /***/ }),
  143350. /***/ "./Shaders/line.vertex.ts":
  143351. /*!********************************!*\
  143352. !*** ./Shaders/line.vertex.ts ***!
  143353. \********************************/
  143354. /*! exports provided: lineVertexShader */
  143355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143356. "use strict";
  143357. __webpack_require__.r(__webpack_exports__);
  143358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  143359. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143360. var name = 'lineVertexShader';
  143361. 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}";
  143362. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143363. /** @hidden */
  143364. var lineVertexShader = { name: name, shader: shader };
  143365. /***/ }),
  143366. /***/ "./Shaders/motionBlur.fragment.ts":
  143367. /*!****************************************!*\
  143368. !*** ./Shaders/motionBlur.fragment.ts ***!
  143369. \****************************************/
  143370. /*! exports provided: motionBlurPixelShader */
  143371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143372. "use strict";
  143373. __webpack_require__.r(__webpack_exports__);
  143374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  143375. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143376. var name = 'motionBlurPixelShader';
  143377. 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*2.0-1.0;\nvec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.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);\ngl_FragColor.a=1.0;\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  143378. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143379. /** @hidden */
  143380. var motionBlurPixelShader = { name: name, shader: shader };
  143381. /***/ }),
  143382. /***/ "./Shaders/noise.fragment.ts":
  143383. /*!***********************************!*\
  143384. !*** ./Shaders/noise.fragment.ts ***!
  143385. \***********************************/
  143386. /*! exports provided: noisePixelShader */
  143387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143388. "use strict";
  143389. __webpack_require__.r(__webpack_exports__);
  143390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  143391. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143392. var name = 'noisePixelShader';
  143393. 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";
  143394. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143395. /** @hidden */
  143396. var noisePixelShader = { name: name, shader: shader };
  143397. /***/ }),
  143398. /***/ "./Shaders/outline.fragment.ts":
  143399. /*!*************************************!*\
  143400. !*** ./Shaders/outline.fragment.ts ***!
  143401. \*************************************/
  143402. /*! exports provided: outlinePixelShader */
  143403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143404. "use strict";
  143405. __webpack_require__.r(__webpack_exports__);
  143406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  143407. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143408. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  143409. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  143410. var name = 'outlinePixelShader';
  143411. 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}";
  143412. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143413. /** @hidden */
  143414. var outlinePixelShader = { name: name, shader: shader };
  143415. /***/ }),
  143416. /***/ "./Shaders/outline.vertex.ts":
  143417. /*!***********************************!*\
  143418. !*** ./Shaders/outline.vertex.ts ***!
  143419. \***********************************/
  143420. /*! exports provided: outlineVertexShader */
  143421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143422. "use strict";
  143423. __webpack_require__.r(__webpack_exports__);
  143424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  143425. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143426. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  143427. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  143428. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  143429. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  143430. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  143431. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  143432. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  143433. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  143434. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  143435. var name = 'outlineVertexShader';
  143436. var shader = "\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\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 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\nvec3 offsetPosition=positionUpdated+(normalUpdated*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(uvUpdated,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";
  143437. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143438. /** @hidden */
  143439. var outlineVertexShader = { name: name, shader: shader };
  143440. /***/ }),
  143441. /***/ "./Shaders/particles.fragment.ts":
  143442. /*!***************************************!*\
  143443. !*** ./Shaders/particles.fragment.ts ***!
  143444. \***************************************/
  143445. /*! exports provided: particlesPixelShader */
  143446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143447. "use strict";
  143448. __webpack_require__.r(__webpack_exports__);
  143449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  143450. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143451. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  143452. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  143453. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143454. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  143455. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  143456. var name = 'particlesPixelShader';
  143457. 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}";
  143458. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143459. /** @hidden */
  143460. var particlesPixelShader = { name: name, shader: shader };
  143461. /***/ }),
  143462. /***/ "./Shaders/particles.vertex.ts":
  143463. /*!*************************************!*\
  143464. !*** ./Shaders/particles.vertex.ts ***!
  143465. \*************************************/
  143466. /*! exports provided: particlesVertexShader */
  143467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143468. "use strict";
  143469. __webpack_require__.r(__webpack_exports__);
  143470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  143471. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143472. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  143473. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  143474. var name = 'particlesVertexShader';
  143475. 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}";
  143476. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143477. /** @hidden */
  143478. var particlesVertexShader = { name: name, shader: shader };
  143479. /***/ }),
  143480. /***/ "./Shaders/pass.fragment.ts":
  143481. /*!**********************************!*\
  143482. !*** ./Shaders/pass.fragment.ts ***!
  143483. \**********************************/
  143484. /*! exports provided: passPixelShader */
  143485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143486. "use strict";
  143487. __webpack_require__.r(__webpack_exports__);
  143488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  143489. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143490. var name = 'passPixelShader';
  143491. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  143492. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143493. /** @hidden */
  143494. var passPixelShader = { name: name, shader: shader };
  143495. /***/ }),
  143496. /***/ "./Shaders/passCube.fragment.ts":
  143497. /*!**************************************!*\
  143498. !*** ./Shaders/passCube.fragment.ts ***!
  143499. \**************************************/
  143500. /*! exports provided: passCubePixelShader */
  143501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143502. "use strict";
  143503. __webpack_require__.r(__webpack_exports__);
  143504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  143505. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143506. var name = 'passCubePixelShader';
  143507. 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}";
  143508. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143509. /** @hidden */
  143510. var passCubePixelShader = { name: name, shader: shader };
  143511. /***/ }),
  143512. /***/ "./Shaders/pbr.fragment.ts":
  143513. /*!*********************************!*\
  143514. !*** ./Shaders/pbr.fragment.ts ***!
  143515. \*********************************/
  143516. /*! exports provided: pbrPixelShader */
  143517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143518. "use strict";
  143519. __webpack_require__.r(__webpack_exports__);
  143520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  143521. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143522. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  143523. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  143524. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  143525. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  143526. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  143527. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  143528. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  143529. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  143530. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  143531. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  143532. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143533. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  143534. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  143535. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  143536. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  143537. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  143538. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  143539. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  143540. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  143541. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  143542. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  143543. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  143544. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  143545. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  143546. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  143547. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  143548. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  143549. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  143550. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  143551. var name = 'pbrPixelShader';
  143552. 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#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\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#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\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#elif defined(SS_LINEARSPECULARREFRACTION)\nfloat refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,roughness);\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#elif defined(LINEARSPECULARREFLECTION)\nfloat refractionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\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=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#elif defined(USEIRRADIANCEMAP)\nenvironmentIrradiance=sampleReflection(irradianceSampler,reflectionCoords).rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\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#elif defined(LINEARSPECULARREFLECTION)\nfloat sheenReflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,sheenRoughness);\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#elif defined(LINEARSPECULARREFLECTION)\nfloat sheenReflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,clearCoatRoughness);\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#if defined(REFLECTION) && defined(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\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);\n#endif\n\nsurfaceAlbedo*=(1.-refractionIntensity);\n#ifdef REFLECTION\n\nenvironmentIrradiance*=(1.-refractionIntensity);\n#endif\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(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\n#if defined(USESPHERICALFROMREFLECTIONMAP)\nvec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);\n#elif defined(USEIRRADIANCEMAP)\nvec3 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceVector).rgb;\n#ifdef RGBDREFLECTION\nrefractionIrradiance.rgb=fromRGBD(refractionIrradiance);\n#endif\n#ifdef GAMMAREFLECTION\nrefractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);\n#endif\n#else\nvec3 refractionIrradiance=vec3(0.);\n#endif\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(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";
  143553. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143554. /** @hidden */
  143555. var pbrPixelShader = { name: name, shader: shader };
  143556. /***/ }),
  143557. /***/ "./Shaders/pbr.vertex.ts":
  143558. /*!*******************************!*\
  143559. !*** ./Shaders/pbr.vertex.ts ***!
  143560. \*******************************/
  143561. /*! exports provided: pbrVertexShader */
  143562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143563. "use strict";
  143564. __webpack_require__.r(__webpack_exports__);
  143565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  143566. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143567. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  143568. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  143569. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143570. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  143571. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  143572. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  143573. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  143574. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  143575. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  143576. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  143577. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  143578. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  143579. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  143580. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  143581. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  143582. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  143583. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  143584. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  143585. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  143586. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  143587. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  143588. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  143589. var name = 'pbrVertexShader';
  143590. 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#ifdef UV1\nvec2 uvUpdated=uv;\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=computeEnvironmentIrradiance(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 uvUpdated=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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}";
  143591. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143592. /** @hidden */
  143593. var pbrVertexShader = { name: name, shader: shader };
  143594. /***/ }),
  143595. /***/ "./Shaders/postprocess.vertex.ts":
  143596. /*!***************************************!*\
  143597. !*** ./Shaders/postprocess.vertex.ts ***!
  143598. \***************************************/
  143599. /*! exports provided: postprocessVertexShader */
  143600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143601. "use strict";
  143602. __webpack_require__.r(__webpack_exports__);
  143603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  143604. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143605. var name = 'postprocessVertexShader';
  143606. 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}";
  143607. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143608. /** @hidden */
  143609. var postprocessVertexShader = { name: name, shader: shader };
  143610. /***/ }),
  143611. /***/ "./Shaders/procedural.vertex.ts":
  143612. /*!**************************************!*\
  143613. !*** ./Shaders/procedural.vertex.ts ***!
  143614. \**************************************/
  143615. /*! exports provided: proceduralVertexShader */
  143616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143617. "use strict";
  143618. __webpack_require__.r(__webpack_exports__);
  143619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  143620. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143621. var name = 'proceduralVertexShader';
  143622. 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}";
  143623. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143624. /** @hidden */
  143625. var proceduralVertexShader = { name: name, shader: shader };
  143626. /***/ }),
  143627. /***/ "./Shaders/refraction.fragment.ts":
  143628. /*!****************************************!*\
  143629. !*** ./Shaders/refraction.fragment.ts ***!
  143630. \****************************************/
  143631. /*! exports provided: refractionPixelShader */
  143632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143633. "use strict";
  143634. __webpack_require__.r(__webpack_exports__);
  143635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  143636. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143637. var name = 'refractionPixelShader';
  143638. 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}";
  143639. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143640. /** @hidden */
  143641. var refractionPixelShader = { name: name, shader: shader };
  143642. /***/ }),
  143643. /***/ "./Shaders/rgbdDecode.fragment.ts":
  143644. /*!****************************************!*\
  143645. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  143646. \****************************************/
  143647. /*! exports provided: rgbdDecodePixelShader */
  143648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143649. "use strict";
  143650. __webpack_require__.r(__webpack_exports__);
  143651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  143652. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143653. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143654. var name = 'rgbdDecodePixelShader';
  143655. 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}";
  143656. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143657. /** @hidden */
  143658. var rgbdDecodePixelShader = { name: name, shader: shader };
  143659. /***/ }),
  143660. /***/ "./Shaders/rgbdEncode.fragment.ts":
  143661. /*!****************************************!*\
  143662. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  143663. \****************************************/
  143664. /*! exports provided: rgbdEncodePixelShader */
  143665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143666. "use strict";
  143667. __webpack_require__.r(__webpack_exports__);
  143668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  143669. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143670. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143671. var name = 'rgbdEncodePixelShader';
  143672. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  143673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143674. /** @hidden */
  143675. var rgbdEncodePixelShader = { name: name, shader: shader };
  143676. /***/ }),
  143677. /***/ "./Shaders/shadowMap.fragment.ts":
  143678. /*!***************************************!*\
  143679. !*** ./Shaders/shadowMap.fragment.ts ***!
  143680. \***************************************/
  143681. /*! exports provided: shadowMapPixelShader */
  143682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143683. "use strict";
  143684. __webpack_require__.r(__webpack_exports__);
  143685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  143686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143687. /* harmony import */ var _ShadersInclude_packingFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/packingFunctions */ "./Shaders/ShadersInclude/packingFunctions.ts");
  143688. var name = 'shadowMapPixelShader';
  143689. var shader = "#ifndef FLOAT\n#include<packingFunctions>\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}";
  143690. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143691. /** @hidden */
  143692. var shadowMapPixelShader = { name: name, shader: shader };
  143693. /***/ }),
  143694. /***/ "./Shaders/shadowMap.vertex.ts":
  143695. /*!*************************************!*\
  143696. !*** ./Shaders/shadowMap.vertex.ts ***!
  143697. \*************************************/
  143698. /*! exports provided: shadowMapVertexShader */
  143699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143700. "use strict";
  143701. __webpack_require__.r(__webpack_exports__);
  143702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  143703. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143704. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  143705. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  143706. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  143707. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  143708. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  143709. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  143710. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  143711. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  143712. var name = 'shadowMapVertexShader';
  143713. 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#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\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(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  143714. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143715. /** @hidden */
  143716. var shadowMapVertexShader = { name: name, shader: shader };
  143717. /***/ }),
  143718. /***/ "./Shaders/sharpen.fragment.ts":
  143719. /*!*************************************!*\
  143720. !*** ./Shaders/sharpen.fragment.ts ***!
  143721. \*************************************/
  143722. /*! exports provided: sharpenPixelShader */
  143723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143724. "use strict";
  143725. __webpack_require__.r(__webpack_exports__);
  143726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  143727. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143728. var name = 'sharpenPixelShader';
  143729. 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}";
  143730. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143731. /** @hidden */
  143732. var sharpenPixelShader = { name: name, shader: shader };
  143733. /***/ }),
  143734. /***/ "./Shaders/sprites.fragment.ts":
  143735. /*!*************************************!*\
  143736. !*** ./Shaders/sprites.fragment.ts ***!
  143737. \*************************************/
  143738. /*! exports provided: spritesPixelShader */
  143739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143740. "use strict";
  143741. __webpack_require__.r(__webpack_exports__);
  143742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  143743. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143744. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  143745. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  143746. var name = 'spritesPixelShader';
  143747. 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}";
  143748. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143749. /** @hidden */
  143750. var spritesPixelShader = { name: name, shader: shader };
  143751. /***/ }),
  143752. /***/ "./Shaders/sprites.vertex.ts":
  143753. /*!***********************************!*\
  143754. !*** ./Shaders/sprites.vertex.ts ***!
  143755. \***********************************/
  143756. /*! exports provided: spritesVertexShader */
  143757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143758. "use strict";
  143759. __webpack_require__.r(__webpack_exports__);
  143760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  143761. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143762. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  143763. var name = 'spritesVertexShader';
  143764. 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}";
  143765. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143766. /** @hidden */
  143767. var spritesVertexShader = { name: name, shader: shader };
  143768. /***/ }),
  143769. /***/ "./Shaders/ssao.fragment.ts":
  143770. /*!**********************************!*\
  143771. !*** ./Shaders/ssao.fragment.ts ***!
  143772. \**********************************/
  143773. /*! exports provided: ssaoPixelShader */
  143774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143775. "use strict";
  143776. __webpack_require__.r(__webpack_exports__);
  143777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  143778. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143779. var name = 'ssaoPixelShader';
  143780. 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";
  143781. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143782. /** @hidden */
  143783. var ssaoPixelShader = { name: name, shader: shader };
  143784. /***/ }),
  143785. /***/ "./Shaders/ssao2.fragment.ts":
  143786. /*!***********************************!*\
  143787. !*** ./Shaders/ssao2.fragment.ts ***!
  143788. \***********************************/
  143789. /*! exports provided: ssao2PixelShader */
  143790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143791. "use strict";
  143792. __webpack_require__.r(__webpack_exports__);
  143793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  143794. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143795. var name = 'ssao2PixelShader';
  143796. 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";
  143797. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143798. /** @hidden */
  143799. var ssao2PixelShader = { name: name, shader: shader };
  143800. /***/ }),
  143801. /***/ "./Shaders/ssaoCombine.fragment.ts":
  143802. /*!*****************************************!*\
  143803. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  143804. \*****************************************/
  143805. /*! exports provided: ssaoCombinePixelShader */
  143806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143807. "use strict";
  143808. __webpack_require__.r(__webpack_exports__);
  143809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  143810. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143811. var name = 'ssaoCombinePixelShader';
  143812. 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";
  143813. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143814. /** @hidden */
  143815. var ssaoCombinePixelShader = { name: name, shader: shader };
  143816. /***/ }),
  143817. /***/ "./Shaders/standard.fragment.ts":
  143818. /*!**************************************!*\
  143819. !*** ./Shaders/standard.fragment.ts ***!
  143820. \**************************************/
  143821. /*! exports provided: standardPixelShader */
  143822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143823. "use strict";
  143824. __webpack_require__.r(__webpack_exports__);
  143825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  143826. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143827. /* harmony import */ var _ShadersInclude_packingFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/packingFunctions */ "./Shaders/ShadersInclude/packingFunctions.ts");
  143828. var name = 'standardPixelShader';
  143829. 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\n#include<packingFunctions>\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";
  143830. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143831. /** @hidden */
  143832. var standardPixelShader = { name: name, shader: shader };
  143833. /***/ }),
  143834. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  143835. /*!***************************************************!*\
  143836. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  143837. \***************************************************/
  143838. /*! exports provided: stereoscopicInterlacePixelShader */
  143839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143840. "use strict";
  143841. __webpack_require__.r(__webpack_exports__);
  143842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  143843. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143844. var name = 'stereoscopicInterlacePixelShader';
  143845. 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}";
  143846. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143847. /** @hidden */
  143848. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  143849. /***/ }),
  143850. /***/ "./Shaders/tonemap.fragment.ts":
  143851. /*!*************************************!*\
  143852. !*** ./Shaders/tonemap.fragment.ts ***!
  143853. \*************************************/
  143854. /*! exports provided: tonemapPixelShader */
  143855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143856. "use strict";
  143857. __webpack_require__.r(__webpack_exports__);
  143858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  143859. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143860. var name = 'tonemapPixelShader';
  143861. 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}";
  143862. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143863. /** @hidden */
  143864. var tonemapPixelShader = { name: name, shader: shader };
  143865. /***/ }),
  143866. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  143867. /*!*******************************************************!*\
  143868. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  143869. \*******************************************************/
  143870. /*! exports provided: volumetricLightScatteringPixelShader */
  143871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143872. "use strict";
  143873. __webpack_require__.r(__webpack_exports__);
  143874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  143875. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143876. var name = 'volumetricLightScatteringPixelShader';
  143877. 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";
  143878. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143879. /** @hidden */
  143880. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  143881. /***/ }),
  143882. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  143883. /*!***********************************************************!*\
  143884. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  143885. \***********************************************************/
  143886. /*! exports provided: volumetricLightScatteringPassPixelShader */
  143887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143888. "use strict";
  143889. __webpack_require__.r(__webpack_exports__);
  143890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  143891. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143892. var name = 'volumetricLightScatteringPassPixelShader';
  143893. 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";
  143894. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143895. /** @hidden */
  143896. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  143897. /***/ }),
  143898. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  143899. /*!****************************************************!*\
  143900. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  143901. \****************************************************/
  143902. /*! exports provided: vrDistortionCorrectionPixelShader */
  143903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143904. "use strict";
  143905. __webpack_require__.r(__webpack_exports__);
  143906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  143907. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143908. var name = 'vrDistortionCorrectionPixelShader';
  143909. 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}";
  143910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143911. /** @hidden */
  143912. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  143913. /***/ }),
  143914. /***/ "./Shaders/vrMultiviewToSingleview.fragment.ts":
  143915. /*!*****************************************************!*\
  143916. !*** ./Shaders/vrMultiviewToSingleview.fragment.ts ***!
  143917. \*****************************************************/
  143918. /*! exports provided: vrMultiviewToSingleviewPixelShader */
  143919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143920. "use strict";
  143921. __webpack_require__.r(__webpack_exports__);
  143922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrMultiviewToSingleviewPixelShader", function() { return vrMultiviewToSingleviewPixelShader; });
  143923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  143924. var name = 'vrMultiviewToSingleviewPixelShader';
  143925. var shader = "precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";
  143926. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  143927. /** @hidden */
  143928. var vrMultiviewToSingleviewPixelShader = { name: name, shader: shader };
  143929. /***/ }),
  143930. /***/ "./Sprites/index.ts":
  143931. /*!**************************!*\
  143932. !*** ./Sprites/index.ts ***!
  143933. \**************************/
  143934. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  143935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143936. "use strict";
  143937. __webpack_require__.r(__webpack_exports__);
  143938. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  143939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  143940. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  143941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  143942. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  143943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  143944. /***/ }),
  143945. /***/ "./Sprites/sprite.ts":
  143946. /*!***************************!*\
  143947. !*** ./Sprites/sprite.ts ***!
  143948. \***************************/
  143949. /*! exports provided: Sprite */
  143950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143951. "use strict";
  143952. __webpack_require__.r(__webpack_exports__);
  143953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  143954. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  143955. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
  143956. /**
  143957. * Class used to represent a sprite
  143958. * @see http://doc.babylonjs.com/babylon101/sprites
  143959. */
  143960. var Sprite = /** @class */ (function () {
  143961. /**
  143962. * Creates a new Sprite
  143963. * @param name defines the name
  143964. * @param manager defines the manager
  143965. */
  143966. function Sprite(
  143967. /** defines the name */
  143968. name, manager) {
  143969. this.name = name;
  143970. /** Gets or sets the main color */
  143971. this.color = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  143972. /** Gets or sets the width */
  143973. this.width = 1.0;
  143974. /** Gets or sets the height */
  143975. this.height = 1.0;
  143976. /** Gets or sets rotation angle */
  143977. this.angle = 0;
  143978. /** Gets or sets the cell index in the sprite sheet */
  143979. this.cellIndex = 0;
  143980. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  143981. this.invertU = 0;
  143982. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  143983. this.invertV = 0;
  143984. /** Gets the list of attached animations */
  143985. this.animations = new Array();
  143986. /** Gets or sets a boolean indicating if the sprite can be picked */
  143987. this.isPickable = false;
  143988. this._animationStarted = false;
  143989. this._loopAnimation = false;
  143990. this._fromIndex = 0;
  143991. this._toIndex = 0;
  143992. this._delay = 0;
  143993. this._direction = 1;
  143994. this._time = 0;
  143995. /**
  143996. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  143997. */
  143998. this.isVisible = true;
  143999. this._manager = manager;
  144000. this._manager.sprites.push(this);
  144001. this.position = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  144002. }
  144003. Object.defineProperty(Sprite.prototype, "size", {
  144004. /**
  144005. * Gets or sets the sprite size
  144006. */
  144007. get: function () {
  144008. return this.width;
  144009. },
  144010. set: function (value) {
  144011. this.width = value;
  144012. this.height = value;
  144013. },
  144014. enumerable: true,
  144015. configurable: true
  144016. });
  144017. /**
  144018. * Starts an animation
  144019. * @param from defines the initial key
  144020. * @param to defines the end key
  144021. * @param loop defines if the animation must loop
  144022. * @param delay defines the start delay (in ms)
  144023. * @param onAnimationEnd defines a callback to call when animation ends
  144024. */
  144025. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  144026. this._fromIndex = from;
  144027. this._toIndex = to;
  144028. this._loopAnimation = loop;
  144029. this._delay = delay;
  144030. this._animationStarted = true;
  144031. if (from < to) {
  144032. this._direction = 1;
  144033. }
  144034. else {
  144035. this._direction = -1;
  144036. this._toIndex = from;
  144037. this._fromIndex = to;
  144038. }
  144039. this.cellIndex = from;
  144040. this._time = 0;
  144041. this._onAnimationEnd = onAnimationEnd;
  144042. };
  144043. /** Stops current animation (if any) */
  144044. Sprite.prototype.stopAnimation = function () {
  144045. this._animationStarted = false;
  144046. };
  144047. /** @hidden */
  144048. Sprite.prototype._animate = function (deltaTime) {
  144049. if (!this._animationStarted) {
  144050. return;
  144051. }
  144052. this._time += deltaTime;
  144053. if (this._time > this._delay) {
  144054. this._time = this._time % this._delay;
  144055. this.cellIndex += this._direction;
  144056. if (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) {
  144057. if (this._loopAnimation) {
  144058. this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex;
  144059. }
  144060. else {
  144061. this.cellIndex = this._toIndex;
  144062. this._animationStarted = false;
  144063. if (this._onAnimationEnd) {
  144064. this._onAnimationEnd();
  144065. }
  144066. if (this.disposeWhenFinishedAnimating) {
  144067. this.dispose();
  144068. }
  144069. }
  144070. }
  144071. }
  144072. };
  144073. /** Release associated resources */
  144074. Sprite.prototype.dispose = function () {
  144075. for (var i = 0; i < this._manager.sprites.length; i++) {
  144076. if (this._manager.sprites[i] == this) {
  144077. this._manager.sprites.splice(i, 1);
  144078. }
  144079. }
  144080. };
  144081. return Sprite;
  144082. }());
  144083. /***/ }),
  144084. /***/ "./Sprites/spriteManager.ts":
  144085. /*!**********************************!*\
  144086. !*** ./Sprites/spriteManager.ts ***!
  144087. \**********************************/
  144088. /*! exports provided: SpriteManager */
  144089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144090. "use strict";
  144091. __webpack_require__.r(__webpack_exports__);
  144092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  144093. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  144094. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  144095. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  144096. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.vector */ "./Maths/math.vector.ts");
  144097. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  144098. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  144099. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  144100. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  144101. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  144102. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  144103. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  144104. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  144105. /**
  144106. * Class used to manage multiple sprites on the same spritesheet
  144107. * @see http://doc.babylonjs.com/babylon101/sprites
  144108. */
  144109. var SpriteManager = /** @class */ (function () {
  144110. /**
  144111. * Creates a new sprite manager
  144112. * @param name defines the manager's name
  144113. * @param imgUrl defines the sprite sheet url
  144114. * @param capacity defines the maximum allowed number of sprites
  144115. * @param cellSize defines the size of a sprite cell
  144116. * @param scene defines the hosting scene
  144117. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  144118. * @param samplingMode defines the smapling mode to use with spritesheet
  144119. */
  144120. function SpriteManager(
  144121. /** defines the manager's name */
  144122. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  144123. if (epsilon === void 0) { epsilon = 0.01; }
  144124. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  144125. this.name = name;
  144126. /** Gets the list of sprites */
  144127. this.sprites = new Array();
  144128. /** Gets or sets the rendering group id (0 by default) */
  144129. this.renderingGroupId = 0;
  144130. /** Gets or sets camera layer mask */
  144131. this.layerMask = 0x0FFFFFFF;
  144132. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  144133. this.fogEnabled = true;
  144134. /** Gets or sets a boolean indicating if the sprites are pickable */
  144135. this.isPickable = false;
  144136. /**
  144137. * An event triggered when the manager is disposed.
  144138. */
  144139. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  144140. this._vertexBuffers = {};
  144141. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  144142. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  144143. }
  144144. this._capacity = capacity;
  144145. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  144146. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  144147. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  144148. if (cellSize.width && cellSize.height) {
  144149. this.cellWidth = cellSize.width;
  144150. this.cellHeight = cellSize.height;
  144151. }
  144152. else if (cellSize !== undefined) {
  144153. this.cellWidth = cellSize;
  144154. this.cellHeight = cellSize;
  144155. }
  144156. else {
  144157. return;
  144158. }
  144159. this._epsilon = epsilon;
  144160. this._scene = scene;
  144161. this._scene.spriteManagers.push(this);
  144162. var indices = [];
  144163. var index = 0;
  144164. for (var count = 0; count < capacity; count++) {
  144165. indices.push(index);
  144166. indices.push(index + 1);
  144167. indices.push(index + 2);
  144168. indices.push(index);
  144169. indices.push(index + 2);
  144170. indices.push(index + 3);
  144171. index += 4;
  144172. }
  144173. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  144174. // VBO
  144175. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  144176. this._vertexData = new Float32Array(capacity * 16 * 4);
  144177. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  144178. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  144179. var options = this._buffer.createVertexBuffer("options", 4, 4);
  144180. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  144181. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  144182. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  144183. this._vertexBuffers["options"] = options;
  144184. this._vertexBuffers["cellInfo"] = cellInfo;
  144185. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  144186. // Effects
  144187. 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"], "");
  144188. 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");
  144189. }
  144190. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  144191. /**
  144192. * Callback called when the manager is disposed
  144193. */
  144194. set: function (callback) {
  144195. if (this._onDisposeObserver) {
  144196. this.onDisposeObservable.remove(this._onDisposeObserver);
  144197. }
  144198. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  144199. },
  144200. enumerable: true,
  144201. configurable: true
  144202. });
  144203. Object.defineProperty(SpriteManager.prototype, "texture", {
  144204. /**
  144205. * Gets or sets the spritesheet texture
  144206. */
  144207. get: function () {
  144208. return this._spriteTexture;
  144209. },
  144210. set: function (value) {
  144211. this._spriteTexture = value;
  144212. },
  144213. enumerable: true,
  144214. configurable: true
  144215. });
  144216. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  144217. var arrayOffset = index * 16;
  144218. if (offsetX === 0) {
  144219. offsetX = this._epsilon;
  144220. }
  144221. else if (offsetX === 1) {
  144222. offsetX = 1 - this._epsilon;
  144223. }
  144224. if (offsetY === 0) {
  144225. offsetY = this._epsilon;
  144226. }
  144227. else if (offsetY === 1) {
  144228. offsetY = 1 - this._epsilon;
  144229. }
  144230. this._vertexData[arrayOffset] = sprite.position.x;
  144231. this._vertexData[arrayOffset + 1] = sprite.position.y;
  144232. this._vertexData[arrayOffset + 2] = sprite.position.z;
  144233. this._vertexData[arrayOffset + 3] = sprite.angle;
  144234. this._vertexData[arrayOffset + 4] = sprite.width;
  144235. this._vertexData[arrayOffset + 5] = sprite.height;
  144236. this._vertexData[arrayOffset + 6] = offsetX;
  144237. this._vertexData[arrayOffset + 7] = offsetY;
  144238. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  144239. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  144240. var offset = (sprite.cellIndex / rowSize) >> 0;
  144241. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  144242. this._vertexData[arrayOffset + 11] = offset;
  144243. // Color
  144244. this._vertexData[arrayOffset + 12] = sprite.color.r;
  144245. this._vertexData[arrayOffset + 13] = sprite.color.g;
  144246. this._vertexData[arrayOffset + 14] = sprite.color.b;
  144247. this._vertexData[arrayOffset + 15] = sprite.color.a;
  144248. };
  144249. /**
  144250. * Intersects the sprites with a ray
  144251. * @param ray defines the ray to intersect with
  144252. * @param camera defines the current active camera
  144253. * @param predicate defines a predicate used to select candidate sprites
  144254. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  144255. * @returns null if no hit or a PickingInfo
  144256. */
  144257. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  144258. var count = Math.min(this._capacity, this.sprites.length);
  144259. var min = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  144260. var max = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  144261. var distance = Number.MAX_VALUE;
  144262. var currentSprite = null;
  144263. var pickedPoint = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  144264. var cameraSpacePosition = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  144265. var cameraView = camera.getViewMatrix();
  144266. for (var index = 0; index < count; index++) {
  144267. var sprite = this.sprites[index];
  144268. if (!sprite) {
  144269. continue;
  144270. }
  144271. if (predicate) {
  144272. if (!predicate(sprite)) {
  144273. continue;
  144274. }
  144275. }
  144276. else if (!sprite.isPickable) {
  144277. continue;
  144278. }
  144279. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  144280. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  144281. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  144282. if (ray.intersectsBoxMinMax(min, max)) {
  144283. var currentDistance = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  144284. if (distance > currentDistance) {
  144285. distance = currentDistance;
  144286. currentSprite = sprite;
  144287. if (fastCheck) {
  144288. break;
  144289. }
  144290. }
  144291. }
  144292. }
  144293. if (currentSprite) {
  144294. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  144295. cameraView.invertToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0]);
  144296. result.hit = true;
  144297. result.pickedSprite = currentSprite;
  144298. result.distance = distance;
  144299. // Get picked point
  144300. var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
  144301. direction.copyFrom(ray.direction);
  144302. direction.normalize();
  144303. direction.scaleInPlace(distance);
  144304. ray.origin.addToRef(direction, pickedPoint);
  144305. result.pickedPoint = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Matrix[0]);
  144306. return result;
  144307. }
  144308. return null;
  144309. };
  144310. /**
  144311. * Render all child sprites
  144312. */
  144313. SpriteManager.prototype.render = function () {
  144314. // Check
  144315. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  144316. || !this._spriteTexture.isReady() || !this.sprites.length) {
  144317. return;
  144318. }
  144319. var engine = this._scene.getEngine();
  144320. var baseSize = this._spriteTexture.getBaseSize();
  144321. // Sprites
  144322. var deltaTime = engine.getDeltaTime();
  144323. var max = Math.min(this._capacity, this.sprites.length);
  144324. var rowSize = baseSize.width / this.cellWidth;
  144325. var offset = 0;
  144326. var noSprite = true;
  144327. for (var index = 0; index < max; index++) {
  144328. var sprite = this.sprites[index];
  144329. if (!sprite || !sprite.isVisible) {
  144330. continue;
  144331. }
  144332. noSprite = false;
  144333. sprite._animate(deltaTime);
  144334. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  144335. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  144336. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  144337. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  144338. }
  144339. if (noSprite) {
  144340. return;
  144341. }
  144342. this._buffer.update(this._vertexData);
  144343. // Render
  144344. var effect = this._effectBase;
  144345. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  144346. effect = this._effectFog;
  144347. }
  144348. engine.enableEffect(effect);
  144349. var viewMatrix = this._scene.getViewMatrix();
  144350. effect.setTexture("diffuseSampler", this._spriteTexture);
  144351. effect.setMatrix("view", viewMatrix);
  144352. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  144353. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  144354. // Fog
  144355. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  144356. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  144357. effect.setColor3("vFogColor", this._scene.fogColor);
  144358. }
  144359. // VBOs
  144360. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  144361. // Draw order
  144362. engine.setDepthFunctionToLessOrEqual();
  144363. effect.setBool("alphaTest", true);
  144364. engine.setColorWrite(false);
  144365. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  144366. engine.setColorWrite(true);
  144367. effect.setBool("alphaTest", false);
  144368. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  144369. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  144370. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  144371. };
  144372. /**
  144373. * Release associated resources
  144374. */
  144375. SpriteManager.prototype.dispose = function () {
  144376. if (this._buffer) {
  144377. this._buffer.dispose();
  144378. this._buffer = null;
  144379. }
  144380. if (this._indexBuffer) {
  144381. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  144382. this._indexBuffer = null;
  144383. }
  144384. if (this._spriteTexture) {
  144385. this._spriteTexture.dispose();
  144386. this._spriteTexture = null;
  144387. }
  144388. // Remove from scene
  144389. var index = this._scene.spriteManagers.indexOf(this);
  144390. this._scene.spriteManagers.splice(index, 1);
  144391. // Callback
  144392. this.onDisposeObservable.notifyObservers(this);
  144393. this.onDisposeObservable.clear();
  144394. };
  144395. return SpriteManager;
  144396. }());
  144397. /***/ }),
  144398. /***/ "./Sprites/spriteSceneComponent.ts":
  144399. /*!*****************************************!*\
  144400. !*** ./Sprites/spriteSceneComponent.ts ***!
  144401. \*****************************************/
  144402. /*! exports provided: SpriteSceneComponent */
  144403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144404. "use strict";
  144405. __webpack_require__.r(__webpack_exports__);
  144406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  144407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  144408. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  144409. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  144410. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  144411. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  144412. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  144413. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  144414. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  144415. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  144416. return null;
  144417. }
  144418. var pickingInfo = null;
  144419. if (!camera) {
  144420. if (!this.activeCamera) {
  144421. return null;
  144422. }
  144423. camera = this.activeCamera;
  144424. }
  144425. if (this.spriteManagers.length > 0) {
  144426. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  144427. var spriteManager = this.spriteManagers[spriteIndex];
  144428. if (!spriteManager.isPickable) {
  144429. continue;
  144430. }
  144431. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  144432. if (!result || !result.hit) {
  144433. continue;
  144434. }
  144435. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  144436. continue;
  144437. }
  144438. pickingInfo = result;
  144439. if (fastCheck) {
  144440. break;
  144441. }
  144442. }
  144443. }
  144444. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  144445. };
  144446. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  144447. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  144448. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  144449. };
  144450. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  144451. if (!this._tempSpritePickingRay) {
  144452. return null;
  144453. }
  144454. if (!camera) {
  144455. if (!this.activeCamera) {
  144456. return null;
  144457. }
  144458. camera = this.activeCamera;
  144459. }
  144460. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  144461. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  144462. };
  144463. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  144464. if (this._pointerOverSprite === sprite) {
  144465. return;
  144466. }
  144467. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  144468. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  144469. }
  144470. this._pointerOverSprite = sprite;
  144471. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  144472. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  144473. }
  144474. };
  144475. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  144476. return this._pointerOverSprite;
  144477. };
  144478. /**
  144479. * Defines the sprite scene component responsible to manage sprites
  144480. * in a given scene.
  144481. */
  144482. var SpriteSceneComponent = /** @class */ (function () {
  144483. /**
  144484. * Creates a new instance of the component for the given scene
  144485. * @param scene Defines the scene to register the component in
  144486. */
  144487. function SpriteSceneComponent(scene) {
  144488. /**
  144489. * The component name helpfull to identify the component in the list of scene components.
  144490. */
  144491. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  144492. this.scene = scene;
  144493. this.scene.spriteManagers = new Array();
  144494. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  144495. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  144496. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  144497. this._spritePredicate = function (sprite) {
  144498. if (!sprite.actionManager) {
  144499. return false;
  144500. }
  144501. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  144502. };
  144503. }
  144504. /**
  144505. * Registers the component in a given scene
  144506. */
  144507. SpriteSceneComponent.prototype.register = function () {
  144508. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  144509. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  144510. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  144511. };
  144512. /**
  144513. * Rebuilds the elements related to this component in case of
  144514. * context lost for instance.
  144515. */
  144516. SpriteSceneComponent.prototype.rebuild = function () {
  144517. /** Nothing to do for sprites */
  144518. };
  144519. /**
  144520. * Disposes the component and the associated ressources.
  144521. */
  144522. SpriteSceneComponent.prototype.dispose = function () {
  144523. this.scene.onBeforeSpritesRenderingObservable.clear();
  144524. this.scene.onAfterSpritesRenderingObservable.clear();
  144525. var spriteManagers = this.scene.spriteManagers;
  144526. while (spriteManagers.length) {
  144527. spriteManagers[0].dispose();
  144528. }
  144529. };
  144530. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  144531. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  144532. if (result) {
  144533. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  144534. }
  144535. return result;
  144536. };
  144537. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  144538. var scene = this.scene;
  144539. if (isMeshPicked) {
  144540. scene.setPointerOverSprite(null);
  144541. }
  144542. else {
  144543. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  144544. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  144545. scene.setPointerOverSprite(pickResult.pickedSprite);
  144546. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  144547. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  144548. }
  144549. else {
  144550. canvas.style.cursor = scene.hoverCursor;
  144551. }
  144552. }
  144553. else {
  144554. scene.setPointerOverSprite(null);
  144555. }
  144556. }
  144557. return pickResult;
  144558. };
  144559. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  144560. var scene = this.scene;
  144561. scene._pickedDownSprite = null;
  144562. if (scene.spriteManagers.length > 0) {
  144563. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  144564. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  144565. if (pickResult.pickedSprite.actionManager) {
  144566. scene._pickedDownSprite = pickResult.pickedSprite;
  144567. switch (evt.button) {
  144568. case 0:
  144569. 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));
  144570. break;
  144571. case 1:
  144572. 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));
  144573. break;
  144574. case 2:
  144575. 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));
  144576. break;
  144577. }
  144578. if (pickResult.pickedSprite.actionManager) {
  144579. 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));
  144580. }
  144581. }
  144582. }
  144583. }
  144584. return pickResult;
  144585. };
  144586. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  144587. var scene = this.scene;
  144588. if (scene.spriteManagers.length > 0) {
  144589. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  144590. if (spritePickResult) {
  144591. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  144592. if (spritePickResult.pickedSprite.actionManager) {
  144593. 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));
  144594. if (spritePickResult.pickedSprite.actionManager) {
  144595. if (!this.scene._inputManager._isPointerSwiping()) {
  144596. 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));
  144597. }
  144598. }
  144599. }
  144600. }
  144601. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  144602. 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));
  144603. }
  144604. }
  144605. }
  144606. return pickResult;
  144607. };
  144608. return SpriteSceneComponent;
  144609. }());
  144610. /***/ }),
  144611. /***/ "./States/alphaCullingState.ts":
  144612. /*!*************************************!*\
  144613. !*** ./States/alphaCullingState.ts ***!
  144614. \*************************************/
  144615. /*! exports provided: _AlphaState */
  144616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144617. "use strict";
  144618. __webpack_require__.r(__webpack_exports__);
  144619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  144620. /**
  144621. * @hidden
  144622. **/
  144623. var _AlphaState = /** @class */ (function () {
  144624. /**
  144625. * Initializes the state.
  144626. */
  144627. function _AlphaState() {
  144628. this._isAlphaBlendDirty = false;
  144629. this._isBlendFunctionParametersDirty = false;
  144630. this._isBlendEquationParametersDirty = false;
  144631. this._isBlendConstantsDirty = false;
  144632. this._alphaBlend = false;
  144633. this._blendFunctionParameters = new Array(4);
  144634. this._blendEquationParameters = new Array(2);
  144635. this._blendConstants = new Array(4);
  144636. this.reset();
  144637. }
  144638. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  144639. get: function () {
  144640. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  144641. },
  144642. enumerable: true,
  144643. configurable: true
  144644. });
  144645. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  144646. get: function () {
  144647. return this._alphaBlend;
  144648. },
  144649. set: function (value) {
  144650. if (this._alphaBlend === value) {
  144651. return;
  144652. }
  144653. this._alphaBlend = value;
  144654. this._isAlphaBlendDirty = true;
  144655. },
  144656. enumerable: true,
  144657. configurable: true
  144658. });
  144659. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  144660. if (this._blendConstants[0] === r &&
  144661. this._blendConstants[1] === g &&
  144662. this._blendConstants[2] === b &&
  144663. this._blendConstants[3] === a) {
  144664. return;
  144665. }
  144666. this._blendConstants[0] = r;
  144667. this._blendConstants[1] = g;
  144668. this._blendConstants[2] = b;
  144669. this._blendConstants[3] = a;
  144670. this._isBlendConstantsDirty = true;
  144671. };
  144672. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  144673. if (this._blendFunctionParameters[0] === value0 &&
  144674. this._blendFunctionParameters[1] === value1 &&
  144675. this._blendFunctionParameters[2] === value2 &&
  144676. this._blendFunctionParameters[3] === value3) {
  144677. return;
  144678. }
  144679. this._blendFunctionParameters[0] = value0;
  144680. this._blendFunctionParameters[1] = value1;
  144681. this._blendFunctionParameters[2] = value2;
  144682. this._blendFunctionParameters[3] = value3;
  144683. this._isBlendFunctionParametersDirty = true;
  144684. };
  144685. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  144686. if (this._blendEquationParameters[0] === rgb &&
  144687. this._blendEquationParameters[1] === alpha) {
  144688. return;
  144689. }
  144690. this._blendEquationParameters[0] = rgb;
  144691. this._blendEquationParameters[1] = alpha;
  144692. this._isBlendEquationParametersDirty = true;
  144693. };
  144694. _AlphaState.prototype.reset = function () {
  144695. this._alphaBlend = false;
  144696. this._blendFunctionParameters[0] = null;
  144697. this._blendFunctionParameters[1] = null;
  144698. this._blendFunctionParameters[2] = null;
  144699. this._blendFunctionParameters[3] = null;
  144700. this._blendEquationParameters[0] = null;
  144701. this._blendEquationParameters[1] = null;
  144702. this._blendConstants[0] = null;
  144703. this._blendConstants[1] = null;
  144704. this._blendConstants[2] = null;
  144705. this._blendConstants[3] = null;
  144706. this._isAlphaBlendDirty = true;
  144707. this._isBlendFunctionParametersDirty = false;
  144708. this._isBlendEquationParametersDirty = false;
  144709. this._isBlendConstantsDirty = false;
  144710. };
  144711. _AlphaState.prototype.apply = function (gl) {
  144712. if (!this.isDirty) {
  144713. return;
  144714. }
  144715. // Alpha blend
  144716. if (this._isAlphaBlendDirty) {
  144717. if (this._alphaBlend) {
  144718. gl.enable(gl.BLEND);
  144719. }
  144720. else {
  144721. gl.disable(gl.BLEND);
  144722. }
  144723. this._isAlphaBlendDirty = false;
  144724. }
  144725. // Alpha function
  144726. if (this._isBlendFunctionParametersDirty) {
  144727. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  144728. this._isBlendFunctionParametersDirty = false;
  144729. }
  144730. // Alpha equation
  144731. if (this._isBlendEquationParametersDirty) {
  144732. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  144733. this._isBlendEquationParametersDirty = false;
  144734. }
  144735. // Constants
  144736. if (this._isBlendConstantsDirty) {
  144737. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  144738. this._isBlendConstantsDirty = false;
  144739. }
  144740. };
  144741. return _AlphaState;
  144742. }());
  144743. /***/ }),
  144744. /***/ "./States/depthCullingState.ts":
  144745. /*!*************************************!*\
  144746. !*** ./States/depthCullingState.ts ***!
  144747. \*************************************/
  144748. /*! exports provided: _DepthCullingState */
  144749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144750. "use strict";
  144751. __webpack_require__.r(__webpack_exports__);
  144752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  144753. /**
  144754. * @hidden
  144755. **/
  144756. var _DepthCullingState = /** @class */ (function () {
  144757. /**
  144758. * Initializes the state.
  144759. */
  144760. function _DepthCullingState() {
  144761. this._isDepthTestDirty = false;
  144762. this._isDepthMaskDirty = false;
  144763. this._isDepthFuncDirty = false;
  144764. this._isCullFaceDirty = false;
  144765. this._isCullDirty = false;
  144766. this._isZOffsetDirty = false;
  144767. this._isFrontFaceDirty = false;
  144768. this.reset();
  144769. }
  144770. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  144771. get: function () {
  144772. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  144773. },
  144774. enumerable: true,
  144775. configurable: true
  144776. });
  144777. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  144778. get: function () {
  144779. return this._zOffset;
  144780. },
  144781. set: function (value) {
  144782. if (this._zOffset === value) {
  144783. return;
  144784. }
  144785. this._zOffset = value;
  144786. this._isZOffsetDirty = true;
  144787. },
  144788. enumerable: true,
  144789. configurable: true
  144790. });
  144791. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  144792. get: function () {
  144793. return this._cullFace;
  144794. },
  144795. set: function (value) {
  144796. if (this._cullFace === value) {
  144797. return;
  144798. }
  144799. this._cullFace = value;
  144800. this._isCullFaceDirty = true;
  144801. },
  144802. enumerable: true,
  144803. configurable: true
  144804. });
  144805. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  144806. get: function () {
  144807. return this._cull;
  144808. },
  144809. set: function (value) {
  144810. if (this._cull === value) {
  144811. return;
  144812. }
  144813. this._cull = value;
  144814. this._isCullDirty = true;
  144815. },
  144816. enumerable: true,
  144817. configurable: true
  144818. });
  144819. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  144820. get: function () {
  144821. return this._depthFunc;
  144822. },
  144823. set: function (value) {
  144824. if (this._depthFunc === value) {
  144825. return;
  144826. }
  144827. this._depthFunc = value;
  144828. this._isDepthFuncDirty = true;
  144829. },
  144830. enumerable: true,
  144831. configurable: true
  144832. });
  144833. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  144834. get: function () {
  144835. return this._depthMask;
  144836. },
  144837. set: function (value) {
  144838. if (this._depthMask === value) {
  144839. return;
  144840. }
  144841. this._depthMask = value;
  144842. this._isDepthMaskDirty = true;
  144843. },
  144844. enumerable: true,
  144845. configurable: true
  144846. });
  144847. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  144848. get: function () {
  144849. return this._depthTest;
  144850. },
  144851. set: function (value) {
  144852. if (this._depthTest === value) {
  144853. return;
  144854. }
  144855. this._depthTest = value;
  144856. this._isDepthTestDirty = true;
  144857. },
  144858. enumerable: true,
  144859. configurable: true
  144860. });
  144861. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  144862. get: function () {
  144863. return this._frontFace;
  144864. },
  144865. set: function (value) {
  144866. if (this._frontFace === value) {
  144867. return;
  144868. }
  144869. this._frontFace = value;
  144870. this._isFrontFaceDirty = true;
  144871. },
  144872. enumerable: true,
  144873. configurable: true
  144874. });
  144875. _DepthCullingState.prototype.reset = function () {
  144876. this._depthMask = true;
  144877. this._depthTest = true;
  144878. this._depthFunc = null;
  144879. this._cullFace = null;
  144880. this._cull = null;
  144881. this._zOffset = 0;
  144882. this._frontFace = null;
  144883. this._isDepthTestDirty = true;
  144884. this._isDepthMaskDirty = true;
  144885. this._isDepthFuncDirty = false;
  144886. this._isCullFaceDirty = false;
  144887. this._isCullDirty = false;
  144888. this._isZOffsetDirty = false;
  144889. this._isFrontFaceDirty = false;
  144890. };
  144891. _DepthCullingState.prototype.apply = function (gl) {
  144892. if (!this.isDirty) {
  144893. return;
  144894. }
  144895. // Cull
  144896. if (this._isCullDirty) {
  144897. if (this.cull) {
  144898. gl.enable(gl.CULL_FACE);
  144899. }
  144900. else {
  144901. gl.disable(gl.CULL_FACE);
  144902. }
  144903. this._isCullDirty = false;
  144904. }
  144905. // Cull face
  144906. if (this._isCullFaceDirty) {
  144907. gl.cullFace(this.cullFace);
  144908. this._isCullFaceDirty = false;
  144909. }
  144910. // Depth mask
  144911. if (this._isDepthMaskDirty) {
  144912. gl.depthMask(this.depthMask);
  144913. this._isDepthMaskDirty = false;
  144914. }
  144915. // Depth test
  144916. if (this._isDepthTestDirty) {
  144917. if (this.depthTest) {
  144918. gl.enable(gl.DEPTH_TEST);
  144919. }
  144920. else {
  144921. gl.disable(gl.DEPTH_TEST);
  144922. }
  144923. this._isDepthTestDirty = false;
  144924. }
  144925. // Depth func
  144926. if (this._isDepthFuncDirty) {
  144927. gl.depthFunc(this.depthFunc);
  144928. this._isDepthFuncDirty = false;
  144929. }
  144930. // zOffset
  144931. if (this._isZOffsetDirty) {
  144932. if (this.zOffset) {
  144933. gl.enable(gl.POLYGON_OFFSET_FILL);
  144934. gl.polygonOffset(this.zOffset, 0);
  144935. }
  144936. else {
  144937. gl.disable(gl.POLYGON_OFFSET_FILL);
  144938. }
  144939. this._isZOffsetDirty = false;
  144940. }
  144941. // Front face
  144942. if (this._isFrontFaceDirty) {
  144943. gl.frontFace(this.frontFace);
  144944. this._isFrontFaceDirty = false;
  144945. }
  144946. };
  144947. return _DepthCullingState;
  144948. }());
  144949. /***/ }),
  144950. /***/ "./States/index.ts":
  144951. /*!*************************!*\
  144952. !*** ./States/index.ts ***!
  144953. \*************************/
  144954. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  144955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144956. "use strict";
  144957. __webpack_require__.r(__webpack_exports__);
  144958. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  144959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  144960. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  144961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  144962. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  144963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  144964. /***/ }),
  144965. /***/ "./States/stencilState.ts":
  144966. /*!********************************!*\
  144967. !*** ./States/stencilState.ts ***!
  144968. \********************************/
  144969. /*! exports provided: _StencilState */
  144970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144971. "use strict";
  144972. __webpack_require__.r(__webpack_exports__);
  144973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  144974. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  144975. /**
  144976. * @hidden
  144977. **/
  144978. var _StencilState = /** @class */ (function () {
  144979. function _StencilState() {
  144980. this._isStencilTestDirty = false;
  144981. this._isStencilMaskDirty = false;
  144982. this._isStencilFuncDirty = false;
  144983. this._isStencilOpDirty = false;
  144984. this.reset();
  144985. }
  144986. Object.defineProperty(_StencilState.prototype, "isDirty", {
  144987. get: function () {
  144988. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  144989. },
  144990. enumerable: true,
  144991. configurable: true
  144992. });
  144993. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  144994. get: function () {
  144995. return this._stencilFunc;
  144996. },
  144997. set: function (value) {
  144998. if (this._stencilFunc === value) {
  144999. return;
  145000. }
  145001. this._stencilFunc = value;
  145002. this._isStencilFuncDirty = true;
  145003. },
  145004. enumerable: true,
  145005. configurable: true
  145006. });
  145007. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  145008. get: function () {
  145009. return this._stencilFuncRef;
  145010. },
  145011. set: function (value) {
  145012. if (this._stencilFuncRef === value) {
  145013. return;
  145014. }
  145015. this._stencilFuncRef = value;
  145016. this._isStencilFuncDirty = true;
  145017. },
  145018. enumerable: true,
  145019. configurable: true
  145020. });
  145021. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  145022. get: function () {
  145023. return this._stencilFuncMask;
  145024. },
  145025. set: function (value) {
  145026. if (this._stencilFuncMask === value) {
  145027. return;
  145028. }
  145029. this._stencilFuncMask = value;
  145030. this._isStencilFuncDirty = true;
  145031. },
  145032. enumerable: true,
  145033. configurable: true
  145034. });
  145035. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  145036. get: function () {
  145037. return this._stencilOpStencilFail;
  145038. },
  145039. set: function (value) {
  145040. if (this._stencilOpStencilFail === value) {
  145041. return;
  145042. }
  145043. this._stencilOpStencilFail = value;
  145044. this._isStencilOpDirty = true;
  145045. },
  145046. enumerable: true,
  145047. configurable: true
  145048. });
  145049. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  145050. get: function () {
  145051. return this._stencilOpDepthFail;
  145052. },
  145053. set: function (value) {
  145054. if (this._stencilOpDepthFail === value) {
  145055. return;
  145056. }
  145057. this._stencilOpDepthFail = value;
  145058. this._isStencilOpDirty = true;
  145059. },
  145060. enumerable: true,
  145061. configurable: true
  145062. });
  145063. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  145064. get: function () {
  145065. return this._stencilOpStencilDepthPass;
  145066. },
  145067. set: function (value) {
  145068. if (this._stencilOpStencilDepthPass === value) {
  145069. return;
  145070. }
  145071. this._stencilOpStencilDepthPass = value;
  145072. this._isStencilOpDirty = true;
  145073. },
  145074. enumerable: true,
  145075. configurable: true
  145076. });
  145077. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  145078. get: function () {
  145079. return this._stencilMask;
  145080. },
  145081. set: function (value) {
  145082. if (this._stencilMask === value) {
  145083. return;
  145084. }
  145085. this._stencilMask = value;
  145086. this._isStencilMaskDirty = true;
  145087. },
  145088. enumerable: true,
  145089. configurable: true
  145090. });
  145091. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  145092. get: function () {
  145093. return this._stencilTest;
  145094. },
  145095. set: function (value) {
  145096. if (this._stencilTest === value) {
  145097. return;
  145098. }
  145099. this._stencilTest = value;
  145100. this._isStencilTestDirty = true;
  145101. },
  145102. enumerable: true,
  145103. configurable: true
  145104. });
  145105. _StencilState.prototype.reset = function () {
  145106. this._stencilTest = false;
  145107. this._stencilMask = 0xFF;
  145108. this._stencilFunc = _StencilState.ALWAYS;
  145109. this._stencilFuncRef = 1;
  145110. this._stencilFuncMask = 0xFF;
  145111. this._stencilOpStencilFail = _StencilState.KEEP;
  145112. this._stencilOpDepthFail = _StencilState.KEEP;
  145113. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  145114. this._isStencilTestDirty = true;
  145115. this._isStencilMaskDirty = true;
  145116. this._isStencilFuncDirty = true;
  145117. this._isStencilOpDirty = true;
  145118. };
  145119. _StencilState.prototype.apply = function (gl) {
  145120. if (!this.isDirty) {
  145121. return;
  145122. }
  145123. // Stencil test
  145124. if (this._isStencilTestDirty) {
  145125. if (this.stencilTest) {
  145126. gl.enable(gl.STENCIL_TEST);
  145127. }
  145128. else {
  145129. gl.disable(gl.STENCIL_TEST);
  145130. }
  145131. this._isStencilTestDirty = false;
  145132. }
  145133. // Stencil mask
  145134. if (this._isStencilMaskDirty) {
  145135. gl.stencilMask(this.stencilMask);
  145136. this._isStencilMaskDirty = false;
  145137. }
  145138. // Stencil func
  145139. if (this._isStencilFuncDirty) {
  145140. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  145141. this._isStencilFuncDirty = false;
  145142. }
  145143. // Stencil op
  145144. if (this._isStencilOpDirty) {
  145145. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  145146. this._isStencilOpDirty = false;
  145147. }
  145148. };
  145149. /** 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 */
  145150. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  145151. /** Passed to stencilOperation to specify that stencil value must be kept */
  145152. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  145153. /** Passed to stencilOperation to specify that stencil value must be replaced */
  145154. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  145155. return _StencilState;
  145156. }());
  145157. /***/ }),
  145158. /***/ "./abstractScene.ts":
  145159. /*!**************************!*\
  145160. !*** ./abstractScene.ts ***!
  145161. \**************************/
  145162. /*! exports provided: AbstractScene */
  145163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  145164. "use strict";
  145165. __webpack_require__.r(__webpack_exports__);
  145166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  145167. /**
  145168. * Base class of the scene acting as a container for the different elements composing a scene.
  145169. * This class is dynamically extended by the different components of the scene increasing
  145170. * flexibility and reducing coupling
  145171. */
  145172. var AbstractScene = /** @class */ (function () {
  145173. function AbstractScene() {
  145174. /**
  145175. * Gets the list of root nodes (ie. nodes with no parent)
  145176. */
  145177. this.rootNodes = new Array();
  145178. /** All of the cameras added to this scene
  145179. * @see http://doc.babylonjs.com/babylon101/cameras
  145180. */
  145181. this.cameras = new Array();
  145182. /**
  145183. * All of the lights added to this scene
  145184. * @see http://doc.babylonjs.com/babylon101/lights
  145185. */
  145186. this.lights = new Array();
  145187. /**
  145188. * All of the (abstract) meshes added to this scene
  145189. */
  145190. this.meshes = new Array();
  145191. /**
  145192. * The list of skeletons added to the scene
  145193. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  145194. */
  145195. this.skeletons = new Array();
  145196. /**
  145197. * All of the particle systems added to this scene
  145198. * @see http://doc.babylonjs.com/babylon101/particles
  145199. */
  145200. this.particleSystems = new Array();
  145201. /**
  145202. * Gets a list of Animations associated with the scene
  145203. */
  145204. this.animations = [];
  145205. /**
  145206. * All of the animation groups added to this scene
  145207. * @see http://doc.babylonjs.com/how_to/group
  145208. */
  145209. this.animationGroups = new Array();
  145210. /**
  145211. * All of the multi-materials added to this scene
  145212. * @see http://doc.babylonjs.com/how_to/multi_materials
  145213. */
  145214. this.multiMaterials = new Array();
  145215. /**
  145216. * All of the materials added to this scene
  145217. * In the context of a Scene, it is not supposed to be modified manually.
  145218. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  145219. * Note also that the order of the Material wihin the array is not significant and might change.
  145220. * @see http://doc.babylonjs.com/babylon101/materials
  145221. */
  145222. this.materials = new Array();
  145223. /**
  145224. * The list of morph target managers added to the scene
  145225. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  145226. */
  145227. this.morphTargetManagers = new Array();
  145228. /**
  145229. * The list of geometries used in the scene.
  145230. */
  145231. this.geometries = new Array();
  145232. /**
  145233. * All of the tranform nodes added to this scene
  145234. * In the context of a Scene, it is not supposed to be modified manually.
  145235. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  145236. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  145237. * @see http://doc.babylonjs.com/how_to/transformnode
  145238. */
  145239. this.transformNodes = new Array();
  145240. /**
  145241. * ActionManagers available on the scene.
  145242. */
  145243. this.actionManagers = new Array();
  145244. /**
  145245. * Textures to keep.
  145246. */
  145247. this.textures = new Array();
  145248. /**
  145249. * Environment texture for the scene
  145250. */
  145251. this.environmentTexture = null;
  145252. }
  145253. /**
  145254. * Adds a parser in the list of available ones
  145255. * @param name Defines the name of the parser
  145256. * @param parser Defines the parser to add
  145257. */
  145258. AbstractScene.AddParser = function (name, parser) {
  145259. this._BabylonFileParsers[name] = parser;
  145260. };
  145261. /**
  145262. * Gets a general parser from the list of avaialble ones
  145263. * @param name Defines the name of the parser
  145264. * @returns the requested parser or null
  145265. */
  145266. AbstractScene.GetParser = function (name) {
  145267. if (this._BabylonFileParsers[name]) {
  145268. return this._BabylonFileParsers[name];
  145269. }
  145270. return null;
  145271. };
  145272. /**
  145273. * Adds n individual parser in the list of available ones
  145274. * @param name Defines the name of the parser
  145275. * @param parser Defines the parser to add
  145276. */
  145277. AbstractScene.AddIndividualParser = function (name, parser) {
  145278. this._IndividualBabylonFileParsers[name] = parser;
  145279. };
  145280. /**
  145281. * Gets an individual parser from the list of avaialble ones
  145282. * @param name Defines the name of the parser
  145283. * @returns the requested parser or null
  145284. */
  145285. AbstractScene.GetIndividualParser = function (name) {
  145286. if (this._IndividualBabylonFileParsers[name]) {
  145287. return this._IndividualBabylonFileParsers[name];
  145288. }
  145289. return null;
  145290. };
  145291. /**
  145292. * Parser json data and populate both a scene and its associated container object
  145293. * @param jsonData Defines the data to parse
  145294. * @param scene Defines the scene to parse the data for
  145295. * @param container Defines the container attached to the parsing sequence
  145296. * @param rootUrl Defines the root url of the data
  145297. */
  145298. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  145299. for (var parserName in this._BabylonFileParsers) {
  145300. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  145301. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  145302. }
  145303. }
  145304. };
  145305. /**
  145306. * Stores the list of available parsers in the application.
  145307. */
  145308. AbstractScene._BabylonFileParsers = {};
  145309. /**
  145310. * Stores the list of available individual parsers in the application.
  145311. */
  145312. AbstractScene._IndividualBabylonFileParsers = {};
  145313. return AbstractScene;
  145314. }());
  145315. /***/ }),
  145316. /***/ "./assetContainer.ts":
  145317. /*!***************************!*\
  145318. !*** ./assetContainer.ts ***!
  145319. \***************************/
  145320. /*! exports provided: KeepAssets, AssetContainer */
  145321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  145322. "use strict";
  145323. __webpack_require__.r(__webpack_exports__);
  145324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  145325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  145326. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  145327. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  145328. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  145329. /**
  145330. * Set of assets to keep when moving a scene into an asset container.
  145331. */
  145332. var KeepAssets = /** @class */ (function (_super) {
  145333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  145334. function KeepAssets() {
  145335. return _super !== null && _super.apply(this, arguments) || this;
  145336. }
  145337. return KeepAssets;
  145338. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  145339. /**
  145340. * Container with a set of assets that can be added or removed from a scene.
  145341. */
  145342. var AssetContainer = /** @class */ (function (_super) {
  145343. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  145344. /**
  145345. * Instantiates an AssetContainer.
  145346. * @param scene The scene the AssetContainer belongs to.
  145347. */
  145348. function AssetContainer(scene) {
  145349. var _this = _super.call(this) || this;
  145350. _this.scene = scene;
  145351. _this["sounds"] = [];
  145352. _this["effectLayers"] = [];
  145353. _this["layers"] = [];
  145354. _this["lensFlareSystems"] = [];
  145355. _this["proceduralTextures"] = [];
  145356. _this["reflectionProbes"] = [];
  145357. return _this;
  145358. }
  145359. /**
  145360. * Adds all the assets from the container to the scene.
  145361. */
  145362. AssetContainer.prototype.addAllToScene = function () {
  145363. var _this = this;
  145364. this.cameras.forEach(function (o) {
  145365. _this.scene.addCamera(o);
  145366. });
  145367. this.lights.forEach(function (o) {
  145368. _this.scene.addLight(o);
  145369. });
  145370. this.meshes.forEach(function (o) {
  145371. _this.scene.addMesh(o);
  145372. });
  145373. this.skeletons.forEach(function (o) {
  145374. _this.scene.addSkeleton(o);
  145375. });
  145376. this.animations.forEach(function (o) {
  145377. _this.scene.addAnimation(o);
  145378. });
  145379. this.animationGroups.forEach(function (o) {
  145380. _this.scene.addAnimationGroup(o);
  145381. });
  145382. this.multiMaterials.forEach(function (o) {
  145383. _this.scene.addMultiMaterial(o);
  145384. });
  145385. this.materials.forEach(function (o) {
  145386. _this.scene.addMaterial(o);
  145387. });
  145388. this.morphTargetManagers.forEach(function (o) {
  145389. _this.scene.addMorphTargetManager(o);
  145390. });
  145391. this.geometries.forEach(function (o) {
  145392. _this.scene.addGeometry(o);
  145393. });
  145394. this.transformNodes.forEach(function (o) {
  145395. _this.scene.addTransformNode(o);
  145396. });
  145397. this.actionManagers.forEach(function (o) {
  145398. _this.scene.addActionManager(o);
  145399. });
  145400. this.textures.forEach(function (o) {
  145401. _this.scene.addTexture(o);
  145402. });
  145403. this.reflectionProbes.forEach(function (o) {
  145404. _this.scene.addReflectionProbe(o);
  145405. });
  145406. if (this.environmentTexture) {
  145407. this.scene.environmentTexture = this.environmentTexture;
  145408. }
  145409. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  145410. var component = _a[_i];
  145411. component.addFromContainer(this);
  145412. }
  145413. };
  145414. /**
  145415. * Removes all the assets in the container from the scene
  145416. */
  145417. AssetContainer.prototype.removeAllFromScene = function () {
  145418. var _this = this;
  145419. this.cameras.forEach(function (o) {
  145420. _this.scene.removeCamera(o);
  145421. });
  145422. this.lights.forEach(function (o) {
  145423. _this.scene.removeLight(o);
  145424. });
  145425. this.meshes.forEach(function (o) {
  145426. _this.scene.removeMesh(o);
  145427. });
  145428. this.skeletons.forEach(function (o) {
  145429. _this.scene.removeSkeleton(o);
  145430. });
  145431. this.animations.forEach(function (o) {
  145432. _this.scene.removeAnimation(o);
  145433. });
  145434. this.animationGroups.forEach(function (o) {
  145435. _this.scene.removeAnimationGroup(o);
  145436. });
  145437. this.multiMaterials.forEach(function (o) {
  145438. _this.scene.removeMultiMaterial(o);
  145439. });
  145440. this.materials.forEach(function (o) {
  145441. _this.scene.removeMaterial(o);
  145442. });
  145443. this.morphTargetManagers.forEach(function (o) {
  145444. _this.scene.removeMorphTargetManager(o);
  145445. });
  145446. this.geometries.forEach(function (o) {
  145447. _this.scene.removeGeometry(o);
  145448. });
  145449. this.transformNodes.forEach(function (o) {
  145450. _this.scene.removeTransformNode(o);
  145451. });
  145452. this.actionManagers.forEach(function (o) {
  145453. _this.scene.removeActionManager(o);
  145454. });
  145455. this.textures.forEach(function (o) {
  145456. _this.scene.removeTexture(o);
  145457. });
  145458. this.reflectionProbes.forEach(function (o) {
  145459. _this.scene.removeReflectionProbe(o);
  145460. });
  145461. if (this.environmentTexture === this.scene.environmentTexture) {
  145462. this.scene.environmentTexture = null;
  145463. }
  145464. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  145465. var component = _a[_i];
  145466. component.removeFromContainer(this);
  145467. }
  145468. };
  145469. /**
  145470. * Disposes all the assets in the container
  145471. */
  145472. AssetContainer.prototype.dispose = function () {
  145473. this.cameras.forEach(function (o) {
  145474. o.dispose();
  145475. });
  145476. this.cameras = [];
  145477. this.lights.forEach(function (o) {
  145478. o.dispose();
  145479. });
  145480. this.lights = [];
  145481. this.meshes.forEach(function (o) {
  145482. o.dispose();
  145483. });
  145484. this.meshes = [];
  145485. this.skeletons.forEach(function (o) {
  145486. o.dispose();
  145487. });
  145488. this.skeletons = [];
  145489. this.animationGroups.forEach(function (o) {
  145490. o.dispose();
  145491. });
  145492. this.animationGroups = [];
  145493. this.multiMaterials.forEach(function (o) {
  145494. o.dispose();
  145495. });
  145496. this.multiMaterials = [];
  145497. this.materials.forEach(function (o) {
  145498. o.dispose();
  145499. });
  145500. this.materials = [];
  145501. this.geometries.forEach(function (o) {
  145502. o.dispose();
  145503. });
  145504. this.geometries = [];
  145505. this.transformNodes.forEach(function (o) {
  145506. o.dispose();
  145507. });
  145508. this.transformNodes = [];
  145509. this.actionManagers.forEach(function (o) {
  145510. o.dispose();
  145511. });
  145512. this.actionManagers = [];
  145513. this.textures.forEach(function (o) {
  145514. o.dispose();
  145515. });
  145516. this.textures = [];
  145517. this.reflectionProbes.forEach(function (o) {
  145518. o.dispose();
  145519. });
  145520. this.reflectionProbes = [];
  145521. if (this.environmentTexture) {
  145522. this.environmentTexture.dispose();
  145523. this.environmentTexture = null;
  145524. }
  145525. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  145526. var component = _a[_i];
  145527. component.removeFromContainer(this, true);
  145528. }
  145529. };
  145530. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  145531. if (!sourceAssets) {
  145532. return;
  145533. }
  145534. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  145535. var asset = sourceAssets_1[_i];
  145536. var move = true;
  145537. if (keepAssets) {
  145538. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  145539. var keepAsset = keepAssets_1[_a];
  145540. if (asset === keepAsset) {
  145541. move = false;
  145542. break;
  145543. }
  145544. }
  145545. }
  145546. if (move) {
  145547. targetAssets.push(asset);
  145548. }
  145549. }
  145550. };
  145551. /**
  145552. * Removes all the assets contained in the scene and adds them to the container.
  145553. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  145554. */
  145555. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  145556. if (keepAssets === undefined) {
  145557. keepAssets = new KeepAssets();
  145558. }
  145559. for (var key in this) {
  145560. if (this.hasOwnProperty(key)) {
  145561. this[key] = this[key] || (key === "environmentTexture" ? null : []);
  145562. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  145563. }
  145564. }
  145565. this.removeAllFromScene();
  145566. };
  145567. /**
  145568. * 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.
  145569. * @returns the root mesh
  145570. */
  145571. AssetContainer.prototype.createRootMesh = function () {
  145572. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  145573. this.meshes.forEach(function (m) {
  145574. if (!m.parent) {
  145575. rootMesh.addChild(m);
  145576. }
  145577. });
  145578. this.meshes.unshift(rootMesh);
  145579. return rootMesh;
  145580. };
  145581. return AssetContainer;
  145582. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  145583. /***/ }),
  145584. /***/ "./index.ts":
  145585. /*!******************!*\
  145586. !*** ./index.ts ***!
  145587. \******************/
  145588. /*! 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, 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, _MeshCollisionData, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, WebGLPipelineContext, WebGL2ShaderProcessor, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, PlaneDragGizmo, 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, DynamicTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, EffectRenderer, EffectWrapper, Scalar, Space, Axis, Color3, Color4, TmpColors, ToGammaSpace, ToLinearSpace, Epsilon, Frustum, Plane, Size, Vector2, Vector3, Vector4, Quaternion, Matrix, TmpVectors, Viewport, SphericalHarmonics, SphericalPolynomial, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, MeshLODLevel, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DataBuffer, WebGLDataBuffer, 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, CubeMapToSphericalPolynomialTools, 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, Tools, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, BRDFTextureTools, ColorGradient, Color3Gradient, FactorGradient, GradientHelper, PerfCounter, RetryStrategy, LoadFileError, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRInput, WebXRControllerTeleportation, WebXRControllerPointerSelection, WebXRControllerModelLoader, WebXRController, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, NodeMaterialBlockTargets, NodeMaterialBlockConnectionPointTypes, NodeMaterialConnectionPoint, NodeMaterialBlock, NodeMaterialDefines, NodeMaterial, NodeMaterialWellKnownValues, Orientation, BezierCurve, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, DracoCompression, TiledBoxBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TiledPlaneBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, RecastJSPlugin, RecastJSCrowd, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, _BasisTextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, MultiplyBlock, AddBlock, ClampBlock, CrossBlock, DotBlock, TransformBlock, NodeMaterialOptimizer, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline, VertexOutputBlock, BonesBlock, InstancesBlock, MorphTargetsBlock, FragmentOutputBlock, AlphaTestBlock, ColorMergerBlock, VectorMergerBlock, ColorSplitterBlock, VectorSplitterBlock, ImageProcessingBlock, FogBlock, LightBlock, TextureBlock, InputBlock */
  145589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  145590. "use strict";
  145591. __webpack_require__.r(__webpack_exports__);
  145592. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  145593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  145594. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  145595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  145596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  145597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  145598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  145599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  145600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  145601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  145602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  145603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  145604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  145605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  145606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  145607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  145608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  145609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  145610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  145611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  145612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  145613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  145614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  145615. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  145616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  145617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["_IAnimationState"]; });
  145618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  145619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  145620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  145621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  145622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  145623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  145624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  145625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  145626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  145627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  145628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  145629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  145630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  145631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  145632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  145633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  145634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  145635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  145636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  145637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  145638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  145639. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  145640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  145641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  145642. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  145643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  145644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  145645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  145646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  145647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  145648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  145649. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  145650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  145651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  145652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  145653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  145654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  145655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  145656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  145657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  145658. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  145659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  145660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  145661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  145662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  145663. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  145664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  145665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  145666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  145667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  145668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  145669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  145670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  145671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  145672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  145673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  145674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  145675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  145676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  145677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  145678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  145679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  145680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  145681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  145682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  145683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  145684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  145685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  145686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  145687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  145688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  145689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  145690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  145691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  145692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  145693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  145694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  145695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  145696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  145697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  145698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  145699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  145700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  145701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  145702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  145703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  145704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  145705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  145706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  145707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  145708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  145709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  145710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  145711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  145712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  145713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  145714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  145715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  145716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  145717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  145718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  145719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerTeleportation", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRControllerTeleportation"]; });
  145720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerPointerSelection", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRControllerPointerSelection"]; });
  145721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRControllerModelLoader", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRControllerModelLoader"]; });
  145722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  145723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  145724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  145725. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  145726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  145727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  145728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  145729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  145730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["_MeshCollisionData"]; });
  145731. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  145732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  145733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  145734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  145735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  145736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  145737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  145738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  145739. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  145740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  145741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  145742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  145743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  145744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  145745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  145746. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  145747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  145748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  145749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  145750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  145751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  145752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  145753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  145754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  145755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["WebGLPipelineContext"]; });
  145756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGL2ShaderProcessor", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["WebGL2ShaderProcessor"]; });
  145757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  145758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  145759. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  145760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  145761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  145762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  145763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  145764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  145765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  145766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  145767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  145768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  145769. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  145770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  145771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  145772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  145773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  145774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  145775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  145776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  145777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  145778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  145779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  145780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  145781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  145782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  145783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  145784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  145785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  145786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  145787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  145788. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  145789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  145790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  145791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  145792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  145793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  145794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  145795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  145796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  145797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  145798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  145799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneDragGizmo"]; });
  145800. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  145801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  145802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  145803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  145804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  145805. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  145806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  145807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  145808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  145809. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  145810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  145811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  145812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  145813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  145814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  145815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  145816. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  145817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  145818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  145819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  145820. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  145821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  145822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  145823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  145824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  145825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  145826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  145827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  145828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  145829. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  145830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  145831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  145832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  145833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  145834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  145835. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  145836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  145837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  145838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  145839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  145840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  145841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  145842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  145843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  145844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  145845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  145846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  145847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  145848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  145849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  145850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  145851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  145852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  145853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  145854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  145855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  145856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  145857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  145858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  145859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  145860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  145861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  145862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  145863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  145864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectRenderer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectRenderer"]; });
  145865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectWrapper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectWrapper"]; });
  145866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  145867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterialDefines"]; });
  145868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  145869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  145870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  145871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  145872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  145873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  145874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  145875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  145876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  145877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  145878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HtmlElementTexture"]; });
  145879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockTargets", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialBlockTargets"]; });
  145880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlockConnectionPointTypes", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialBlockConnectionPointTypes"]; });
  145881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialConnectionPoint", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialConnectionPoint"]; });
  145882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialBlock"]; });
  145883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialDefines"]; });
  145884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterial"]; });
  145885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialWellKnownValues", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialWellKnownValues"]; });
  145886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  145887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  145888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  145889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  145890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BasisTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_BasisTextureLoader"]; });
  145891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  145892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  145893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  145894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  145895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiplyBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiplyBlock"]; });
  145896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AddBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["AddBlock"]; });
  145897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClampBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ClampBlock"]; });
  145898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CrossBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CrossBlock"]; });
  145899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DotBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DotBlock"]; });
  145900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["TransformBlock"]; });
  145901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeMaterialOptimizer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NodeMaterialOptimizer"]; });
  145902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexOutputBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VertexOutputBlock"]; });
  145903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BonesBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BonesBlock"]; });
  145904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancesBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InstancesBlock"]; });
  145905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetsBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MorphTargetsBlock"]; });
  145906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FragmentOutputBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FragmentOutputBlock"]; });
  145907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AlphaTestBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["AlphaTestBlock"]; });
  145908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorMergerBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorMergerBlock"]; });
  145909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorMergerBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VectorMergerBlock"]; });
  145910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorSplitterBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorSplitterBlock"]; });
  145911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VectorSplitterBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VectorSplitterBlock"]; });
  145912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingBlock"]; });
  145913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FogBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FogBlock"]; });
  145914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["LightBlock"]; });
  145915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["TextureBlock"]; });
  145916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputBlock", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InputBlock"]; });
  145917. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  145918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  145919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  145920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  145921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  145922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  145923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpColors", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["TmpColors"]; });
  145924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  145925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  145926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  145927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  145928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  145929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  145930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  145931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  145932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  145933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  145934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  145935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TmpVectors", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["TmpVectors"]; });
  145936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  145937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  145938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  145939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  145940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  145941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  145942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  145943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  145944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  145945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  145946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  145947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  145948. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  145949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  145950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  145951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  145952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  145953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  145954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  145955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  145956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  145957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  145958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  145959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  145960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  145961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  145962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  145963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  145964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  145965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  145966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  145967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  145968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  145969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  145970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  145971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  145972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  145973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  145974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  145975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  145976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  145977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  145978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  145979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  145980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  145981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DataBuffer"]; });
  145982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["WebGLDataBuffer"]; });
  145983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  145984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledBoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TiledBoxBuilder"]; });
  145985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  145986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  145987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["HemisphereBuilder"]; });
  145988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  145989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  145990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  145991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  145992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledPlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TiledPlaneBuilder"]; });
  145993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  145994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  145995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  145996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  145997. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  145998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  145999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  146000. /* harmony import */ var _Navigation_index__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Navigation/index */ "./Navigation/index.ts");
  146001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSPlugin", function() { return _Navigation_index__WEBPACK_IMPORTED_MODULE_25__["RecastJSPlugin"]; });
  146002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RecastJSCrowd", function() { return _Navigation_index__WEBPACK_IMPORTED_MODULE_25__["RecastJSCrowd"]; });
  146003. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./node */ "./node.ts");
  146004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_26__["Node"]; });
  146005. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  146006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_27__["Database"]; });
  146007. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  146008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["BaseParticleSystem"]; });
  146009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["GPUParticleSystem"]; });
  146010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["Particle"]; });
  146011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["ParticleHelper"]; });
  146012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["ParticleSystem"]; });
  146013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["_IDoNeedToBeInTheBuild"]; });
  146014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["ParticleSystemSet"]; });
  146015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["SolidParticle"]; });
  146016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["ModelShape"]; });
  146017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["DepthSortedParticle"]; });
  146018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["SolidParticleSystem"]; });
  146019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["SubEmitterType"]; });
  146020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["SubEmitter"]; });
  146021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["BoxParticleEmitter"]; });
  146022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["ConeParticleEmitter"]; });
  146023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["CylinderParticleEmitter"]; });
  146024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["CylinderDirectedParticleEmitter"]; });
  146025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["HemisphericParticleEmitter"]; });
  146026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["PointParticleEmitter"]; });
  146027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["SphereParticleEmitter"]; });
  146028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_28__["SphereDirectedParticleEmitter"]; });
  146029. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  146030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsEngine"]; });
  146031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsEngineSceneComponent"]; });
  146032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsHelper"]; });
  146033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsRadialExplosionEventOptions"]; });
  146034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsUpdraftEventOptions"]; });
  146035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsVortexEventOptions"]; });
  146036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsRadialImpulseFalloff"]; });
  146037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsUpdraftMode"]; });
  146038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsImpostor"]; });
  146039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["PhysicsJoint"]; });
  146040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["DistanceJoint"]; });
  146041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["MotorEnabledJoint"]; });
  146042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["HingeJoint"]; });
  146043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["Hinge2Joint"]; });
  146044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["CannonJSPlugin"]; });
  146045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["AmmoJSPlugin"]; });
  146046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_29__["OimoJSPlugin"]; });
  146047. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  146048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["AnaglyphPostProcess"]; });
  146049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["BlackAndWhitePostProcess"]; });
  146050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["BloomEffect"]; });
  146051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["BloomMergePostProcess"]; });
  146052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["BlurPostProcess"]; });
  146053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["ChromaticAberrationPostProcess"]; });
  146054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["CircleOfConfusionPostProcess"]; });
  146055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["ColorCorrectionPostProcess"]; });
  146056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["ConvolutionPostProcess"]; });
  146057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DepthOfFieldBlurPostProcess"]; });
  146058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DepthOfFieldEffectBlurLevel"]; });
  146059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DepthOfFieldEffect"]; });
  146060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DepthOfFieldMergePostProcessOptions"]; });
  146061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DepthOfFieldMergePostProcess"]; });
  146062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DisplayPassPostProcess"]; });
  146063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["ExtractHighlightsPostProcess"]; });
  146064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["FilterPostProcess"]; });
  146065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["FxaaPostProcess"]; });
  146066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["GrainPostProcess"]; });
  146067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["HighlightsPostProcess"]; });
  146068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["ImageProcessingPostProcess"]; });
  146069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["MotionBlurPostProcess"]; });
  146070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PassPostProcess"]; });
  146071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PassCubePostProcess"]; });
  146072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PostProcess"]; });
  146073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PostProcessManager"]; });
  146074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["RefractionPostProcess"]; });
  146075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["SharpenPostProcess"]; });
  146076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["StereoscopicInterlacePostProcess"]; });
  146077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["TonemappingOperator"]; });
  146078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["TonemapPostProcess"]; });
  146079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["VolumetricLightScatteringPostProcess"]; });
  146080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["VRDistortionCorrectionPostProcess"]; });
  146081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  146082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PostProcessRenderEffect"]; });
  146083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PostProcessRenderPipeline"]; });
  146084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PostProcessRenderPipelineManager"]; });
  146085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["PostProcessRenderPipelineManagerSceneComponent"]; });
  146086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["DefaultRenderingPipeline"]; });
  146087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["LensRenderingPipeline"]; });
  146088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["SSAO2RenderingPipeline"]; });
  146089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["SSAORenderingPipeline"]; });
  146090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_30__["StandardRenderingPipeline"]; });
  146091. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  146092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_31__["ReflectionProbe"]; });
  146093. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  146094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["BoundingBoxRenderer"]; });
  146095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["DepthRenderer"]; });
  146096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["DepthRendererSceneComponent"]; });
  146097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["EdgesRenderer"]; });
  146098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["LineEdgesRenderer"]; });
  146099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["GeometryBufferRenderer"]; });
  146100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["GeometryBufferRendererSceneComponent"]; });
  146101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["OutlineRenderer"]; });
  146102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["RenderingGroup"]; });
  146103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["RenderingGroupInfo"]; });
  146104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["RenderingManager"]; });
  146105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_32__["UtilityLayerRenderer"]; });
  146106. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  146107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_33__["Scene"]; });
  146108. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  146109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_34__["SceneComponentConstants"]; });
  146110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_34__["Stage"]; });
  146111. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  146112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_35__["Sprite"]; });
  146113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_35__["SpriteManager"]; });
  146114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_35__["SpriteSceneComponent"]; });
  146115. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  146116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_36__["_AlphaState"]; });
  146117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_36__["_DepthCullingState"]; });
  146118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_36__["_StencilState"]; });
  146119. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  146120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["AndOrNotEvaluator"]; });
  146121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["AssetTaskState"]; });
  146122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["AbstractAssetTask"]; });
  146123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["AssetsProgressEvent"]; });
  146124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["MeshAssetTask"]; });
  146125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["TextFileAssetTask"]; });
  146126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["BinaryFileAssetTask"]; });
  146127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["ImageAssetTask"]; });
  146128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["TextureAssetTask"]; });
  146129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["CubeTextureAssetTask"]; });
  146130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["HDRCubeTextureAssetTask"]; });
  146131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["EquiRectangularCubeTextureAssetTask"]; });
  146132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["AssetsManager"]; });
  146133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["DDSTools"]; });
  146134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["expandToProperty"]; });
  146135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serialize"]; });
  146136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsTexture"]; });
  146137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsColor3"]; });
  146138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsFresnelParameters"]; });
  146139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsVector2"]; });
  146140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsVector3"]; });
  146141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsMeshReference"]; });
  146142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsColorCurves"]; });
  146143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsColor4"]; });
  146144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsImageProcessingConfiguration"]; });
  146145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsQuaternion"]; });
  146146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsMatrix"]; });
  146147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["serializeAsCameraReference"]; });
  146148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SerializationHelper"]; });
  146149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Deferred"]; });
  146150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["EnvironmentTextureTools"]; });
  146151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["MeshExploder"]; });
  146152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["FilesInput"]; });
  146153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["CubeMapToSphericalPolynomialTools"]; });
  146154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["KhronosTextureContainer"]; });
  146155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["EventState"]; });
  146156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Observer"]; });
  146157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["MultiObserver"]; });
  146158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Observable"]; });
  146159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PerformanceMonitor"]; });
  146160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["RollingAverage"]; });
  146161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PromisePolyfill"]; });
  146162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SceneOptimization"]; });
  146163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["TextureOptimization"]; });
  146164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["HardwareScalingOptimization"]; });
  146165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["ShadowsOptimization"]; });
  146166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PostProcessesOptimization"]; });
  146167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["LensFlaresOptimization"]; });
  146168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["CustomOptimization"]; });
  146169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["ParticlesOptimization"]; });
  146170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["RenderTargetsOptimization"]; });
  146171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["MergeMeshesOptimization"]; });
  146172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SceneOptimizerOptions"]; });
  146173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SceneOptimizer"]; });
  146174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SceneSerializer"]; });
  146175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SmartArray"]; });
  146176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["SmartArrayNoDuplicate"]; });
  146177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["StringDictionary"]; });
  146178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Tags"]; });
  146179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["TextureTools"]; });
  146180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["TGATools"]; });
  146181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Tools"]; });
  146182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["className"]; });
  146183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["AsyncLoop"]; });
  146184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["VideoRecorder"]; });
  146185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["JoystickAxis"]; });
  146186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["VirtualJoystick"]; });
  146187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["WorkerPool"]; });
  146188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Logger"]; });
  146189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["_TypeStore"]; });
  146190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["FilesInputStore"]; });
  146191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["DeepCopier"]; });
  146192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PivotTools"]; });
  146193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PrecisionDate"]; });
  146194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["ScreenshotTools"]; });
  146195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["WebRequest"]; });
  146196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["InspectableType"]; });
  146197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["BRDFTextureTools"]; });
  146198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["ColorGradient"]; });
  146199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["Color3Gradient"]; });
  146200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["FactorGradient"]; });
  146201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GradientHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["GradientHelper"]; });
  146202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PerfCounter"]; });
  146203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["RetryStrategy"]; });
  146204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["LoadFileError"]; });
  146205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["HDRTools"]; });
  146206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_37__["PanoramaToCubeMapTools"]; });
  146207. /***/ }),
  146208. /***/ "./node.ts":
  146209. /*!*****************!*\
  146210. !*** ./node.ts ***!
  146211. \*****************/
  146212. /*! exports provided: Node */
  146213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  146214. "use strict";
  146215. __webpack_require__.r(__webpack_exports__);
  146216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  146217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  146218. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math.vector */ "./Maths/math.vector.ts");
  146219. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  146220. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  146221. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  146222. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  146223. /**
  146224. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  146225. */
  146226. var Node = /** @class */ (function () {
  146227. /**
  146228. * Creates a new Node
  146229. * @param name the name and id to be given to this node
  146230. * @param scene the scene this node will be added to
  146231. * @param addToRootNodes the node will be added to scene.rootNodes
  146232. */
  146233. function Node(name, scene, addToRootNodes) {
  146234. if (scene === void 0) { scene = null; }
  146235. if (addToRootNodes === void 0) { addToRootNodes = true; }
  146236. /**
  146237. * Gets or sets a string used to store user defined state for the node
  146238. */
  146239. this.state = "";
  146240. /**
  146241. * Gets or sets an object used to store user defined information for the node
  146242. */
  146243. this.metadata = null;
  146244. /**
  146245. * For internal use only. Please do not use.
  146246. */
  146247. this.reservedDataStore = null;
  146248. /**
  146249. * Gets or sets a boolean used to define if the node must be serialized
  146250. */
  146251. this.doNotSerialize = false;
  146252. /** @hidden */
  146253. this._isDisposed = false;
  146254. /**
  146255. * Gets a list of Animations associated with the node
  146256. */
  146257. this.animations = new Array();
  146258. this._ranges = {};
  146259. /**
  146260. * Callback raised when the node is ready to be used
  146261. */
  146262. this.onReady = null;
  146263. this._isEnabled = true;
  146264. this._isParentEnabled = true;
  146265. this._isReady = true;
  146266. /** @hidden */
  146267. this._currentRenderId = -1;
  146268. this._parentUpdateId = -1;
  146269. /** @hidden */
  146270. this._childUpdateId = -1;
  146271. /** @hidden */
  146272. this._waitingParentId = null;
  146273. /** @hidden */
  146274. this._cache = {};
  146275. this._parentNode = null;
  146276. this._children = null;
  146277. /** @hidden */
  146278. this._worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  146279. /** @hidden */
  146280. this._worldMatrixDeterminant = 0;
  146281. /** @hidden */
  146282. this._worldMatrixDeterminantIsDirty = true;
  146283. /** @hidden */
  146284. this._sceneRootNodesIndex = -1;
  146285. this._animationPropertiesOverride = null;
  146286. /** @hidden */
  146287. this._isNode = true;
  146288. /**
  146289. * An event triggered when the mesh is disposed
  146290. */
  146291. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  146292. this._onDisposeObserver = null;
  146293. // Behaviors
  146294. this._behaviors = new Array();
  146295. this.name = name;
  146296. this.id = name;
  146297. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  146298. this.uniqueId = this._scene.getUniqueId();
  146299. this._initCache();
  146300. if (addToRootNodes) {
  146301. this.addToSceneRootNodes();
  146302. }
  146303. }
  146304. /**
  146305. * Add a new node constructor
  146306. * @param type defines the type name of the node to construct
  146307. * @param constructorFunc defines the constructor function
  146308. */
  146309. Node.AddNodeConstructor = function (type, constructorFunc) {
  146310. this._NodeConstructors[type] = constructorFunc;
  146311. };
  146312. /**
  146313. * Returns a node constructor based on type name
  146314. * @param type defines the type name
  146315. * @param name defines the new node name
  146316. * @param scene defines the hosting scene
  146317. * @param options defines optional options to transmit to constructors
  146318. * @returns the new constructor or null
  146319. */
  146320. Node.Construct = function (type, name, scene, options) {
  146321. var constructorFunc = this._NodeConstructors[type];
  146322. if (!constructorFunc) {
  146323. return null;
  146324. }
  146325. return constructorFunc(name, scene, options);
  146326. };
  146327. /**
  146328. * Gets a boolean indicating if the node has been disposed
  146329. * @returns true if the node was disposed
  146330. */
  146331. Node.prototype.isDisposed = function () {
  146332. return this._isDisposed;
  146333. };
  146334. Object.defineProperty(Node.prototype, "parent", {
  146335. get: function () {
  146336. return this._parentNode;
  146337. },
  146338. /**
  146339. * Gets or sets the parent of the node (without keeping the current position in the scene)
  146340. * @see https://doc.babylonjs.com/how_to/parenting
  146341. */
  146342. set: function (parent) {
  146343. if (this._parentNode === parent) {
  146344. return;
  146345. }
  146346. var previousParentNode = this._parentNode;
  146347. // Remove self from list of children of parent
  146348. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  146349. var index = this._parentNode._children.indexOf(this);
  146350. if (index !== -1) {
  146351. this._parentNode._children.splice(index, 1);
  146352. }
  146353. if (!parent && !this._isDisposed) {
  146354. this.addToSceneRootNodes();
  146355. }
  146356. }
  146357. // Store new parent
  146358. this._parentNode = parent;
  146359. // Add as child to new parent
  146360. if (this._parentNode) {
  146361. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  146362. this._parentNode._children = new Array();
  146363. }
  146364. this._parentNode._children.push(this);
  146365. if (!previousParentNode) {
  146366. this.removeFromSceneRootNodes();
  146367. }
  146368. }
  146369. // Enabled state
  146370. this._syncParentEnabledState();
  146371. },
  146372. enumerable: true,
  146373. configurable: true
  146374. });
  146375. Node.prototype.addToSceneRootNodes = function () {
  146376. if (this._sceneRootNodesIndex === -1) {
  146377. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  146378. this._scene.rootNodes.push(this);
  146379. }
  146380. };
  146381. Node.prototype.removeFromSceneRootNodes = function () {
  146382. if (this._sceneRootNodesIndex !== -1) {
  146383. var rootNodes = this._scene.rootNodes;
  146384. var lastIdx = rootNodes.length - 1;
  146385. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  146386. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  146387. this._scene.rootNodes.pop();
  146388. this._sceneRootNodesIndex = -1;
  146389. }
  146390. };
  146391. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  146392. /**
  146393. * Gets or sets the animation properties override
  146394. */
  146395. get: function () {
  146396. if (!this._animationPropertiesOverride) {
  146397. return this._scene.animationPropertiesOverride;
  146398. }
  146399. return this._animationPropertiesOverride;
  146400. },
  146401. set: function (value) {
  146402. this._animationPropertiesOverride = value;
  146403. },
  146404. enumerable: true,
  146405. configurable: true
  146406. });
  146407. /**
  146408. * Gets a string idenfifying the name of the class
  146409. * @returns "Node" string
  146410. */
  146411. Node.prototype.getClassName = function () {
  146412. return "Node";
  146413. };
  146414. Object.defineProperty(Node.prototype, "onDispose", {
  146415. /**
  146416. * Sets a callback that will be raised when the node will be disposed
  146417. */
  146418. set: function (callback) {
  146419. if (this._onDisposeObserver) {
  146420. this.onDisposeObservable.remove(this._onDisposeObserver);
  146421. }
  146422. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  146423. },
  146424. enumerable: true,
  146425. configurable: true
  146426. });
  146427. /**
  146428. * Gets the scene of the node
  146429. * @returns a scene
  146430. */
  146431. Node.prototype.getScene = function () {
  146432. return this._scene;
  146433. };
  146434. /**
  146435. * Gets the engine of the node
  146436. * @returns a Engine
  146437. */
  146438. Node.prototype.getEngine = function () {
  146439. return this._scene.getEngine();
  146440. };
  146441. /**
  146442. * Attach a behavior to the node
  146443. * @see http://doc.babylonjs.com/features/behaviour
  146444. * @param behavior defines the behavior to attach
  146445. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  146446. * @returns the current Node
  146447. */
  146448. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  146449. var _this = this;
  146450. if (attachImmediately === void 0) { attachImmediately = false; }
  146451. var index = this._behaviors.indexOf(behavior);
  146452. if (index !== -1) {
  146453. return this;
  146454. }
  146455. behavior.init();
  146456. if (this._scene.isLoading && !attachImmediately) {
  146457. // We defer the attach when the scene will be loaded
  146458. this._scene.onDataLoadedObservable.addOnce(function () {
  146459. behavior.attach(_this);
  146460. });
  146461. }
  146462. else {
  146463. behavior.attach(this);
  146464. }
  146465. this._behaviors.push(behavior);
  146466. return this;
  146467. };
  146468. /**
  146469. * Remove an attached behavior
  146470. * @see http://doc.babylonjs.com/features/behaviour
  146471. * @param behavior defines the behavior to attach
  146472. * @returns the current Node
  146473. */
  146474. Node.prototype.removeBehavior = function (behavior) {
  146475. var index = this._behaviors.indexOf(behavior);
  146476. if (index === -1) {
  146477. return this;
  146478. }
  146479. this._behaviors[index].detach();
  146480. this._behaviors.splice(index, 1);
  146481. return this;
  146482. };
  146483. Object.defineProperty(Node.prototype, "behaviors", {
  146484. /**
  146485. * Gets the list of attached behaviors
  146486. * @see http://doc.babylonjs.com/features/behaviour
  146487. */
  146488. get: function () {
  146489. return this._behaviors;
  146490. },
  146491. enumerable: true,
  146492. configurable: true
  146493. });
  146494. /**
  146495. * Gets an attached behavior by name
  146496. * @param name defines the name of the behavior to look for
  146497. * @see http://doc.babylonjs.com/features/behaviour
  146498. * @returns null if behavior was not found else the requested behavior
  146499. */
  146500. Node.prototype.getBehaviorByName = function (name) {
  146501. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  146502. var behavior = _a[_i];
  146503. if (behavior.name === name) {
  146504. return behavior;
  146505. }
  146506. }
  146507. return null;
  146508. };
  146509. /**
  146510. * Returns the latest update of the World matrix
  146511. * @returns a Matrix
  146512. */
  146513. Node.prototype.getWorldMatrix = function () {
  146514. if (this._currentRenderId !== this._scene.getRenderId()) {
  146515. this.computeWorldMatrix();
  146516. }
  146517. return this._worldMatrix;
  146518. };
  146519. /** @hidden */
  146520. Node.prototype._getWorldMatrixDeterminant = function () {
  146521. if (this._worldMatrixDeterminantIsDirty) {
  146522. this._worldMatrixDeterminantIsDirty = false;
  146523. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  146524. }
  146525. return this._worldMatrixDeterminant;
  146526. };
  146527. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  146528. /**
  146529. * Returns directly the latest state of the mesh World matrix.
  146530. * A Matrix is returned.
  146531. */
  146532. get: function () {
  146533. return this._worldMatrix;
  146534. },
  146535. enumerable: true,
  146536. configurable: true
  146537. });
  146538. // override it in derived class if you add new variables to the cache
  146539. // and call the parent class method
  146540. /** @hidden */
  146541. Node.prototype._initCache = function () {
  146542. this._cache = {};
  146543. this._cache.parent = undefined;
  146544. };
  146545. /** @hidden */
  146546. Node.prototype.updateCache = function (force) {
  146547. if (!force && this.isSynchronized()) {
  146548. return;
  146549. }
  146550. this._cache.parent = this.parent;
  146551. this._updateCache();
  146552. };
  146553. /** @hidden */
  146554. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  146555. if (initialCall === void 0) { initialCall = true; }
  146556. if (!this.parent) {
  146557. return null;
  146558. }
  146559. return this.parent._getActionManagerForTrigger(trigger, false);
  146560. };
  146561. // override it in derived class if you add new variables to the cache
  146562. // and call the parent class method if !ignoreParentClass
  146563. /** @hidden */
  146564. Node.prototype._updateCache = function (ignoreParentClass) {
  146565. };
  146566. // override it in derived class if you add new variables to the cache
  146567. /** @hidden */
  146568. Node.prototype._isSynchronized = function () {
  146569. return true;
  146570. };
  146571. /** @hidden */
  146572. Node.prototype._markSyncedWithParent = function () {
  146573. if (this._parentNode) {
  146574. this._parentUpdateId = this._parentNode._childUpdateId;
  146575. }
  146576. };
  146577. /** @hidden */
  146578. Node.prototype.isSynchronizedWithParent = function () {
  146579. if (!this._parentNode) {
  146580. return true;
  146581. }
  146582. if (this._parentUpdateId !== this._parentNode._childUpdateId) {
  146583. return false;
  146584. }
  146585. return this._parentNode.isSynchronized();
  146586. };
  146587. /** @hidden */
  146588. Node.prototype.isSynchronized = function () {
  146589. if (this._cache.parent != this._parentNode) {
  146590. this._cache.parent = this._parentNode;
  146591. return false;
  146592. }
  146593. if (this._parentNode && !this.isSynchronizedWithParent()) {
  146594. return false;
  146595. }
  146596. return this._isSynchronized();
  146597. };
  146598. /**
  146599. * Is this node ready to be used/rendered
  146600. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  146601. * @return true if the node is ready
  146602. */
  146603. Node.prototype.isReady = function (completeCheck) {
  146604. if (completeCheck === void 0) { completeCheck = false; }
  146605. return this._isReady;
  146606. };
  146607. /**
  146608. * Is this node enabled?
  146609. * 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
  146610. * @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
  146611. * @return whether this node (and its parent) is enabled
  146612. */
  146613. Node.prototype.isEnabled = function (checkAncestors) {
  146614. if (checkAncestors === void 0) { checkAncestors = true; }
  146615. if (checkAncestors === false) {
  146616. return this._isEnabled;
  146617. }
  146618. if (!this._isEnabled) {
  146619. return false;
  146620. }
  146621. return this._isParentEnabled;
  146622. };
  146623. /** @hidden */
  146624. Node.prototype._syncParentEnabledState = function () {
  146625. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  146626. if (this._children) {
  146627. this._children.forEach(function (c) {
  146628. c._syncParentEnabledState(); // Force children to update accordingly
  146629. });
  146630. }
  146631. };
  146632. /**
  146633. * Set the enabled state of this node
  146634. * @param value defines the new enabled state
  146635. */
  146636. Node.prototype.setEnabled = function (value) {
  146637. this._isEnabled = value;
  146638. this._syncParentEnabledState();
  146639. };
  146640. /**
  146641. * Is this node a descendant of the given node?
  146642. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  146643. * @param ancestor defines the parent node to inspect
  146644. * @returns a boolean indicating if this node is a descendant of the given node
  146645. */
  146646. Node.prototype.isDescendantOf = function (ancestor) {
  146647. if (this.parent) {
  146648. if (this.parent === ancestor) {
  146649. return true;
  146650. }
  146651. return this.parent.isDescendantOf(ancestor);
  146652. }
  146653. return false;
  146654. };
  146655. /** @hidden */
  146656. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  146657. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  146658. if (!this._children) {
  146659. return;
  146660. }
  146661. for (var index = 0; index < this._children.length; index++) {
  146662. var item = this._children[index];
  146663. if (!predicate || predicate(item)) {
  146664. results.push(item);
  146665. }
  146666. if (!directDescendantsOnly) {
  146667. item._getDescendants(results, false, predicate);
  146668. }
  146669. }
  146670. };
  146671. /**
  146672. * Will return all nodes that have this node as ascendant
  146673. * @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
  146674. * @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
  146675. * @return all children nodes of all types
  146676. */
  146677. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  146678. var results = new Array();
  146679. this._getDescendants(results, directDescendantsOnly, predicate);
  146680. return results;
  146681. };
  146682. /**
  146683. * Get all child-meshes of this node
  146684. * @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)
  146685. * @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
  146686. * @returns an array of AbstractMesh
  146687. */
  146688. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  146689. var results = [];
  146690. this._getDescendants(results, directDescendantsOnly, function (node) {
  146691. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  146692. });
  146693. return results;
  146694. };
  146695. /**
  146696. * Get all direct children of this node
  146697. * @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
  146698. * @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)
  146699. * @returns an array of Node
  146700. */
  146701. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  146702. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  146703. return this.getDescendants(directDescendantsOnly, predicate);
  146704. };
  146705. /** @hidden */
  146706. Node.prototype._setReady = function (state) {
  146707. if (state === this._isReady) {
  146708. return;
  146709. }
  146710. if (!state) {
  146711. this._isReady = false;
  146712. return;
  146713. }
  146714. if (this.onReady) {
  146715. this.onReady(this);
  146716. }
  146717. this._isReady = true;
  146718. };
  146719. /**
  146720. * Get an animation by name
  146721. * @param name defines the name of the animation to look for
  146722. * @returns null if not found else the requested animation
  146723. */
  146724. Node.prototype.getAnimationByName = function (name) {
  146725. for (var i = 0; i < this.animations.length; i++) {
  146726. var animation = this.animations[i];
  146727. if (animation.name === name) {
  146728. return animation;
  146729. }
  146730. }
  146731. return null;
  146732. };
  146733. /**
  146734. * Creates an animation range for this node
  146735. * @param name defines the name of the range
  146736. * @param from defines the starting key
  146737. * @param to defines the end key
  146738. */
  146739. Node.prototype.createAnimationRange = function (name, from, to) {
  146740. // check name not already in use
  146741. if (!this._ranges[name]) {
  146742. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  146743. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  146744. if (this.animations[i]) {
  146745. this.animations[i].createRange(name, from, to);
  146746. }
  146747. }
  146748. }
  146749. };
  146750. /**
  146751. * Delete a specific animation range
  146752. * @param name defines the name of the range to delete
  146753. * @param deleteFrames defines if animation frames from the range must be deleted as well
  146754. */
  146755. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  146756. if (deleteFrames === void 0) { deleteFrames = true; }
  146757. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  146758. if (this.animations[i]) {
  146759. this.animations[i].deleteRange(name, deleteFrames);
  146760. }
  146761. }
  146762. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  146763. };
  146764. /**
  146765. * Get an animation range by name
  146766. * @param name defines the name of the animation range to look for
  146767. * @returns null if not found else the requested animation range
  146768. */
  146769. Node.prototype.getAnimationRange = function (name) {
  146770. return this._ranges[name];
  146771. };
  146772. /**
  146773. * Gets the list of all animation ranges defined on this node
  146774. * @returns an array
  146775. */
  146776. Node.prototype.getAnimationRanges = function () {
  146777. var animationRanges = [];
  146778. var name;
  146779. for (name in this._ranges) {
  146780. animationRanges.push(this._ranges[name]);
  146781. }
  146782. return animationRanges;
  146783. };
  146784. /**
  146785. * Will start the animation sequence
  146786. * @param name defines the range frames for animation sequence
  146787. * @param loop defines if the animation should loop (false by default)
  146788. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  146789. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  146790. * @returns the object created for this animation. If range does not exist, it will return null
  146791. */
  146792. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  146793. var range = this.getAnimationRange(name);
  146794. if (!range) {
  146795. return null;
  146796. }
  146797. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  146798. };
  146799. /**
  146800. * Serialize animation ranges into a JSON compatible object
  146801. * @returns serialization object
  146802. */
  146803. Node.prototype.serializeAnimationRanges = function () {
  146804. var serializationRanges = [];
  146805. for (var name in this._ranges) {
  146806. var localRange = this._ranges[name];
  146807. if (!localRange) {
  146808. continue;
  146809. }
  146810. var range = {};
  146811. range.name = name;
  146812. range.from = localRange.from;
  146813. range.to = localRange.to;
  146814. serializationRanges.push(range);
  146815. }
  146816. return serializationRanges;
  146817. };
  146818. /**
  146819. * Computes the world matrix of the node
  146820. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  146821. * @returns the world matrix
  146822. */
  146823. Node.prototype.computeWorldMatrix = function (force) {
  146824. if (!this._worldMatrix) {
  146825. this._worldMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  146826. }
  146827. return this._worldMatrix;
  146828. };
  146829. /**
  146830. * Releases resources associated with this node.
  146831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  146832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  146833. */
  146834. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  146835. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  146836. this._isDisposed = true;
  146837. if (!doNotRecurse) {
  146838. var nodes = this.getDescendants(true);
  146839. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  146840. var node = nodes_1[_i];
  146841. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  146842. }
  146843. }
  146844. if (!this.parent) {
  146845. this.removeFromSceneRootNodes();
  146846. }
  146847. else {
  146848. this.parent = null;
  146849. }
  146850. // Callback
  146851. this.onDisposeObservable.notifyObservers(this);
  146852. this.onDisposeObservable.clear();
  146853. // Behaviors
  146854. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  146855. var behavior = _b[_a];
  146856. behavior.detach();
  146857. }
  146858. this._behaviors = [];
  146859. };
  146860. /**
  146861. * Parse animation range data from a serialization object and store them into a given node
  146862. * @param node defines where to store the animation ranges
  146863. * @param parsedNode defines the serialization object to read data from
  146864. * @param scene defines the hosting scene
  146865. */
  146866. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  146867. if (parsedNode.ranges) {
  146868. for (var index = 0; index < parsedNode.ranges.length; index++) {
  146869. var data = parsedNode.ranges[index];
  146870. node.createAnimationRange(data.name, data.from, data.to);
  146871. }
  146872. }
  146873. };
  146874. /**
  146875. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  146876. * @param includeDescendants Include bounding info from descendants as well (true by default)
  146877. * @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
  146878. * @returns the new bounding vectors
  146879. */
  146880. Node.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  146881. if (includeDescendants === void 0) { includeDescendants = true; }
  146882. if (predicate === void 0) { predicate = null; }
  146883. // Ensures that all world matrix will be recomputed.
  146884. this.getScene().incrementRenderId();
  146885. this.computeWorldMatrix(true);
  146886. var min;
  146887. var max;
  146888. var thisAbstractMesh = this;
  146889. if (thisAbstractMesh.getBoundingInfo && thisAbstractMesh.subMeshes) {
  146890. // If this is an abstract mesh get its bounding info
  146891. var boundingInfo = thisAbstractMesh.getBoundingInfo();
  146892. min = boundingInfo.boundingBox.minimumWorld.clone();
  146893. max = boundingInfo.boundingBox.maximumWorld.clone();
  146894. }
  146895. else {
  146896. min = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  146897. max = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  146898. }
  146899. if (includeDescendants) {
  146900. var descendants = this.getDescendants(false);
  146901. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  146902. var descendant = descendants_1[_i];
  146903. var childMesh = descendant;
  146904. childMesh.computeWorldMatrix(true);
  146905. // Filters meshes based on custom predicate function.
  146906. if (predicate && !predicate(childMesh)) {
  146907. continue;
  146908. }
  146909. //make sure we have the needed params to get mix and max
  146910. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  146911. continue;
  146912. }
  146913. var childBoundingInfo = childMesh.getBoundingInfo();
  146914. var boundingBox = childBoundingInfo.boundingBox;
  146915. var minBox = boundingBox.minimumWorld;
  146916. var maxBox = boundingBox.maximumWorld;
  146917. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CheckExtends(minBox, min, max);
  146918. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CheckExtends(maxBox, min, max);
  146919. }
  146920. }
  146921. return {
  146922. min: min,
  146923. max: max
  146924. };
  146925. };
  146926. /** @hidden */
  146927. Node._AnimationRangeFactory = function (name, from, to) {
  146928. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  146929. };
  146930. Node._NodeConstructors = {};
  146931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  146932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  146933. ], Node.prototype, "name", void 0);
  146934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  146935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  146936. ], Node.prototype, "id", void 0);
  146937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  146938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  146939. ], Node.prototype, "uniqueId", void 0);
  146940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  146941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  146942. ], Node.prototype, "state", void 0);
  146943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  146944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  146945. ], Node.prototype, "metadata", void 0);
  146946. return Node;
  146947. }());
  146948. /***/ }),
  146949. /***/ "./scene.ts":
  146950. /*!******************!*\
  146951. !*** ./scene.ts ***!
  146952. \******************/
  146953. /*! exports provided: Scene */
  146954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  146955. "use strict";
  146956. __webpack_require__.r(__webpack_exports__);
  146957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  146958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  146959. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  146960. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  146961. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  146962. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  146963. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  146964. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  146965. /* harmony import */ var _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math.vector */ "./Maths/math.vector.ts");
  146966. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/transformNode */ "./Meshes/transformNode.ts");
  146967. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  146968. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  146969. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  146970. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  146971. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  146972. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  146973. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  146974. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  146975. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  146976. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  146977. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  146978. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  146979. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  146980. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  146981. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  146982. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  146983. /* harmony import */ var _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Inputs/scene.inputManager */ "./Inputs/scene.inputManager.ts");
  146984. /* harmony import */ var _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/perfCounter */ "./Misc/perfCounter.ts");
  146985. /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Maths/math.color */ "./Maths/math.color.ts");
  146986. /* harmony import */ var _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Maths/math.frustum */ "./Maths/math.frustum.ts");
  146987. /* harmony import */ var _Misc_uniqueIdGenerator__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./Misc/uniqueIdGenerator */ "./Misc/uniqueIdGenerator.ts");
  146988. /**
  146989. * Represents a scene to be rendered by the engine.
  146990. * @see http://doc.babylonjs.com/features/scene
  146991. */
  146992. var Scene = /** @class */ (function (_super) {
  146993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  146994. /**
  146995. * Creates a new Scene
  146996. * @param engine defines the engine to use to render this scene
  146997. * @param options defines the scene options
  146998. */
  146999. function Scene(engine, options) {
  147000. var _this = _super.call(this) || this;
  147001. // Members
  147002. /** @hidden */
  147003. _this._inputManager = new _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"](_this);
  147004. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  147005. _this.cameraToUseForPointers = null;
  147006. /** @hidden */
  147007. _this._isScene = true;
  147008. /**
  147009. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  147010. */
  147011. _this.autoClear = true;
  147012. /**
  147013. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  147014. */
  147015. _this.autoClearDepthAndStencil = true;
  147016. /**
  147017. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  147018. */
  147019. _this.clearColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_27__["Color4"](0.2, 0.2, 0.3, 1.0);
  147020. /**
  147021. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  147022. */
  147023. _this.ambientColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_27__["Color3"](0, 0, 0);
  147024. _this._forceWireframe = false;
  147025. _this._forcePointsCloud = false;
  147026. /**
  147027. * Gets or sets a boolean indicating if animations are enabled
  147028. */
  147029. _this.animationsEnabled = true;
  147030. _this._animationPropertiesOverride = null;
  147031. /**
  147032. * Gets or sets a boolean indicating if a constant deltatime has to be used
  147033. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  147034. */
  147035. _this.useConstantAnimationDeltaTime = false;
  147036. /**
  147037. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  147038. * Please note that it requires to run a ray cast through the scene on every frame
  147039. */
  147040. _this.constantlyUpdateMeshUnderPointer = false;
  147041. /**
  147042. * Defines the HTML cursor to use when hovering over interactive elements
  147043. */
  147044. _this.hoverCursor = "pointer";
  147045. /**
  147046. * Defines the HTML default cursor to use (empty by default)
  147047. */
  147048. _this.defaultCursor = "";
  147049. /**
  147050. * This is used to call preventDefault() on pointer down
  147051. * in order to block unwanted artifacts like system double clicks
  147052. */
  147053. _this.preventDefaultOnPointerDown = true;
  147054. /**
  147055. * This is used to call preventDefault() on pointer up
  147056. * in order to block unwanted artifacts like system double clicks
  147057. */
  147058. _this.preventDefaultOnPointerUp = true;
  147059. // Metadata
  147060. /**
  147061. * Gets or sets user defined metadata
  147062. */
  147063. _this.metadata = null;
  147064. /**
  147065. * For internal use only. Please do not use.
  147066. */
  147067. _this.reservedDataStore = null;
  147068. /**
  147069. * Use this array to add regular expressions used to disable offline support for specific urls
  147070. */
  147071. _this.disableOfflineSupportExceptionRules = new Array();
  147072. /**
  147073. * An event triggered when the scene is disposed.
  147074. */
  147075. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147076. _this._onDisposeObserver = null;
  147077. /**
  147078. * An event triggered before rendering the scene (right after animations and physics)
  147079. */
  147080. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147081. _this._onBeforeRenderObserver = null;
  147082. /**
  147083. * An event triggered after rendering the scene
  147084. */
  147085. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147086. /**
  147087. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  147088. */
  147089. _this.onAfterRenderCameraObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147090. _this._onAfterRenderObserver = null;
  147091. /**
  147092. * An event triggered before animating the scene
  147093. */
  147094. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147095. /**
  147096. * An event triggered after animations processing
  147097. */
  147098. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147099. /**
  147100. * An event triggered before draw calls are ready to be sent
  147101. */
  147102. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147103. /**
  147104. * An event triggered after draw calls have been sent
  147105. */
  147106. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147107. /**
  147108. * An event triggered when the scene is ready
  147109. */
  147110. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147111. /**
  147112. * An event triggered before rendering a camera
  147113. */
  147114. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147115. _this._onBeforeCameraRenderObserver = null;
  147116. /**
  147117. * An event triggered after rendering a camera
  147118. */
  147119. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147120. _this._onAfterCameraRenderObserver = null;
  147121. /**
  147122. * An event triggered when active meshes evaluation is about to start
  147123. */
  147124. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147125. /**
  147126. * An event triggered when active meshes evaluation is done
  147127. */
  147128. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147129. /**
  147130. * An event triggered when particles rendering is about to start
  147131. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  147132. */
  147133. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147134. /**
  147135. * An event triggered when particles rendering is done
  147136. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  147137. */
  147138. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147139. /**
  147140. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  147141. */
  147142. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147143. /**
  147144. * An event triggered when a camera is created
  147145. */
  147146. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147147. /**
  147148. * An event triggered when a camera is removed
  147149. */
  147150. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147151. /**
  147152. * An event triggered when a light is created
  147153. */
  147154. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147155. /**
  147156. * An event triggered when a light is removed
  147157. */
  147158. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147159. /**
  147160. * An event triggered when a geometry is created
  147161. */
  147162. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147163. /**
  147164. * An event triggered when a geometry is removed
  147165. */
  147166. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147167. /**
  147168. * An event triggered when a transform node is created
  147169. */
  147170. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147171. /**
  147172. * An event triggered when a transform node is removed
  147173. */
  147174. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147175. /**
  147176. * An event triggered when a mesh is created
  147177. */
  147178. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147179. /**
  147180. * An event triggered when a mesh is removed
  147181. */
  147182. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147183. /**
  147184. * An event triggered when a skeleton is created
  147185. */
  147186. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147187. /**
  147188. * An event triggered when a skeleton is removed
  147189. */
  147190. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147191. /**
  147192. * An event triggered when a material is created
  147193. */
  147194. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147195. /**
  147196. * An event triggered when a material is removed
  147197. */
  147198. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147199. /**
  147200. * An event triggered when a texture is created
  147201. */
  147202. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147203. /**
  147204. * An event triggered when a texture is removed
  147205. */
  147206. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147207. /**
  147208. * An event triggered when render targets are about to be rendered
  147209. * Can happen multiple times per frame.
  147210. */
  147211. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147212. /**
  147213. * An event triggered when render targets were rendered.
  147214. * Can happen multiple times per frame.
  147215. */
  147216. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147217. /**
  147218. * An event triggered before calculating deterministic simulation step
  147219. */
  147220. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147221. /**
  147222. * An event triggered after calculating deterministic simulation step
  147223. */
  147224. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147225. /**
  147226. * An event triggered when the activeCamera property is updated
  147227. */
  147228. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147229. /**
  147230. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  147231. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  147232. * 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)
  147233. */
  147234. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147235. /**
  147236. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  147237. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  147238. * 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)
  147239. */
  147240. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147241. /**
  147242. * This Observable will when a mesh has been imported into the scene.
  147243. */
  147244. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147245. // Animations
  147246. /** @hidden */
  147247. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  147248. /**
  147249. * 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).
  147250. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  147251. */
  147252. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147253. /**
  147254. * Observable event triggered each time an input event is received from the rendering canvas
  147255. */
  147256. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147257. // Keyboard
  147258. /**
  147259. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  147260. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  147261. */
  147262. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147263. /**
  147264. * Observable event triggered each time an keyboard event is received from the hosting window
  147265. */
  147266. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  147267. // Coordinates system
  147268. _this._useRightHandedSystem = false;
  147269. // Deterministic lockstep
  147270. _this._timeAccumulator = 0;
  147271. _this._currentStepId = 0;
  147272. _this._currentInternalStep = 0;
  147273. // Fog
  147274. _this._fogEnabled = true;
  147275. _this._fogMode = Scene.FOGMODE_NONE;
  147276. /**
  147277. * Gets or sets the fog color to use
  147278. * @see http://doc.babylonjs.com/babylon101/environment#fog
  147279. * (Default is Color3(0.2, 0.2, 0.3))
  147280. */
  147281. _this.fogColor = new _Maths_math_color__WEBPACK_IMPORTED_MODULE_27__["Color3"](0.2, 0.2, 0.3);
  147282. /**
  147283. * Gets or sets the fog density to use
  147284. * @see http://doc.babylonjs.com/babylon101/environment#fog
  147285. * (Default is 0.1)
  147286. */
  147287. _this.fogDensity = 0.1;
  147288. /**
  147289. * Gets or sets the fog start distance to use
  147290. * @see http://doc.babylonjs.com/babylon101/environment#fog
  147291. * (Default is 0)
  147292. */
  147293. _this.fogStart = 0;
  147294. /**
  147295. * Gets or sets the fog end distance to use
  147296. * @see http://doc.babylonjs.com/babylon101/environment#fog
  147297. * (Default is 1000)
  147298. */
  147299. _this.fogEnd = 1000.0;
  147300. // Lights
  147301. _this._shadowsEnabled = true;
  147302. _this._lightsEnabled = true;
  147303. /** All of the active cameras added to this scene. */
  147304. _this.activeCameras = new Array();
  147305. // Textures
  147306. _this._texturesEnabled = true;
  147307. // Particles
  147308. /**
  147309. * Gets or sets a boolean indicating if particles are enabled on this scene
  147310. */
  147311. _this.particlesEnabled = true;
  147312. // Sprites
  147313. /**
  147314. * Gets or sets a boolean indicating if sprites are enabled on this scene
  147315. */
  147316. _this.spritesEnabled = true;
  147317. // Skeletons
  147318. _this._skeletonsEnabled = true;
  147319. // Lens flares
  147320. /**
  147321. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  147322. */
  147323. _this.lensFlaresEnabled = true;
  147324. // Collisions
  147325. /**
  147326. * Gets or sets a boolean indicating if collisions are enabled on this scene
  147327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  147328. */
  147329. _this.collisionsEnabled = true;
  147330. /**
  147331. * Defines the gravity applied to this scene (used only for collisions)
  147332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  147333. */
  147334. _this.gravity = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  147335. // Postprocesses
  147336. /**
  147337. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  147338. */
  147339. _this.postProcessesEnabled = true;
  147340. /**
  147341. * The list of postprocesses added to the scene
  147342. */
  147343. _this.postProcesses = new Array();
  147344. // Customs render targets
  147345. /**
  147346. * Gets or sets a boolean indicating if render targets are enabled on this scene
  147347. */
  147348. _this.renderTargetsEnabled = true;
  147349. /**
  147350. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  147351. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  147352. */
  147353. _this.dumpNextRenderTargets = false;
  147354. /**
  147355. * The list of user defined render targets added to the scene
  147356. */
  147357. _this.customRenderTargets = new Array();
  147358. /**
  147359. * Gets the list of meshes imported to the scene through SceneLoader
  147360. */
  147361. _this.importedMeshesFiles = new Array();
  147362. // Probes
  147363. /**
  147364. * Gets or sets a boolean indicating if probes are enabled on this scene
  147365. */
  147366. _this.probesEnabled = true;
  147367. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  147368. // Procedural textures
  147369. /**
  147370. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  147371. */
  147372. _this.proceduralTexturesEnabled = true;
  147373. // Performance counters
  147374. _this._totalVertices = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_26__["PerfCounter"]();
  147375. /** @hidden */
  147376. _this._activeIndices = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_26__["PerfCounter"]();
  147377. /** @hidden */
  147378. _this._activeParticles = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_26__["PerfCounter"]();
  147379. /** @hidden */
  147380. _this._activeBones = new _Misc_perfCounter__WEBPACK_IMPORTED_MODULE_26__["PerfCounter"]();
  147381. /** @hidden */
  147382. _this._animationTime = 0;
  147383. /**
  147384. * Gets or sets a general scale for animation speed
  147385. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  147386. */
  147387. _this.animationTimeScale = 1;
  147388. _this._renderId = 0;
  147389. _this._frameId = 0;
  147390. _this._executeWhenReadyTimeoutId = -1;
  147391. _this._intermediateRendering = false;
  147392. _this._viewUpdateFlag = -1;
  147393. _this._projectionUpdateFlag = -1;
  147394. /** @hidden */
  147395. _this._toBeDisposed = new Array(256);
  147396. _this._activeRequests = new Array();
  147397. /** @hidden */
  147398. _this._pendingData = new Array();
  147399. _this._isDisposed = false;
  147400. /**
  147401. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  147402. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  147403. */
  147404. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  147405. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  147406. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  147407. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  147408. /** @hidden */
  147409. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  147410. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  147411. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  147412. /** @hidden */
  147413. _this._activeAnimatables = new Array();
  147414. _this._transformMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  147415. /**
  147416. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  147417. * This is useful if there are more lights that the maximum simulteanous authorized
  147418. */
  147419. _this.requireLightSorting = false;
  147420. /**
  147421. * @hidden
  147422. * Backing store of defined scene components.
  147423. */
  147424. _this._components = [];
  147425. /**
  147426. * @hidden
  147427. * Backing store of defined scene components.
  147428. */
  147429. _this._serializableComponents = [];
  147430. /**
  147431. * List of components to register on the next registration step.
  147432. */
  147433. _this._transientComponents = [];
  147434. /**
  147435. * @hidden
  147436. * Defines the actions happening before camera updates.
  147437. */
  147438. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147439. /**
  147440. * @hidden
  147441. * Defines the actions happening before clear the canvas.
  147442. */
  147443. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147444. /**
  147445. * @hidden
  147446. * Defines the actions when collecting render targets for the frame.
  147447. */
  147448. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147449. /**
  147450. * @hidden
  147451. * Defines the actions happening for one camera in the frame.
  147452. */
  147453. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147454. /**
  147455. * @hidden
  147456. * Defines the actions happening during the per mesh ready checks.
  147457. */
  147458. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147459. /**
  147460. * @hidden
  147461. * Defines the actions happening before evaluate active mesh checks.
  147462. */
  147463. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147464. /**
  147465. * @hidden
  147466. * Defines the actions happening during the evaluate sub mesh checks.
  147467. */
  147468. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147469. /**
  147470. * @hidden
  147471. * Defines the actions happening during the active mesh stage.
  147472. */
  147473. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147474. /**
  147475. * @hidden
  147476. * Defines the actions happening during the per camera render target step.
  147477. */
  147478. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147479. /**
  147480. * @hidden
  147481. * Defines the actions happening just before the active camera is drawing.
  147482. */
  147483. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147484. /**
  147485. * @hidden
  147486. * Defines the actions happening just before a render target is drawing.
  147487. */
  147488. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147489. /**
  147490. * @hidden
  147491. * Defines the actions happening just before a rendering group is drawing.
  147492. */
  147493. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147494. /**
  147495. * @hidden
  147496. * Defines the actions happening just before a mesh is drawing.
  147497. */
  147498. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147499. /**
  147500. * @hidden
  147501. * Defines the actions happening just after a mesh has been drawn.
  147502. */
  147503. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147504. /**
  147505. * @hidden
  147506. * Defines the actions happening just after a rendering group has been drawn.
  147507. */
  147508. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147509. /**
  147510. * @hidden
  147511. * Defines the actions happening just after the active camera has been drawn.
  147512. */
  147513. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147514. /**
  147515. * @hidden
  147516. * Defines the actions happening just after a render target has been drawn.
  147517. */
  147518. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147519. /**
  147520. * @hidden
  147521. * Defines the actions happening just after rendering all cameras and computing intersections.
  147522. */
  147523. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147524. /**
  147525. * @hidden
  147526. * Defines the actions happening when a pointer move event happens.
  147527. */
  147528. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147529. /**
  147530. * @hidden
  147531. * Defines the actions happening when a pointer down event happens.
  147532. */
  147533. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147534. /**
  147535. * @hidden
  147536. * Defines the actions happening when a pointer up event happens.
  147537. */
  147538. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  147539. /**
  147540. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  147541. */
  147542. _this.geometriesByUniqueId = null;
  147543. _this._defaultMeshCandidates = {
  147544. data: [],
  147545. length: 0
  147546. };
  147547. _this._defaultSubMeshCandidates = {
  147548. data: [],
  147549. length: 0
  147550. };
  147551. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  147552. _this._activeMeshesFrozen = false;
  147553. /** @hidden */
  147554. _this._allowPostProcessClearColor = true;
  147555. /**
  147556. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  147557. */
  147558. _this.getDeterministicFrameTime = function () {
  147559. return 1000.0 / 60.0; // frame time in ms
  147560. };
  147561. _this._blockMaterialDirtyMechanism = false;
  147562. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__["EngineStore"].LastCreatedEngine;
  147563. if (!options || !options.virtual) {
  147564. _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__["EngineStore"]._LastCreatedScene = _this;
  147565. _this._engine.scenes.push(_this);
  147566. }
  147567. _this._uid = null;
  147568. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_18__["RenderingManager"](_this);
  147569. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_17__["PostProcessManager"]) {
  147570. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_17__["PostProcessManager"](_this);
  147571. }
  147572. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_21__["DomManagement"].IsWindowObjectExist()) {
  147573. _this.attachControl();
  147574. }
  147575. // Uniform Buffer
  147576. _this._createUbo();
  147577. // Default Image processing definition
  147578. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  147579. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]();
  147580. }
  147581. _this.setDefaultCandidateProviders();
  147582. if (options && options.useGeometryUniqueIdsMap === true) {
  147583. _this.geometriesByUniqueId = {};
  147584. }
  147585. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  147586. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  147587. if (!options || !options.virtual) {
  147588. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  147589. }
  147590. return _this;
  147591. }
  147592. /**
  147593. * Factory used to create the default material.
  147594. * @param name The name of the material to create
  147595. * @param scene The scene to create the material for
  147596. * @returns The default material
  147597. */
  147598. Scene.DefaultMaterialFactory = function (scene) {
  147599. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("StandardMaterial");
  147600. };
  147601. /**
  147602. * Factory used to create the a collision coordinator.
  147603. * @returns The collision coordinator
  147604. */
  147605. Scene.CollisionCoordinatorFactory = function () {
  147606. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  147607. };
  147608. Object.defineProperty(Scene.prototype, "environmentTexture", {
  147609. /**
  147610. * Texture used in all pbr material as the reflection texture.
  147611. * As in the majority of the scene they are the same (exception for multi room and so on),
  147612. * this is easier to reference from here than from all the materials.
  147613. */
  147614. get: function () {
  147615. return this._environmentTexture;
  147616. },
  147617. /**
  147618. * Texture used in all pbr material as the reflection texture.
  147619. * As in the majority of the scene they are the same (exception for multi room and so on),
  147620. * this is easier to set here than in all the materials.
  147621. */
  147622. set: function (value) {
  147623. if (this._environmentTexture === value) {
  147624. return;
  147625. }
  147626. this._environmentTexture = value;
  147627. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_TextureDirtyFlag);
  147628. },
  147629. enumerable: true,
  147630. configurable: true
  147631. });
  147632. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  147633. /**
  147634. * Default image processing configuration used either in the rendering
  147635. * Forward main pass or through the imageProcessingPostProcess if present.
  147636. * As in the majority of the scene they are the same (exception for multi camera),
  147637. * this is easier to reference from here than from all the materials and post process.
  147638. *
  147639. * No setter as we it is a shared configuration, you can set the values instead.
  147640. */
  147641. get: function () {
  147642. return this._imageProcessingConfiguration;
  147643. },
  147644. enumerable: true,
  147645. configurable: true
  147646. });
  147647. Object.defineProperty(Scene.prototype, "forceWireframe", {
  147648. get: function () {
  147649. return this._forceWireframe;
  147650. },
  147651. /**
  147652. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  147653. */
  147654. set: function (value) {
  147655. if (this._forceWireframe === value) {
  147656. return;
  147657. }
  147658. this._forceWireframe = value;
  147659. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  147660. },
  147661. enumerable: true,
  147662. configurable: true
  147663. });
  147664. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  147665. get: function () {
  147666. return this._forcePointsCloud;
  147667. },
  147668. /**
  147669. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  147670. */
  147671. set: function (value) {
  147672. if (this._forcePointsCloud === value) {
  147673. return;
  147674. }
  147675. this._forcePointsCloud = value;
  147676. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  147677. },
  147678. enumerable: true,
  147679. configurable: true
  147680. });
  147681. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  147682. /**
  147683. * Gets or sets the animation properties override
  147684. */
  147685. get: function () {
  147686. return this._animationPropertiesOverride;
  147687. },
  147688. set: function (value) {
  147689. this._animationPropertiesOverride = value;
  147690. },
  147691. enumerable: true,
  147692. configurable: true
  147693. });
  147694. Object.defineProperty(Scene.prototype, "onDispose", {
  147695. /** Sets a function to be executed when this scene is disposed. */
  147696. set: function (callback) {
  147697. if (this._onDisposeObserver) {
  147698. this.onDisposeObservable.remove(this._onDisposeObserver);
  147699. }
  147700. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  147701. },
  147702. enumerable: true,
  147703. configurable: true
  147704. });
  147705. Object.defineProperty(Scene.prototype, "beforeRender", {
  147706. /** Sets a function to be executed before rendering this scene */
  147707. set: function (callback) {
  147708. if (this._onBeforeRenderObserver) {
  147709. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  147710. }
  147711. if (callback) {
  147712. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  147713. }
  147714. },
  147715. enumerable: true,
  147716. configurable: true
  147717. });
  147718. Object.defineProperty(Scene.prototype, "afterRender", {
  147719. /** Sets a function to be executed after rendering this scene */
  147720. set: function (callback) {
  147721. if (this._onAfterRenderObserver) {
  147722. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  147723. }
  147724. if (callback) {
  147725. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  147726. }
  147727. },
  147728. enumerable: true,
  147729. configurable: true
  147730. });
  147731. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  147732. /** Sets a function to be executed before rendering a camera*/
  147733. set: function (callback) {
  147734. if (this._onBeforeCameraRenderObserver) {
  147735. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  147736. }
  147737. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  147738. },
  147739. enumerable: true,
  147740. configurable: true
  147741. });
  147742. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  147743. /** Sets a function to be executed after rendering a camera*/
  147744. set: function (callback) {
  147745. if (this._onAfterCameraRenderObserver) {
  147746. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  147747. }
  147748. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  147749. },
  147750. enumerable: true,
  147751. configurable: true
  147752. });
  147753. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  147754. /**
  147755. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  147756. */
  147757. get: function () {
  147758. return this._inputManager.unTranslatedPointer;
  147759. },
  147760. enumerable: true,
  147761. configurable: true
  147762. });
  147763. Object.defineProperty(Scene, "DragMovementThreshold", {
  147764. /**
  147765. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  147766. */
  147767. get: function () {
  147768. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DragMovementThreshold;
  147769. },
  147770. set: function (value) {
  147771. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DragMovementThreshold = value;
  147772. },
  147773. enumerable: true,
  147774. configurable: true
  147775. });
  147776. Object.defineProperty(Scene, "LongPressDelay", {
  147777. /**
  147778. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  147779. */
  147780. get: function () {
  147781. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].LongPressDelay;
  147782. },
  147783. set: function (value) {
  147784. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].LongPressDelay = value;
  147785. },
  147786. enumerable: true,
  147787. configurable: true
  147788. });
  147789. Object.defineProperty(Scene, "DoubleClickDelay", {
  147790. /**
  147791. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  147792. */
  147793. get: function () {
  147794. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DoubleClickDelay;
  147795. },
  147796. set: function (value) {
  147797. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DoubleClickDelay = value;
  147798. },
  147799. enumerable: true,
  147800. configurable: true
  147801. });
  147802. Object.defineProperty(Scene, "ExclusiveDoubleClickMode", {
  147803. /** If you need to check double click without raising a single click at first click, enable this flag */
  147804. get: function () {
  147805. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].ExclusiveDoubleClickMode;
  147806. },
  147807. set: function (value) {
  147808. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].ExclusiveDoubleClickMode = value;
  147809. },
  147810. enumerable: true,
  147811. configurable: true
  147812. });
  147813. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  147814. get: function () {
  147815. return this._useRightHandedSystem;
  147816. },
  147817. /**
  147818. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  147819. */
  147820. set: function (value) {
  147821. if (this._useRightHandedSystem === value) {
  147822. return;
  147823. }
  147824. this._useRightHandedSystem = value;
  147825. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  147826. },
  147827. enumerable: true,
  147828. configurable: true
  147829. });
  147830. /**
  147831. * Sets the step Id used by deterministic lock step
  147832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  147833. * @param newStepId defines the step Id
  147834. */
  147835. Scene.prototype.setStepId = function (newStepId) {
  147836. this._currentStepId = newStepId;
  147837. };
  147838. /**
  147839. * Gets the step Id used by deterministic lock step
  147840. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  147841. * @returns the step Id
  147842. */
  147843. Scene.prototype.getStepId = function () {
  147844. return this._currentStepId;
  147845. };
  147846. /**
  147847. * Gets the internal step used by deterministic lock step
  147848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  147849. * @returns the internal step
  147850. */
  147851. Scene.prototype.getInternalStep = function () {
  147852. return this._currentInternalStep;
  147853. };
  147854. Object.defineProperty(Scene.prototype, "fogEnabled", {
  147855. get: function () {
  147856. return this._fogEnabled;
  147857. },
  147858. /**
  147859. * Gets or sets a boolean indicating if fog is enabled on this scene
  147860. * @see http://doc.babylonjs.com/babylon101/environment#fog
  147861. * (Default is true)
  147862. */
  147863. set: function (value) {
  147864. if (this._fogEnabled === value) {
  147865. return;
  147866. }
  147867. this._fogEnabled = value;
  147868. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  147869. },
  147870. enumerable: true,
  147871. configurable: true
  147872. });
  147873. Object.defineProperty(Scene.prototype, "fogMode", {
  147874. get: function () {
  147875. return this._fogMode;
  147876. },
  147877. /**
  147878. * Gets or sets the fog mode to use
  147879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  147880. * | mode | value |
  147881. * | --- | --- |
  147882. * | FOGMODE_NONE | 0 |
  147883. * | FOGMODE_EXP | 1 |
  147884. * | FOGMODE_EXP2 | 2 |
  147885. * | FOGMODE_LINEAR | 3 |
  147886. */
  147887. set: function (value) {
  147888. if (this._fogMode === value) {
  147889. return;
  147890. }
  147891. this._fogMode = value;
  147892. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  147893. },
  147894. enumerable: true,
  147895. configurable: true
  147896. });
  147897. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  147898. get: function () {
  147899. return this._shadowsEnabled;
  147900. },
  147901. /**
  147902. * Gets or sets a boolean indicating if shadows are enabled on this scene
  147903. */
  147904. set: function (value) {
  147905. if (this._shadowsEnabled === value) {
  147906. return;
  147907. }
  147908. this._shadowsEnabled = value;
  147909. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_LightDirtyFlag);
  147910. },
  147911. enumerable: true,
  147912. configurable: true
  147913. });
  147914. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  147915. get: function () {
  147916. return this._lightsEnabled;
  147917. },
  147918. /**
  147919. * Gets or sets a boolean indicating if lights are enabled on this scene
  147920. */
  147921. set: function (value) {
  147922. if (this._lightsEnabled === value) {
  147923. return;
  147924. }
  147925. this._lightsEnabled = value;
  147926. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_LightDirtyFlag);
  147927. },
  147928. enumerable: true,
  147929. configurable: true
  147930. });
  147931. Object.defineProperty(Scene.prototype, "activeCamera", {
  147932. /** Gets or sets the current active camera */
  147933. get: function () {
  147934. return this._activeCamera;
  147935. },
  147936. set: function (value) {
  147937. if (value === this._activeCamera) {
  147938. return;
  147939. }
  147940. this._activeCamera = value;
  147941. this.onActiveCameraChanged.notifyObservers(this);
  147942. },
  147943. enumerable: true,
  147944. configurable: true
  147945. });
  147946. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  147947. /** The default material used on meshes when no material is affected */
  147948. get: function () {
  147949. if (!this._defaultMaterial) {
  147950. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  147951. }
  147952. return this._defaultMaterial;
  147953. },
  147954. /** The default material used on meshes when no material is affected */
  147955. set: function (value) {
  147956. this._defaultMaterial = value;
  147957. },
  147958. enumerable: true,
  147959. configurable: true
  147960. });
  147961. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  147962. get: function () {
  147963. return this._texturesEnabled;
  147964. },
  147965. /**
  147966. * Gets or sets a boolean indicating if textures are enabled on this scene
  147967. */
  147968. set: function (value) {
  147969. if (this._texturesEnabled === value) {
  147970. return;
  147971. }
  147972. this._texturesEnabled = value;
  147973. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_TextureDirtyFlag);
  147974. },
  147975. enumerable: true,
  147976. configurable: true
  147977. });
  147978. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  147979. get: function () {
  147980. return this._skeletonsEnabled;
  147981. },
  147982. /**
  147983. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  147984. */
  147985. set: function (value) {
  147986. if (this._skeletonsEnabled === value) {
  147987. return;
  147988. }
  147989. this._skeletonsEnabled = value;
  147990. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_AttributesDirtyFlag);
  147991. },
  147992. enumerable: true,
  147993. configurable: true
  147994. });
  147995. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  147996. /** @hidden */
  147997. get: function () {
  147998. if (!this._collisionCoordinator) {
  147999. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  148000. this._collisionCoordinator.init(this);
  148001. }
  148002. return this._collisionCoordinator;
  148003. },
  148004. enumerable: true,
  148005. configurable: true
  148006. });
  148007. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  148008. /**
  148009. * Gets the list of frustum planes (built from the active camera)
  148010. */
  148011. get: function () {
  148012. return this._frustumPlanes;
  148013. },
  148014. enumerable: true,
  148015. configurable: true
  148016. });
  148017. /**
  148018. * Registers the transient components if needed.
  148019. */
  148020. Scene.prototype._registerTransientComponents = function () {
  148021. // Register components that have been associated lately to the scene.
  148022. if (this._transientComponents.length > 0) {
  148023. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  148024. var component = _a[_i];
  148025. component.register();
  148026. }
  148027. this._transientComponents = [];
  148028. }
  148029. };
  148030. /**
  148031. * @hidden
  148032. * Add a component to the scene.
  148033. * Note that the ccomponent could be registered on th next frame if this is called after
  148034. * the register component stage.
  148035. * @param component Defines the component to add to the scene
  148036. */
  148037. Scene.prototype._addComponent = function (component) {
  148038. this._components.push(component);
  148039. this._transientComponents.push(component);
  148040. var serializableComponent = component;
  148041. if (serializableComponent.addFromContainer && serializableComponent.serialize) {
  148042. this._serializableComponents.push(serializableComponent);
  148043. }
  148044. };
  148045. /**
  148046. * @hidden
  148047. * Gets a component from the scene.
  148048. * @param name defines the name of the component to retrieve
  148049. * @returns the component or null if not present
  148050. */
  148051. Scene.prototype._getComponent = function (name) {
  148052. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  148053. var component = _a[_i];
  148054. if (component.name === name) {
  148055. return component;
  148056. }
  148057. }
  148058. return null;
  148059. };
  148060. /**
  148061. * Gets a string idenfifying the name of the class
  148062. * @returns "Scene" string
  148063. */
  148064. Scene.prototype.getClassName = function () {
  148065. return "Scene";
  148066. };
  148067. /**
  148068. * @hidden
  148069. */
  148070. Scene.prototype._getDefaultMeshCandidates = function () {
  148071. this._defaultMeshCandidates.data = this.meshes;
  148072. this._defaultMeshCandidates.length = this.meshes.length;
  148073. return this._defaultMeshCandidates;
  148074. };
  148075. /**
  148076. * @hidden
  148077. */
  148078. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  148079. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  148080. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  148081. return this._defaultSubMeshCandidates;
  148082. };
  148083. /**
  148084. * Sets the default candidate providers for the scene.
  148085. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  148086. * and getCollidingSubMeshCandidates to their default function
  148087. */
  148088. Scene.prototype.setDefaultCandidateProviders = function () {
  148089. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  148090. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  148091. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  148092. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  148093. };
  148094. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  148095. /**
  148096. * Gets the mesh that is currently under the pointer
  148097. */
  148098. get: function () {
  148099. return this._inputManager.meshUnderPointer;
  148100. },
  148101. enumerable: true,
  148102. configurable: true
  148103. });
  148104. Object.defineProperty(Scene.prototype, "pointerX", {
  148105. /**
  148106. * Gets or sets the current on-screen X position of the pointer
  148107. */
  148108. get: function () {
  148109. return this._inputManager.pointerX;
  148110. },
  148111. set: function (value) {
  148112. this._inputManager.pointerX = value;
  148113. },
  148114. enumerable: true,
  148115. configurable: true
  148116. });
  148117. Object.defineProperty(Scene.prototype, "pointerY", {
  148118. /**
  148119. * Gets or sets the current on-screen Y position of the pointer
  148120. */
  148121. get: function () {
  148122. return this._inputManager.pointerY;
  148123. },
  148124. set: function (value) {
  148125. this._inputManager.pointerY = value;
  148126. },
  148127. enumerable: true,
  148128. configurable: true
  148129. });
  148130. /**
  148131. * Gets the cached material (ie. the latest rendered one)
  148132. * @returns the cached material
  148133. */
  148134. Scene.prototype.getCachedMaterial = function () {
  148135. return this._cachedMaterial;
  148136. };
  148137. /**
  148138. * Gets the cached effect (ie. the latest rendered one)
  148139. * @returns the cached effect
  148140. */
  148141. Scene.prototype.getCachedEffect = function () {
  148142. return this._cachedEffect;
  148143. };
  148144. /**
  148145. * Gets the cached visibility state (ie. the latest rendered one)
  148146. * @returns the cached visibility state
  148147. */
  148148. Scene.prototype.getCachedVisibility = function () {
  148149. return this._cachedVisibility;
  148150. };
  148151. /**
  148152. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  148153. * @param material defines the current material
  148154. * @param effect defines the current effect
  148155. * @param visibility defines the current visibility state
  148156. * @returns true if one parameter is not cached
  148157. */
  148158. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  148159. if (visibility === void 0) { visibility = 1; }
  148160. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  148161. };
  148162. /**
  148163. * Gets the engine associated with the scene
  148164. * @returns an Engine
  148165. */
  148166. Scene.prototype.getEngine = function () {
  148167. return this._engine;
  148168. };
  148169. /**
  148170. * Gets the total number of vertices rendered per frame
  148171. * @returns the total number of vertices rendered per frame
  148172. */
  148173. Scene.prototype.getTotalVertices = function () {
  148174. return this._totalVertices.current;
  148175. };
  148176. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  148177. /**
  148178. * Gets the performance counter for total vertices
  148179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  148180. */
  148181. get: function () {
  148182. return this._totalVertices;
  148183. },
  148184. enumerable: true,
  148185. configurable: true
  148186. });
  148187. /**
  148188. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  148189. * @returns the total number of active indices rendered per frame
  148190. */
  148191. Scene.prototype.getActiveIndices = function () {
  148192. return this._activeIndices.current;
  148193. };
  148194. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  148195. /**
  148196. * Gets the performance counter for active indices
  148197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  148198. */
  148199. get: function () {
  148200. return this._activeIndices;
  148201. },
  148202. enumerable: true,
  148203. configurable: true
  148204. });
  148205. /**
  148206. * Gets the total number of active particles rendered per frame
  148207. * @returns the total number of active particles rendered per frame
  148208. */
  148209. Scene.prototype.getActiveParticles = function () {
  148210. return this._activeParticles.current;
  148211. };
  148212. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  148213. /**
  148214. * Gets the performance counter for active particles
  148215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  148216. */
  148217. get: function () {
  148218. return this._activeParticles;
  148219. },
  148220. enumerable: true,
  148221. configurable: true
  148222. });
  148223. /**
  148224. * Gets the total number of active bones rendered per frame
  148225. * @returns the total number of active bones rendered per frame
  148226. */
  148227. Scene.prototype.getActiveBones = function () {
  148228. return this._activeBones.current;
  148229. };
  148230. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  148231. /**
  148232. * Gets the performance counter for active bones
  148233. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  148234. */
  148235. get: function () {
  148236. return this._activeBones;
  148237. },
  148238. enumerable: true,
  148239. configurable: true
  148240. });
  148241. /**
  148242. * Gets the array of active meshes
  148243. * @returns an array of AbstractMesh
  148244. */
  148245. Scene.prototype.getActiveMeshes = function () {
  148246. return this._activeMeshes;
  148247. };
  148248. /**
  148249. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  148250. * @returns a number
  148251. */
  148252. Scene.prototype.getAnimationRatio = function () {
  148253. return this._animationRatio !== undefined ? this._animationRatio : 1;
  148254. };
  148255. /**
  148256. * Gets an unique Id for the current render phase
  148257. * @returns a number
  148258. */
  148259. Scene.prototype.getRenderId = function () {
  148260. return this._renderId;
  148261. };
  148262. /**
  148263. * Gets an unique Id for the current frame
  148264. * @returns a number
  148265. */
  148266. Scene.prototype.getFrameId = function () {
  148267. return this._frameId;
  148268. };
  148269. /** Call this function if you want to manually increment the render Id*/
  148270. Scene.prototype.incrementRenderId = function () {
  148271. this._renderId++;
  148272. };
  148273. Scene.prototype._createUbo = function () {
  148274. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__["UniformBuffer"](this._engine, undefined, true);
  148275. this._sceneUbo.addUniform("viewProjection", 16);
  148276. this._sceneUbo.addUniform("view", 16);
  148277. };
  148278. /**
  148279. * Use this method to simulate a pointer move on a mesh
  148280. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  148281. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  148282. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  148283. * @returns the current scene
  148284. */
  148285. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  148286. this._inputManager.simulatePointerMove(pickResult, pointerEventInit);
  148287. return this;
  148288. };
  148289. /**
  148290. * Use this method to simulate a pointer down on a mesh
  148291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  148292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  148293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  148294. * @returns the current scene
  148295. */
  148296. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  148297. this._inputManager.simulatePointerDown(pickResult, pointerEventInit);
  148298. return this;
  148299. };
  148300. /**
  148301. * Use this method to simulate a pointer up on a mesh
  148302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  148303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  148304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  148305. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  148306. * @returns the current scene
  148307. */
  148308. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  148309. this._inputManager.simulatePointerUp(pickResult, pointerEventInit, doubleTap);
  148310. return this;
  148311. };
  148312. /**
  148313. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  148314. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  148315. * @returns true if the pointer was captured
  148316. */
  148317. Scene.prototype.isPointerCaptured = function (pointerId) {
  148318. if (pointerId === void 0) { pointerId = 0; }
  148319. return this._inputManager.isPointerCaptured(pointerId);
  148320. };
  148321. /**
  148322. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  148323. * @param attachUp defines if you want to attach events to pointerup
  148324. * @param attachDown defines if you want to attach events to pointerdown
  148325. * @param attachMove defines if you want to attach events to pointermove
  148326. */
  148327. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  148328. if (attachUp === void 0) { attachUp = true; }
  148329. if (attachDown === void 0) { attachDown = true; }
  148330. if (attachMove === void 0) { attachMove = true; }
  148331. this._inputManager.attachControl(attachUp, attachDown, attachMove);
  148332. };
  148333. /** Detaches all event handlers*/
  148334. Scene.prototype.detachControl = function () {
  148335. this._inputManager.detachControl();
  148336. };
  148337. /**
  148338. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  148339. * Delay loaded resources are not taking in account
  148340. * @return true if all required resources are ready
  148341. */
  148342. Scene.prototype.isReady = function () {
  148343. if (this._isDisposed) {
  148344. return false;
  148345. }
  148346. var index;
  148347. var engine = this.getEngine();
  148348. // Effects
  148349. if (!engine.areAllEffectsReady()) {
  148350. return false;
  148351. }
  148352. // Pending data
  148353. if (this._pendingData.length > 0) {
  148354. return false;
  148355. }
  148356. // Meshes
  148357. for (index = 0; index < this.meshes.length; index++) {
  148358. var mesh = this.meshes[index];
  148359. if (!mesh.isEnabled()) {
  148360. continue;
  148361. }
  148362. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  148363. continue;
  148364. }
  148365. if (!mesh.isReady(true)) {
  148366. return false;
  148367. }
  148368. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  148369. // Is Ready For Mesh
  148370. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  148371. var step = _a[_i];
  148372. if (!step.action(mesh, hardwareInstancedRendering)) {
  148373. return false;
  148374. }
  148375. }
  148376. }
  148377. // Geometries
  148378. for (index = 0; index < this.geometries.length; index++) {
  148379. var geometry = this.geometries[index];
  148380. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].DELAYLOADSTATE_LOADING) {
  148381. return false;
  148382. }
  148383. }
  148384. // Post-processes
  148385. if (this.activeCameras && this.activeCameras.length > 0) {
  148386. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  148387. var camera = _c[_b];
  148388. if (!camera.isReady(true)) {
  148389. return false;
  148390. }
  148391. }
  148392. }
  148393. else if (this.activeCamera) {
  148394. if (!this.activeCamera.isReady(true)) {
  148395. return false;
  148396. }
  148397. }
  148398. // Particles
  148399. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  148400. var particleSystem = _e[_d];
  148401. if (!particleSystem.isReady()) {
  148402. return false;
  148403. }
  148404. }
  148405. return true;
  148406. };
  148407. /** Resets all cached information relative to material (including effect and visibility) */
  148408. Scene.prototype.resetCachedMaterial = function () {
  148409. this._cachedMaterial = null;
  148410. this._cachedEffect = null;
  148411. this._cachedVisibility = null;
  148412. };
  148413. /**
  148414. * Registers a function to be called before every frame render
  148415. * @param func defines the function to register
  148416. */
  148417. Scene.prototype.registerBeforeRender = function (func) {
  148418. this.onBeforeRenderObservable.add(func);
  148419. };
  148420. /**
  148421. * Unregisters a function called before every frame render
  148422. * @param func defines the function to unregister
  148423. */
  148424. Scene.prototype.unregisterBeforeRender = function (func) {
  148425. this.onBeforeRenderObservable.removeCallback(func);
  148426. };
  148427. /**
  148428. * Registers a function to be called after every frame render
  148429. * @param func defines the function to register
  148430. */
  148431. Scene.prototype.registerAfterRender = function (func) {
  148432. this.onAfterRenderObservable.add(func);
  148433. };
  148434. /**
  148435. * Unregisters a function called after every frame render
  148436. * @param func defines the function to unregister
  148437. */
  148438. Scene.prototype.unregisterAfterRender = function (func) {
  148439. this.onAfterRenderObservable.removeCallback(func);
  148440. };
  148441. Scene.prototype._executeOnceBeforeRender = function (func) {
  148442. var _this = this;
  148443. var execFunc = function () {
  148444. func();
  148445. setTimeout(function () {
  148446. _this.unregisterBeforeRender(execFunc);
  148447. });
  148448. };
  148449. this.registerBeforeRender(execFunc);
  148450. };
  148451. /**
  148452. * The provided function will run before render once and will be disposed afterwards.
  148453. * A timeout delay can be provided so that the function will be executed in N ms.
  148454. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  148455. * @param func The function to be executed.
  148456. * @param timeout optional delay in ms
  148457. */
  148458. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  148459. var _this = this;
  148460. if (timeout !== undefined) {
  148461. setTimeout(function () {
  148462. _this._executeOnceBeforeRender(func);
  148463. }, timeout);
  148464. }
  148465. else {
  148466. this._executeOnceBeforeRender(func);
  148467. }
  148468. };
  148469. /** @hidden */
  148470. Scene.prototype._addPendingData = function (data) {
  148471. this._pendingData.push(data);
  148472. };
  148473. /** @hidden */
  148474. Scene.prototype._removePendingData = function (data) {
  148475. var wasLoading = this.isLoading;
  148476. var index = this._pendingData.indexOf(data);
  148477. if (index !== -1) {
  148478. this._pendingData.splice(index, 1);
  148479. }
  148480. if (wasLoading && !this.isLoading) {
  148481. this.onDataLoadedObservable.notifyObservers(this);
  148482. }
  148483. };
  148484. /**
  148485. * Returns the number of items waiting to be loaded
  148486. * @returns the number of items waiting to be loaded
  148487. */
  148488. Scene.prototype.getWaitingItemsCount = function () {
  148489. return this._pendingData.length;
  148490. };
  148491. Object.defineProperty(Scene.prototype, "isLoading", {
  148492. /**
  148493. * Returns a boolean indicating if the scene is still loading data
  148494. */
  148495. get: function () {
  148496. return this._pendingData.length > 0;
  148497. },
  148498. enumerable: true,
  148499. configurable: true
  148500. });
  148501. /**
  148502. * Registers a function to be executed when the scene is ready
  148503. * @param {Function} func - the function to be executed
  148504. */
  148505. Scene.prototype.executeWhenReady = function (func) {
  148506. var _this = this;
  148507. this.onReadyObservable.add(func);
  148508. if (this._executeWhenReadyTimeoutId !== -1) {
  148509. return;
  148510. }
  148511. this._executeWhenReadyTimeoutId = setTimeout(function () {
  148512. _this._checkIsReady();
  148513. }, 150);
  148514. };
  148515. /**
  148516. * Returns a promise that resolves when the scene is ready
  148517. * @returns A promise that resolves when the scene is ready
  148518. */
  148519. Scene.prototype.whenReadyAsync = function () {
  148520. var _this = this;
  148521. return new Promise(function (resolve) {
  148522. _this.executeWhenReady(function () {
  148523. resolve();
  148524. });
  148525. });
  148526. };
  148527. /** @hidden */
  148528. Scene.prototype._checkIsReady = function () {
  148529. var _this = this;
  148530. this._registerTransientComponents();
  148531. if (this.isReady()) {
  148532. this.onReadyObservable.notifyObservers(this);
  148533. this.onReadyObservable.clear();
  148534. this._executeWhenReadyTimeoutId = -1;
  148535. return;
  148536. }
  148537. if (this._isDisposed) {
  148538. this.onReadyObservable.clear();
  148539. this._executeWhenReadyTimeoutId = -1;
  148540. return;
  148541. }
  148542. this._executeWhenReadyTimeoutId = setTimeout(function () {
  148543. _this._checkIsReady();
  148544. }, 150);
  148545. };
  148546. Object.defineProperty(Scene.prototype, "animatables", {
  148547. /**
  148548. * Gets all animatable attached to the scene
  148549. */
  148550. get: function () {
  148551. return this._activeAnimatables;
  148552. },
  148553. enumerable: true,
  148554. configurable: true
  148555. });
  148556. /**
  148557. * Resets the last animation time frame.
  148558. * Useful to override when animations start running when loading a scene for the first time.
  148559. */
  148560. Scene.prototype.resetLastAnimationTimeFrame = function () {
  148561. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  148562. };
  148563. // Matrix
  148564. /**
  148565. * Gets the current view matrix
  148566. * @returns a Matrix
  148567. */
  148568. Scene.prototype.getViewMatrix = function () {
  148569. return this._viewMatrix;
  148570. };
  148571. /**
  148572. * Gets the current projection matrix
  148573. * @returns a Matrix
  148574. */
  148575. Scene.prototype.getProjectionMatrix = function () {
  148576. return this._projectionMatrix;
  148577. };
  148578. /**
  148579. * Gets the current transform matrix
  148580. * @returns a Matrix made of View * Projection
  148581. */
  148582. Scene.prototype.getTransformMatrix = function () {
  148583. return this._transformMatrix;
  148584. };
  148585. /**
  148586. * Sets the current transform matrix
  148587. * @param viewL defines the View matrix to use
  148588. * @param projectionL defines the Projection matrix to use
  148589. * @param viewR defines the right View matrix to use (if provided)
  148590. * @param projectionR defines the right Projection matrix to use (if provided)
  148591. */
  148592. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  148593. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  148594. return;
  148595. }
  148596. this._viewUpdateFlag = viewL.updateFlag;
  148597. this._projectionUpdateFlag = projectionL.updateFlag;
  148598. this._viewMatrix = viewL;
  148599. this._projectionMatrix = projectionL;
  148600. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  148601. // Update frustum
  148602. if (!this._frustumPlanes) {
  148603. this._frustumPlanes = _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_28__["Frustum"].GetPlanes(this._transformMatrix);
  148604. }
  148605. else {
  148606. _Maths_math_frustum__WEBPACK_IMPORTED_MODULE_28__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  148607. }
  148608. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  148609. this._updateMultiviewUbo(viewR, projectionR);
  148610. }
  148611. else if (this._sceneUbo.useUbo) {
  148612. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  148613. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  148614. this._sceneUbo.update();
  148615. }
  148616. };
  148617. /**
  148618. * Gets the uniform buffer used to store scene data
  148619. * @returns a UniformBuffer
  148620. */
  148621. Scene.prototype.getSceneUniformBuffer = function () {
  148622. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  148623. };
  148624. /**
  148625. * Gets an unique (relatively to the current scene) Id
  148626. * @returns an unique number for the scene
  148627. */
  148628. Scene.prototype.getUniqueId = function () {
  148629. return _Misc_uniqueIdGenerator__WEBPACK_IMPORTED_MODULE_29__["UniqueIdGenerator"].UniqueId;
  148630. };
  148631. /**
  148632. * Add a mesh to the list of scene's meshes
  148633. * @param newMesh defines the mesh to add
  148634. * @param recursive if all child meshes should also be added to the scene
  148635. */
  148636. Scene.prototype.addMesh = function (newMesh, recursive) {
  148637. var _this = this;
  148638. if (recursive === void 0) { recursive = false; }
  148639. this.meshes.push(newMesh);
  148640. newMesh._resyncLightSources();
  148641. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  148642. if (recursive) {
  148643. newMesh.getChildMeshes().forEach(function (m) {
  148644. _this.addMesh(m);
  148645. });
  148646. }
  148647. };
  148648. /**
  148649. * Remove a mesh for the list of scene's meshes
  148650. * @param toRemove defines the mesh to remove
  148651. * @param recursive if all child meshes should also be removed from the scene
  148652. * @returns the index where the mesh was in the mesh list
  148653. */
  148654. Scene.prototype.removeMesh = function (toRemove, recursive) {
  148655. var _this = this;
  148656. if (recursive === void 0) { recursive = false; }
  148657. var index = this.meshes.indexOf(toRemove);
  148658. if (index !== -1) {
  148659. // Remove from the scene if mesh found
  148660. this.meshes[index] = this.meshes[this.meshes.length - 1];
  148661. this.meshes.pop();
  148662. }
  148663. this.onMeshRemovedObservable.notifyObservers(toRemove);
  148664. if (recursive) {
  148665. toRemove.getChildMeshes().forEach(function (m) {
  148666. _this.removeMesh(m);
  148667. });
  148668. }
  148669. return index;
  148670. };
  148671. /**
  148672. * Add a transform node to the list of scene's transform nodes
  148673. * @param newTransformNode defines the transform node to add
  148674. */
  148675. Scene.prototype.addTransformNode = function (newTransformNode) {
  148676. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  148677. this.transformNodes.push(newTransformNode);
  148678. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  148679. };
  148680. /**
  148681. * Remove a transform node for the list of scene's transform nodes
  148682. * @param toRemove defines the transform node to remove
  148683. * @returns the index where the transform node was in the transform node list
  148684. */
  148685. Scene.prototype.removeTransformNode = function (toRemove) {
  148686. var index = toRemove._indexInSceneTransformNodesArray;
  148687. if (index !== -1) {
  148688. if (index !== this.transformNodes.length - 1) {
  148689. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  148690. this.transformNodes[index] = lastNode;
  148691. lastNode._indexInSceneTransformNodesArray = index;
  148692. }
  148693. toRemove._indexInSceneTransformNodesArray = -1;
  148694. this.transformNodes.pop();
  148695. }
  148696. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  148697. return index;
  148698. };
  148699. /**
  148700. * Remove a skeleton for the list of scene's skeletons
  148701. * @param toRemove defines the skeleton to remove
  148702. * @returns the index where the skeleton was in the skeleton list
  148703. */
  148704. Scene.prototype.removeSkeleton = function (toRemove) {
  148705. var index = this.skeletons.indexOf(toRemove);
  148706. if (index !== -1) {
  148707. // Remove from the scene if found
  148708. this.skeletons.splice(index, 1);
  148709. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  148710. }
  148711. return index;
  148712. };
  148713. /**
  148714. * Remove a morph target for the list of scene's morph targets
  148715. * @param toRemove defines the morph target to remove
  148716. * @returns the index where the morph target was in the morph target list
  148717. */
  148718. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  148719. var index = this.morphTargetManagers.indexOf(toRemove);
  148720. if (index !== -1) {
  148721. // Remove from the scene if found
  148722. this.morphTargetManagers.splice(index, 1);
  148723. }
  148724. return index;
  148725. };
  148726. /**
  148727. * Remove a light for the list of scene's lights
  148728. * @param toRemove defines the light to remove
  148729. * @returns the index where the light was in the light list
  148730. */
  148731. Scene.prototype.removeLight = function (toRemove) {
  148732. var index = this.lights.indexOf(toRemove);
  148733. if (index !== -1) {
  148734. // Remove from meshes
  148735. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  148736. var mesh = _a[_i];
  148737. mesh._removeLightSource(toRemove);
  148738. }
  148739. // Remove from the scene if mesh found
  148740. this.lights.splice(index, 1);
  148741. this.sortLightsByPriority();
  148742. }
  148743. this.onLightRemovedObservable.notifyObservers(toRemove);
  148744. return index;
  148745. };
  148746. /**
  148747. * Remove a camera for the list of scene's cameras
  148748. * @param toRemove defines the camera to remove
  148749. * @returns the index where the camera was in the camera list
  148750. */
  148751. Scene.prototype.removeCamera = function (toRemove) {
  148752. var index = this.cameras.indexOf(toRemove);
  148753. if (index !== -1) {
  148754. // Remove from the scene if mesh found
  148755. this.cameras.splice(index, 1);
  148756. }
  148757. // Remove from activeCameras
  148758. var index2 = this.activeCameras.indexOf(toRemove);
  148759. if (index2 !== -1) {
  148760. // Remove from the scene if mesh found
  148761. this.activeCameras.splice(index2, 1);
  148762. }
  148763. // Reset the activeCamera
  148764. if (this.activeCamera === toRemove) {
  148765. if (this.cameras.length > 0) {
  148766. this.activeCamera = this.cameras[0];
  148767. }
  148768. else {
  148769. this.activeCamera = null;
  148770. }
  148771. }
  148772. this.onCameraRemovedObservable.notifyObservers(toRemove);
  148773. return index;
  148774. };
  148775. /**
  148776. * Remove a particle system for the list of scene's particle systems
  148777. * @param toRemove defines the particle system to remove
  148778. * @returns the index where the particle system was in the particle system list
  148779. */
  148780. Scene.prototype.removeParticleSystem = function (toRemove) {
  148781. var index = this.particleSystems.indexOf(toRemove);
  148782. if (index !== -1) {
  148783. this.particleSystems.splice(index, 1);
  148784. }
  148785. return index;
  148786. };
  148787. /**
  148788. * Remove a animation for the list of scene's animations
  148789. * @param toRemove defines the animation to remove
  148790. * @returns the index where the animation was in the animation list
  148791. */
  148792. Scene.prototype.removeAnimation = function (toRemove) {
  148793. var index = this.animations.indexOf(toRemove);
  148794. if (index !== -1) {
  148795. this.animations.splice(index, 1);
  148796. }
  148797. return index;
  148798. };
  148799. /**
  148800. * Will stop the animation of the given target
  148801. * @param target - the target
  148802. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  148803. * @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)
  148804. */
  148805. Scene.prototype.stopAnimation = function (target, animationName, targetMask) {
  148806. // Do nothing as code will be provided by animation component
  148807. };
  148808. /**
  148809. * Removes the given animation group from this scene.
  148810. * @param toRemove The animation group to remove
  148811. * @returns The index of the removed animation group
  148812. */
  148813. Scene.prototype.removeAnimationGroup = function (toRemove) {
  148814. var index = this.animationGroups.indexOf(toRemove);
  148815. if (index !== -1) {
  148816. this.animationGroups.splice(index, 1);
  148817. }
  148818. return index;
  148819. };
  148820. /**
  148821. * Removes the given multi-material from this scene.
  148822. * @param toRemove The multi-material to remove
  148823. * @returns The index of the removed multi-material
  148824. */
  148825. Scene.prototype.removeMultiMaterial = function (toRemove) {
  148826. var index = this.multiMaterials.indexOf(toRemove);
  148827. if (index !== -1) {
  148828. this.multiMaterials.splice(index, 1);
  148829. }
  148830. return index;
  148831. };
  148832. /**
  148833. * Removes the given material from this scene.
  148834. * @param toRemove The material to remove
  148835. * @returns The index of the removed material
  148836. */
  148837. Scene.prototype.removeMaterial = function (toRemove) {
  148838. var index = toRemove._indexInSceneMaterialArray;
  148839. if (index !== -1 && index < this.materials.length) {
  148840. if (index !== this.materials.length - 1) {
  148841. var lastMaterial = this.materials[this.materials.length - 1];
  148842. this.materials[index] = lastMaterial;
  148843. lastMaterial._indexInSceneMaterialArray = index;
  148844. }
  148845. toRemove._indexInSceneMaterialArray = -1;
  148846. this.materials.pop();
  148847. }
  148848. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  148849. return index;
  148850. };
  148851. /**
  148852. * Removes the given action manager from this scene.
  148853. * @param toRemove The action manager to remove
  148854. * @returns The index of the removed action manager
  148855. */
  148856. Scene.prototype.removeActionManager = function (toRemove) {
  148857. var index = this.actionManagers.indexOf(toRemove);
  148858. if (index !== -1) {
  148859. this.actionManagers.splice(index, 1);
  148860. }
  148861. return index;
  148862. };
  148863. /**
  148864. * Removes the given texture from this scene.
  148865. * @param toRemove The texture to remove
  148866. * @returns The index of the removed texture
  148867. */
  148868. Scene.prototype.removeTexture = function (toRemove) {
  148869. var index = this.textures.indexOf(toRemove);
  148870. if (index !== -1) {
  148871. this.textures.splice(index, 1);
  148872. }
  148873. this.onTextureRemovedObservable.notifyObservers(toRemove);
  148874. return index;
  148875. };
  148876. /**
  148877. * Adds the given light to this scene
  148878. * @param newLight The light to add
  148879. */
  148880. Scene.prototype.addLight = function (newLight) {
  148881. this.lights.push(newLight);
  148882. this.sortLightsByPriority();
  148883. // Add light to all meshes (To support if the light is removed and then readded)
  148884. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  148885. var mesh = _a[_i];
  148886. if (mesh.lightSources.indexOf(newLight) === -1) {
  148887. mesh.lightSources.push(newLight);
  148888. mesh._resyncLightSources();
  148889. }
  148890. }
  148891. this.onNewLightAddedObservable.notifyObservers(newLight);
  148892. };
  148893. /**
  148894. * Sorts the list list based on light priorities
  148895. */
  148896. Scene.prototype.sortLightsByPriority = function () {
  148897. if (this.requireLightSorting) {
  148898. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_14__["Light"].CompareLightsPriority);
  148899. }
  148900. };
  148901. /**
  148902. * Adds the given camera to this scene
  148903. * @param newCamera The camera to add
  148904. */
  148905. Scene.prototype.addCamera = function (newCamera) {
  148906. this.cameras.push(newCamera);
  148907. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  148908. };
  148909. /**
  148910. * Adds the given skeleton to this scene
  148911. * @param newSkeleton The skeleton to add
  148912. */
  148913. Scene.prototype.addSkeleton = function (newSkeleton) {
  148914. this.skeletons.push(newSkeleton);
  148915. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  148916. };
  148917. /**
  148918. * Adds the given particle system to this scene
  148919. * @param newParticleSystem The particle system to add
  148920. */
  148921. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  148922. this.particleSystems.push(newParticleSystem);
  148923. };
  148924. /**
  148925. * Adds the given animation to this scene
  148926. * @param newAnimation The animation to add
  148927. */
  148928. Scene.prototype.addAnimation = function (newAnimation) {
  148929. this.animations.push(newAnimation);
  148930. };
  148931. /**
  148932. * Adds the given animation group to this scene.
  148933. * @param newAnimationGroup The animation group to add
  148934. */
  148935. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  148936. this.animationGroups.push(newAnimationGroup);
  148937. };
  148938. /**
  148939. * Adds the given multi-material to this scene
  148940. * @param newMultiMaterial The multi-material to add
  148941. */
  148942. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  148943. this.multiMaterials.push(newMultiMaterial);
  148944. };
  148945. /**
  148946. * Adds the given material to this scene
  148947. * @param newMaterial The material to add
  148948. */
  148949. Scene.prototype.addMaterial = function (newMaterial) {
  148950. newMaterial._indexInSceneMaterialArray = this.materials.length;
  148951. this.materials.push(newMaterial);
  148952. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  148953. };
  148954. /**
  148955. * Adds the given morph target to this scene
  148956. * @param newMorphTargetManager The morph target to add
  148957. */
  148958. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  148959. this.morphTargetManagers.push(newMorphTargetManager);
  148960. };
  148961. /**
  148962. * Adds the given geometry to this scene
  148963. * @param newGeometry The geometry to add
  148964. */
  148965. Scene.prototype.addGeometry = function (newGeometry) {
  148966. if (this.geometriesByUniqueId) {
  148967. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  148968. }
  148969. this.geometries.push(newGeometry);
  148970. };
  148971. /**
  148972. * Adds the given action manager to this scene
  148973. * @param newActionManager The action manager to add
  148974. */
  148975. Scene.prototype.addActionManager = function (newActionManager) {
  148976. this.actionManagers.push(newActionManager);
  148977. };
  148978. /**
  148979. * Adds the given texture to this scene.
  148980. * @param newTexture The texture to add
  148981. */
  148982. Scene.prototype.addTexture = function (newTexture) {
  148983. this.textures.push(newTexture);
  148984. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  148985. };
  148986. /**
  148987. * Switch active camera
  148988. * @param newCamera defines the new active camera
  148989. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  148990. */
  148991. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  148992. if (attachControl === void 0) { attachControl = true; }
  148993. var canvas = this._engine.getRenderingCanvas();
  148994. if (!canvas) {
  148995. return;
  148996. }
  148997. if (this.activeCamera) {
  148998. this.activeCamera.detachControl(canvas);
  148999. }
  149000. this.activeCamera = newCamera;
  149001. if (attachControl) {
  149002. newCamera.attachControl(canvas);
  149003. }
  149004. };
  149005. /**
  149006. * sets the active camera of the scene using its ID
  149007. * @param id defines the camera's ID
  149008. * @return the new active camera or null if none found.
  149009. */
  149010. Scene.prototype.setActiveCameraByID = function (id) {
  149011. var camera = this.getCameraByID(id);
  149012. if (camera) {
  149013. this.activeCamera = camera;
  149014. return camera;
  149015. }
  149016. return null;
  149017. };
  149018. /**
  149019. * sets the active camera of the scene using its name
  149020. * @param name defines the camera's name
  149021. * @returns the new active camera or null if none found.
  149022. */
  149023. Scene.prototype.setActiveCameraByName = function (name) {
  149024. var camera = this.getCameraByName(name);
  149025. if (camera) {
  149026. this.activeCamera = camera;
  149027. return camera;
  149028. }
  149029. return null;
  149030. };
  149031. /**
  149032. * get an animation group using its name
  149033. * @param name defines the material's name
  149034. * @return the animation group or null if none found.
  149035. */
  149036. Scene.prototype.getAnimationGroupByName = function (name) {
  149037. for (var index = 0; index < this.animationGroups.length; index++) {
  149038. if (this.animationGroups[index].name === name) {
  149039. return this.animationGroups[index];
  149040. }
  149041. }
  149042. return null;
  149043. };
  149044. /**
  149045. * Get a material using its unique id
  149046. * @param uniqueId defines the material's unique id
  149047. * @return the material or null if none found.
  149048. */
  149049. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  149050. for (var index = 0; index < this.materials.length; index++) {
  149051. if (this.materials[index].uniqueId === uniqueId) {
  149052. return this.materials[index];
  149053. }
  149054. }
  149055. return null;
  149056. };
  149057. /**
  149058. * get a material using its id
  149059. * @param id defines the material's ID
  149060. * @return the material or null if none found.
  149061. */
  149062. Scene.prototype.getMaterialByID = function (id) {
  149063. for (var index = 0; index < this.materials.length; index++) {
  149064. if (this.materials[index].id === id) {
  149065. return this.materials[index];
  149066. }
  149067. }
  149068. return null;
  149069. };
  149070. /**
  149071. * Gets a the last added material using a given id
  149072. * @param id defines the material's ID
  149073. * @return the last material with the given id or null if none found.
  149074. */
  149075. Scene.prototype.getLastMaterialByID = function (id) {
  149076. for (var index = this.materials.length - 1; index >= 0; index--) {
  149077. if (this.materials[index].id === id) {
  149078. return this.materials[index];
  149079. }
  149080. }
  149081. return null;
  149082. };
  149083. /**
  149084. * Gets a material using its name
  149085. * @param name defines the material's name
  149086. * @return the material or null if none found.
  149087. */
  149088. Scene.prototype.getMaterialByName = function (name) {
  149089. for (var index = 0; index < this.materials.length; index++) {
  149090. if (this.materials[index].name === name) {
  149091. return this.materials[index];
  149092. }
  149093. }
  149094. return null;
  149095. };
  149096. /**
  149097. * Gets a camera using its id
  149098. * @param id defines the id to look for
  149099. * @returns the camera or null if not found
  149100. */
  149101. Scene.prototype.getCameraByID = function (id) {
  149102. for (var index = 0; index < this.cameras.length; index++) {
  149103. if (this.cameras[index].id === id) {
  149104. return this.cameras[index];
  149105. }
  149106. }
  149107. return null;
  149108. };
  149109. /**
  149110. * Gets a camera using its unique id
  149111. * @param uniqueId defines the unique id to look for
  149112. * @returns the camera or null if not found
  149113. */
  149114. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  149115. for (var index = 0; index < this.cameras.length; index++) {
  149116. if (this.cameras[index].uniqueId === uniqueId) {
  149117. return this.cameras[index];
  149118. }
  149119. }
  149120. return null;
  149121. };
  149122. /**
  149123. * Gets a camera using its name
  149124. * @param name defines the camera's name
  149125. * @return the camera or null if none found.
  149126. */
  149127. Scene.prototype.getCameraByName = function (name) {
  149128. for (var index = 0; index < this.cameras.length; index++) {
  149129. if (this.cameras[index].name === name) {
  149130. return this.cameras[index];
  149131. }
  149132. }
  149133. return null;
  149134. };
  149135. /**
  149136. * Gets a bone using its id
  149137. * @param id defines the bone's id
  149138. * @return the bone or null if not found
  149139. */
  149140. Scene.prototype.getBoneByID = function (id) {
  149141. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  149142. var skeleton = this.skeletons[skeletonIndex];
  149143. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  149144. if (skeleton.bones[boneIndex].id === id) {
  149145. return skeleton.bones[boneIndex];
  149146. }
  149147. }
  149148. }
  149149. return null;
  149150. };
  149151. /**
  149152. * Gets a bone using its id
  149153. * @param name defines the bone's name
  149154. * @return the bone or null if not found
  149155. */
  149156. Scene.prototype.getBoneByName = function (name) {
  149157. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  149158. var skeleton = this.skeletons[skeletonIndex];
  149159. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  149160. if (skeleton.bones[boneIndex].name === name) {
  149161. return skeleton.bones[boneIndex];
  149162. }
  149163. }
  149164. }
  149165. return null;
  149166. };
  149167. /**
  149168. * Gets a light node using its name
  149169. * @param name defines the the light's name
  149170. * @return the light or null if none found.
  149171. */
  149172. Scene.prototype.getLightByName = function (name) {
  149173. for (var index = 0; index < this.lights.length; index++) {
  149174. if (this.lights[index].name === name) {
  149175. return this.lights[index];
  149176. }
  149177. }
  149178. return null;
  149179. };
  149180. /**
  149181. * Gets a light node using its id
  149182. * @param id defines the light's id
  149183. * @return the light or null if none found.
  149184. */
  149185. Scene.prototype.getLightByID = function (id) {
  149186. for (var index = 0; index < this.lights.length; index++) {
  149187. if (this.lights[index].id === id) {
  149188. return this.lights[index];
  149189. }
  149190. }
  149191. return null;
  149192. };
  149193. /**
  149194. * Gets a light node using its scene-generated unique ID
  149195. * @param uniqueId defines the light's unique id
  149196. * @return the light or null if none found.
  149197. */
  149198. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  149199. for (var index = 0; index < this.lights.length; index++) {
  149200. if (this.lights[index].uniqueId === uniqueId) {
  149201. return this.lights[index];
  149202. }
  149203. }
  149204. return null;
  149205. };
  149206. /**
  149207. * Gets a particle system by id
  149208. * @param id defines the particle system id
  149209. * @return the corresponding system or null if none found
  149210. */
  149211. Scene.prototype.getParticleSystemByID = function (id) {
  149212. for (var index = 0; index < this.particleSystems.length; index++) {
  149213. if (this.particleSystems[index].id === id) {
  149214. return this.particleSystems[index];
  149215. }
  149216. }
  149217. return null;
  149218. };
  149219. /**
  149220. * Gets a geometry using its ID
  149221. * @param id defines the geometry's id
  149222. * @return the geometry or null if none found.
  149223. */
  149224. Scene.prototype.getGeometryByID = function (id) {
  149225. for (var index = 0; index < this.geometries.length; index++) {
  149226. if (this.geometries[index].id === id) {
  149227. return this.geometries[index];
  149228. }
  149229. }
  149230. return null;
  149231. };
  149232. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  149233. if (this.geometriesByUniqueId) {
  149234. var index_1 = this.geometriesByUniqueId[uniqueId];
  149235. if (index_1 !== undefined) {
  149236. return this.geometries[index_1];
  149237. }
  149238. }
  149239. else {
  149240. for (var index = 0; index < this.geometries.length; index++) {
  149241. if (this.geometries[index].uniqueId === uniqueId) {
  149242. return this.geometries[index];
  149243. }
  149244. }
  149245. }
  149246. return null;
  149247. };
  149248. /**
  149249. * Add a new geometry to this scene
  149250. * @param geometry defines the geometry to be added to the scene.
  149251. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  149252. * @return a boolean defining if the geometry was added or not
  149253. */
  149254. Scene.prototype.pushGeometry = function (geometry, force) {
  149255. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  149256. return false;
  149257. }
  149258. this.addGeometry(geometry);
  149259. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  149260. return true;
  149261. };
  149262. /**
  149263. * Removes an existing geometry
  149264. * @param geometry defines the geometry to be removed from the scene
  149265. * @return a boolean defining if the geometry was removed or not
  149266. */
  149267. Scene.prototype.removeGeometry = function (geometry) {
  149268. var index;
  149269. if (this.geometriesByUniqueId) {
  149270. index = this.geometriesByUniqueId[geometry.uniqueId];
  149271. if (index === undefined) {
  149272. return false;
  149273. }
  149274. }
  149275. else {
  149276. index = this.geometries.indexOf(geometry);
  149277. if (index < 0) {
  149278. return false;
  149279. }
  149280. }
  149281. if (index !== this.geometries.length - 1) {
  149282. var lastGeometry = this.geometries[this.geometries.length - 1];
  149283. this.geometries[index] = lastGeometry;
  149284. if (this.geometriesByUniqueId) {
  149285. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  149286. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  149287. }
  149288. }
  149289. this.geometries.pop();
  149290. this.onGeometryRemovedObservable.notifyObservers(geometry);
  149291. return true;
  149292. };
  149293. /**
  149294. * Gets the list of geometries attached to the scene
  149295. * @returns an array of Geometry
  149296. */
  149297. Scene.prototype.getGeometries = function () {
  149298. return this.geometries;
  149299. };
  149300. /**
  149301. * Gets the first added mesh found of a given ID
  149302. * @param id defines the id to search for
  149303. * @return the mesh found or null if not found at all
  149304. */
  149305. Scene.prototype.getMeshByID = function (id) {
  149306. for (var index = 0; index < this.meshes.length; index++) {
  149307. if (this.meshes[index].id === id) {
  149308. return this.meshes[index];
  149309. }
  149310. }
  149311. return null;
  149312. };
  149313. /**
  149314. * Gets a list of meshes using their id
  149315. * @param id defines the id to search for
  149316. * @returns a list of meshes
  149317. */
  149318. Scene.prototype.getMeshesByID = function (id) {
  149319. return this.meshes.filter(function (m) {
  149320. return m.id === id;
  149321. });
  149322. };
  149323. /**
  149324. * Gets the first added transform node found of a given ID
  149325. * @param id defines the id to search for
  149326. * @return the found transform node or null if not found at all.
  149327. */
  149328. Scene.prototype.getTransformNodeByID = function (id) {
  149329. for (var index = 0; index < this.transformNodes.length; index++) {
  149330. if (this.transformNodes[index].id === id) {
  149331. return this.transformNodes[index];
  149332. }
  149333. }
  149334. return null;
  149335. };
  149336. /**
  149337. * Gets a transform node with its auto-generated unique id
  149338. * @param uniqueId efines the unique id to search for
  149339. * @return the found transform node or null if not found at all.
  149340. */
  149341. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  149342. for (var index = 0; index < this.transformNodes.length; index++) {
  149343. if (this.transformNodes[index].uniqueId === uniqueId) {
  149344. return this.transformNodes[index];
  149345. }
  149346. }
  149347. return null;
  149348. };
  149349. /**
  149350. * Gets a list of transform nodes using their id
  149351. * @param id defines the id to search for
  149352. * @returns a list of transform nodes
  149353. */
  149354. Scene.prototype.getTransformNodesByID = function (id) {
  149355. return this.transformNodes.filter(function (m) {
  149356. return m.id === id;
  149357. });
  149358. };
  149359. /**
  149360. * Gets a mesh with its auto-generated unique id
  149361. * @param uniqueId defines the unique id to search for
  149362. * @return the found mesh or null if not found at all.
  149363. */
  149364. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  149365. for (var index = 0; index < this.meshes.length; index++) {
  149366. if (this.meshes[index].uniqueId === uniqueId) {
  149367. return this.meshes[index];
  149368. }
  149369. }
  149370. return null;
  149371. };
  149372. /**
  149373. * Gets a the last added mesh using a given id
  149374. * @param id defines the id to search for
  149375. * @return the found mesh or null if not found at all.
  149376. */
  149377. Scene.prototype.getLastMeshByID = function (id) {
  149378. for (var index = this.meshes.length - 1; index >= 0; index--) {
  149379. if (this.meshes[index].id === id) {
  149380. return this.meshes[index];
  149381. }
  149382. }
  149383. return null;
  149384. };
  149385. /**
  149386. * Gets a the last added node (Mesh, Camera, Light) using a given id
  149387. * @param id defines the id to search for
  149388. * @return the found node or null if not found at all
  149389. */
  149390. Scene.prototype.getLastEntryByID = function (id) {
  149391. var index;
  149392. for (index = this.meshes.length - 1; index >= 0; index--) {
  149393. if (this.meshes[index].id === id) {
  149394. return this.meshes[index];
  149395. }
  149396. }
  149397. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  149398. if (this.transformNodes[index].id === id) {
  149399. return this.transformNodes[index];
  149400. }
  149401. }
  149402. for (index = this.cameras.length - 1; index >= 0; index--) {
  149403. if (this.cameras[index].id === id) {
  149404. return this.cameras[index];
  149405. }
  149406. }
  149407. for (index = this.lights.length - 1; index >= 0; index--) {
  149408. if (this.lights[index].id === id) {
  149409. return this.lights[index];
  149410. }
  149411. }
  149412. return null;
  149413. };
  149414. /**
  149415. * Gets a node (Mesh, Camera, Light) using a given id
  149416. * @param id defines the id to search for
  149417. * @return the found node or null if not found at all
  149418. */
  149419. Scene.prototype.getNodeByID = function (id) {
  149420. var mesh = this.getMeshByID(id);
  149421. if (mesh) {
  149422. return mesh;
  149423. }
  149424. var transformNode = this.getTransformNodeByID(id);
  149425. if (transformNode) {
  149426. return transformNode;
  149427. }
  149428. var light = this.getLightByID(id);
  149429. if (light) {
  149430. return light;
  149431. }
  149432. var camera = this.getCameraByID(id);
  149433. if (camera) {
  149434. return camera;
  149435. }
  149436. var bone = this.getBoneByID(id);
  149437. if (bone) {
  149438. return bone;
  149439. }
  149440. return null;
  149441. };
  149442. /**
  149443. * Gets a node (Mesh, Camera, Light) using a given name
  149444. * @param name defines the name to search for
  149445. * @return the found node or null if not found at all.
  149446. */
  149447. Scene.prototype.getNodeByName = function (name) {
  149448. var mesh = this.getMeshByName(name);
  149449. if (mesh) {
  149450. return mesh;
  149451. }
  149452. var transformNode = this.getTransformNodeByName(name);
  149453. if (transformNode) {
  149454. return transformNode;
  149455. }
  149456. var light = this.getLightByName(name);
  149457. if (light) {
  149458. return light;
  149459. }
  149460. var camera = this.getCameraByName(name);
  149461. if (camera) {
  149462. return camera;
  149463. }
  149464. var bone = this.getBoneByName(name);
  149465. if (bone) {
  149466. return bone;
  149467. }
  149468. return null;
  149469. };
  149470. /**
  149471. * Gets a mesh using a given name
  149472. * @param name defines the name to search for
  149473. * @return the found mesh or null if not found at all.
  149474. */
  149475. Scene.prototype.getMeshByName = function (name) {
  149476. for (var index = 0; index < this.meshes.length; index++) {
  149477. if (this.meshes[index].name === name) {
  149478. return this.meshes[index];
  149479. }
  149480. }
  149481. return null;
  149482. };
  149483. /**
  149484. * Gets a transform node using a given name
  149485. * @param name defines the name to search for
  149486. * @return the found transform node or null if not found at all.
  149487. */
  149488. Scene.prototype.getTransformNodeByName = function (name) {
  149489. for (var index = 0; index < this.transformNodes.length; index++) {
  149490. if (this.transformNodes[index].name === name) {
  149491. return this.transformNodes[index];
  149492. }
  149493. }
  149494. return null;
  149495. };
  149496. /**
  149497. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  149498. * @param id defines the id to search for
  149499. * @return the found skeleton or null if not found at all.
  149500. */
  149501. Scene.prototype.getLastSkeletonByID = function (id) {
  149502. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  149503. if (this.skeletons[index].id === id) {
  149504. return this.skeletons[index];
  149505. }
  149506. }
  149507. return null;
  149508. };
  149509. /**
  149510. * Gets a skeleton using a given auto generated unique id
  149511. * @param uniqueId defines the unique id to search for
  149512. * @return the found skeleton or null if not found at all.
  149513. */
  149514. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  149515. for (var index = 0; index < this.skeletons.length; index++) {
  149516. if (this.skeletons[index].uniqueId === uniqueId) {
  149517. return this.skeletons[index];
  149518. }
  149519. }
  149520. return null;
  149521. };
  149522. /**
  149523. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  149524. * @param id defines the id to search for
  149525. * @return the found skeleton or null if not found at all.
  149526. */
  149527. Scene.prototype.getSkeletonById = function (id) {
  149528. for (var index = 0; index < this.skeletons.length; index++) {
  149529. if (this.skeletons[index].id === id) {
  149530. return this.skeletons[index];
  149531. }
  149532. }
  149533. return null;
  149534. };
  149535. /**
  149536. * Gets a skeleton using a given name
  149537. * @param name defines the name to search for
  149538. * @return the found skeleton or null if not found at all.
  149539. */
  149540. Scene.prototype.getSkeletonByName = function (name) {
  149541. for (var index = 0; index < this.skeletons.length; index++) {
  149542. if (this.skeletons[index].name === name) {
  149543. return this.skeletons[index];
  149544. }
  149545. }
  149546. return null;
  149547. };
  149548. /**
  149549. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  149550. * @param id defines the id to search for
  149551. * @return the found morph target manager or null if not found at all.
  149552. */
  149553. Scene.prototype.getMorphTargetManagerById = function (id) {
  149554. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  149555. if (this.morphTargetManagers[index].uniqueId === id) {
  149556. return this.morphTargetManagers[index];
  149557. }
  149558. }
  149559. return null;
  149560. };
  149561. /**
  149562. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  149563. * @param id defines the id to search for
  149564. * @return the found morph target or null if not found at all.
  149565. */
  149566. Scene.prototype.getMorphTargetById = function (id) {
  149567. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  149568. var morphTargetManager = this.morphTargetManagers[managerIndex];
  149569. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  149570. var target = morphTargetManager.getTarget(index);
  149571. if (target.id === id) {
  149572. return target;
  149573. }
  149574. }
  149575. }
  149576. return null;
  149577. };
  149578. /**
  149579. * Gets a boolean indicating if the given mesh is active
  149580. * @param mesh defines the mesh to look for
  149581. * @returns true if the mesh is in the active list
  149582. */
  149583. Scene.prototype.isActiveMesh = function (mesh) {
  149584. return (this._activeMeshes.indexOf(mesh) !== -1);
  149585. };
  149586. Object.defineProperty(Scene.prototype, "uid", {
  149587. /**
  149588. * Return a unique id as a string which can serve as an identifier for the scene
  149589. */
  149590. get: function () {
  149591. if (!this._uid) {
  149592. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  149593. }
  149594. return this._uid;
  149595. },
  149596. enumerable: true,
  149597. configurable: true
  149598. });
  149599. /**
  149600. * Add an externaly attached data from its key.
  149601. * This method call will fail and return false, if such key already exists.
  149602. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  149603. * @param key the unique key that identifies the data
  149604. * @param data the data object to associate to the key for this Engine instance
  149605. * @return true if no such key were already present and the data was added successfully, false otherwise
  149606. */
  149607. Scene.prototype.addExternalData = function (key, data) {
  149608. if (!this._externalData) {
  149609. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  149610. }
  149611. return this._externalData.add(key, data);
  149612. };
  149613. /**
  149614. * Get an externaly attached data from its key
  149615. * @param key the unique key that identifies the data
  149616. * @return the associated data, if present (can be null), or undefined if not present
  149617. */
  149618. Scene.prototype.getExternalData = function (key) {
  149619. if (!this._externalData) {
  149620. return null;
  149621. }
  149622. return this._externalData.get(key);
  149623. };
  149624. /**
  149625. * Get an externaly attached data from its key, create it using a factory if it's not already present
  149626. * @param key the unique key that identifies the data
  149627. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  149628. * @return the associated data, can be null if the factory returned null.
  149629. */
  149630. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  149631. if (!this._externalData) {
  149632. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  149633. }
  149634. return this._externalData.getOrAddWithFactory(key, factory);
  149635. };
  149636. /**
  149637. * Remove an externaly attached data from the Engine instance
  149638. * @param key the unique key that identifies the data
  149639. * @return true if the data was successfully removed, false if it doesn't exist
  149640. */
  149641. Scene.prototype.removeExternalData = function (key) {
  149642. return this._externalData.remove(key);
  149643. };
  149644. Scene.prototype._evaluateSubMesh = function (subMesh, mesh, initialMesh) {
  149645. if (initialMesh.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  149646. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  149647. var step = _a[_i];
  149648. step.action(mesh, subMesh);
  149649. }
  149650. var material = subMesh.getMaterial();
  149651. if (material !== null && material !== undefined) {
  149652. // Render targets
  149653. if (material.hasRenderTargetTextures && material.getRenderTargetTextures != null) {
  149654. if (this._processedMaterials.indexOf(material) === -1) {
  149655. this._processedMaterials.push(material);
  149656. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  149657. }
  149658. }
  149659. // Dispatch
  149660. this._activeIndices.addCount(subMesh.indexCount, false);
  149661. this._renderingManager.dispatch(subMesh, mesh, material);
  149662. }
  149663. }
  149664. };
  149665. /**
  149666. * Clear the processed materials smart array preventing retention point in material dispose.
  149667. */
  149668. Scene.prototype.freeProcessedMaterials = function () {
  149669. this._processedMaterials.dispose();
  149670. };
  149671. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  149672. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  149673. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  149674. * when disposing several meshes in a row or a hierarchy of meshes.
  149675. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  149676. */
  149677. get: function () {
  149678. return this._preventFreeActiveMeshesAndRenderingGroups;
  149679. },
  149680. set: function (value) {
  149681. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  149682. return;
  149683. }
  149684. if (value) {
  149685. this.freeActiveMeshes();
  149686. this.freeRenderingGroups();
  149687. }
  149688. this._preventFreeActiveMeshesAndRenderingGroups = value;
  149689. },
  149690. enumerable: true,
  149691. configurable: true
  149692. });
  149693. /**
  149694. * Clear the active meshes smart array preventing retention point in mesh dispose.
  149695. */
  149696. Scene.prototype.freeActiveMeshes = function () {
  149697. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  149698. return;
  149699. }
  149700. this._activeMeshes.dispose();
  149701. if (this.activeCamera && this.activeCamera._activeMeshes) {
  149702. this.activeCamera._activeMeshes.dispose();
  149703. }
  149704. if (this.activeCameras) {
  149705. for (var i = 0; i < this.activeCameras.length; i++) {
  149706. var activeCamera = this.activeCameras[i];
  149707. if (activeCamera && activeCamera._activeMeshes) {
  149708. activeCamera._activeMeshes.dispose();
  149709. }
  149710. }
  149711. }
  149712. };
  149713. /**
  149714. * Clear the info related to rendering groups preventing retention points during dispose.
  149715. */
  149716. Scene.prototype.freeRenderingGroups = function () {
  149717. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  149718. return;
  149719. }
  149720. if (this._renderingManager) {
  149721. this._renderingManager.freeRenderingGroups();
  149722. }
  149723. if (this.textures) {
  149724. for (var i = 0; i < this.textures.length; i++) {
  149725. var texture = this.textures[i];
  149726. if (texture && texture.renderList) {
  149727. texture.freeRenderingGroups();
  149728. }
  149729. }
  149730. }
  149731. };
  149732. /** @hidden */
  149733. Scene.prototype._isInIntermediateRendering = function () {
  149734. return this._intermediateRendering;
  149735. };
  149736. /**
  149737. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  149738. * @returns the current scene
  149739. */
  149740. Scene.prototype.freezeActiveMeshes = function () {
  149741. if (!this.activeCamera) {
  149742. return this;
  149743. }
  149744. if (!this._frustumPlanes) {
  149745. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  149746. }
  149747. this._evaluateActiveMeshes();
  149748. this._activeMeshesFrozen = true;
  149749. for (var index = 0; index < this._activeMeshes.length; index++) {
  149750. this._activeMeshes.data[index]._freeze();
  149751. }
  149752. return this;
  149753. };
  149754. /**
  149755. * Use this function to restart evaluating active meshes on every frame
  149756. * @returns the current scene
  149757. */
  149758. Scene.prototype.unfreezeActiveMeshes = function () {
  149759. for (var index = 0; index < this.meshes.length; index++) {
  149760. var mesh = this.meshes[index];
  149761. if (mesh._internalAbstractMeshDataInfo) {
  149762. mesh._internalAbstractMeshDataInfo._isActive = false;
  149763. }
  149764. }
  149765. for (var index = 0; index < this._activeMeshes.length; index++) {
  149766. this._activeMeshes.data[index]._unFreeze();
  149767. }
  149768. this._activeMeshesFrozen = false;
  149769. return this;
  149770. };
  149771. Scene.prototype._evaluateActiveMeshes = function () {
  149772. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  149773. var len_1 = this._activeMeshes.length;
  149774. for (var i = 0; i < len_1; i++) {
  149775. var mesh = this._activeMeshes.data[i];
  149776. mesh.computeWorldMatrix();
  149777. }
  149778. return;
  149779. }
  149780. if (!this.activeCamera) {
  149781. return;
  149782. }
  149783. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  149784. this.activeCamera._activeMeshes.reset();
  149785. this._activeMeshes.reset();
  149786. this._renderingManager.reset();
  149787. this._processedMaterials.reset();
  149788. this._activeParticleSystems.reset();
  149789. this._activeSkeletons.reset();
  149790. this._softwareSkinnedMeshes.reset();
  149791. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  149792. var step = _a[_i];
  149793. step.action();
  149794. }
  149795. // Determine mesh candidates
  149796. var meshes = this.getActiveMeshCandidates();
  149797. // Check each mesh
  149798. var len = meshes.length;
  149799. for (var i = 0; i < len; i++) {
  149800. var mesh = meshes.data[i];
  149801. if (mesh.isBlocked) {
  149802. continue;
  149803. }
  149804. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  149805. if (!mesh.isReady() || !mesh.isEnabled() || mesh.scaling.lengthSquared() === 0) {
  149806. continue;
  149807. }
  149808. mesh.computeWorldMatrix();
  149809. // Intersections
  149810. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  149811. this._meshesForIntersections.pushNoDuplicate(mesh);
  149812. }
  149813. // Switch to current LOD
  149814. var meshToRender = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  149815. if (meshToRender === undefined || meshToRender === null) {
  149816. continue;
  149817. }
  149818. // Compute world matrix if LOD is billboard
  149819. if (meshToRender !== mesh && meshToRender.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__["TransformNode"].BILLBOARDMODE_NONE) {
  149820. meshToRender.computeWorldMatrix();
  149821. }
  149822. mesh._preActivate();
  149823. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  149824. this._activeMeshes.push(mesh);
  149825. this.activeCamera._activeMeshes.push(mesh);
  149826. if (meshToRender !== mesh) {
  149827. meshToRender._activate(this._renderId, false);
  149828. }
  149829. if (mesh._activate(this._renderId, false)) {
  149830. if (!mesh.isAnInstance) {
  149831. meshToRender._internalAbstractMeshDataInfo._onlyForInstances = false;
  149832. }
  149833. meshToRender._internalAbstractMeshDataInfo._isActive = true;
  149834. this._activeMesh(mesh, meshToRender);
  149835. }
  149836. mesh._postActivate();
  149837. }
  149838. }
  149839. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  149840. // Particle systems
  149841. if (this.particlesEnabled) {
  149842. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  149843. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  149844. var particleSystem = this.particleSystems[particleIndex];
  149845. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  149846. continue;
  149847. }
  149848. var emitter = particleSystem.emitter;
  149849. if (!emitter.position || emitter.isEnabled()) {
  149850. this._activeParticleSystems.push(particleSystem);
  149851. particleSystem.animate();
  149852. this._renderingManager.dispatchParticles(particleSystem);
  149853. }
  149854. }
  149855. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  149856. }
  149857. };
  149858. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  149859. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  149860. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  149861. mesh.skeleton.prepare();
  149862. }
  149863. if (!mesh.computeBonesUsingShaders) {
  149864. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  149865. }
  149866. }
  149867. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  149868. var step = _a[_i];
  149869. step.action(sourceMesh, mesh);
  149870. }
  149871. if (mesh !== undefined && mesh !== null
  149872. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  149873. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  149874. var len = subMeshes.length;
  149875. for (var i = 0; i < len; i++) {
  149876. var subMesh = subMeshes.data[i];
  149877. this._evaluateSubMesh(subMesh, mesh, sourceMesh);
  149878. }
  149879. }
  149880. };
  149881. /**
  149882. * Update the transform matrix to update from the current active camera
  149883. * @param force defines a boolean used to force the update even if cache is up to date
  149884. */
  149885. Scene.prototype.updateTransformMatrix = function (force) {
  149886. if (!this.activeCamera) {
  149887. return;
  149888. }
  149889. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  149890. };
  149891. Scene.prototype._bindFrameBuffer = function () {
  149892. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  149893. this.activeCamera._multiviewTexture._bindFrameBuffer();
  149894. }
  149895. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  149896. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  149897. if (useMultiview) {
  149898. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  149899. }
  149900. else {
  149901. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  149902. if (internalTexture) {
  149903. this.getEngine().bindFramebuffer(internalTexture);
  149904. }
  149905. else {
  149906. _Misc_logger__WEBPACK_IMPORTED_MODULE_22__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  149907. }
  149908. }
  149909. }
  149910. else {
  149911. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  149912. }
  149913. };
  149914. /** @hidden */
  149915. Scene.prototype._renderForCamera = function (camera, rigParent) {
  149916. if (camera && camera._skipRendering) {
  149917. return;
  149918. }
  149919. var engine = this._engine;
  149920. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  149921. this._activeCamera = camera;
  149922. if (!this.activeCamera) {
  149923. throw new Error("Active camera not set");
  149924. }
  149925. // Viewport
  149926. engine.setViewport(this.activeCamera.viewport);
  149927. // Camera
  149928. this.resetCachedMaterial();
  149929. this._renderId++;
  149930. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  149931. if (useMultiview) {
  149932. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  149933. }
  149934. else {
  149935. this.updateTransformMatrix();
  149936. }
  149937. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  149938. // Meshes
  149939. this._evaluateActiveMeshes();
  149940. // Software skinning
  149941. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  149942. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  149943. mesh.applySkeleton(mesh.skeleton);
  149944. }
  149945. // Render targets
  149946. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  149947. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  149948. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  149949. }
  149950. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  149951. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  149952. }
  149953. // Collects render targets from external components.
  149954. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  149955. var step = _a[_i];
  149956. step.action(this._renderTargets);
  149957. }
  149958. if (this.renderTargetsEnabled) {
  149959. this._intermediateRendering = true;
  149960. var needRebind = false;
  149961. if (this._renderTargets.length > 0) {
  149962. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  149963. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  149964. var renderTarget = this._renderTargets.data[renderIndex];
  149965. if (renderTarget._shouldRender()) {
  149966. this._renderId++;
  149967. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  149968. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  149969. needRebind = true;
  149970. }
  149971. }
  149972. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  149973. this._renderId++;
  149974. }
  149975. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  149976. var step = _c[_b];
  149977. needRebind = step.action(this.activeCamera) || needRebind;
  149978. }
  149979. this._intermediateRendering = false;
  149980. // Need to bind if sub-camera has an outputRenderTarget eg. for webXR
  149981. if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  149982. needRebind = true;
  149983. }
  149984. // Restore framebuffer after rendering to targets
  149985. if (needRebind) {
  149986. this._bindFrameBuffer();
  149987. }
  149988. }
  149989. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  149990. // Prepare Frame
  149991. if (this.postProcessManager && !camera._multiviewTexture) {
  149992. this.postProcessManager._prepareFrame();
  149993. }
  149994. // Before Camera Draw
  149995. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  149996. var step = _e[_d];
  149997. step.action(this.activeCamera);
  149998. }
  149999. // Render
  150000. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  150001. this._renderingManager.render(null, null, true, true);
  150002. this.onAfterDrawPhaseObservable.notifyObservers(this);
  150003. // After Camera Draw
  150004. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  150005. var step = _g[_f];
  150006. step.action(this.activeCamera);
  150007. }
  150008. // Finalize frame
  150009. if (this.postProcessManager && !camera._multiviewTexture) {
  150010. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  150011. }
  150012. // Reset some special arrays
  150013. this._renderTargets.reset();
  150014. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  150015. };
  150016. Scene.prototype._processSubCameras = function (camera) {
  150017. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  150018. this._renderForCamera(camera);
  150019. this.onAfterRenderCameraObservable.notifyObservers(camera);
  150020. return;
  150021. }
  150022. if (camera._useMultiviewToSingleView) {
  150023. this._renderMultiviewToSingleView(camera);
  150024. }
  150025. else {
  150026. // rig cameras
  150027. for (var index = 0; index < camera._rigCameras.length; index++) {
  150028. this._renderForCamera(camera._rigCameras[index], camera);
  150029. }
  150030. }
  150031. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  150032. this._activeCamera = camera;
  150033. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  150034. this.onAfterRenderCameraObservable.notifyObservers(camera);
  150035. };
  150036. Scene.prototype._checkIntersections = function () {
  150037. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  150038. var sourceMesh = this._meshesForIntersections.data[index];
  150039. if (!sourceMesh.actionManager) {
  150040. continue;
  150041. }
  150042. for (var actionIndex = 0; sourceMesh.actionManager && actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  150043. var action = sourceMesh.actionManager.actions[actionIndex];
  150044. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  150045. var parameters = action.getTriggerParameter();
  150046. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameters : parameters.mesh;
  150047. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  150048. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  150049. if (areIntersecting && currentIntersectionInProgress === -1) {
  150050. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  150051. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_16__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  150052. sourceMesh._intersectionsInProgress.push(otherMesh);
  150053. }
  150054. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  150055. sourceMesh._intersectionsInProgress.push(otherMesh);
  150056. }
  150057. }
  150058. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  150059. //They intersected, and now they don't.
  150060. //is this trigger an exit trigger? execute an event.
  150061. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  150062. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_16__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  150063. }
  150064. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  150065. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  150066. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameter : parameter.mesh;
  150067. return otherMesh === parameterMesh;
  150068. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  150069. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  150070. }
  150071. }
  150072. }
  150073. }
  150074. }
  150075. };
  150076. /** @hidden */
  150077. Scene.prototype._advancePhysicsEngineStep = function (step) {
  150078. // Do nothing. Code will be replaced if physics engine component is referenced
  150079. };
  150080. /** @hidden */
  150081. Scene.prototype._animate = function () {
  150082. // Nothing to do as long as Animatable have not been imported.
  150083. };
  150084. /** Execute all animations (for a frame) */
  150085. Scene.prototype.animate = function () {
  150086. if (this._engine.isDeterministicLockStep()) {
  150087. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  150088. var defaultFPS = (60.0 / 1000.0);
  150089. var defaultFrameTime = this.getDeterministicFrameTime();
  150090. var stepsTaken = 0;
  150091. var maxSubSteps = this._engine.getLockstepMaxSteps();
  150092. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  150093. internalSteps = Math.min(internalSteps, maxSubSteps);
  150094. do {
  150095. this.onBeforeStepObservable.notifyObservers(this);
  150096. // Animations
  150097. this._animationRatio = defaultFrameTime * defaultFPS;
  150098. this._animate();
  150099. this.onAfterAnimationsObservable.notifyObservers(this);
  150100. // Physics
  150101. this._advancePhysicsEngineStep(defaultFrameTime);
  150102. this.onAfterStepObservable.notifyObservers(this);
  150103. this._currentStepId++;
  150104. stepsTaken++;
  150105. deltaTime -= defaultFrameTime;
  150106. } while (deltaTime > 0 && stepsTaken < internalSteps);
  150107. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  150108. }
  150109. else {
  150110. // Animations
  150111. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  150112. this._animationRatio = deltaTime * (60.0 / 1000.0);
  150113. this._animate();
  150114. this.onAfterAnimationsObservable.notifyObservers(this);
  150115. // Physics
  150116. this._advancePhysicsEngineStep(deltaTime);
  150117. }
  150118. };
  150119. /**
  150120. * Render the scene
  150121. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  150122. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  150123. */
  150124. Scene.prototype.render = function (updateCameras, ignoreAnimations) {
  150125. if (updateCameras === void 0) { updateCameras = true; }
  150126. if (ignoreAnimations === void 0) { ignoreAnimations = false; }
  150127. if (this.isDisposed) {
  150128. return;
  150129. }
  150130. this._frameId++;
  150131. // Register components that have been associated lately to the scene.
  150132. this._registerTransientComponents();
  150133. this._activeParticles.fetchNewFrame();
  150134. this._totalVertices.fetchNewFrame();
  150135. this._activeIndices.fetchNewFrame();
  150136. this._activeBones.fetchNewFrame();
  150137. this._meshesForIntersections.reset();
  150138. this.resetCachedMaterial();
  150139. this.onBeforeAnimationsObservable.notifyObservers(this);
  150140. // Actions
  150141. if (this.actionManager) {
  150142. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnEveryFrameTrigger);
  150143. }
  150144. // Animations
  150145. if (!ignoreAnimations) {
  150146. this.animate();
  150147. }
  150148. // Before camera update steps
  150149. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  150150. var step = _a[_i];
  150151. step.action();
  150152. }
  150153. // Update Cameras
  150154. if (updateCameras) {
  150155. if (this.activeCameras.length > 0) {
  150156. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  150157. var camera = this.activeCameras[cameraIndex];
  150158. camera.update();
  150159. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  150160. // rig cameras
  150161. for (var index = 0; index < camera._rigCameras.length; index++) {
  150162. camera._rigCameras[index].update();
  150163. }
  150164. }
  150165. }
  150166. }
  150167. else if (this.activeCamera) {
  150168. this.activeCamera.update();
  150169. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  150170. // rig cameras
  150171. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  150172. this.activeCamera._rigCameras[index].update();
  150173. }
  150174. }
  150175. }
  150176. }
  150177. // Before render
  150178. this.onBeforeRenderObservable.notifyObservers(this);
  150179. // Customs render targets
  150180. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  150181. var engine = this.getEngine();
  150182. var currentActiveCamera = this.activeCamera;
  150183. if (this.renderTargetsEnabled) {
  150184. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  150185. this._intermediateRendering = true;
  150186. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  150187. var renderTarget = this.customRenderTargets[customIndex];
  150188. if (renderTarget._shouldRender()) {
  150189. this._renderId++;
  150190. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  150191. if (!this.activeCamera) {
  150192. throw new Error("Active camera not set");
  150193. }
  150194. // Viewport
  150195. engine.setViewport(this.activeCamera.viewport);
  150196. // Camera
  150197. this.updateTransformMatrix();
  150198. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  150199. }
  150200. }
  150201. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  150202. this._intermediateRendering = false;
  150203. this._renderId++;
  150204. }
  150205. // Restore back buffer
  150206. this.activeCamera = currentActiveCamera;
  150207. this._bindFrameBuffer();
  150208. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  150209. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  150210. var step = _c[_b];
  150211. step.action();
  150212. }
  150213. // Clear
  150214. if (this.autoClearDepthAndStencil || this.autoClear) {
  150215. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  150216. }
  150217. // Collects render targets from external components.
  150218. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  150219. var step = _e[_d];
  150220. step.action(this._renderTargets);
  150221. }
  150222. // Multi-cameras?
  150223. if (this.activeCameras.length > 0) {
  150224. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  150225. if (cameraIndex > 0) {
  150226. this._engine.clear(null, false, true, true);
  150227. }
  150228. this._processSubCameras(this.activeCameras[cameraIndex]);
  150229. }
  150230. }
  150231. else {
  150232. if (!this.activeCamera) {
  150233. throw new Error("No camera defined");
  150234. }
  150235. this._processSubCameras(this.activeCamera);
  150236. }
  150237. // Intersection checks
  150238. this._checkIntersections();
  150239. // Executes the after render stage actions.
  150240. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  150241. var step = _g[_f];
  150242. step.action();
  150243. }
  150244. // After render
  150245. if (this.afterRender) {
  150246. this.afterRender();
  150247. }
  150248. this.onAfterRenderObservable.notifyObservers(this);
  150249. // Cleaning
  150250. if (this._toBeDisposed.length) {
  150251. for (var index = 0; index < this._toBeDisposed.length; index++) {
  150252. var data = this._toBeDisposed[index];
  150253. if (data) {
  150254. data.dispose();
  150255. }
  150256. }
  150257. this._toBeDisposed = [];
  150258. }
  150259. if (this.dumpNextRenderTargets) {
  150260. this.dumpNextRenderTargets = false;
  150261. }
  150262. this._activeBones.addCount(0, true);
  150263. this._activeIndices.addCount(0, true);
  150264. this._activeParticles.addCount(0, true);
  150265. };
  150266. /**
  150267. * Freeze all materials
  150268. * A frozen material will not be updatable but should be faster to render
  150269. */
  150270. Scene.prototype.freezeMaterials = function () {
  150271. for (var i = 0; i < this.materials.length; i++) {
  150272. this.materials[i].freeze();
  150273. }
  150274. };
  150275. /**
  150276. * Unfreeze all materials
  150277. * A frozen material will not be updatable but should be faster to render
  150278. */
  150279. Scene.prototype.unfreezeMaterials = function () {
  150280. for (var i = 0; i < this.materials.length; i++) {
  150281. this.materials[i].unfreeze();
  150282. }
  150283. };
  150284. /**
  150285. * Releases all held ressources
  150286. */
  150287. Scene.prototype.dispose = function () {
  150288. this.beforeRender = null;
  150289. this.afterRender = null;
  150290. if (_Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__["EngineStore"]._LastCreatedScene === this) {
  150291. _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__["EngineStore"]._LastCreatedScene = null;
  150292. }
  150293. this.skeletons = [];
  150294. this.morphTargetManagers = [];
  150295. this._transientComponents = [];
  150296. this._isReadyForMeshStage.clear();
  150297. this._beforeEvaluateActiveMeshStage.clear();
  150298. this._evaluateSubMeshStage.clear();
  150299. this._activeMeshStage.clear();
  150300. this._cameraDrawRenderTargetStage.clear();
  150301. this._beforeCameraDrawStage.clear();
  150302. this._beforeRenderTargetDrawStage.clear();
  150303. this._beforeRenderingGroupDrawStage.clear();
  150304. this._beforeRenderingMeshStage.clear();
  150305. this._afterRenderingMeshStage.clear();
  150306. this._afterRenderingGroupDrawStage.clear();
  150307. this._afterCameraDrawStage.clear();
  150308. this._afterRenderTargetDrawStage.clear();
  150309. this._afterRenderStage.clear();
  150310. this._beforeCameraUpdateStage.clear();
  150311. this._beforeClearStage.clear();
  150312. this._gatherRenderTargetsStage.clear();
  150313. this._gatherActiveCameraRenderTargetsStage.clear();
  150314. this._pointerMoveStage.clear();
  150315. this._pointerDownStage.clear();
  150316. this._pointerUpStage.clear();
  150317. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  150318. var component = _a[_i];
  150319. component.dispose();
  150320. }
  150321. this.importedMeshesFiles = new Array();
  150322. if (this.stopAllAnimations) {
  150323. this.stopAllAnimations();
  150324. }
  150325. this.resetCachedMaterial();
  150326. // Smart arrays
  150327. if (this.activeCamera) {
  150328. this.activeCamera._activeMeshes.dispose();
  150329. this.activeCamera = null;
  150330. }
  150331. this._activeMeshes.dispose();
  150332. this._renderingManager.dispose();
  150333. this._processedMaterials.dispose();
  150334. this._activeParticleSystems.dispose();
  150335. this._activeSkeletons.dispose();
  150336. this._softwareSkinnedMeshes.dispose();
  150337. this._renderTargets.dispose();
  150338. this._registeredForLateAnimationBindings.dispose();
  150339. this._meshesForIntersections.dispose();
  150340. this._toBeDisposed = [];
  150341. // Abort active requests
  150342. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  150343. var request = _c[_b];
  150344. request.abort();
  150345. }
  150346. // Events
  150347. this.onDisposeObservable.notifyObservers(this);
  150348. this.onDisposeObservable.clear();
  150349. this.onBeforeRenderObservable.clear();
  150350. this.onAfterRenderObservable.clear();
  150351. this.onBeforeRenderTargetsRenderObservable.clear();
  150352. this.onAfterRenderTargetsRenderObservable.clear();
  150353. this.onAfterStepObservable.clear();
  150354. this.onBeforeStepObservable.clear();
  150355. this.onBeforeActiveMeshesEvaluationObservable.clear();
  150356. this.onAfterActiveMeshesEvaluationObservable.clear();
  150357. this.onBeforeParticlesRenderingObservable.clear();
  150358. this.onAfterParticlesRenderingObservable.clear();
  150359. this.onBeforeDrawPhaseObservable.clear();
  150360. this.onAfterDrawPhaseObservable.clear();
  150361. this.onBeforeAnimationsObservable.clear();
  150362. this.onAfterAnimationsObservable.clear();
  150363. this.onDataLoadedObservable.clear();
  150364. this.onBeforeRenderingGroupObservable.clear();
  150365. this.onAfterRenderingGroupObservable.clear();
  150366. this.onMeshImportedObservable.clear();
  150367. this.onBeforeCameraRenderObservable.clear();
  150368. this.onAfterCameraRenderObservable.clear();
  150369. this.onReadyObservable.clear();
  150370. this.onNewCameraAddedObservable.clear();
  150371. this.onCameraRemovedObservable.clear();
  150372. this.onNewLightAddedObservable.clear();
  150373. this.onLightRemovedObservable.clear();
  150374. this.onNewGeometryAddedObservable.clear();
  150375. this.onGeometryRemovedObservable.clear();
  150376. this.onNewTransformNodeAddedObservable.clear();
  150377. this.onTransformNodeRemovedObservable.clear();
  150378. this.onNewMeshAddedObservable.clear();
  150379. this.onMeshRemovedObservable.clear();
  150380. this.onNewSkeletonAddedObservable.clear();
  150381. this.onSkeletonRemovedObservable.clear();
  150382. this.onNewMaterialAddedObservable.clear();
  150383. this.onMaterialRemovedObservable.clear();
  150384. this.onNewTextureAddedObservable.clear();
  150385. this.onTextureRemovedObservable.clear();
  150386. this.onPrePointerObservable.clear();
  150387. this.onPointerObservable.clear();
  150388. this.onPreKeyboardObservable.clear();
  150389. this.onKeyboardObservable.clear();
  150390. this.onActiveCameraChanged.clear();
  150391. this.detachControl();
  150392. // Detach cameras
  150393. var canvas = this._engine.getRenderingCanvas();
  150394. if (canvas) {
  150395. var index;
  150396. for (index = 0; index < this.cameras.length; index++) {
  150397. this.cameras[index].detachControl(canvas);
  150398. }
  150399. }
  150400. // Release animation groups
  150401. while (this.animationGroups.length) {
  150402. this.animationGroups[0].dispose();
  150403. }
  150404. // Release lights
  150405. while (this.lights.length) {
  150406. this.lights[0].dispose();
  150407. }
  150408. // Release meshes
  150409. while (this.meshes.length) {
  150410. this.meshes[0].dispose(true);
  150411. }
  150412. while (this.transformNodes.length) {
  150413. this.transformNodes[0].dispose(true);
  150414. }
  150415. // Release cameras
  150416. while (this.cameras.length) {
  150417. this.cameras[0].dispose();
  150418. }
  150419. // Release materials
  150420. if (this._defaultMaterial) {
  150421. this._defaultMaterial.dispose();
  150422. }
  150423. while (this.multiMaterials.length) {
  150424. this.multiMaterials[0].dispose();
  150425. }
  150426. while (this.materials.length) {
  150427. this.materials[0].dispose();
  150428. }
  150429. // Release particles
  150430. while (this.particleSystems.length) {
  150431. this.particleSystems[0].dispose();
  150432. }
  150433. // Release postProcesses
  150434. while (this.postProcesses.length) {
  150435. this.postProcesses[0].dispose();
  150436. }
  150437. // Release textures
  150438. while (this.textures.length) {
  150439. this.textures[0].dispose();
  150440. }
  150441. // Release UBO
  150442. this._sceneUbo.dispose();
  150443. if (this._multiviewSceneUbo) {
  150444. this._multiviewSceneUbo.dispose();
  150445. }
  150446. // Post-processes
  150447. this.postProcessManager.dispose();
  150448. // Remove from engine
  150449. index = this._engine.scenes.indexOf(this);
  150450. if (index > -1) {
  150451. this._engine.scenes.splice(index, 1);
  150452. }
  150453. this._engine.wipeCaches(true);
  150454. this._isDisposed = true;
  150455. };
  150456. Object.defineProperty(Scene.prototype, "isDisposed", {
  150457. /**
  150458. * Gets if the scene is already disposed
  150459. */
  150460. get: function () {
  150461. return this._isDisposed;
  150462. },
  150463. enumerable: true,
  150464. configurable: true
  150465. });
  150466. /**
  150467. * Call this function to reduce memory footprint of the scene.
  150468. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  150469. */
  150470. Scene.prototype.clearCachedVertexData = function () {
  150471. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  150472. var mesh = this.meshes[meshIndex];
  150473. var geometry = mesh.geometry;
  150474. if (geometry) {
  150475. geometry._indices = [];
  150476. for (var vbName in geometry._vertexBuffers) {
  150477. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  150478. continue;
  150479. }
  150480. geometry._vertexBuffers[vbName]._buffer._data = null;
  150481. }
  150482. }
  150483. }
  150484. };
  150485. /**
  150486. * This function will remove the local cached buffer data from texture.
  150487. * It will save memory but will prevent the texture from being rebuilt
  150488. */
  150489. Scene.prototype.cleanCachedTextureBuffer = function () {
  150490. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  150491. var baseTexture = _a[_i];
  150492. var buffer = baseTexture._buffer;
  150493. if (buffer) {
  150494. baseTexture._buffer = null;
  150495. }
  150496. }
  150497. };
  150498. /**
  150499. * Get the world extend vectors with an optional filter
  150500. *
  150501. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  150502. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  150503. */
  150504. Scene.prototype.getWorldExtends = function (filterPredicate) {
  150505. var min = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  150506. var max = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  150507. filterPredicate = filterPredicate || (function () { return true; });
  150508. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  150509. mesh.computeWorldMatrix(true);
  150510. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  150511. return;
  150512. }
  150513. var boundingInfo = mesh.getBoundingInfo();
  150514. var minBox = boundingInfo.boundingBox.minimumWorld;
  150515. var maxBox = boundingInfo.boundingBox.maximumWorld;
  150516. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].CheckExtends(minBox, min, max);
  150517. _Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].CheckExtends(maxBox, min, max);
  150518. });
  150519. return {
  150520. min: min,
  150521. max: max
  150522. };
  150523. };
  150524. // Picking
  150525. /**
  150526. * Creates a ray that can be used to pick in the scene
  150527. * @param x defines the x coordinate of the origin (on-screen)
  150528. * @param y defines the y coordinate of the origin (on-screen)
  150529. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  150530. * @param camera defines the camera to use for the picking
  150531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  150532. * @returns a Ray
  150533. */
  150534. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  150535. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  150536. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150537. };
  150538. /**
  150539. * Creates a ray that can be used to pick in the scene
  150540. * @param x defines the x coordinate of the origin (on-screen)
  150541. * @param y defines the y coordinate of the origin (on-screen)
  150542. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  150543. * @param result defines the ray where to store the picking ray
  150544. * @param camera defines the camera to use for the picking
  150545. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  150546. * @returns the current scene
  150547. */
  150548. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  150549. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  150550. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150551. };
  150552. /**
  150553. * Creates a ray that can be used to pick in the scene
  150554. * @param x defines the x coordinate of the origin (on-screen)
  150555. * @param y defines the y coordinate of the origin (on-screen)
  150556. * @param camera defines the camera to use for the picking
  150557. * @returns a Ray
  150558. */
  150559. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  150560. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150561. };
  150562. /**
  150563. * Creates a ray that can be used to pick in the scene
  150564. * @param x defines the x coordinate of the origin (on-screen)
  150565. * @param y defines the y coordinate of the origin (on-screen)
  150566. * @param result defines the ray where to store the picking ray
  150567. * @param camera defines the camera to use for the picking
  150568. * @returns the current scene
  150569. */
  150570. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  150571. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150572. };
  150573. /** Launch a ray to try to pick a mesh in the scene
  150574. * @param x position on screen
  150575. * @param y position on screen
  150576. * @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
  150577. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  150578. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  150579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  150580. * @returns a PickingInfo
  150581. */
  150582. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  150583. // Dummy info if picking as not been imported
  150584. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__["PickingInfo"]();
  150585. pi._pickingUnavailable = true;
  150586. return pi;
  150587. };
  150588. /** Use the given ray to pick a mesh in the scene
  150589. * @param ray The ray to use to pick meshes
  150590. * @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
  150591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  150592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  150593. * @returns a PickingInfo
  150594. */
  150595. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  150596. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150597. };
  150598. /**
  150599. * Launch a ray to try to pick a mesh in the scene
  150600. * @param x X position on screen
  150601. * @param y Y position on screen
  150602. * @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
  150603. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  150604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  150605. * @returns an array of PickingInfo
  150606. */
  150607. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  150608. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150609. };
  150610. /**
  150611. * Launch a ray to try to pick a mesh in the scene
  150612. * @param ray Ray to use
  150613. * @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
  150614. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  150615. * @returns an array of PickingInfo
  150616. */
  150617. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  150618. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  150619. };
  150620. /**
  150621. * Force the value of meshUnderPointer
  150622. * @param mesh defines the mesh to use
  150623. */
  150624. Scene.prototype.setPointerOverMesh = function (mesh) {
  150625. this._inputManager.setPointerOverMesh(mesh);
  150626. };
  150627. /**
  150628. * Gets the mesh under the pointer
  150629. * @returns a Mesh or null if no mesh is under the pointer
  150630. */
  150631. Scene.prototype.getPointerOverMesh = function () {
  150632. return this._inputManager.getPointerOverMesh();
  150633. };
  150634. // Misc.
  150635. /** @hidden */
  150636. Scene.prototype._rebuildGeometries = function () {
  150637. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  150638. var geometry = _a[_i];
  150639. geometry._rebuild();
  150640. }
  150641. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  150642. var mesh = _c[_b];
  150643. mesh._rebuild();
  150644. }
  150645. if (this.postProcessManager) {
  150646. this.postProcessManager._rebuild();
  150647. }
  150648. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  150649. var component = _e[_d];
  150650. component.rebuild();
  150651. }
  150652. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  150653. var system = _g[_f];
  150654. system.rebuild();
  150655. }
  150656. };
  150657. /** @hidden */
  150658. Scene.prototype._rebuildTextures = function () {
  150659. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  150660. var texture = _a[_i];
  150661. texture._rebuild();
  150662. }
  150663. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_TextureDirtyFlag);
  150664. };
  150665. // Tags
  150666. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  150667. if (tagsQuery === undefined) {
  150668. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  150669. return list;
  150670. }
  150671. var listByTags = [];
  150672. forEach = forEach || (function (item) { return; });
  150673. for (var i in list) {
  150674. var item = list[i];
  150675. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  150676. listByTags.push(item);
  150677. forEach(item);
  150678. }
  150679. }
  150680. return listByTags;
  150681. };
  150682. /**
  150683. * Get a list of meshes by tags
  150684. * @param tagsQuery defines the tags query to use
  150685. * @param forEach defines a predicate used to filter results
  150686. * @returns an array of Mesh
  150687. */
  150688. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  150689. return this._getByTags(this.meshes, tagsQuery, forEach);
  150690. };
  150691. /**
  150692. * Get a list of cameras by tags
  150693. * @param tagsQuery defines the tags query to use
  150694. * @param forEach defines a predicate used to filter results
  150695. * @returns an array of Camera
  150696. */
  150697. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  150698. return this._getByTags(this.cameras, tagsQuery, forEach);
  150699. };
  150700. /**
  150701. * Get a list of lights by tags
  150702. * @param tagsQuery defines the tags query to use
  150703. * @param forEach defines a predicate used to filter results
  150704. * @returns an array of Light
  150705. */
  150706. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  150707. return this._getByTags(this.lights, tagsQuery, forEach);
  150708. };
  150709. /**
  150710. * Get a list of materials by tags
  150711. * @param tagsQuery defines the tags query to use
  150712. * @param forEach defines a predicate used to filter results
  150713. * @returns an array of Material
  150714. */
  150715. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  150716. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  150717. };
  150718. /**
  150719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  150720. * This allowed control for front to back rendering or reversly depending of the special needs.
  150721. *
  150722. * @param renderingGroupId The rendering group id corresponding to its index
  150723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  150724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  150725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  150726. */
  150727. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  150728. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  150729. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  150730. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  150731. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  150732. };
  150733. /**
  150734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  150735. *
  150736. * @param renderingGroupId The rendering group id corresponding to its index
  150737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  150738. * @param depth Automatically clears depth between groups if true and autoClear is true.
  150739. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  150740. */
  150741. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  150742. if (depth === void 0) { depth = true; }
  150743. if (stencil === void 0) { stencil = true; }
  150744. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  150745. };
  150746. /**
  150747. * Gets the current auto clear configuration for one rendering group of the rendering
  150748. * manager.
  150749. * @param index the rendering group index to get the information for
  150750. * @returns The auto clear setup for the requested rendering group
  150751. */
  150752. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  150753. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  150754. };
  150755. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  150756. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  150757. get: function () {
  150758. return this._blockMaterialDirtyMechanism;
  150759. },
  150760. set: function (value) {
  150761. if (this._blockMaterialDirtyMechanism === value) {
  150762. return;
  150763. }
  150764. this._blockMaterialDirtyMechanism = value;
  150765. if (!value) { // Do a complete update
  150766. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_AllDirtyFlag);
  150767. }
  150768. },
  150769. enumerable: true,
  150770. configurable: true
  150771. });
  150772. /**
  150773. * Will flag all materials as dirty to trigger new shader compilation
  150774. * @param flag defines the flag used to specify which material part must be marked as dirty
  150775. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  150776. */
  150777. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  150778. if (this._blockMaterialDirtyMechanism) {
  150779. return;
  150780. }
  150781. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  150782. var material = _a[_i];
  150783. if (predicate && !predicate(material)) {
  150784. continue;
  150785. }
  150786. material.markAsDirty(flag);
  150787. }
  150788. };
  150789. /** @hidden */
  150790. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  150791. var _this = this;
  150792. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  150793. this._activeRequests.push(request);
  150794. request.onCompleteObservable.add(function (request) {
  150795. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  150796. });
  150797. return request;
  150798. };
  150799. /** @hidden */
  150800. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  150801. var _this = this;
  150802. return new Promise(function (resolve, reject) {
  150803. _this._loadFile(url, function (data) {
  150804. resolve(data);
  150805. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  150806. reject(exception);
  150807. });
  150808. });
  150809. };
  150810. /** The fog is deactivated */
  150811. Scene.FOGMODE_NONE = 0;
  150812. /** The fog density is following an exponential function */
  150813. Scene.FOGMODE_EXP = 1;
  150814. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  150815. Scene.FOGMODE_EXP2 = 2;
  150816. /** The fog density is following a linear function. */
  150817. Scene.FOGMODE_LINEAR = 3;
  150818. /**
  150819. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  150820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  150821. */
  150822. Scene.MinDeltaTime = 1.0;
  150823. /**
  150824. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  150825. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  150826. */
  150827. Scene.MaxDeltaTime = 1000.0;
  150828. return Scene;
  150829. }(_abstractScene__WEBPACK_IMPORTED_MODULE_11__["AbstractScene"]));
  150830. /***/ }),
  150831. /***/ "./sceneComponent.ts":
  150832. /*!***************************!*\
  150833. !*** ./sceneComponent.ts ***!
  150834. \***************************/
  150835. /*! exports provided: SceneComponentConstants, Stage */
  150836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  150837. "use strict";
  150838. __webpack_require__.r(__webpack_exports__);
  150839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  150840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  150841. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  150842. /**
  150843. * Groups all the scene component constants in one place to ease maintenance.
  150844. * @hidden
  150845. */
  150846. var SceneComponentConstants = /** @class */ (function () {
  150847. function SceneComponentConstants() {
  150848. }
  150849. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  150850. SceneComponentConstants.NAME_LAYER = "Layer";
  150851. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  150852. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  150853. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  150854. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  150855. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  150856. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  150857. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  150858. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  150859. SceneComponentConstants.NAME_SPRITE = "Sprite";
  150860. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  150861. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  150862. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  150863. SceneComponentConstants.NAME_OCTREE = "Octree";
  150864. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  150865. SceneComponentConstants.NAME_AUDIO = "Audio";
  150866. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  150867. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  150868. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  150869. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  150870. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  150871. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  150872. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  150873. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  150874. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  150875. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  150876. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  150877. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  150878. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  150879. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  150880. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  150881. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  150882. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  150883. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  150884. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  150885. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  150886. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  150887. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  150888. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  150889. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  150890. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  150891. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  150892. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  150893. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  150894. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  150895. return SceneComponentConstants;
  150896. }());
  150897. /**
  150898. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  150899. * @hidden
  150900. */
  150901. var Stage = /** @class */ (function (_super) {
  150902. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  150903. /**
  150904. * Hide ctor from the rest of the world.
  150905. * @param items The items to add.
  150906. */
  150907. function Stage(items) {
  150908. return _super.apply(this, items) || this;
  150909. }
  150910. /**
  150911. * Creates a new Stage.
  150912. * @returns A new instance of a Stage
  150913. */
  150914. Stage.Create = function () {
  150915. return Object.create(Stage.prototype);
  150916. };
  150917. /**
  150918. * Registers a step in an ordered way in the targeted stage.
  150919. * @param index Defines the position to register the step in
  150920. * @param component Defines the component attached to the step
  150921. * @param action Defines the action to launch during the step
  150922. */
  150923. Stage.prototype.registerStep = function (index, component, action) {
  150924. var i = 0;
  150925. var maxIndex = Number.MAX_VALUE;
  150926. for (; i < this.length; i++) {
  150927. var step = this[i];
  150928. maxIndex = step.index;
  150929. if (index < maxIndex) {
  150930. break;
  150931. }
  150932. }
  150933. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  150934. };
  150935. /**
  150936. * Clears all the steps from the stage.
  150937. */
  150938. Stage.prototype.clear = function () {
  150939. this.length = 0;
  150940. };
  150941. return Stage;
  150942. }(Array));
  150943. /***/ })
  150944. /******/ });
  150945. });
  150946. //# sourceMappingURL=babylon.max.js.map